Switch to unified view

a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp
...
...
60
#include "rcldb.h"
60
#include "rcldb.h"
61
#include "rclconfig.h"
61
#include "rclconfig.h"
62
#include "pathut.h"
62
#include "pathut.h"
63
#include "uiprefs_w.h"
63
#include "uiprefs_w.h"
64
#include "viewaction_w.h"
64
#include "viewaction_w.h"
65
#include "debuglog.h"
65
66
66
void UIPrefsDialog::init()
67
void UIPrefsDialog::init()
67
{
68
{
68
    m_viewAction = 0;
69
    m_viewAction = 0;
69
70
70
    connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
71
    connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
71
    connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
72
    connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
72
    connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
73
    connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
73
    connect(extraDbLE,SIGNAL(textChanged(const QString&)), this, 
74
      SLOT(extraDbTextChanged(const QString&)));
75
74
76
    connect(addExtraDbPB, SIGNAL(clicked()), 
75
    connect(addExtraDbPB, SIGNAL(clicked()), 
77
        this, SLOT(addExtraDbPB_clicked()));
76
        this, SLOT(addExtraDbPB_clicked()));
78
    connect(delExtraDbPB, SIGNAL(clicked()), 
77
    connect(delExtraDbPB, SIGNAL(clicked()), 
79
        this, SLOT(delExtraDbPB_clicked()));
78
        this, SLOT(delExtraDbPB_clicked()));
...
...
82
    connect(actAllExtraDbPB, SIGNAL(clicked()), 
81
    connect(actAllExtraDbPB, SIGNAL(clicked()), 
83
        this, SLOT(actAllExtraDbPB_clicked()));
82
        this, SLOT(actAllExtraDbPB_clicked()));
84
    connect(unacAllExtraDbPB, SIGNAL(clicked()), 
83
    connect(unacAllExtraDbPB, SIGNAL(clicked()), 
85
        this, SLOT(unacAllExtraDbPB_clicked()));
84
        this, SLOT(unacAllExtraDbPB_clicked()));
86
85
87
    connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
88
    connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
86
    connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
89
    connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
87
    connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
90
    connect(buildAbsCB, SIGNAL(toggled(bool)), 
88
    connect(buildAbsCB, SIGNAL(toggled(bool)), 
91
        replAbsCB, SLOT(setEnabled(bool)));
89
        replAbsCB, SLOT(setEnabled(bool)));
92
    connect(useDesktopOpenCB, SIGNAL(toggled(bool)), 
90
    connect(useDesktopOpenCB, SIGNAL(toggled(bool)), 
...
...
357
    item->setOn(false);
355
    item->setOn(false);
358
    ++it;
356
    ++it;
359
    }
357
    }
360
}
358
}
361
359
360
void UIPrefsDialog::delExtraDbPB_clicked()
361
{
362
    list<QCheckListItem*> dlt;
363
    QListViewItemIterator it(idxLV);
364
    while (it.current()) {
365
  QCheckListItem *item = (QCheckListItem *)it.current();
366
  if (item->isSelected()) {
367
      dlt.push_back(item);
368
  }
369
  ++it;
370
    }
371
    for (list<QCheckListItem*>::iterator it = dlt.begin(); 
372
   it != dlt.end(); it++) 
373
  delete *it;
374
}
375
362
/** 
376
/** 
363
 * Add the current content of the extra db line editor to the list of all
377
 * Browse to add another index.
364
 * extra dbs. We do a textual comparison to check for duplicates, except for
378
 * We do a textual comparison to check for duplicates, except for
365
 * the main db for which we check inode numbers. 
379
 * the main db for which we check inode numbers. 
366
 */
380
 */
367
void UIPrefsDialog::addExtraDbPB_clicked()
381
void UIPrefsDialog::addExtraDbPB_clicked()
368
{
382
{
383
    QFileDialog fdia;
384
    bool savedh = fdia.showHiddenFiles();
385
    fdia.setShowHiddenFiles(true);
386
    QString input = QFileDialog::getExistingDirectory("", this, 0, 
387
       tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)"));
388
    fdia.setShowHiddenFiles(savedh);
389
    if (input.isEmpty())
390
  return;
391
369
    string dbdir = (const char *)extraDbLE->text().local8Bit();
392
    string dbdir = (const char *)input.local8Bit();
393
    LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str()));
370
    path_catslash(dbdir);
394
    path_catslash(dbdir);
