Switch to unified view

a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp
...
...
50
#include <qcursor.h>
50
#include <qcursor.h>
51
#include <qevent.h>
51
#include <qevent.h>
52
#include <QFileSystemWatcher>
52
#include <QFileSystemWatcher>
53
#include <QThread>
53
#include <QThread>
54
#include <QProgressDialog>
54
#include <QProgressDialog>
55
#include <QToolBar>
55
56
56
#include "recoll.h"
57
#include "recoll.h"
57
#include "debuglog.h"
58
#include "debuglog.h"
58
#include "mimehandler.h"
59
#include "mimehandler.h"
59
#include "pathut.h"
60
#include "pathut.h"
...
...
154
        curid = id;
155
        curid = id;
155
    }
156
    }
156
    }
157
    }
157
    curid->setChecked(true);
158
    curid->setChecked(true);
158
159
159
    // Toolbar+combobox version of the category selector
160
    m_toolsTB = new QToolBar(this);
160
    QComboBox *catgCMB = 0;
161
    if (prefs.catgToolBar) {
162
        QToolBar *catgToolBar = new QToolBar(this);
163
  catgCMB = new QComboBox(catgToolBar);
164
  catgCMB->setEditable(FALSE);
165
  catgCMB->addItem(tr("All"));
166
        catgToolBar->setObjectName(QString::fromUtf8("catgToolBar"));
161
    m_toolsTB->setObjectName(QString::fromUtf8("m_toolsTB"));
167
  catgCMB->setToolTip(tr("Document category filter"));
162
    m_toolsTB->addAction(toolsAdvanced_SearchAction);
168
        catgToolBar->addWidget(catgCMB);
163
    m_toolsTB->addAction(toolsDoc_HistoryAction);
164
    m_toolsTB->addAction(toolsSpellAction);
169
        this->addToolBar(Qt::TopToolBarArea, catgToolBar);
165
    this->addToolBar(Qt::TopToolBarArea, m_toolsTB);
170
    }
171
166
172
    // Document categories buttons
167
    m_resTB = new QToolBar(this);
168
    m_resTB->setObjectName(QString::fromUtf8("m_resTB"));
169
    this->addToolBar(Qt::TopToolBarArea, m_resTB);
170
171
    // Document filter buttons and combobox
172
    // Combobox version of the document filter control
173
    m_filtCMB = new QComboBox(m_resTB);
174
    m_filtCMB->setEditable(FALSE);
175
    m_filtCMB->addItem(tr("All"));
176
    m_filtCMB->setToolTip(tr("Document filter"));
177
    // Buttons version of the document filter control
178
    m_filtFRM = new QFrame(this);
179
    m_filtFRM->setObjectName(QString::fromUtf8("m_filtFRM"));
180
    QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Maximum);
181
    sizePolicy2.setHorizontalStretch(0);
182
    sizePolicy2.setVerticalStretch(0);
183
    sizePolicy2.setHeightForWidth(m_filtFRM->sizePolicy().hasHeightForWidth());
184
    m_filtFRM->setSizePolicy(sizePolicy2);
173
    QHBoxLayout *bgrphbox = new QHBoxLayout(catgBGRP);
185
    QHBoxLayout *bgrphbox = new QHBoxLayout(m_filtFRM);
174
    QButtonGroup *bgrp  = new QButtonGroup(catgBGRP);
186
    m_filtBGRP  = new QButtonGroup(m_filtFRM);
187
    QRadioButton *allRDB = new QRadioButton(m_filtFRM);
188
    verticalLayout->insertWidget(1, m_filtFRM);
189
    allRDB->setObjectName(QString::fromUtf8("allRDB"));
190
    allRDB->setGeometry(QRect(0, 0, 45, 20));
191
    allRDB->setText(tr("All"));
175
    bgrphbox->addWidget(allRDB);
192
    bgrphbox->addWidget(allRDB);
176
    int bgrpid = 0;
193
    int bgrpid = 0;
177
    bgrp->addButton(allRDB, bgrpid++);
194
    m_filtBGRP->addButton(allRDB, bgrpid++);
178
    connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int)));
179
    allRDB->setChecked(true);
195
    allRDB->setChecked(true);
196
197
    // Menu version of the document filter control
198
    m_filtMN = new QMenu(MenuBar);
199
    m_filtMN->setObjectName(QString::fromUtf8("m_filtMN"));
200
    MenuBar->insertMenu(helpMenu->menuAction(), m_filtMN);
201
    m_filtMN->setTitle("F&ilter");
202
    QActionGroup *fltag = new QActionGroup(this);
203
    fltag->setExclusive(true);
204
    QAction *act = fltag->addAction(tr("All"));
205
    m_filtMN->addAction(act);
206
    act->setCheckable(true);
207
    act->setData((int)0);
208
209
    // Go through the filter list and setup buttons and combobox
180
    vector<string> cats;
210
    vector<string> cats;
181
    theconfig->getGuiFilterNames(cats);
211
    theconfig->getGuiFilterNames(cats);
