]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/searchcriterionvalue.cpp
* adjust order of search options
[dolphin.git] / src / search / searchcriterionvalue.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com> *
3 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
4 * *
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. *
9 * *
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. *
14 * *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "searchcriterionvalue.h"
22
23 #include <klineedit.h>
24 #include <klocale.h>
25
26 #include <nepomuk/tag.h>
27
28 #include <QComboBox>
29 #include <QDateEdit>
30 #include <QLabel>
31 #include <QHBoxLayout>
32 #include <QShowEvent>
33
34 SearchCriterionValue::SearchCriterionValue(QWidget* parent) :
35 QWidget(parent)
36 {
37 }
38
39 SearchCriterionValue::~SearchCriterionValue()
40 {
41 }
42
43 // -------------------------------------------------------------------------
44
45 DateValue::DateValue(QWidget* parent) :
46 SearchCriterionValue(parent),
47 m_dateEdit(0)
48 {
49 m_dateEdit = new QDateEdit(this);
50
51 QHBoxLayout* layout = new QHBoxLayout(this);
52 layout->setMargin(0);
53 layout->addWidget(m_dateEdit);
54 }
55
56 DateValue::~DateValue()
57 {
58 }
59
60 QString DateValue::value() const
61 {
62 return QString();
63 }
64
65 // -------------------------------------------------------------------------
66
67 TagValue::TagValue(QWidget* parent) :
68 SearchCriterionValue(parent),
69 m_tags(0)
70 {
71 m_tags = new QComboBox(this);
72 m_tags->setInsertPolicy(QComboBox::InsertAlphabetically);
73
74 QHBoxLayout* layout = new QHBoxLayout(this);
75 layout->setMargin(0);
76 layout->addWidget(m_tags);
77 }
78
79 TagValue::~TagValue()
80 {
81 }
82
83 QString TagValue::value() const
84 {
85 return QString();
86 }
87
88 void TagValue::showEvent(QShowEvent* event)
89 {
90 if (!event->spontaneous() && (m_tags->count() == 0)) {
91 const QList<Nepomuk::Tag> tags = Nepomuk::Tag::allTags();
92 foreach (const Nepomuk::Tag& tag, tags) {
93 m_tags->addItem(tag.label());
94 }
95
96 if (tags.count() == 0) {
97 m_tags->addItem(i18nc("@label", "No Tags Available"));
98 }
99 }
100 SearchCriterionValue::showEvent(event);
101 }
102
103 // -------------------------------------------------------------------------
104
105 SizeValue::SizeValue(QWidget* parent) :
106 SearchCriterionValue(parent),
107 m_lineEdit(0),
108 m_units(0)
109 {
110 m_lineEdit = new KLineEdit(this);
111 m_lineEdit->setClearButtonShown(true);
112
113 m_units = new QComboBox(this);
114 // TODO: check the KByte vs. KiByte dilemma :-/
115 m_units->addItem(i18nc("@label", "Byte"));
116 m_units->addItem(i18nc("@label", "KByte"));
117 m_units->addItem(i18nc("@label", "MByte"));
118 m_units->addItem(i18nc("@label", "GByte"));
119
120 QHBoxLayout* layout = new QHBoxLayout(this);
121 layout->setMargin(0);
122 layout->addWidget(m_lineEdit);
123 layout->addWidget(m_units);
124 }
125
126 SizeValue::~SizeValue()
127 {
128 }
129
130 QString SizeValue::value() const
131 {
132 return QString();
133 }
134
135 #include "searchcriterionvalue.moc"