Switch to unified view

a/src/qtgui/advsearch.ui.h b/src/qtgui/advsearch.ui.h
1
/*
2
 *   This program is free software; you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation; either version 2 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program; if not, write to the
14
 *   Free Software Foundation, Inc.,
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
17
/****************************************************************************
1
/****************************************************************************
18
** ui.h extension file, included from the uic-generated form implementation.
2
** ui.h extension file, included from the uic-generated form implementation.
19
**
3
**
20
** If you want to add, delete, or rename functions or slots, use
4
** If you want to add, delete, or rename functions or slots, use
21
** Qt Designer to update this file, preserving your code.
5
** Qt Designer to update this file, preserving your code.
...
...
23
** You should not define a constructor or destructor in this file.
7
** You should not define a constructor or destructor in this file.
24
** Instead, write your code in functions called init() and destroy().
8
** Instead, write your code in functions called init() and destroy().
25
** These will automatically be called by the form's constructor and
9
** These will automatically be called by the form's constructor and
26
** destructor.
10
** destructor.
27
*****************************************************************************/
11
*****************************************************************************/
28
29
#include <qfiledialog.h>
30
#include <qmessagebox.h>
31
32
#include <list>
33
#include <string>
34
35
#ifndef NO_NAMESPACES
36
using std::list;
37
using std::string;
38
#endif /* NO_NAMESPACES */
39
40
#include "recoll.h"
41
#include "rclconfig.h"
42
#include "debuglog.h"
43
#include "searchdata.h"
44
45
extern RclConfig *rclconfig;
46
47
// Constructor/initialization
48
void advsearch::init()
49
{
50
    list<string> types = rclconfig->getAllMimeTypes();
51
52
    QStringList ql;
53
    for (list<string>::iterator it = types.begin(); it != types.end(); it++) {
54
  ql.append(it->c_str());
55
    }
56
    yesFiltypsLB->insertStringList(ql);
57
}
58
59
// Move selected file types from the searched to the ignored box
60
void advsearch::delFiltypPB_clicked()
61
{
62
    list<int> trl;
63
    QStringList moved;
64
    for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
65
  QListBoxItem *item = yesFiltypsLB->item(i);
66
  if (item && item->isSelected()) {
67
      moved.push_back(item->text());
68
      trl.push_front(i);
69
  }
70
    }
71
    if (!moved.empty()) {
72
  noFiltypsLB->insertStringList(moved);
73
  for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
74
      yesFiltypsLB->removeItem(*it);
75
    }
76
    yesFiltypsLB->sort();
77
    noFiltypsLB->sort();
78
}
79
80
void advsearch::delAFiltypPB_clicked()
81
{
82
    for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
83
  yesFiltypsLB->setSelected(i, true);
84
    }
85
    delFiltypPB_clicked();
86
}
87
88
// Move selected file types from the ignored to the searched box
89
void advsearch::addFiltypPB_clicked()
90
{
91
    list<int> trl;
92
    QStringList moved;
93
    for (unsigned int i = 0; i < noFiltypsLB->count(); i++) {
94
  QListBoxItem *item = noFiltypsLB->item(i);
95
  if (item && item->isSelected()) {
96
      moved.push_back(item->text());
97
      trl.push_front(i);
98
  }
99
    }
100
    if (!moved.empty()) {
101
  yesFiltypsLB->insertStringList(moved);
102
  for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
103
      noFiltypsLB->removeItem(*it);
104
    }
105
    yesFiltypsLB->sort();
106
    noFiltypsLB->sort();
107
}
108
109
void advsearch::addAFiltypPB_clicked()
110
{
111
    for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
112
  noFiltypsLB->setSelected(i, true);
113
    }
114
    addFiltypPB_clicked();
115
}
116
117
118
// Activate file type selection
119
void advsearch::restrictFtCB_toggled(bool on)
120
{
121
    yesFiltypsLB->setEnabled(on);
122
    delFiltypPB->setEnabled(on);
123
    addFiltypPB->setEnabled(on);
124
    delAFiltypPB->setEnabled(on);
125
    addAFiltypPB->setEnabled(on);
126
    noFiltypsLB->setEnabled(on);
127
}
128
129
void advsearch::searchPB_clicked()
130
{
131
    Rcl::AdvSearchData mydata;
132
133
    mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
134
    mydata.phrase  = string((const char*)(phraseLE->text().utf8()));
135
    mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
136
    mydata.orwords1 = string((const char*)(orWords1LE->text().utf8()));
137
    mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
138
    mydata.filename = string((const char*)(fileNameLE->text().utf8()));
139
140
    if (mydata.allwords.empty() && mydata.phrase.empty() && 
141
  mydata.orwords.empty() && mydata.orwords1.empty() && 
142
  mydata.filename.empty()) {
143
  if (mydata.nowords.empty())
144
      return;
145
  QMessageBox::warning(0, "Recoll",
146
               tr("Cannot execute pure negative query. "
147
              "Please enter common terms in the 'any words' field")); 
148
  return;
149
    }
150
151
    if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
152
  for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
153
      QCString ctext = yesFiltypsLB->item(i)->text().utf8();
154
      mydata.filetypes.push_back(string((const char *)ctext));
155
  }
156
    }
157
    if (!subtreeLE->text().isEmpty()) {
158
  mydata.topdir = string((const char*)(subtreeLE->text().utf8()));
159
    }
160
    emit startSearch(mydata);
161
}
162
163
164
void advsearch::browsePB_clicked()
165
{
166
    QString dir = QFileDialog::getExistingDirectory();
167
    subtreeLE->setText(dir);
168
}
169