182
    // Text for button 0 is not used. Next statement just avoids unused
183
    // variable compiler warning for catg_strings
184
    m_catgbutvec.push_back(catg_strings[0]);
212
    m_catgbutvec.push_back(catg_strings[0]);
185
    for (vector<string>::const_iterator it = cats.begin();
213
    for (vector<string>::const_iterator it = cats.begin();
186
     it != cats.end(); it++) {
214
     it != cats.end(); it++) {
187
    QRadioButton *but = new QRadioButton(catgBGRP);
215
    QRadioButton *but = new QRadioButton(m_filtFRM);
188
    QString catgnm = QString::fromUtf8(it->c_str(), it->length());
216
    QString catgnm = QString::fromUtf8(it->c_str(), it->length());
189
    m_catgbutvec.push_back(*it);
217
    m_catgbutvec.push_back(*it);
190
    // We strip text before the first colon before setting the button name.
218
    // We strip text before the first colon before setting the button name.
191
    // This is so that the user can decide the order of buttons by naming 
219
    // This is so that the user can decide the order of buttons by naming 
192
    // the filter,ie, a:media b:messages etc.
220
    // the filter,ie, a:media b:messages etc.
...
...
194
    int colon = catgnm.indexOf(':');
222
    int colon = catgnm.indexOf(':');
195
    if (colon != -1) {
223
    if (colon != -1) {
196
        but_txt = catgnm.right(catgnm.size()-(colon+1));
224
        but_txt = catgnm.right(catgnm.size()-(colon+1));
197
    }
225
    }
198
    but->setText(tr(but_txt.toUtf8()));
226
    but->setText(tr(but_txt.toUtf8()));
199
  if (prefs.catgToolBar && catgCMB)
227
        m_filtCMB->addItem(tr(but_txt.toUtf8()));
200
      catgCMB->addItem(tr(catgnm.toUtf8()));
201
        bgrphbox->addWidget(but);
228
        bgrphbox->addWidget(but);
202
        bgrp->addButton(but, bgrpid++);
229
        m_filtBGRP->addButton(but, bgrpid++);
230
        QAction *act = fltag->addAction(tr(but_txt.toUtf8()));
231
        m_filtMN->addAction(act);
232
        act->setCheckable(true);
233
        act->setData((int)(m_catgbutvec.size()-1));
234
        m_filtMN->connect(m_filtMN, SIGNAL(triggered(QAction *)), this, 
235
                          SLOT(catgFilter(QAction *)));
203
    }
236
    }
204
    catgBGRP->setLayout(bgrphbox);
237
    m_filtFRM->setLayout(bgrphbox);
205
238
    connect(m_filtBGRP, SIGNAL(buttonClicked(int)),this, SLOT(catgFilter(int)));
206
    if (prefs.catgToolBar)
239
    connect(m_filtCMB, SIGNAL(activated(int)), this, SLOT(catgFilter(int)));
207
  catgBGRP->hide();
208
240
209
    sSearch->queryText->installEventFilter(this);
241
    sSearch->queryText->installEventFilter(this);
210
242
211
    restable = new ResTable(this);
243
    restable = new ResTable(this);
212
    verticalLayout->insertWidget(2, restable);
244
    verticalLayout->insertWidget(2, restable);
...
...
264
    connect(queryPrefsAction, SIGNAL(triggered()), 
296
    connect(queryPrefsAction, SIGNAL(triggered()), 
265
        this, SLOT(showUIPrefs()));
297
        this, SLOT(showUIPrefs()));
266
    connect(extIdxAction, SIGNAL(triggered()), 
298
    connect(extIdxAction, SIGNAL(triggered()), 
267
        this, SLOT(showExtIdxDialog()));
299
        this, SLOT(showExtIdxDialog()));
268
300
269
    if (prefs.catgToolBar && catgCMB)
270
  connect(catgCMB, SIGNAL(activated(int)), 
271
      this, SLOT(catgFilter(int)));
272
    connect(toggleFullScreenAction, SIGNAL(triggered()), 
301
    connect(toggleFullScreenAction, SIGNAL(triggered()), 
273
            this, SLOT(toggleFullScreen()));
302
            this, SLOT(toggleFullScreen()));
274
    connect(actionShowQueryDetails, SIGNAL(triggered()),
303
    connect(actionShowQueryDetails, SIGNAL(triggered()),
275
        reslist, SLOT(showQueryDetails()));
304
        reslist, SLOT(showQueryDetails()));
276
    connect(periodictimer, SIGNAL(timeout()), 
305
    connect(periodictimer, SIGNAL(timeout()), 
...
...
348
    connect(reslist, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)), 
377
    connect(reslist, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)), 
349
        this, SLOT(startPreview(int, Rcl::Doc, int)));
378
        this, SLOT(startPreview(int, Rcl::Doc, int)));
350
    connect(reslist, SIGNAL(previewRequested(Rcl::Doc)), 
379
    connect(reslist, SIGNAL(previewRequested(Rcl::Doc)), 
351
        this, SLOT(startPreview(Rcl::Doc)));
380
        this, SLOT(startPreview(Rcl::Doc)));
