Switch to unified view

a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp
...
...
32
#include <qtooltip.h>
32
#include <qtooltip.h>
33
#include <qcombobox.h>
33
#include <qcombobox.h>
34
#if (QT_VERSION < 0x040000)
34
#if (QT_VERSION < 0x040000)
35
#include <qlistview.h>
35
#include <qlistview.h>
36
#else
36
#else
37
#define QListView Q3ListView
37
#include <QTableWidget>
38
#define QListViewItem Q3ListViewItem
39
#define QListViewItemIterator Q3ListViewItemIterator
40
#include <q3listview.h>
41
#endif
38
#endif
42
39
43
#include "debuglog.h"
40
#include "debuglog.h"
44
#include "recoll.h"
41
#include "recoll.h"
45
#include "spell_w.h"
42
#include "spell_w.h"
...
...
90
    connect(baseWordLE, SIGNAL(textChanged(const QString&)), 
87
    connect(baseWordLE, SIGNAL(textChanged(const QString&)), 
91
        this, SLOT(wordChanged(const QString&)));
88
        this, SLOT(wordChanged(const QString&)));
92
    connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
89
    connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
93
    connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
90
    connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
94
    connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
91
    connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
92
    connect(expTypeCMB, SIGNAL(activated(int)), this, SLOT(modeSet(int)));
95
93
94
#if (QT_VERSION < 0x040000)
96
    connect(suggsLV,
95
    connect(suggsLV,
97
#if (QT_VERSION < 0x040000)
98
     SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)),
96
            SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)),
99
#else
100
     SIGNAL(doubleClicked(Q3ListViewItem *, const QPoint &, int)),
101
#endif
102
     this, SLOT(textDoubleClicked()));
97
            this, SLOT(textDoubleClicked()));
103
98
    // No initial sorting: user can choose to establish one
104
    connect(expTypeCMB, SIGNAL(activated(int)), 
99
    suggsLV->setSorting(100, false);
105
      this, SLOT(modeSet(int)));
100
#else
101
    QStringList labels(tr("Term"));
102
    labels.push_back(tr("Count"));
103
    suggsLV->setHorizontalHeaderLabels(labels);
104
    suggsLV->setShowGrid(0);
105
    suggsLV->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
106
    connect(suggsLV,
107
     SIGNAL(cellDoubleClicked(int, int)),
108
            this, SLOT(textDoubleClicked(int, int)));
109
#endif
106
110
107
    suggsLV->setColumnWidth(0, 200);
111
    suggsLV->setColumnWidth(0, 200);
108
    suggsLV->setColumnWidth(1, 100);
112
    suggsLV->setColumnWidth(1, 100);
109
    // No initial sorting: user can choose to establish one
110
    suggsLV->setSorting(100, false);
111
}
113
}
112
114
115
#if (QT_VERSION < 0x040000)
113
// Subclass qlistviewitem for numeric sorting on column 1
116
// Subclass qlistviewitem for numeric sorting on column 1
114
class MyListViewItem : public QListViewItem
117
class MyListViewItem : public QListViewItem
115
{
118
{
116
public:
119
public:
117
    MyListViewItem(QListView *listView, const QString& s1, const QString& s2)
120
    MyListViewItem(QListView *listView, const QString& s1, const QString& s2)
...
...
125
        return i->text(1).toInt() - text(1).toInt();
128
        return i->text(1).toInt() - text(1).toInt();
126
    // ??
129
    // ??
127
    return 0;
130
    return 0;
128
    }
131
    }
