1
/***************************************************************************
2
* Copyright (C) 2004-2011 by Thomas Fischer *
3
* fischer@unix-ag.uni-kl.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
#include <QGridLayout>
28
#include "websearchgeneral.h"
30
WebSearchQueryFormGeneral::WebSearchQueryFormGeneral(QWidget *parent)
31
: WebSearchQueryFormAbstract(parent)
33
QGridLayout *layout = new QGridLayout(this);
36
QLabel *label = new QLabel(i18n("Free text:"), this);
37
layout->addWidget(label, 0, 0, 1, 1);
38
KLineEdit *lineEdit = new KLineEdit(this);
39
lineEdit->setClearButtonShown(true);
40
lineEdit->setFocus(Qt::TabFocusReason);
41
layout->addWidget(lineEdit, 0, 1, 1, 1);
42
queryFields.insert(WebSearchAbstract::queryKeyFreeText, lineEdit);
43
label->setBuddy(lineEdit);
44
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
46
label = new QLabel(i18n("Title:"), this);
47
layout->addWidget(label, 1, 0, 1, 1);
48
lineEdit = new KLineEdit(this);
49
lineEdit->setClearButtonShown(true);
50
queryFields.insert(WebSearchAbstract::queryKeyTitle, lineEdit);
51
layout->addWidget(lineEdit, 1, 1, 1, 1);
52
label->setBuddy(lineEdit);
53
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
55
label = new QLabel(i18n("Author:"), this);
56
layout->addWidget(label, 2, 0, 1, 1);
57
lineEdit = new KLineEdit(this);
58
lineEdit->setClearButtonShown(true);
59
queryFields.insert(WebSearchAbstract::queryKeyAuthor, lineEdit);
60
layout->addWidget(lineEdit, 2, 1, 1, 1);
61
label->setBuddy(lineEdit);
62
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
64
label = new QLabel(i18n("Year:"), this);
65
layout->addWidget(label, 3, 0, 1, 1);
66
lineEdit = new KLineEdit(this);
67
lineEdit->setClearButtonShown(true);
68
queryFields.insert(WebSearchAbstract::queryKeyYear, lineEdit);
69
layout->addWidget(lineEdit, 3, 1, 1, 1);
70
label->setBuddy(lineEdit);
71
connect(lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
73
label = new QLabel(i18n("Number of Results:"), this);
74
layout->addWidget(label, 4, 0, 1, 1);
75
numResultsField = new QSpinBox(this);
76
numResultsField->setMinimum(3);
77
numResultsField->setMaximum(100);
78
numResultsField->setValue(20);
79
layout->addWidget(numResultsField, 4, 1, 1, 1);
80
label->setBuddy(numResultsField);
82
layout->setRowStretch(5, 100);
85
bool WebSearchQueryFormGeneral::readyToStart() const
87
for (QMap<QString, KLineEdit*>::ConstIterator it = queryFields.constBegin(); it != queryFields.constEnd(); ++it)
88
if (!it.value()->text().isEmpty())
94
QMap<QString, QString> WebSearchQueryFormGeneral::getQueryTerms()
96
QMap<QString, QString> result;
98
for (QMap<QString, KLineEdit*>::ConstIterator it = queryFields.constBegin(); it != queryFields.constEnd(); ++it) {
99
if (!it.value()->text().isEmpty())
100
result.insert(it.key(), it.value()->text());
106
int WebSearchQueryFormGeneral::getNumResults()
108
return numResultsField->value();