352
381
382
    setFilterCtlStyle(prefs.filterCtlStyle);
383
353
    if (prefs.keepSort && prefs.sortActive) {
384
    if (prefs.keepSort && prefs.sortActive) {
354
    m_sortspec.field = (const char *)prefs.sortField.toUtf8();
385
    m_sortspec.field = (const char *)prefs.sortField.toUtf8();
355
    m_sortspec.desc = prefs.sortDesc;
386
    m_sortspec.desc = prefs.sortDesc;
356
    onSortDataChanged(m_sortspec);
387
    onSortDataChanged(m_sortspec);
357
    emit sortDataChanged(m_sortspec);
388
    emit sortDataChanged(m_sortspec);
...
...
366
397
367
void RclMain::resultCount(int n)
398
void RclMain::resultCount(int n)
368
{
399
{
369
    actionSortByDateAsc->setEnabled(n>0);
400
    actionSortByDateAsc->setEnabled(n>0);
370
    actionSortByDateDesc->setEnabled(n>0);
401
    actionSortByDateDesc->setEnabled(n>0);
402
}
403
404
void RclMain::setFilterCtlStyle(int stl)
405
{
406
    switch (stl) {
407
    case PrefsPack::FCS_MN:
408
        setupResTB(false);
409
        m_filtFRM->setVisible(false);
410
        m_filtMN->menuAction()->setVisible(true);
411
        break;
412
    case PrefsPack::FCS_CMB:
413
        setupResTB(true);
414
        m_filtFRM->setVisible(false);
415
        m_filtMN->menuAction()->setVisible(false);
416
        break;
417
    case PrefsPack::FCS_BT:
418
    default:
419
        setupResTB(false);
420
        m_filtFRM->setVisible(true);
421
        m_filtMN->menuAction()->setVisible(false);
422
    }
423
}
424
425
// Set up the "results" toolbox, adding the filter combobox or not depending
426
// on config option
427
void RclMain::setupResTB(bool combo)
428
{
429
    m_resTB->clear();
430
    m_resTB->addAction(firstPageAction);
431
    m_resTB->addAction(prevPageAction);
432
    m_resTB->addAction(nextPageAction);
433
    m_resTB->addSeparator();
434
    m_resTB->addAction(actionSortByDateAsc);
435
    m_resTB->addAction(actionSortByDateDesc);
436
    if (combo) {
437
        m_resTB->addSeparator();
438
        m_filtCMB->show();
439
        m_resTB->addWidget(m_filtCMB);
440
    } else {
441
        m_filtCMB->hide();
442
    }
443
    m_resTB->addSeparator();
444
    m_resTB->addAction(actionShowResultsAsTable);
371
}
445
}
372
446
373
// This is called by a timer right after we come up. Try to open
447
// This is called by a timer right after we come up. Try to open
374
// the database and talk to the user if we can't
448
// the database and talk to the user if we can't
375
void RclMain::initDbOpen()
449
void RclMain::initDbOpen()
...
...
2078
    if (m_source.isNull())
2152
    if (m_source.isNull())
2079
    return "";
2153
    return "";
2080
    return QString::fromUtf8(m_source->getDescription().c_str());
2154
    return QString::fromUtf8(m_source->getDescription().c_str());
2081
}
2155
}
2082
2156
2157
// Set filter, action style
2158
void RclMain::catgFilter(QAction *act)
2159
{
2160
    int id = act->data().toInt();
2161
    catgFilter(id);
2162
}
2163
2083
// User pressed a category button: set filter params in reslist
2164
// User pressed a filter button: set filter params in reslist
2084
void RclMain::catgFilter(int id)
2165
void RclMain::catgFilter(int id)
2085
{
2166
{
2086
    LOGDEB(("RclMain::catgFilter: id %d\n"));
2167
    LOGDEB(("RclMain::catgFilter: id %d\n", id));
2087
    if (id < 0 || id >= int(m_catgbutvec.size()))
2168
    if (id < 0 || id >= int(m_catgbutvec.size()))
2088
    return; 
2169
    return; 
2170
2171
    switch (prefs.filterCtlStyle) {
2172
    case PrefsPack::FCS_MN:
2173
        m_filtCMB->setCurrentIndex(id);
2174
        m_filtBGRP->buttons()[id]->setChecked(true);
2175
        break;
2176
    case PrefsPack::FCS_CMB:
2177
        m_filtBGRP->buttons()[id]->setChecked(true);
2178
        m_filtMN->actions()[id]->setChecked(true);
2179
        break;
2180
    case PrefsPack::FCS_BT:
2181
    default:
2182
        m_filtCMB->setCurrentIndex(id);
2183
        m_filtMN->actions()[id]->setChecked(true);
2184
    }
2089
2185
2090
    m_filtspec.reset();
2186
    m_filtspec.reset();
2091
2187
2092
    if (id != 0)  {
2188
    if (id != 0)  {
2093
    string catg = m_catgbutvec[id];
2189
    string catg = m_catgbutvec[id];