┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-02-05 23:33:08 +0100
committerPeter Penz <[email protected]>2011-02-05 23:33:08 +0100
commit27456a2f73b3d01cc94233fda958d0b22cb1ac5b (patch)
tree10f247281b858a63e63fbf4c72c53bf62c12d219 /src
parent0a9cdfa4ed20d5efca8bb6d5a156ccf506c58bcc (diff)
Provide a hook for externally triggered search queries
In this case the "From Here"/"Everywhere" buttons and the "Filename"/"Content" buttons are useless. Currently they just get disabled but the plan is to provide a better visual indication of the current query and to remove them completely.
Diffstat (limited to 'src')
-rw-r--r--src/dolphinviewcontainer.cpp4
-rw-r--r--src/search/dolphinsearchbox.cpp33
-rw-r--r--src/search/dolphinsearchbox.h14
3 files changed, 49 insertions, 2 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 922259858..dd70ed24e 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -212,13 +212,13 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
m_urlNavigator->setVisible(!enabled);
if (enabled) {
+ KUrl url = m_urlNavigator->locationUrl();
m_searchBox->setText(QString());
+ m_searchBox->setReadOnly(isSearchUrl(url));
// Remember the most recent non-search URL as search path
// of the search-box, so that it can be restored
// when switching back to the URL navigator.
- KUrl url = m_urlNavigator->locationUrl();
-
int index = m_urlNavigator->historyIndex();
const int historySize = m_urlNavigator->historySize();
while (isSearchUrl(url) && (index < historySize)) {
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index c7d08ff1f..dfffff4bb 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -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)
{
@@ -146,6 +148,19 @@ void DolphinSearchBox::selectAll()
m_searchInput->selectAll();
}
+void DolphinSearchBox::setReadOnly(bool readOnly)
+{
+ if (m_readOnly != readOnly) {
+ m_readOnly = readOnly;
+ applyReadOnlyState();
+ }
+}
+
+bool DolphinSearchBox::isReadOnly() const
+{
+ return m_readOnly;
+}
+
bool DolphinSearchBox::event(QEvent* event)
{
if (event->type() == QEvent::Polish) {
@@ -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"
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index 07fda5c29..cb4806292 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -25,6 +25,7 @@
#include <QWidget>
class AbstractSearchFilterWidget;
+class QLabel;
class KLineEdit;
class KSeparator;
class QFormLayout;
@@ -75,6 +76,14 @@ public:
*/
void selectAll();
+ /**
+ * @param readOnly If set to true the searchbox cannot be modified
+ * by the user and acts as visual indicator for
+ * an externally triggered search query.
+ */
+ void setReadOnly(bool readOnly);
+ bool isReadOnly() const;
+
protected:
virtual bool event(QEvent* event);
virtual void showEvent(QShowEvent* event);
@@ -118,8 +127,11 @@ private:
*/
KUrl nepomukUrlForSearching() const;
+ void applyReadOnlyState();
+
private:
bool m_startedSearching;
+ bool m_readOnly;
QVBoxLayout* m_topLayout;
@@ -130,6 +142,8 @@ private:
QPushButton* m_fromHereButton;
QPushButton* m_everywhereButton;
+ QLabel* m_infoLabel;
+
KUrl m_searchPath;
QTimer* m_startSearchTimer;