From c5e40d85106e1499ccf55d67355bc8a8413b7d12 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 1 Dec 2010 16:15:22 +0100 Subject: [PATCH] replaced all q3 widgets except textbrowsers --- .hgignore | 18 +- src/common/rclconfig.cpp | 4 +- src/qtgui/guiutils.cpp | 5 - src/qtgui/rclhelp.cpp | 9 +- src/qtgui/rclmain.ui | 2 +- src/qtgui/rclmain_w.cpp | 70 +- src/qtgui/rclmain_w.h | 36 +- src/qtgui/sort_w.cpp | 5 - src/qtgui/sort_w.h | 26 +- src/qtgui/spell_w.cpp | 80 +-- src/qtgui/spell_w.h | 20 +- src/qtgui/ssearch_w.cpp | 89 --- src/qtgui/ssearch_w.h | 24 +- src/qtgui/ssearchb.ui | 207 +++--- src/qtgui/uiprefs.ui | 1350 +++++++++++++++++------------------- src/qtgui/uiprefs_w.cpp | 139 ++-- src/qtgui/uiprefs_w.h | 25 +- src/qtgui/viewaction.ui | 212 +++--- src/qtgui/viewaction_w.cpp | 92 ++- src/qtgui/viewaction_w.h | 37 +- 20 files changed, 1014 insertions(+), 1436 deletions(-) diff --git a/.hgignore b/.hgignore index 2dfec0ca..39a601d9 100644 --- a/.hgignore +++ b/.hgignore @@ -58,30 +58,18 @@ src/lib/alldeps src/lib/librcl.a src/mk/localdefs src/mk/sysconf -src/qt4gui/.moc/* -src/qt4gui/.ui/* -src/qt4gui/Makefile -src/qt4gui/advsearch.ui -src/qt4gui/images -src/qt4gui/preview.ui -src/qt4gui/qrc_recoll.cpp -src/qt4gui/recoll -src/qt4gui/recoll.app -src/qt4gui/recoll.pro -src/qt4gui/sort.ui -src/qt4gui/ssearchb.ui -src/qt4gui/uiprefs.ui -src/qt4gui/viewaction.ui src/qtgui/.moc/* +src/qtgui/.obj/* src/qtgui/.ui/* src/qtgui/Makefile src/qtgui/i18n/*.qm +src/qtgui/qrc_recoll.cpp src/qtgui/recoll src/qtgui/recoll.pro src/query/alldeps src/query/recollq src/query/xadump src/recollinstall -src/sampleconf/recoll.conf src/sampleconf/rclmon.sh +src/sampleconf/recoll.conf website/usermanual/* diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 96e63e55..616ebb22 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -740,8 +740,8 @@ bool RclConfig::getFieldConfParam(const string &name, const string &sk, string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag) { - LOGDEB(("RclConfig::getMimeViewerDef: mtype %s apptag %s\n", - mtype.c_str(), apptag.c_str())); + LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n", + mtype.c_str(), apptag.c_str())); string hs; if (mimeview == 0) return hs; diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 46da186d..8948bfcd 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -64,12 +64,7 @@ PrefsPack prefs; void rwSettings(bool writing) { LOGDEB1(("rwSettings: write %d\n", int(writing))); -#if QT_VERSION >= 0x040000 QSettings settings("Recoll.org", "recoll"); -#else - QSettings settings; - settings.setPath("Recoll.org", "Recoll", QSettings::User); -#endif SETTING_RW(prefs.mainwidth, "/Recoll/geometry/width", Num, 0); SETTING_RW(prefs.mainheight, "/Recoll/geometry/height", Num, 0); SETTING_RW(prefs.pvwidth, "/Recoll/geometry/pvwidth", Num, 0); diff --git a/src/qtgui/rclhelp.cpp b/src/qtgui/rclhelp.cpp index 64378087..81b07d17 100644 --- a/src/qtgui/rclhelp.cpp +++ b/src/qtgui/rclhelp.cpp @@ -22,11 +22,6 @@ static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.57 2008-10-13 07:57:12 dockes E #include #include -#if (QT_VERSION < 0x040000) -#define Q34EVOVERRIDE QEvent::AccelOverride -#else -#define Q34EVOVERRIDE QEvent::ShortcutOverride -#endif #include "recoll.h" #include "rclhelp.h" @@ -48,7 +43,8 @@ HelpClient::HelpClient(QObject *parent, const char *name) bool HelpClient::eventFilter(QObject *obj, QEvent *event) { static time_t last_start; - if (event->type() == QEvent::KeyPress || event->type() == Q34EVOVERRIDE) { + if (event->type() == QEvent::KeyPress || + event->type() == QEvent::ShortcutOverride) { // LOGDEB(("HelpClient::eventFilter: %d\n", (int)event->type())); QKeyEvent *ke = static_cast(event); if (ke->key() == Qt::Key_F1 || ke->key() == Qt::Key_Help) { @@ -78,4 +74,3 @@ bool HelpClient::eventFilter(QObject *obj, QEvent *event) } return false; } - diff --git a/src/qtgui/rclmain.ui b/src/qtgui/rclmain.ui index 24b95290..dcda3168 100644 --- a/src/qtgui/rclmain.ui +++ b/src/qtgui/rclmain.ui @@ -108,7 +108,7 @@ 0 0 800 - 31 + 23 diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 30a701a8..4de8ab42 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -34,20 +34,7 @@ using std::pair; #include #include #include - -#if (QT_VERSION < 0x040000) -#include -#include -#include -#include -#include -#undef RCLQT4 -#define RCLQT3 1 -#else -#undef RCLQT3 -#define RCLQT4 1 #include -#endif #include #include @@ -92,18 +79,6 @@ using namespace confgui; extern "C" int XFlush(void *); QString g_stringAllStem, g_stringNoStem; -// Taken from qt designer. Don't know why it's needed. -#if RCLQT3 -static QIconSet createIconSet(const QString &name) -{ - QIconSet ic(QPixmap::fromMimeSource(name)); - QString iname = "d_" + name; - ic.setPixmap(QPixmap::fromMimeSource(iname), - QIconSet::Small, QIconSet::Disabled ); - return ic; -} -#endif - void RclMain::init() { // This is just to get the common catg strings into the message file @@ -175,14 +150,8 @@ void RclMain::init() // A shortcut to get the focus back to the search entry. QKeySequence seq("Ctrl+Shift+s"); -#if RCLQT4 QShortcut *sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT (focusToSearch())); -#else - QAccel *sc = new QAccel(this); - sc->insertItem(seq); - connect(sc, SIGNAL (activated(int)), this, SLOT (focusToSearch())); -#endif // Toolbar+combobox version of the category selector @@ -191,26 +160,20 @@ void RclMain::init() QToolBar *catgToolBar = new QToolBar(this); catgCMB = new QComboBox(FALSE, catgToolBar, "catCMB"); catgCMB->insertItem(tr("All")); -#if RCLQT4 catgToolBar->setObjectName(QString::fromUtf8("catgToolBar")); catgCMB->setToolTip(tr("Document category filter")); catgToolBar->addWidget(catgCMB); this->addToolBar(Qt::TopToolBarArea, catgToolBar); -#endif } // Document categories buttons -#if RCLQT3 - catgBGRP->setColumnLayout(1, Qt::Vertical); - connect(catgBGRP, SIGNAL(clicked(int)), this, SLOT(catgFilter(int))); -#else QHBoxLayout *bgrphbox = new QHBoxLayout(catgBGRP); QButtonGroup *bgrp = new QButtonGroup(catgBGRP); bgrphbox->addWidget(allRDB); int bgrpid = 0; bgrp->addButton(allRDB, bgrpid++); connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int))); -#endif + allRDB->setChecked(true); list cats; rclconfig->getMimeCategories(cats); @@ -225,27 +188,17 @@ void RclMain::init() but->setText(tr(catgnm)); if (prefs.catgToolBar && catgCMB) catgCMB->insertItem(tr(catgnm)); -#if RCLQT4 bgrphbox->addWidget(but); bgrp->addButton(but, bgrpid++); -#endif } -#if RCLQT3 - catgBGRP->setButton(0); -#else catgBGRP->setLayout(bgrphbox); -#endif if (prefs.catgToolBar) catgBGRP->hide(); // Connections connect(sSearch, SIGNAL(startSearch(RefCntr)), this, SLOT(startSearch(RefCntr))); -#if RCLQT4 sSearch->queryText->installEventFilter(this); -#else - sSearch->queryText->lineEdit()->installEventFilter(this); -#endif connect(preferencesMenu, SIGNAL(activated(int)), this, SLOT(setStemLang(int))); @@ -310,15 +263,6 @@ void RclMain::init() // speeded up during indexing periodictimer->start(1000); -#if RCLQT3 - nextPageAction->setIconSet(createIconSet("nextpage.png")); - prevPageAction->setIconSet(createIconSet("prevpage.png")); - firstPageAction->setIconSet(createIconSet("firstpage.png")); - toolsSpellAction->setIconSet(QPixmap::fromMimeSource("spell.png")); - toolsDoc_HistoryAction->setIconSet(QPixmap::fromMimeSource("history.png")); - toolsAdvanced_SearchAction->setIconSet(QPixmap::fromMimeSource("asearch.png")); - toolsSort_parametersAction->setIconSet(QPixmap::fromMimeSource("sortparms.png")); -#else toolsSpellAction->setIcon(QIcon(":/images/spell.png")); nextPageAction->setIcon(QIcon(":/images/nextpage.png")); prevPageAction->setIcon(QIcon(":/images/prevpage.png")); @@ -326,8 +270,6 @@ void RclMain::init() toolsDoc_HistoryAction->setIcon(QIcon(":/images/history.png")); toolsAdvanced_SearchAction->setIcon(QIcon(":/images/asearch.png")); toolsSort_parametersAction->setIcon(QIcon(":/images/sortparms.png")); -#endif - // If requested by prefs, restore sort state. The easiest way is to let // a SortForm do it for us. @@ -350,11 +292,7 @@ void RclMain::initDbOpen() if (!maybeOpenDb(reason)) { nodb = true; switch (QMessageBox:: -#if (QT_VERSION >= 0x030200) question -#else - information -#endif (this, "Recoll", qApp->translate("Main", "Could not open database in ") + QString::fromLocal8Bit(rclconfig->getDbDir().c_str()) + @@ -391,11 +329,7 @@ void RclMain::initDbOpen() void RclMain::focusToSearch() { LOGDEB(("Giving focus to sSearch\n")); - sSearch->queryText->setFocus( -#if RCLQT4 - Qt::ShortcutFocusReason -#endif - ); + sSearch->queryText->setFocus(Qt::ShortcutFocusReason); } void RclMain::setStemLang(int id) diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 4e1d4b91..e6411a85 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -32,43 +32,25 @@ #include "pathut.h" class ExecCmd; - -#if QT_VERSION < 0x040000 -#include "rclmain.h" -#else -#include "ui_rclmain.h" -#endif - -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -class DummyRclMainBase : public RclMainBase -{ - public: DummyRclMainBase(QWidget* parent = 0) : RclMainBase(parent) {} -}; -#define RCLMAINPARENT QWidget -#else -class DummyRclMainBase : public QMainWindow, public Ui::RclMainBase -{ -public: DummyRclMainBase(QWidget *parent) :QMainWindow(parent){setupUi(this);} -#define RCLMAINPARENT QMainWindow -}; -#endif -//MOC_SKIP_END - class Preview; + +#include "ui_rclmain.h" + namespace confgui { -class ConfIndexW; + class ConfIndexW; } + using confgui::ConfIndexW; -class RclMain : public DummyRclMainBase +class RclMain : public QMainWindow, public Ui::RclMainBase { Q_OBJECT public: - RclMain(RCLMAINPARENT * parent = 0) - : DummyRclMainBase(parent) + RclMain(QWidget * parent = 0) + : QMainWindow(parent) { + setupUi(this); init(); } ~RclMain() {} diff --git a/src/qtgui/sort_w.cpp b/src/qtgui/sort_w.cpp index 1b077748..e9c37fca 100644 --- a/src/qtgui/sort_w.cpp +++ b/src/qtgui/sort_w.cpp @@ -36,13 +36,8 @@ void SortForm::init() slabs += tr("Date"); slabs += tr("Mime type"); -#if QT_VERSION < 0x040000 - fldCMB1->insertStringList(slabs); - fldCMB2->insertStringList(slabs); -#else fldCMB1->addItems(slabs); fldCMB2->addItems(slabs); -#endif // Initialize values from prefs: mcntSB->setValue(prefs.sortDepth); diff --git a/src/qtgui/sort_w.h b/src/qtgui/sort_w.h index d95c9876..88dd9c57 100644 --- a/src/qtgui/sort_w.h +++ b/src/qtgui/sort_w.h @@ -21,41 +21,23 @@ #include #include #include "sortseq.h" -#if (QT_VERSION < 0x040000) -#include "sort.h" -#else #include "ui_sort.h" -#endif class QDialog; -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -class DummySortFormBase : public SortFormBase -{ - public: DummySortFormBase(QWidget* parent = 0) : SortFormBase(parent) {} -}; -#else -class DummySortFormBase : public QDialog, public Ui::SortFormBase -{ -public: DummySortFormBase(QWidget* parent):QDialog(parent){setupUi(this);} -}; -#endif -//MOC_SKIP_END - -class SortForm : public DummySortFormBase +class SortForm : public QDialog, public Ui::SortFormBase { Q_OBJECT public: - SortForm(QDialog* parent = 0) - : DummySortFormBase(parent) + SortForm(QWidget* parent = 0) + : QDialog(parent) { + setupUi(this); init(); } ~SortForm() {} - public slots: virtual void apply(); virtual void setData(); diff --git a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp index 0d295730..fcbb264e 100644 --- a/src/qtgui/spell_w.cpp +++ b/src/qtgui/spell_w.cpp @@ -31,12 +31,8 @@ static char rcsid[] = "@(#$Id: spell_w.cpp,v 1.11 2007-02-19 16:28:05 dockes Exp #include #include #include -#if (QT_VERSION < 0x040000) -#include -#else #include #include -#endif #include "debuglog.h" #include "recoll.h" @@ -92,59 +88,25 @@ void SpellW::init() connect(dismissPB, SIGNAL(clicked()), this, SLOT(close())); connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(modeSet(int))); -#if (QT_VERSION < 0x040000) - connect(suggsLV, - SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), - this, SLOT(textDoubleClicked())); - // No initial sorting: user can choose to establish one - suggsLV->setSorting(100, false); -#else QStringList labels(tr("Term")); labels.push_back(tr("Doc. / Tot.")); suggsLV->setHorizontalHeaderLabels(labels); suggsLV->setShowGrid(0); suggsLV->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + suggsLV->verticalHeader()->setDefaultSectionSize(20); connect(suggsLV, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(textDoubleClicked(int, int))); -#endif suggsLV->setColumnWidth(0, 200); suggsLV->setColumnWidth(1, 150); } -#if (QT_VERSION < 0x040000) -// Subclass qlistviewitem for numeric sorting on column 1 -class MyListViewItem : public QListViewItem -{ -public: - MyListViewItem(QListView *listView, const QString& s1, const QString& s2) - : QListViewItem(listView, s1, s2) - { } - - int compare(QListViewItem * i, int col, bool) const { - if (col == 0) - return i->text(0).compare(text(0)); - if (col == 1) - return i->text(1).toInt() - text(1).toInt(); - // ?? - return 0; - } -}; -#else - - -#endif - /* Expand term according to current mode */ void SpellW::doExpand() { // Can't clear qt4 table widget: resets column headers too -#if (QT_VERSION < 0x040000) - suggsLV->clear(); -#else suggsLV->setRowCount(0); -#endif if (baseWordLE->text().isEmpty()) return; @@ -209,43 +171,25 @@ void SpellW::doExpand() if (res.entries.empty()) { -#if (QT_VERSION < 0x040000) - new MyListViewItem(suggsLV, tr("No expansion found"), ""); -#else suggsLV->setItem(0, 0, new QTableWidgetItem(tr("No expansion found"))); -#endif } else { -#if (QT_VERSION < 0x040000) - for (list::reverse_iterator it = - res.entries.rbegin(); - it != res.entries.rend(); it++) { -#else int row = 0; for (list::iterator it = res.entries.begin(); it != res.entries.end(); it++) { -#endif LOGDEB(("SpellW::expand: %6d [%s]\n", it->wcf, it->term.c_str())); char num[30]; if (it->wcf) sprintf(num, "%d / %d", it->docs, it->wcf); else num[0] = 0; -#if (QT_VERSION < 0x040000) - new MyListViewItem(suggsLV, - QString::fromUtf8(it->term.c_str()), - QString::fromAscii(num)); -#else if (suggsLV->rowCount() <= row) suggsLV->setRowCount(row+1); suggsLV->setItem(row, 0, new QTableWidgetItem(QString::fromUtf8(it->term.c_str()))); suggsLV->setItem(row++, 1, new QTableWidgetItem(QString::fromAscii(num))); -#endif } -#if (QT_VERSION >= 0x040000) suggsLV->setRowCount(row+1); -#endif } } @@ -253,40 +197,18 @@ void SpellW::wordChanged(const QString &text) { if (text.isEmpty()) { expandPB->setEnabled(false); -#if (QT_VERSION < 0x040000) - suggsLV->clear(); -#else suggsLV->setRowCount(0); -#endif } else { expandPB->setEnabled(true); } } -#if (QT_VERSION < 0x040000) -void SpellW::textDoubleClicked(int, int){} -void SpellW::textDoubleClicked() -#else void SpellW::textDoubleClicked() {} void SpellW::textDoubleClicked(int row, int) -#endif { -#if (QT_VERSION < 0x040000) - QListViewItemIterator it(suggsLV); - while (it.current()) { - QListViewItem *item = it.current(); - if (!item->isSelected()) { - ++it; - continue; - } - emit(wordSelect((const char *)item->text(0))); - ++it; - } -#else QTableWidgetItem *item = suggsLV->item(row, 0); if (item) emit(wordSelect(item->text())); -#endif } void SpellW::modeSet(int mode) diff --git a/src/qtgui/spell_w.h b/src/qtgui/spell_w.h index c6253998..abcc5033 100644 --- a/src/qtgui/spell_w.h +++ b/src/qtgui/spell_w.h @@ -21,30 +21,16 @@ #include #include -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -#include "spell.h" -class DummySpellBase : public SpellBase -{ - public: DummySpellBase(QWidget* parent = 0) : SpellBase(parent) {} -}; -#else #include "ui_spell.h" -class DummySpellBase : public QWidget, public Ui::SpellBase -{ -public: DummySpellBase(QWidget* parent):QWidget(parent){setupUi(this);} -}; -#endif -//MOC_SKIP_END -class SpellW : public DummySpellBase +class SpellW : public QWidget, public Ui::SpellBase { Q_OBJECT - public: SpellW(QWidget* parent = 0) - : DummySpellBase(parent) + : QWidget(parent) { + setupUi(this); init(); } diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp index 20e4bd11..d9d14eb4 100644 --- a/src/qtgui/ssearch_w.cpp +++ b/src/qtgui/ssearch_w.cpp @@ -56,11 +56,7 @@ void SSearch::init() connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch())); connect(searchTypCMB, SIGNAL(activated(int)), this, SLOT(searchTypeChanged(int))); -#if QT_VERSION >= 0x040000 queryText->installEventFilter(this); -#else - queryText->lineEdit()->installEventFilter(this); -#endif m_escape = false; } @@ -309,90 +305,6 @@ void SSearch::completion() #undef SHOWEVENTS #if defined(SHOWEVENTS) -#if QT_VERSION < 0x040000 -static const char *eventTypeToStr(int tp) -{ - switch (tp) { - case 0: return "None"; - case 1: return "Timer"; - case 2: return "MouseButtonPress"; - case 3: return "MouseButtonRelease"; - case 4: return "MouseButtonDblClick"; - case 5: return "MouseMove"; - case 6: return "KeyPress"; - case 7: return "KeyRelease"; - case 8: return "FocusIn"; - case 9: return "FocusOut"; - case 10: return "Enter"; - case 11: return "Leave"; - case 12: return "Paint"; - case 13: return "Move"; - case 14: return "Resize"; - case 15: return "Create"; - case 16: return "Destroy"; - case 17: return "Show"; - case 18: return "Hide"; - case 19: return "Close"; - case 20: return "Quit"; - case 21: return "Reparent"; - case 22: return "ShowMinimized"; - case 23: return "ShowNormal"; - case 24: return "WindowActivate"; - case 25: return "WindowDeactivate"; - case 26: return "ShowToParent"; - case 27: return "HideToParent"; - case 28: return "ShowMaximized"; - case 29: return "ShowFullScreen"; - case 30: return "Accel"; - case 31: return "Wheel"; - case 32: return "AccelAvailable"; - case 33: return "CaptionChange"; - case 34: return "IconChange"; - case 35: return "ParentFontChange"; - case 36: return "ApplicationFontChange"; - case 37: return "ParentPaletteChange"; - case 38: return "ApplicationPaletteChange"; - case 39: return "PaletteChange"; - case 40: return "Clipboard"; - case 42: return "Speech"; - case 50: return "SockAct"; - case 51: return "AccelOverride"; - case 52: return "DeferredDelete"; - case 60: return "DragEnter"; - case 61: return "DragMove"; - case 62: return "DragLeave"; - case 63: return "Drop"; - case 64: return "DragResponse"; - case 70: return "ChildInserted"; - case 71: return "ChildRemoved"; - case 72: return "LayoutHint"; - case 73: return "ShowWindowRequest"; - case 74: return "WindowBlocked"; - case 75: return "WindowUnblocked"; - case 80: return "ActivateControl"; - case 81: return "DeactivateControl"; - case 82: return "ContextMenu"; - case 83: return "IMStart"; - case 84: return "IMCompose"; - case 85: return "IMEnd"; - case 86: return "Accessibility"; - case 87: return "TabletMove"; - case 88: return "LocaleChange"; - case 89: return "LanguageChange"; - case 90: return "LayoutDirectionChange"; - case 91: return "Style"; - case 92: return "TabletPress"; - case 93: return "TabletRelease"; - case 94: return "OkRequest"; - case 95: return "HelpRequest"; - case 96: return "WindowStateChange"; - case 97: return "IconDrag"; - case 1000: return "User"; - case 65535: return "MaxUser"; - default: return "Unknown"; - } -} -#else static const char *eventTypeToStr(int tp) { switch (tp) { @@ -531,7 +443,6 @@ static const char *eventTypeToStr(int tp) } } #endif -#endif bool SSearch::eventFilter(QObject *, QEvent *event) { diff --git a/src/qtgui/ssearch_w.h b/src/qtgui/ssearch_w.h index 3c723fb3..67b2a73e 100644 --- a/src/qtgui/ssearch_w.h +++ b/src/qtgui/ssearch_w.h @@ -23,27 +23,10 @@ #include "recoll.h" #include "searchdata.h" #include "refcntr.h" -#if (QT_VERSION < 0x040000) -#include "ssearchb.h" -#else + #include "ui_ssearchb.h" -#endif -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -class DummySSearchBase : public SSearchBase -{ - public: DummySSearchBase(QWidget* parent = 0) : SSearchBase(parent) {} -}; -#else -class DummySSearchBase : public QWidget, public Ui::SSearchBase -{ -public: DummySSearchBase(QWidget* parent) : QWidget(parent) {setupUi(this);} -}; -#endif -//MOC_SKIP_END - -class SSearch : public DummySSearchBase +class SSearch : public QWidget, public Ui::SSearchBase { Q_OBJECT @@ -51,8 +34,9 @@ public: enum SSearchType {SST_ANY = 0, SST_ALL = 1, SST_FNM = 2, SST_LANG = 3}; SSearch(QWidget* parent = 0, const char * = 0) - : DummySSearchBase(parent) + : QWidget(parent) { + setupUi(this); init(); } ~SSearch(){} diff --git a/src/qtgui/ssearchb.ui b/src/qtgui/ssearchb.ui index 3fd52592..af3c29f0 100644 --- a/src/qtgui/ssearchb.ui +++ b/src/qtgui/ssearchb.ui @@ -1,109 +1,106 @@ - - - - - SSearchBase - - - - 0 - 0 - 593 - 48 - - - - SSearchBase - + + SSearchBase + + + + 0 + 0 + 593 + 48 + + + + SSearchBase + + + + 2 + + + 4 + + - - 4 - - - 2 - - - - - - - false - - - Clear - - - Ctrl+S - - - Erase search entry - - - - - - - false - - - Search - - - - - - Start query - - - - - - - Qt::TabFocus - - - Choose search type. - - - - - - - - 7 - 0 - 8 - 0 - - - - - 155 - 0 - - - - true - - - 30 - - - QComboBox::NoInsert - - - false - - - Enter search terms here. Type ESC SPC for completions of current term. - - - - - + + + + false + + + Erase search entry + + + Clear + + + Ctrl+S + + + + + + + false + + + Start query + + + Search + + + + + + + + + + Qt::TabFocus + + + Choose search type. + + + + + + + + 8 + 0 + + + + + 155 + 0 + + + + Enter search terms here. Type ESC SPC for completions of current term. + + + true + + + 30 + + + QComboBox::NoInsert + + + false + + + - - - qPixmapFromMimeSource + + + + + qPixmapFromMimeSource + + diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index 56b12d98..703da789 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -1,703 +1,663 @@ - - - - - UIPrefsDialogBase - - - - 0 - 0 - 400 - 300 - - - - User preferences - - - true - + + uiPrefsDialogBase + + + + 0 + 0 + 527 + 559 + + + + User preferences + + + true + + + - + + + + + User interface + - - - - - User interface - - - - - - - - - - - 5 - 5 - 1 - 0 - - - - Number of entries in a result page - - - false - - - - - - - 1 - - - 8 - - - - - - - - - If checked, results with the same content under different names will only be shown once. - - - Hide duplicate results. - - - false - - - - - - - - - Highlight color for query terms - - - false - - - - - - - - 50 - 0 - - - - - - - - - - - - Result list font - - - false - - - - - - - Helvetica-10 - - - Opens a dialog to select the result list font - - - - - - - Reset - - - Resets the result list font to the system default - - - - - - - - - - - - 7 - 7 - 0 - 0 - - - - Result paragraph<br>format string - - - Defines the format for each result list paragraph. Use qt html format and printf-like replacements:<br>%A Abstract<br> %D Date<br> %I Icon image name<br> %K Keywords (if any)<br> %L Preview and Edit links<br> %M Mime type<br> %N Result number<br> %R Relevance percentage<br> %S Size information<br> %T Title<br> %U Url<br> - - - false - - - - - - - - 7 - 7 - 1 - 0 - - - - - 0 - 0 - - - - Q3ScrollView::Manual - - - Qt::PlainText - - - - - - true - - - Q3TextEdit::AutoNone - - - - - - - - - - - Texts over this size will not be highlighted in preview (too slow). - - - - 5 - 5 - 1 - 0 - - - - Maximum text size highlighted for preview (megabytes) - - - false - - - - - - - 1 - - - 3 - - - - - - - - - Use desktop preferences to choose document editor. - - - false - - - - - - - Choose editor applications - - - - - - - Display category filter as toolbar instead of button panel (needs restart). - - - false - - - - - - - Auto-start simple search on whitespace entry. - - - false - - - - - - - Start with advanced search dialog open. - - - false - - - - - - - Start with sort dialog open. - - - false - - - - - - - Remember sort activation state. - - - false - - - - - - - Prefer Html to plain text for preview. - - - false - - - - - - - - - - Search parameters - - - - - - - - - - Stemming language - - - false - - - - - - - - - - - - Automatically add phrase to simple searches - - - A search for [rolling stones] (2 terms) will be changed to [rolling or stones or (rolling phrase 2 stones)]. -This should give higher precedence to the results where the search terms appear exactly as entered. - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - Dynamically build abstracts - - - Do we try to build abstracts for result list entries by using the context of query terms ? -May be slow for big documents. - - - - - - - Replace abstracts from documents - - - Do we synthetize an abstract even if the document seemed to have one? - - - - - - - - - - 5 - 5 - 2 - 0 - - - - Synthetic abstract size (characters) - - - false - - - - - - - - 7 - 0 - 1 - 0 - - - - 100000 - - - 80 - - - 10 - - - 250 - - - - - - - - - - - - 5 - 5 - 1 - 0 - - - - Synthetic abstract context words - - - false - - - - - - - 20000 - - - 2 - - - 4 - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - - - The words in the list will be automatically turned to ext:xxx clauses in the query language entry. - - - - 5 - 5 - 1 - 0 - - - - Query language magic file name suffixes. - - - false - - - - - - - Enable - - - - - - - - 30 - 0 - - - - - - - - - - - 20 - 70 - - - - QSizePolicy::Expanding - - - Qt::Vertical - - - - - - - - - - External Indexes - - - - - - - - Q3ListView::Extended - - - Q3ListView::AllColumns - - - - External indexes - - - true - - - true - - - - - - - - - - Toggle selected - - - - - - - Activate All - - - - - - - Deactivate All - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - - - Remove selected - - - Remove from list. This has no effect on the disk index. - - - - - - - - 16 - 20 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - true - - - Add index - - - Click to add another index directory to the list - - - - - - - - - - - - + + + - - - - - 210 - 20 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - &OK - - - - - - true - - - true - - - Apply changes - - - - - - - &Cancel - - - - - - true - - - Discard changes - - - + + + + + 1 + 0 + + + + Number of entries in a result page + + + false + + + + + + + 1 + + + 8 + + + - + + + + + If checked, results with the same content under different names will only be shown once. + + + Hide duplicate results. + + + false + + + + + + + + + Highlight color for query terms + + + false + + + + + + + + 50 + 0 + + + + + + + + + + + + Result list font + + + false + + + + + + + Opens a dialog to select the result list font + + + Helvetica-10 + + + + + + + Resets the result list font to the system default + + + Reset + + + + + + + + + + + + 0 + 0 + + + + Defines the format for each result list paragraph. Use qt html format and printf-like replacements:<br>%A Abstract<br> %D Date<br> %I Icon image name<br> %K Keywords (if any)<br> %L Preview and Edit links<br> %M Mime type<br> %N Result number<br> %R Relevance percentage<br> %S Size information<br> %T Title<br> %U Url<br> + + + Result paragraph<br>format string + + + false + + + + + + + + 1 + 0 + + + + + 0 + 0 + + + + true + + + + + + + + + + + + + + + 1 + 0 + + + + Texts over this size will not be highlighted in preview (too slow). + + + Maximum text size highlighted for preview (megabytes) + + + false + + + + + + + 1 + + + 3 + + + + + + + + + Use desktop preferences to choose document editor. + + + false + + + + + + + Choose editor applications + + + + + + + Display category filter as toolbar instead of button panel (needs restart). + + + false + + + + + + + Auto-start simple search on whitespace entry. + + + false + + + + + + + Start with advanced search dialog open. + + + false + + + + + + + Start with sort dialog open. + + + false + + + + + + + Remember sort activation state. + + + false + + + + + + + Prefer Html to plain text for preview. + + + false + + + + + - + + + + Search parameters + + + + + + + + + + Stemming language + + + false + + + + + + + + + + + + A search for [rolling stones] (2 terms) will be changed to [rolling or stones or (rolling phrase 2 stones)]. +This should give higher precedence to the results where the search terms appear exactly as entered. + + + Automatically add phrase to simple searches + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + Do we try to build abstracts for result list entries by using the context of query terms ? +May be slow for big documents. + + + Dynamically build abstracts + + + + + + + Do we synthetize an abstract even if the document seemed to have one? + + + Replace abstracts from documents + + + + + + + + + + 2 + 0 + + + + Synthetic abstract size (characters) + + + false + + + + + + + + 1 + 0 + + + + 80 + + + 100000 + + + 10 + + + 250 + + + + + + + + + + + + 1 + 0 + + + + Synthetic abstract context words + + + false + + + + + + + 2 + + + 20000 + + + 4 + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + + 1 + 0 + + + + The words in the list will be automatically turned to ext:xxx clauses in the query language entry. + + + Query language magic file name suffixes. + + + false + + + + + + + Enable + + + + + + + + 30 + 0 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 70 + + + + + + + + + + + External Indexes + + + + + + + + QAbstractItemView::ExtendedSelection + + + + + + + + + Toggle selected + + + + + + + Activate All + + + + + + + Deactivate All + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + Remove from list. This has no effect on the disk index. + + + Remove selected + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 16 + 20 + + + + + + + + true + + + Click to add another index directory to the list + + + Add index + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 210 + 20 + + + + + + + + Apply changes + + + &OK + + + + + + true + + + true + + + + + + + Discard changes + + + &Cancel + + + + + + true + + + + + - - - qPixmapFromMimeSource + + + + + qPixmapFromMimeSource + + diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index c9603ead..da81f9dc 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -31,29 +31,19 @@ static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.26 2008-10-03 08:09:36 dockes E #include #include #include +#include #include #include #include #include #include #include -#if QT_VERSION < 0x040000 -#include -#include #include -#else -#include -#include -#include -#define QListView Q3ListView -#define QCheckListItem Q3CheckListItem -#define QFileDialog Q3FileDialog -#define QListViewItemIterator Q3ListViewItemIterator -#endif #include #include #include #include +#include #include "recoll.h" #include "guiutils.h" @@ -128,7 +118,7 @@ void UIPrefsDialog::setFromPrefs() reslistFontPB->setText(reslistFontFamily + "-" + s.setNum(reslistFontSize)); } - rlfTE->setText(prefs.reslistformat); + rlfTE->setPlainText(prefs.reslistformat); // Stemming language combobox stemLangCMB->clear(); @@ -163,19 +153,23 @@ void UIPrefsDialog::setFromPrefs() idxLV->clear(); for (list::iterator it = prefs.allExtraDbs.begin(); it != prefs.allExtraDbs.end(); it++) { - QCheckListItem *item = - new QCheckListItem(idxLV, QString::fromLocal8Bit(it->c_str()), - QCheckListItem::CheckBox); - if (item) item->setOn(false); + QListWidgetItem *item = + new QListWidgetItem(QString::fromLocal8Bit(it->c_str()), + idxLV); + if (item) + item->setCheckState(Qt::Unchecked); } for (list::iterator it = prefs.activeExtraDbs.begin(); it != prefs.activeExtraDbs.end(); it++) { - QCheckListItem *item; - if ((item = (QCheckListItem *) - idxLV->findItem (QString::fromLocal8Bit(it->c_str()), 0))) { - item->setOn(true); + QListitems = + idxLV->findItems (QString::fromLocal8Bit(it->c_str()), + Qt::MatchFixedString|Qt::MatchCaseSensitive); + for (QList::iterator it = items.begin(); + it != items.end(); it++) { + (*it)->setCheckState(Qt::Checked); } } + idxLV->sortItems(); } void UIPrefsDialog::accept() @@ -195,11 +189,11 @@ void UIPrefsDialog::accept() if (prefs.reslistformat == QString::fromAscii(prefs.getV18DfltResListFormat())) { prefs.reslistformat += " "; - rlfTE->setText(prefs.reslistformat); + rlfTE->setPlainText(prefs.reslistformat); } if (prefs.reslistformat.stripWhiteSpace().isEmpty()) { prefs.reslistformat = prefs.getDfltResListFormat(); - rlfTE->setText(prefs.reslistformat); + rlfTE->setPlainText(prefs.reslistformat); } prefs.creslistformat = (const char*)prefs.reslistformat.utf8(); @@ -228,17 +222,17 @@ void UIPrefsDialog::accept() prefs.autoSuffsEnable = autoSuffsCB->isChecked(); prefs.autoSuffs = autoSuffsLE->text(); - QListViewItemIterator it(idxLV); prefs.allExtraDbs.clear(); prefs.activeExtraDbs.clear(); - while (it.current()) { - QCheckListItem *item = (QCheckListItem *)it.current(); - prefs.allExtraDbs.push_back((const char *)item->text().local8Bit()); - if (item->isOn()) { - prefs.activeExtraDbs.push_back((const char *) - item->text().local8Bit()); + for (int i = 0; i < idxLV->count(); i++) { + QListWidgetItem *item = idxLV->item(i); + if (item) { + prefs.allExtraDbs.push_back((const char *)item->text().local8Bit()); + if (item->checkState() == Qt::Checked) { + prefs.activeExtraDbs.push_back((const char *) + item->text().local8Bit()); + } } - ++it; } rwSettings(true); @@ -325,52 +319,42 @@ void UIPrefsDialog::showViewAction(const QString& mt) //////////////////////////////////////////// // External / extra search indexes setup -// TBD: a way to remove entry from 'all' list (del button?) void UIPrefsDialog::togExtraDbPB_clicked() { - QListViewItemIterator it(idxLV); - while (it.current()) { - QCheckListItem *item = (QCheckListItem *)it.current(); + for (int i = 0; i < idxLV->count(); i++) { + QListWidgetItem *item = idxLV->item(i); if (item->isSelected()) { - item->setOn(!item->isOn()); + if (item->checkState() == Qt::Checked) { + item->setCheckState(Qt::Unchecked); + } else { + item->setCheckState(Qt::Checked); + } } - ++it; } } void UIPrefsDialog::actAllExtraDbPB_clicked() { - QListViewItemIterator it(idxLV); - while (it.current()) { - QCheckListItem *item = (QCheckListItem *)it.current(); - item->setOn(true); - ++it; + for (int i = 0; i < idxLV->count(); i++) { + QListWidgetItem *item = idxLV->item(i); + item->setCheckState(Qt::Checked); } } void UIPrefsDialog::unacAllExtraDbPB_clicked() { - QListViewItemIterator it(idxLV); - while (it.current()) { - QCheckListItem *item = (QCheckListItem *)it.current(); - item->setOn(false); - ++it; + for (int i = 0; i < idxLV->count(); i++) { + QListWidgetItem *item = idxLV->item(i); + item->setCheckState(Qt::Unchecked); } } void UIPrefsDialog::delExtraDbPB_clicked() { - list dlt; - QListViewItemIterator it(idxLV); - while (it.current()) { - QCheckListItem *item = (QCheckListItem *)it.current(); - if (item->isSelected()) { - dlt.push_back(item); - } - ++it; - } - for (list::iterator it = dlt.begin(); - it != dlt.end(); it++) + QList items = idxLV->selectedItems(); + for (QList::iterator it = items.begin(); + it != items.end(); it++) { delete *it; + } } /** @@ -380,14 +364,14 @@ void UIPrefsDialog::delExtraDbPB_clicked() */ void UIPrefsDialog::addExtraDbPB_clicked() { - QFileDialog fdia; - bool savedh = fdia.showHiddenFiles(); - fdia.setShowHiddenFiles(true); - QString input = QFileDialog::getExistingDirectory("", this, 0, - tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)")); - fdia.setShowHiddenFiles(savedh); + static QString lastdir; + + QString input = QFileDialog::getExistingDirectory(this, + tr("Select xapian index directory (ie: /home/buddy/.recoll/xapiandb)"), + lastdir); if (input.isEmpty()) return; + lastdir = input; string dbdir = (const char *)input.local8Bit(); LOGDEB(("ExtraDbDial: got: [%s]\n", dbdir.c_str())); @@ -411,7 +395,14 @@ void UIPrefsDialog::addExtraDbPB_clicked() // For some reason, finditem (which we used to use to detect duplicates // here) does not work anymore here: qt 4.6.3 -#if 1 + QListitems = + idxLV->findItems (input, Qt::MatchFixedString|Qt::MatchCaseSensitive); + if (!items.empty()) { + QMessageBox::warning(0, "Recoll", + tr("The selected directory is already in the index list")); + return; + } +#if 0 string nv = (const char *)input.local8Bit(); QListViewItemIterator it(idxLV); while (it.current()) { @@ -424,20 +415,8 @@ void UIPrefsDialog::addExtraDbPB_clicked() } ++it; } -#else // if findItem worked... - if (idxLV->findItem(input, -#if QT_VERSION < 0x040000 - Qt::CaseSensitive|Qt::ExactMatch -#else - Q3ListView::CaseSensitive|Q3ListView::ExactMatch #endif - )) { - QMessageBox::warning(0, "Recoll", - tr("The selected directory is already in the index list")); - return; - } -#endif - - new QCheckListItem(idxLV, input, QCheckListItem::CheckBox); - idxLV->sort(); + QListWidgetItem *item = new QListWidgetItem(input, idxLV); + item->setCheckState(Qt::Unchecked); + idxLV->sortItems(); } diff --git a/src/qtgui/uiprefs_w.h b/src/qtgui/uiprefs_w.h index 2d723164..6b160a4d 100644 --- a/src/qtgui/uiprefs_w.h +++ b/src/qtgui/uiprefs_w.h @@ -21,39 +21,20 @@ #include #include -#if (QT_VERSION < 0x040000) -#include "uiprefs.h" -#else #include "ui_uiprefs.h" -#endif class QDialog; - -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -class DummyUIPrefsDialogBase : public UIPrefsDialogBase -{ -public: DummyUIPrefsDialogBase(QWidget* parent = 0) - : UIPrefsDialogBase(parent) {} -}; -#else -class DummyUIPrefsDialogBase : public QDialog, public Ui::UIPrefsDialogBase -{ - public: DummyUIPrefsDialogBase(QDialog *parent):QDialog(parent) {setupUi(this);} -}; -#endif -//MOC_SKIP_END - class ViewAction; -class UIPrefsDialog : public DummyUIPrefsDialogBase +class UIPrefsDialog : public QDialog, public Ui::uiPrefsDialogBase { Q_OBJECT public: UIPrefsDialog(QDialog* parent = 0) - : DummyUIPrefsDialogBase(parent) + : QDialog(parent) { + setupUi(this); init(); } ~UIPrefsDialog(){}; diff --git a/src/qtgui/viewaction.ui b/src/qtgui/viewaction.ui index e6cde246..57f4a930 100644 --- a/src/qtgui/viewaction.ui +++ b/src/qtgui/viewaction.ui @@ -1,100 +1,118 @@ - - - - - ViewActionBase - - - - 0 - 0 - 400 - 132 - - - - Native Viewers - - - - - - - - Select one or several mime types then click "Change Action"<br>You can also close this dialog and check "Use desktop preferences"<br>in the main panel to ignore this list and use your desktop defaults. - - - false - - - - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Q3ListView::Extended - - - true - - - true - - - Select one or several file types, then click Change Action to modify the program used to open them - - - - File type - - - true - - - true - - - - - Action - - - true - - - true - - - - - - - - - - Change Action - - - - - - - Close - - - - - - - + + ViewActionBase + + + + 0 + 0 + 446 + 180 + + + + Native Viewers + + + + + + + + Select one or several mime types then click "Change Action"<br>You can also close this dialog and check "Use desktop preferences"<br>in the main panel to ignore this list and use your desktop defaults. + + + false + + + + + + + Select one or several file types, then click Change Action to modify the program used to open them + + + QFrame::StyledPanel + + + QFrame::Sunken + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + true + + + true + + + 2 + + + true + + + true + + + 150 + + + true + + + true + + + false + + + false + + + true + + + true + + + 150 + + + + + + + + + + + Change Action + + + + + + + Close + + + + + - - - qPixmapFromMimeSource + + + + + qPixmapFromMimeSource + + diff --git a/src/qtgui/viewaction_w.cpp b/src/qtgui/viewaction_w.cpp index eeb53e41..ecffcff2 100644 --- a/src/qtgui/viewaction_w.cpp +++ b/src/qtgui/viewaction_w.cpp @@ -26,16 +26,7 @@ using namespace std; #include #include -#if (QT_VERSION < 0x040000) -#include -#define QLVEXACTMATCH Qt::ExactMatch -#else -#include -#define QListView Q3ListView -#define QListViewItem Q3ListViewItem -#define QListViewItemIterator Q3ListViewItemIterator -#define QLVEXACTMATCH Q3ListView::ExactMatch -#endif +#include #include #include @@ -50,71 +41,74 @@ using namespace std; void ViewAction::init() { connect(closePB, SIGNAL(clicked()), this, SLOT(close())); - connect(chgActPB, SIGNAL(clicked()), this, SLOT(editAction())); - connect(actionsLV, -#if (QT_VERSION < 0x040000) - SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), -#else - SIGNAL(doubleClicked(Q3ListViewItem *, const QPoint &, int)), -#endif - this, SLOT(editAction())); + connect(chgActPB, SIGNAL(clicked()), + this, SLOT(editActions())); + connect(actionsLV,SIGNAL(itemDoubleClicked(QTableWidgetItem *)), + this, SLOT(onItemDoubleClicked(QTableWidgetItem *))); fillLists(); - resize(QSize(640, 250).expandedTo(minimumSizeHint()) ); + resize(QSize(640, 250).expandedTo(minimumSizeHint())); } void ViewAction::fillLists() { actionsLV->clear(); + actionsLV->verticalHeader()->setDefaultSectionSize(20); vector > defs; rclconfig->getMimeViewerDefs(defs); + actionsLV->setRowCount(defs.size()); + int row = 0; for (vector >::const_iterator it = defs.begin(); it != defs.end(); it++) { - new QListViewItem(actionsLV, - QString::fromAscii(it->first.c_str()), - QString::fromAscii(it->second.c_str())); + actionsLV->setItem(row, 0, + new QTableWidgetItem(QString::fromAscii(it->first.c_str()))); + actionsLV->setItem(row, 1, + new QTableWidgetItem(QString::fromAscii(it->second.c_str()))); + row++; } - + QStringList labels(tr("Mime type")); + labels.push_back(tr("Command")); + actionsLV->setHorizontalHeaderLabels(labels); } void ViewAction::selectMT(const QString& mt) { - QListViewItem *item = actionsLV->findItem(mt, 0, QLVEXACTMATCH); - if (item) { - actionsLV->ensureItemVisible(item); - actionsLV->setSelected(item, true); - actionsLV->setSelectionAnchor(item); + actionsLV->clearSelection(); + QListitems = + actionsLV->findItems(mt, Qt::MatchFixedString|Qt::MatchCaseSensitive); + for (QList::iterator it = items.begin(); + it != items.end(); it++) { + (*it)->setSelected(true); + actionsLV->setCurrentItem(*it, QItemSelectionModel::Columns); } } - -// To avoid modifying the listview state from the dbl click signal, as -// advised by the manual -void ViewAction::listDblClicked() +void ViewAction::onItemDoubleClicked(QTableWidgetItem * item) { - QTimer::singleShot(0, this, SLOT(editAction())); + actionsLV->clearSelection(); + item->setSelected(true); + QTableWidgetItem *item0 = actionsLV->item(item->row(), 0); + item0->setSelected(true); + editActions(); } -void ViewAction::editAction() +void ViewAction::editActions() { QString action0; list mtypes; bool dowarnmultiple = true; - - QListViewItemIterator it(actionsLV); - while (it.current()) { - QListViewItem *item = it.current(); - if (!item->isSelected()) { - ++it; + for (int row = 0; row < actionsLV->rowCount(); row++) { + QTableWidgetItem *item0 = actionsLV->item(row, 0); + if (!item0->isSelected()) continue; - } - mtypes.push_back((const char *)item->text(0).utf8()); - QString action = (const char *)item->text(1).utf8(); + mtypes.push_back((const char *)item0->text().local8Bit()); + QTableWidgetItem *item1 = actionsLV->item(row, 1); + QString action = item1->text(); if (action0.isEmpty()) { action0 = action; } else { if (action != action0 && dowarnmultiple) { switch (QMessageBox::warning(0, "Recoll", - tr("Changing actions with different " - "current values"), + tr("Changing actions with " + "different current values"), "Continue", "Cancel", 0, 0, 1)) { @@ -123,20 +117,18 @@ void ViewAction::editAction() } } } - ++it; } if (action0.isEmpty()) return; bool ok; - QString text = QInputDialog::getText( - "Recoll", "Edit action:", + QString newaction = QInputDialog::getText("Recoll", "Edit action:", QLineEdit::Normal, action0, &ok, this); - if (!ok || text.isEmpty() ) + if (!ok || newaction.isEmpty() ) return; - string sact = (const char *)text.utf8(); + string sact = (const char *)newaction.local8Bit(); for (list::const_iterator it = mtypes.begin(); it != mtypes.end(); it++) { rclconfig->setMimeViewerDef(*it, sact); diff --git a/src/qtgui/viewaction_w.h b/src/qtgui/viewaction_w.h index afa35730..d3f72f75 100644 --- a/src/qtgui/viewaction_w.h +++ b/src/qtgui/viewaction_w.h @@ -21,52 +21,29 @@ #include #include -#if (QT_VERSION < 0x040000) -#include "viewaction.h" -#else #include "ui_viewaction.h" -#endif class QDialog; class QMouseEvent; +class QTableWidget; -//MOC_SKIP_BEGIN -#if QT_VERSION < 0x040000 -class DummyViewActionBase : public ViewActionBase -{ - public: DummyViewActionBase(QWidget* parent = 0) : ViewActionBase(parent) {} -}; -#else -class DummyViewActionBase : public QDialog, public Ui::ViewActionBase -{ -public: - DummyViewActionBase(QWidget* parent) - : QDialog(parent) - { - setupUi(this); - } -}; -#endif -//MOC_SKIP_END - -class ViewAction : public DummyViewActionBase +class ViewAction : public QDialog, public Ui::ViewActionBase { Q_OBJECT public: - ViewAction(QDialog* parent = 0) - : DummyViewActionBase(parent) + ViewAction(QWidget* parent = 0) + : QDialog(parent) { + setupUi(this); init(); } ~ViewAction() {} - void selectMT(const QString& mt); public slots: - virtual void editAction(); - virtual void listDblClicked(); - + virtual void editActions(); + virtual void onItemDoubleClicked(QTableWidgetItem *); private: virtual void init(); virtual void fillLists();