]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinsearchbox.cpp
Use capitalized includes of recently committed kdelibs headers
[dolphin.git] / src / search / dolphinsearchbox.cpp
index f4588f67f45de3dae0af5159cebd614ee70cca25..dce47c4691778ef5767a075ba82b2df063b04f88 100644 (file)
@@ -25,7 +25,7 @@
 #include <KIcon>
 #include <KLineEdit>
 #include <KLocale>
-#include <kseparator.h>
+#include <KSeparator>
 
 #include <QButtonGroup>
 #include <QDir>
@@ -56,6 +56,7 @@
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
     m_startedSearching(false),
+    m_readOnly(false),
     m_topLayout(0),
     m_searchInput(0),
     m_fileNameButton(0),
@@ -63,6 +64,7 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     m_separator(0),
     m_fromHereButton(0),
     m_everywhereButton(0),
+    m_infoLabel(0),
     m_searchPath(),
     m_startSearchTimer(0)
 {
@@ -73,6 +75,11 @@ DolphinSearchBox::~DolphinSearchBox()
     saveSettings();
 }
 
+void DolphinSearchBox::setText(const QString& text)
+{
+    m_searchInput->setText(text);
+}
+
 QString DolphinSearchBox::text() const
 {
     return m_searchInput->text();
@@ -112,7 +119,7 @@ KUrl DolphinSearchBox::urlForSearching() const
 {
     KUrl url;
     const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
-    if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(url)) {
+    if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath)) {
         url = nepomukUrlForSearching();
     } else {
         url.setProtocol("filenamesearch");
@@ -141,9 +148,17 @@ void DolphinSearchBox::selectAll()
     m_searchInput->selectAll();
 }
 
-void DolphinSearchBox::clearText()
+void DolphinSearchBox::setReadOnly(bool readOnly)
+{
+    if (m_readOnly != readOnly) {
+        m_readOnly = readOnly;
+        applyReadOnlyState();
+    }
+}
+
+bool DolphinSearchBox::isReadOnly() const
 {
-    m_searchInput->clear();
+    return m_readOnly;
 }
 
 bool DolphinSearchBox::event(QEvent* event)
@@ -256,12 +271,16 @@ void DolphinSearchBox::init()
     connect(m_searchInput, SIGNAL(textChanged(QString)),
             this, SLOT(slotSearchTextChanged(QString)));
 
+    // Create information label
+    m_infoLabel = new QLabel("TODO: Provide information about the current query", this);
+
     // Apply layout for the search input
     QHBoxLayout* searchInputLayout = new QHBoxLayout();
     searchInputLayout->setMargin(0);
     searchInputLayout->addWidget(closeButton);
     searchInputLayout->addWidget(searchLabel);
     searchInputLayout->addWidget(m_searchInput);
+    searchInputLayout->addWidget(m_infoLabel);
 
     // Create "Filename" and "Content" button
     m_fileNameButton = new QPushButton(this);
@@ -327,6 +346,8 @@ void DolphinSearchBox::init()
     m_startSearchTimer->setSingleShot(true);
     m_startSearchTimer->setInterval(1000);
     connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchSignal()));
+
+    applyReadOnlyState();
 }
 
 KUrl DolphinSearchBox::nepomukUrlForSearching() const
@@ -370,4 +391,16 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
 #endif
 }
 
+void DolphinSearchBox::applyReadOnlyState()
+{
+    // TODO: This is just an early draft to indicate that a state change
+    // has been done
+    m_searchInput->setVisible(!m_readOnly);
+    m_infoLabel->setVisible(m_readOnly);
+    m_fileNameButton->setEnabled(!m_readOnly);
+    m_contentButton->setEnabled(!m_readOnly);
+    m_fromHereButton->setEnabled(!m_readOnly);
+    m_everywhereButton->setEnabled(!m_readOnly);
+}
+
 #include "dolphinsearchbox.moc"