diff options
| author | Peter Penz <[email protected]> | 2011-04-20 21:19:46 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-04-20 21:21:26 +0200 |
| commit | 27a8c55ec9207ae00da91596ba390e835a066782 (patch) | |
| tree | 2536725509fcff07bdc7fa23dd6ebe34668b3fcc /src | |
| parent | ae488b13186a4cb5d0bc5d7f23b07467d6638979 (diff) | |
Search improvements
Use Query::titleFromQueryUrl() to give a hint what kind of information
is shown to the user.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 2 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 50 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.h | 13 |
3 files changed, 35 insertions, 30 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 15eb7f644..1042ece63 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -254,7 +254,7 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) if (enabled) { KUrl url = m_urlNavigator->locationUrl(); m_searchBox->setText(QString()); - m_searchBox->setReadOnly(isSearchUrl(url)); + m_searchBox->setReadOnly(isSearchUrl(url), url); // Remember the most recent non-search URL as search path // of the search-box, so that it can be restored diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index c4270d383..3a6120d41 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -58,14 +58,16 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) : m_startedSearching(false), m_readOnly(false), m_topLayout(0), + m_searchLabel(0), m_searchInput(0), + m_optionsScrollArea(0), m_fileNameButton(0), m_contentButton(0), m_separator(0), m_fromHereButton(0), m_everywhereButton(0), - m_infoLabel(0), m_searchPath(), + m_readOnlyQuery(), m_startSearchTimer(0) { } @@ -148,10 +150,11 @@ void DolphinSearchBox::selectAll() m_searchInput->selectAll(); } -void DolphinSearchBox::setReadOnly(bool readOnly) +void DolphinSearchBox::setReadOnly(bool readOnly, const KUrl& query) { if (m_readOnly != readOnly) { m_readOnly = readOnly; + m_readOnlyQuery = query; applyReadOnlyState(); } } @@ -266,7 +269,7 @@ void DolphinSearchBox::init() connect(closeButton, SIGNAL(clicked()), SIGNAL(closeRequest())); // Create search label - QLabel* searchLabel = new QLabel(i18nc("@label:textbox", "Find:"), this); + m_searchLabel = new QLabel(this); // Create search box m_searchInput = new KLineEdit(this); @@ -278,16 +281,12 @@ 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_searchLabel); searchInputLayout->addWidget(m_searchInput); - searchInputLayout->addWidget(m_infoLabel); // Create "Filename" and "Content" button m_fileNameButton = new QPushButton(this); @@ -335,20 +334,21 @@ void DolphinSearchBox::init() // in case that not enough width for the options is available. QWidget* optionsContainer = new QWidget(this); optionsContainer->setLayout(optionsLayout); - QScrollArea* optionsScrollArea = new QScrollArea(this); - optionsScrollArea->setFrameShape(QFrame::NoFrame); - optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height()); - optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - optionsScrollArea->setWidget(optionsContainer); - optionsScrollArea->setWidgetResizable(true); + + m_optionsScrollArea = new QScrollArea(this); + m_optionsScrollArea->setFrameShape(QFrame::NoFrame); + m_optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_optionsScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_optionsScrollArea->setMaximumHeight(optionsContainer->sizeHint().height()); + m_optionsScrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + m_optionsScrollArea->setWidget(optionsContainer); + m_optionsScrollArea->setWidgetResizable(true); m_topLayout = new QVBoxLayout(this); + m_topLayout->setMargin(0); m_topLayout->addLayout(searchInputLayout); - m_topLayout->addWidget(optionsScrollArea); + m_topLayout->addWidget(m_optionsScrollArea); - searchLabel->setBuddy(m_searchInput); loadSettings(); // The searching should be started automatically after the user did not change @@ -404,14 +404,14 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const void DolphinSearchBox::applyReadOnlyState() { - // TODO: This is just an early draft to indicate that a state change - // has been done + if (m_readOnly) { + m_searchLabel->setText(Nepomuk::Query::Query::titleFromQueryUrl(m_readOnlyQuery)); + } else { + m_searchLabel->setText(i18nc("@label:textbox", "Find:")); + } + m_searchInput->setVisible(!m_readOnly); - m_infoLabel->setVisible(m_readOnly); - m_fileNameButton->setVisible(!m_readOnly); - m_contentButton->setVisible(!m_readOnly); - m_fromHereButton->setVisible(!m_readOnly); - m_everywhereButton->setVisible(!m_readOnly); + m_optionsScrollArea->setVisible(!m_readOnly); } #include "dolphinsearchbox.moc" diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index 27561481d..2d4f31b3b 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -25,11 +25,12 @@ #include <QWidget> class AbstractSearchFilterWidget; -class QLabel; class KLineEdit; class KSeparator; class QFormLayout; class QPushButton; +class QScrollArea; +class QLabel; class QVBoxLayout; /** @@ -90,8 +91,11 @@ public: * @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. + * @param query If readOnly is true this URL will be used + * to show a human readable information about the + * query. */ - void setReadOnly(bool readOnly); + void setReadOnly(bool readOnly, const KUrl& query = KUrl()); bool isReadOnly() const; protected: @@ -157,16 +161,17 @@ private: QVBoxLayout* m_topLayout; + QLabel* m_searchLabel; KLineEdit* m_searchInput; + QScrollArea* m_optionsScrollArea; QPushButton* m_fileNameButton; QPushButton* m_contentButton; KSeparator* m_separator; QPushButton* m_fromHereButton; QPushButton* m_everywhereButton; - QLabel* m_infoLabel; - KUrl m_searchPath; + KUrl m_readOnlyQuery; QTimer* m_startSearchTimer; }; |
