void DolphinViewContainer::initializeProgress()
{
- if (m_view->url().protocol() == "nepomuksearch") {
+ if (url().protocol() == "nepomuksearch") {
// The Nepomuk IO-slave does not provide any progress information. Give
// an immediate hint to the user that a searching is done:
m_statusBar->setProgressText(i18nc("@info", "Searching..."));
m_statusBar->setProgress(100);
}
- updateStatusBar();
+ if ((url().protocol() == "nepomuksearch") && (m_dirLister->items().count() == 0)) {
+ // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead
+ // of showing the default status bar information ("0 items") a more helpful information is given:
+ m_statusBar->setMessage(i18nc("@info:status", "No items found."), DolphinStatusBar::Information);
+ } else {
+ updateStatusBar();
+ }
QMetaObject::invokeMethod(this, "restoreContentsPos", Qt::QueuedConnection);
// Enable the 'File'->'Create New...' menu only if the directory
public:
struct Comparator
{
- Comparator(const QString& n, const QString& o = QString(), const QString& p = QString()) :
- name(n), operation(o), prefix(p) {}
- QString name; // user visible and translated name
- QString operation; // Nepomuk operation that represents the comparator
- QString prefix; // prefix like "+" or "-" that is part of the Nepomuk query
+ Comparator(const QString& n, const QString& o = QString(),
+ const QString& p = QString(), const QString& a = QString()) :
+ name(n), operation(o), prefix(p), autoValueType(a) {}
+ QString name; // user visible and translated name
+ QString operation; // Nepomuk operation that represents the comparator
+ QString prefix; // prefix like "+" or "-" that is part of the Nepomuk query
+ QString autoValueType; // type for an automatically calculated value of the value widget
};
SearchCriterionDescription(const QString& name,
const int descIndex = m_descriptionsBox->currentIndex();
const SearchCriterionDescription& descr = m_descriptions[descIndex];
const SearchCriterionDescription::Comparator& comp = descr.comparators()[index];
- m_valueWidget->setVisible(!comp.operation.isEmpty());
+
+ m_valueWidget->initializeValue(comp.autoValueType);
+ if (!comp.operation.isEmpty() && comp.autoValueType.isEmpty()) {
+ // only show the value widget, if an operation is defined
+ // and no automatic calculation is provided
+ m_valueWidget->show();
+ }
emit criterionChanged();
}
// add "Date" description
QList<SearchCriterionDescription::Comparator> dateComps;
- dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Anytime"))); // TODO
- dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Today"))); // TODO
- dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This week"))); // TODO
- dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This month"))); // TODO
+ dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Anytime")));
+ dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Today"), ":", "+", "today"));
+ dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This Week"), ">=", "+", "thisWeek"));
+ dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This Month"), ">=", "+", "thisMonth"));
+ dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This Year"), ">=", "+", "thisYear"));
foreach (const SearchCriterionDescription::Comparator& comp, defaultComps) {
dateComps.append(comp);
}
{
}
+void SearchCriterionValue::initializeValue(const QString& valueType)
+{
+ Q_UNUSED(valueType);
+}
+
// -------------------------------------------------------------------------
DateValue::DateValue(QWidget* parent) :
return m_dateWidget->date().toString(Qt::ISODate);
}
+void DateValue::initializeValue(const QString& valueType)
+{
+ if (valueType.isEmpty()) {
+ return;
+ }
+
+ QDate date;
+ if (valueType == "today") {
+ date = QDate::currentDate();
+ } else if (valueType == "thisWeek") {
+ const QDate today = QDate::currentDate();
+ const int dayOfWeek = today.dayOfWeek();
+ date = today.addDays(-dayOfWeek);
+ } else if (valueType == "thisMonth") {
+ const QDate today = QDate::currentDate();
+ date = QDate(today.year(), today.month(), 1);
+ } else if (valueType == "thisYear") {
+ date = QDate(QDate::currentDate().year(), 1, 1);
+ } else {
+ // unknown value-type
+ Q_ASSERT(false);
+ }
+ m_dateWidget->setDate(date);
+}
+
// -------------------------------------------------------------------------
TagValue::TagValue(QWidget* parent) :
SearchCriterionValue(QWidget* parent = 0);
virtual ~SearchCriterionValue();
+ /**
+ * Must be overwritten by derived classes and returns
+ * the string representation of the search criterion value.
+ */
virtual QString value() const = 0;
+ /**
+ * Initializes the widget on the base of the given value-type.
+ * It is in the hand of the derived classes to interprete
+ * the value-type string and create a corresponding value for
+ * the widget (@see SearchCriterionSelector::Comparator).
+ * The default implementation is empty.
+ */
+ virtual void initializeValue(const QString& valueType);
+
signals:
void valueChanged(const QString& value);
};
DateValue(QWidget* parent = 0);
virtual ~DateValue();
virtual QString value() const;
-
+ virtual void initializeValue(const QString& valueType);
+
private:
KDateWidget* m_dateWidget;
};