QT GUI: converted the qt4 term expander dialog to native qt4

This commit is contained in:
Jean-Francois Dockes 2010-01-30 17:31:00 +01:00
parent 7f8c086f4a
commit 603dd8132e
6 changed files with 185 additions and 334 deletions

View File

@ -65,7 +65,6 @@ src/qt4gui/qrc_recoll.cpp
src/qt4gui/recoll
src/qt4gui/recoll.pro
src/qt4gui/sort.ui
src/qt4gui/spell.ui
src/qt4gui/ssearchb.ui
src/qt4gui/uiprefs.ui
src/qt4gui/viewaction.ui

View File

@ -1,315 +0,0 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>RclMain</class>
<widget class="QMainWindow" name="RclMain" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>244</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>16</width>
<height>115</height>
</size>
</property>
<property name="windowTitle" >
<string>Recoll</string>
</property>
<widget class="QWidget" name="widget" >
<layout class="QVBoxLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="SSearchBase" name="sSearch" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="RclResList" name="resList" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QToolBar" name="Toolbar" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<attribute name="toolBarArea" >
<number>4</number>
</attribute>
<addaction name="toolsAdvanced_SearchAction" />
<addaction name="toolsSort_parametersAction" />
<addaction name="toolsDoc_HistoryAction" />
</widget>
<widget class="QToolBar" name="Toolbar1" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<attribute name="toolBarArea" >
<number>4</number>
</attribute>
<addaction name="prevPageAction" />
<addaction name="nextPageAction" />
</widget>
<widget class="QMenuBar" name="MenuBar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="Tools" >
<property name="title" >
<string>&amp;Tools</string>
</property>
<addaction name="toolsDoc_HistoryAction" />
<addaction name="toolsAdvanced_SearchAction" />
<addaction name="toolsSort_parametersAction" />
</widget>
<widget class="QMenu" name="Preferences" >
<property name="title" >
<string>&amp;Preferences</string>
</property>
<addaction name="preferencesQuery_PrefsAction" />
</widget>
<widget class="QMenu" name="Help" >
<property name="title" >
<string>&amp;Help</string>
</property>
<addaction name="userManualAction" />
<addaction name="separator" />
<addaction name="helpAbout_RecollAction" />
</widget>
<widget class="QMenu" name="fileMenu" >
<property name="title" >
<string>&amp;File</string>
</property>
<addaction name="fileStart_IndexingAction" />
<addaction name="separator" />
<addaction name="fileExitAction" />
</widget>
<addaction name="fileMenu" />
<addaction name="Tools" />
<addaction name="Preferences" />
<addaction name="separator" />
<addaction name="Help" />
</widget>
<action name="fileExitAction" >
<property name="text" >
<string>E&amp;xit</string>
</property>
<property name="iconText" >
<string>Exit</string>
</property>
<property name="shortcut" >
<string>Ctrl+Q</string>
</property>
</action>
<action name="fileStart_IndexingAction" >
<property name="text" >
<string>Update &amp;index</string>
</property>
<property name="iconText" >
<string>Update index</string>
</property>
</action>
<action name="helpAbout_RecollAction" >
<property name="text" >
<string>&amp;About Recoll</string>
</property>
<property name="iconText" >
<string>About Recoll</string>
</property>
</action>
<action name="userManualAction" >
<property name="text" >
<string>&amp;User manual</string>
</property>
<property name="iconText" >
<string>User manual</string>
</property>
</action>
<action name="toolsDoc_HistoryAction" >
<property name="icon" >
<iconset resource="icons.qrc" >:/icons/images/history.png</iconset>
</property>
<property name="text" >
<string>Document &amp;History</string>
</property>
<property name="iconText" >
<string>Document &amp;History</string>
</property>
<property name="toolTip" >
<string>Document History</string>
</property>
</action>
<action name="toolsAdvanced_SearchAction" >
<property name="icon" >
<iconset resource="icons.qrc" >:/icons/images/asearch.png</iconset>
</property>
<property name="text" >
<string>&amp;Advanced Search</string>
</property>
<property name="iconText" >
<string>Advanced Search</string>
</property>
<property name="toolTip" >
<string>Advanced/complex Search</string>
</property>
</action>
<action name="toolsSort_parametersAction" >
<property name="icon" >
<iconset resource="icons.qrc" >:/icons/images/sortparms.png</iconset>
</property>
<property name="text" >
<string>&amp;Sort parameters</string>
</property>
<property name="iconText" >
<string>&amp;Sort parameters</string>
</property>
<property name="toolTip" >
<string>Sort parameters</string>
</property>
</action>
<action name="nextPageAction" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="icon" >
<iconset resource="icons.qrc" >:/icons/images/nextpage.png</iconset>
</property>
<property name="iconText" >
<string>Next page</string>
</property>
<property name="toolTip" >
<string>Next page of results</string>
</property>
</action>
<action name="prevPageAction" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="icon" >
<iconset resource="icons.qrc" >:/icons/images/prevpage.png</iconset>
</property>
<property name="iconText" >
<string>Previous page</string>
</property>
<property name="toolTip" >
<string>Previous page of results</string>
</property>
</action>
<action name="preferencesQuery_PrefsAction" >
<property name="text" >
<string>&amp;Query configuration</string>
</property>
<property name="iconText" >
<string>&amp;Query configuration</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>SSearchBase</class>
<extends>QWidget</extends>
<header>ssearchb.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>RclResList</class>
<extends>QWidget</extends>
<header>rclreslist.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<includes>
<include location="local" >ssearchb.h</include>
<include location="local" >rclreslist.h</include>
</includes>
<resources>
<include location="icons.qrc" />
</resources>
<connections>
<connection>
<sender>prevPageAction</sender>
<signal>activated()</signal>
<receiver>resList</receiver>
<slot>resultPageBack()</slot>
<hints>
<hint type="sourcelabel" >
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>nextPageAction</sender>
<signal>activated()</signal>
<receiver>resList</receiver>
<slot>showResultPage()</slot>
<hints>
<hint type="sourcelabel" >
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