129
};
132
};
133
#else
130
134
135
136
#endif
131
137
132
/* Expand term according to current mode */
138
/* Expand term according to current mode */
133
void SpellW::doExpand()
139
void SpellW::doExpand()
134
{
140
{
141
    // Can't clear qt4 table widget: resets column headers too
142
#if (QT_VERSION < 0x040000)
135
    suggsLV->clear();
143
    suggsLV->clear();
144
#else
145
    suggsLV->setRowCount(0);
146
#endif
136
    if (baseWordLE->text().isEmpty()) 
147
    if (baseWordLE->text().isEmpty()) 
137
    return;
148
    return;
138
149
139
    string reason;
150
    string reason;
140
    if (!maybeOpenDb(reason)) {
151
    if (!maybeOpenDb(reason)) {
...
...
191
#endif
202
#endif
192
    }
203
    }
193
204
194
205
195
    if (entries.empty()) {
206
    if (entries.empty()) {
207
#if (QT_VERSION < 0x040000)
196
    new MyListViewItem(suggsLV, tr("No expansion found"), "");
208
    new MyListViewItem(suggsLV, tr("No expansion found"), "");
209
#else
210
        suggsLV->setItem(0, 0, new QTableWidgetItem(tr("No expansion found")));
211
#endif
197
    } else {
212
    } else {
198
  // Seems that need to use a reverse iterator to get same order in 
213
        int row = 0;
199
  // listview and input list ??
214
#if (QT_VERSION < 0x040000)
200
    for (list<Rcl::TermMatchEntry>::reverse_iterator it = entries.rbegin(); 
215
    for (list<Rcl::TermMatchEntry>::reverse_iterator it = entries.rbegin(); 
201
         it != entries.rend(); it++) {
216
         it != entries.rend(); it++) {
217
#else
218
  for (list<Rcl::TermMatchEntry>::iterator it = entries.begin(); 
219
       it != entries.end(); it++) {
220
#endif
202
        LOGDEB(("SpellW::expand: %6d [%s]\n", it->wcf, it->term.c_str()));
221
        LOGDEB(("SpellW::expand: %6d [%s]\n", it->wcf, it->term.c_str()));
203
        char num[20];
222
        char num[20];
204
        if (it->wcf)
223
        if (it->wcf)
205
        sprintf(num, "%d", it->wcf);
224
        sprintf(num, "%d", it->wcf);
206
        else
225
        else
207
        num[0] = 0;
226
        num[0] = 0;
227
#if (QT_VERSION < 0x040000)
208
        new MyListViewItem(suggsLV, 
228
        new MyListViewItem(suggsLV, 
209
                  QString::fromUtf8(it->term.c_str()),
229
                  QString::fromUtf8(it->term.c_str()),
210
                  QString::fromAscii(num));
230
                  QString::fromAscii(num));
231
#else
232
            if (suggsLV->rowCount() <= row)
233
                suggsLV->setRowCount(row+1);
234
            suggsLV->setItem(row, 0, 
235
                    new QTableWidgetItem(QString::fromUtf8(it->term.c_str()))); 
236
            suggsLV->setItem(row++, 1, 
237
                             new QTableWidgetItem(QString::fromAscii(num)));
238
#endif
211
    }
239
    }
240
#if (QT_VERSION >= 0x040000)
241
        suggsLV->setRowCount(row+1);
242
#endif
212
    }
243
    }
213
}
244
}
214
245
215
void SpellW::wordChanged(const QString &text)
246
void SpellW::wordChanged(const QString &text)
216
{
247
{
...
...
220
    } else {
251
    } else {
221
    expandPB->setEnabled(true);
252
    expandPB->setEnabled(true);
222
    }
253
    }
223
}
254
}
224
255
256
#if (QT_VERSION < 0x040000)
225
void SpellW::textDoubleClicked()
257
void SpellW::textDoubleClicked()
258
#else
259
void SpellW::textDoubleClicked(int row, int)
260
#endif
226
{
261
{
262
#if (QT_VERSION < 0x040000)
227
    QListViewItemIterator it(suggsLV);
263
    QListViewItemIterator it(suggsLV);
228
    while (it.current()) {
264
    while (it.current()) {
229
    QListViewItem *item = it.current();
265
    QListViewItem *item = it.current();
230
    if (!item->isSelected()) {
266
    if (!item->isSelected()) {
231
        ++it;
267
        ++it;
232
        continue;
268
        continue;
233
    }
269
    }
234
    emit(wordSelect((const char *)item->text(0)));
270
    emit(wordSelect((const char *)item->text(0)));
235
    ++it;
271
    ++it;
236
    }
272
    }
273
#else
274
    QTableWidgetItem *item = suggsLV->item(row, 0);
275
    if (item)
276
        emit(wordSelect(item->text()));
277
#endif
237
}
278
}
238
279
239
void SpellW::modeSet(int mode)
280
void SpellW::modeSet(int mode)
240
{
281
{
241
    if (mode == 2)
282
    if (mode == 2)