371
    if (!Rcl::Db::testDbDir(dbdir)) {
395
    if (!Rcl::Db::testDbDir(dbdir)) {
372
    QMessageBox::warning(0, "Recoll", 
396
    QMessageBox::warning(0, "Recoll", 
373
        tr("The selected directory does not appear to be a Xapian index"));
397
        tr("The selected directory does not appear to be a Xapian index"));
374
    return;
398
    return;
...
...
376
    struct stat st1, st2;
400
    struct stat st1, st2;
377
    stat(dbdir.c_str(), &st1);
401
    stat(dbdir.c_str(), &st1);
378
    string rcldbdir = RclConfig::getMainConfig()->getDbDir();
402
    string rcldbdir = RclConfig::getMainConfig()->getDbDir();
379
    stat(rcldbdir.c_str(), &st2);
403
    stat(rcldbdir.c_str(), &st2);
380
    path_catslash(rcldbdir);
404
    path_catslash(rcldbdir);
381
    fprintf(stderr, "rcldbdir: [%s]\n", rcldbdir.c_str());
405
382
    if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
406
    if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
383
    QMessageBox::warning(0, "Recoll", 
407
    QMessageBox::warning(0, "Recoll", 
384
                 tr("This is the main/local index!"));
408
                 tr("This is the main/local index!"));
385
    return;
409
    return;
386
    }
410
    }
387
    if (idxLV->findItem(extraDbLE->text(), 
411
412
    // For some reason, finditem (which we used to use to detect duplicates 
413
    // here) does not work anymore here: qt 4.6.3
414
#if 1
415
    string nv = (const char *)input.local8Bit();
416
    LOGDEB(("New value [%s]\n", nv.c_str()));
417
    QListViewItemIterator it(idxLV);
418
    while (it.current()) {
419
  QCheckListItem *item = (QCheckListItem *)it.current();
420
  string ov = (const char *)item->text().local8Bit();
421
  LOGDEB(("From list [%s]\n", ov.c_str()));
422
  if (!ov.compare(nv)) {
423
      QMessageBox::warning(0, "Recoll", 
424
       tr("The selected directory is already in the index list"));
425
      return;
426
  }
427
  ++it;
428
    }
429
#else // if findItem worked...
430
    if (idxLV->findItem(input, 
388
#if QT_VERSION < 0x040000
431
#if QT_VERSION < 0x040000
389
             Qt::CaseSensitive|Qt::ExactMatch
432
                         Qt::CaseSensitive|Qt::ExactMatch
390
#else
433
#else
391
                Q3ListView::CaseSensitive|Q3ListView::ExactMatch
434
                Q3ListView::CaseSensitive|Q3ListView::ExactMatch
392
#endif
435
#endif
393
                    )) {
436
                    )) {
394
    QMessageBox::warning(0, "Recoll", 
437
        QMessageBox::warning(0, "Recoll", 
395
         tr("The selected directory is already in the index list"));
438
         tr("The selected directory is already in the index list"));
396
    return;
439
        return;
397
    }
440
    }
441
#endif
442
398
    new QCheckListItem(idxLV, extraDbLE->text(), QCheckListItem::CheckBox);
443
    new QCheckListItem(idxLV, input, QCheckListItem::CheckBox);
399
    idxLV->sort();
444
    idxLV->sort();
400
}
445
}
401
402
void UIPrefsDialog::delExtraDbPB_clicked()
403
{
404
    list<QCheckListItem*> dlt;
405
    QListViewItemIterator it(idxLV);
406
    while (it.current()) {
407
  QCheckListItem *item = (QCheckListItem *)it.current();
408
  if (item->isSelected()) {
409
      dlt.push_back(item);
410
  }
411
  ++it;
412
    }
413
    for (list<QCheckListItem*>::iterator it = dlt.begin(); 
414
   it != dlt.end(); it++) 
415
  delete *it;
416
}
417
418
void UIPrefsDialog::extraDbTextChanged(const QString &text)
419
{
420
    if (text.isEmpty()) {
421
  addExtraDbPB->setEnabled(false);
422
    } else {
423
  addExtraDbPB->setEnabled(true);
424
    }
425
}
426
427
void UIPrefsDialog::browseDbPB_clicked()
428
{
429
    QFileDialog fdia;
430
    bool savedh = fdia.showHiddenFiles();
431
    fdia.setShowHiddenFiles(true);
432
    QString s = QFileDialog::getExistingDirectory("", this, 0, 
433
       tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)"));
434
435
    fdia.setShowHiddenFiles(savedh);
436
    if (!s.isEmpty()) 
437
  extraDbLE->setText(s);
438
}