124
src/qt4gui/spell.ui Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SpellBase</class>
<widget class="QWidget" name="SpellBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
<string>Term Explorer</string>
</property>
<layout class="QVBoxLayout">
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QGridLayout">
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="baseWordLE">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="expandPB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>&amp;Expand </string>
</property>
<property name="shortcut">
<string>Alt+E</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="stemLangCMB"/>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="expTypeCMB"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="dismissPB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="shortcut">
<string>Alt+C</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QTableWidget" name="suggsLV">
<property name="rowCount">
<number>2</number>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<row/>
<row/>
<column/>
<column/>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<tabstops>
<tabstop>baseWordLE</tabstop>
<tabstop>expandPB</tabstop>
<tabstop>dismissPB</tabstop>
<tabstop>expTypeCMB</tabstop>
<tabstop>stemLangCMB</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -2,7 +2,7 @@
# by "configure"
# Convert the uic files from qt3 to qt4.
UIFILES = advsearch.ui preview.ui sort.ui spell.ui \
UIFILES = advsearch.ui preview.ui sort.ui \
ssearchb.ui uiprefs.ui viewaction.ui
all: always $(UIFILES)
@ -13,8 +13,6 @@ preview.ui : ../qtgui/preview.ui
uic3 -convert ../qtgui/preview.ui > preview.ui
sort.ui : ../qtgui/sort.ui
uic3 -convert ../qtgui/sort.ui > sort.ui
spell.ui : ../qtgui/spell.ui
uic3 -convert ../qtgui/spell.ui > spell.ui
ssearchb.ui : ../qtgui/ssearchb.ui
uic3 -convert ../qtgui/ssearchb.ui > ssearchb.ui
uiprefs.ui : ../qtgui/uiprefs.ui

View File

@ -34,10 +34,7 @@ static char rcsid[] = "@(#$Id: spell_w.cpp,v 1.11 2007-02-19 16:28:05 dockes Exp
#if (QT_VERSION < 0x040000)
#include <qlistview.h>
#else
#define QListView Q3ListView
#define QListViewItem Q3ListViewItem
#define QListViewItemIterator Q3ListViewItemIterator
#include <q3listview.h>
#include <QTableWidget>
#endif
#include "debuglog.h"
@ -92,24 +89,30 @@ void SpellW::init()
connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(modeSet(int)));
connect(suggsLV,
#if (QT_VERSION < 0x040000)
SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)),
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
SIGNAL(doubleClicked(Q3ListViewItem *, const QPoint &, int)),
QStringList labels(tr("Term"));
labels.push_back(tr("Count"));
suggsLV->setHorizontalHeaderLabels(labels);
suggsLV->setShowGrid(0);
suggsLV->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
connect(suggsLV,
SIGNAL(cellDoubleClicked(int, int)),
this, SLOT(textDoubleClicked(int, int)));
#endif
this, SLOT(textDoubleClicked()));
connect(expTypeCMB, SIGNAL(activated(int)),
this, SLOT(modeSet(int)));
suggsLV->setColumnWidth(0, 200);
suggsLV->setColumnWidth(1, 100);
// No initial sorting: user can choose to establish one
suggsLV->setSorting(100, false);
}
#if (QT_VERSION < 0x040000)
// Subclass qlistviewitem for numeric sorting on column 1
class MyListViewItem : public QListViewItem
{
@ -127,12 +130,20 @@ public:
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;
@ -193,22 +204,42 @@ void SpellW::doExpand()
if (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 {
// Seems that need to use a reverse iterator to get same order in
// listview and input list ??
int row = 0;
#if (QT_VERSION < 0x040000)
for (list<Rcl::TermMatchEntry>::reverse_iterator it = entries.rbegin();
it != entries.rend(); it++) {
#else
for (list<Rcl::TermMatchEntry>::iterator it = entries.begin();
it != entries.end(); it++) {
#endif
LOGDEB(("SpellW::expand: %6d [%s]\n", it->wcf, it->term.c_str()));
char num[20];
if (it->wcf)
sprintf(num, "%d", 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
}
}
@ -222,8 +253,13 @@ void SpellW::wordChanged(const QString &text)
}
}
#if (QT_VERSION < 0x040000)
void SpellW::textDoubleClicked()
#else
void SpellW::textDoubleClicked(int row, int)
#endif
{
#if (QT_VERSION < 0x040000)
QListViewItemIterator it(suggsLV);
while (it.current()) {
QListViewItem *item = it.current();
@ -234,6 +270,11 @@ void SpellW::textDoubleClicked()
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)

View File

@ -53,7 +53,11 @@ public:
public slots:
virtual void doExpand();
virtual void wordChanged(const QString&);
#if (QT_VERSION < 0x040000)
virtual void textDoubleClicked();
#else
virtual void textDoubleClicked(int, int);
#endif
virtual void modeSet(int);
signals: