]>
cloud.milkyroute.net Git - dolphin.git/blob - 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> *
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "searchcriterionvalue.h"
23 #include <kdatewidget.h>
24 #include <klineedit.h>
27 #include <nepomuk/tag.h>
31 #include <QIntValidator>
33 #include <QHBoxLayout>
36 SearchCriterionValue::SearchCriterionValue(QWidget
* parent
) :
41 SearchCriterionValue::~SearchCriterionValue()
45 // -------------------------------------------------------------------------
47 DateValue::DateValue(QWidget
* parent
) :
48 SearchCriterionValue(parent
),
51 m_dateWidget
= new KDateWidget(QDate::currentDate(), this);
53 QHBoxLayout
* layout
= new QHBoxLayout(this);
55 layout
->addWidget(m_dateWidget
);
58 DateValue::~DateValue()
62 QString
DateValue::value() const
64 return m_dateWidget
->date().toString(Qt::ISODate
);
67 // -------------------------------------------------------------------------
69 TagValue::TagValue(QWidget
* parent
) :
70 SearchCriterionValue(parent
),
73 m_tags
= new QComboBox(this);
74 m_tags
->setInsertPolicy(QComboBox::InsertAlphabetically
);
76 QHBoxLayout
* layout
= new QHBoxLayout(this);
78 layout
->addWidget(m_tags
);
80 connect(m_tags
, SIGNAL(activated(QString
)),
81 this, SIGNAL(valueChanged(QString
)));
88 QString
TagValue::value() const
90 return m_tags
->currentText();
93 void TagValue::showEvent(QShowEvent
* event
)
95 if (!event
->spontaneous() && (m_tags
->count() == 0)) {
96 const QList
<Nepomuk::Tag
> tags
= Nepomuk::Tag::allTags();
97 foreach (const Nepomuk::Tag
& tag
, tags
) {
98 m_tags
->addItem(tag
.label());
101 if (tags
.count() == 0) {
102 m_tags
->addItem(i18nc("@label", "No Tags Available"));
105 SearchCriterionValue::showEvent(event
);
108 // -------------------------------------------------------------------------
110 SizeValue::SizeValue(QWidget
* parent
) :
111 SearchCriterionValue(parent
),
115 m_lineEdit
= new KLineEdit(this);
116 m_lineEdit
->setClearButtonShown(true);
117 m_lineEdit
->setValidator(new QIntValidator(this));
118 m_lineEdit
->setAlignment(Qt::AlignRight
);
120 m_units
= new QComboBox(this);
121 // TODO: check the KByte vs. KiByte dilemma :-/
122 m_units
->addItem(i18nc("@label", "Byte"));
123 m_units
->addItem(i18nc("@label", "KByte"));
124 m_units
->addItem(i18nc("@label", "MByte"));
125 m_units
->addItem(i18nc("@label", "GByte"));
127 // set 1 MByte as default
128 m_lineEdit
->setText("1");
129 m_units
->setCurrentIndex(2);
131 QHBoxLayout
* layout
= new QHBoxLayout(this);
132 layout
->setMargin(0);
133 layout
->addWidget(m_lineEdit
);
134 layout
->addWidget(m_units
);
137 SizeValue::~SizeValue()
141 QString
SizeValue::value() const
146 #include "searchcriterionvalue.moc"