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)) {
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
QWidget(parent),
m_startedSearching(false),
+ m_readOnly(false),
m_topLayout(0),
m_searchInput(0),
m_fileNameButton(0),
m_separator(0),
m_fromHereButton(0),
m_everywhereButton(0),
+ m_infoLabel(0),
m_searchPath(),
m_startSearchTimer(0)
{
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) {
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);
m_startSearchTimer->setSingleShot(true);
m_startSearchTimer->setInterval(1000);
connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchSignal()));
+
+ applyReadOnlyState();
}
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"
#include <QWidget>
class AbstractSearchFilterWidget;
+class QLabel;
class KLineEdit;
class KSeparator;
class QFormLayout;
*/
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);
*/
KUrl nepomukUrlForSearching() const;
+ void applyReadOnlyState();
+
private:
bool m_startedSearching;
+ bool m_readOnly;
QVBoxLayout* m_topLayout;
QPushButton* m_fromHereButton;
QPushButton* m_everywhereButton;
+ QLabel* m_infoLabel;
+
KUrl m_searchPath;
QTimer* m_startSearchTimer;