dolphinmainwindow.cpp
dolphinnewmenu.cpp
dolphinviewcontainer.cpp
+ dolphinsearchbox.cpp
dolphinstatusbar.cpp
dolphindirlister.cpp
dolphincontextmenu.cpp
#include "dolphinnewmenu.h"
#include "settings/dolphinsettings.h"
#include "settings/dolphinsettingsdialog.h"
+#include "dolphinsearchbox.h"
#include "dolphinstatusbar.h"
#include "dolphinviewcontainer.h"
#include "panels/folders/folderspanel.h"
m_tabBar(0),
m_activeViewContainer(0),
m_centralWidgetLayout(0),
- m_searchBar(0),
+ m_searchBox(0),
m_id(id),
m_tabIndex(0),
m_viewTab(),
canDecode = KUrl::List::canDecode(event->mimeData());
}
-void DolphinMainWindow::searchItems()
+void DolphinMainWindow::searchItems(const KUrl& url)
{
- const QString nepomukString = "nepomuksearch:/" + m_searchBar->text();
- m_activeViewContainer->setUrl(KUrl(nepomukString));
+ m_activeViewContainer->setUrl(url);
}
setupGUI(Keys | Save | Create | ToolBar);
- m_searchBar->setParent(toolBar("searchToolBar"));
- m_searchBar->setFont(KGlobalSettings::generalFont());
- m_searchBar->show();
+ m_searchBox->setParent(toolBar("searchToolBar"));
+ m_searchBox->show();
stateChanged("new_file");
connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
// 'Search' toolbar
- m_searchBar = new KLineEdit(this);
- m_searchBar->setMinimumWidth(150);
- m_searchBar->setClearButtonShown(true);
- connect(m_searchBar, SIGNAL(returnPressed()), this, SLOT(searchItems()));
+ m_searchBox = new DolphinSearchBox(this);
+ connect(m_searchBox, SIGNAL(search(KUrl)), this, SLOT(searchItems(KUrl)));
KAction* search = new KAction(this);
actionCollection()->addAction("search_bar", search);
search->setText(i18nc("@action:inmenu", "Search Bar"));
- search->setDefaultWidget(m_searchBar);
+ search->setDefaultWidget(m_searchBox);
search->setShortcutConfigurable(false);
}
class KAction;
class DolphinViewActionHandler;
class DolphinApplication;
+class DolphinSearchBox;
class DolphinSettingsDialog;
class DolphinViewContainer;
-class KLineEdit;
class KNewMenu;
class KTabBar;
class KUrl;
void slotTestCanDecode(const QDragMoveEvent* event, bool& accept);
/**
- * Searchs items that match to the text entered in the search bar.
+ * Is connected with the Dolphin search box and searchs items that
+ * match to the text entered in the search bar.
*/
- void searchItems();
+ void searchItems(const KUrl& url);
private:
DolphinMainWindow(int id);
KTabBar* m_tabBar;
DolphinViewContainer* m_activeViewContainer;
QVBoxLayout* m_centralWidgetLayout;
- KLineEdit* m_searchBar;
+ DolphinSearchBox* m_searchBox;
int m_id;
struct ViewTab
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+#include "dolphinsearchbox.h"
+
+#include <kdialog.h>
+#include <kglobalsettings.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kicon.h>
+#include <kiconloader.h>
+
+#include <QEvent>
+#include <QHBoxLayout>
+#include <QToolButton>
+
+DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
+ QWidget(parent),
+ m_searchButton(0),
+ m_searchInput(0)
+{
+ QHBoxLayout* hLayout = new QHBoxLayout(this);
+ hLayout->setMargin(0);
+
+ m_searchButton = new QToolButton(this);
+ m_searchButton->setAutoRaise(true);
+ m_searchButton->setIcon(KIcon("nepomuk"));
+ m_searchButton->setToolTip(i18nc("@info:tooltip", "Search"));
+ hLayout->addWidget(m_searchButton);
+
+ connect(m_searchButton, SIGNAL(clicked()),
+ this, SLOT(emitSearchSignal()));
+
+ m_searchInput = new KLineEdit(this);
+ m_searchInput->setLayoutDirection(Qt::LeftToRight);
+ m_searchInput->setClearButtonShown(true);
+ m_searchInput->setMinimumWidth(150);
+ hLayout->addWidget(m_searchInput);
+
+ connect(m_searchInput, SIGNAL(returnPressed()),
+ this, SLOT(emitSearchSignal()));
+}
+
+DolphinSearchBox::~DolphinSearchBox()
+{
+}
+
+bool DolphinSearchBox::event(QEvent* event)
+{
+ if (event->type() == QEvent::Polish) {
+ m_searchInput->setFont(KGlobalSettings::generalFont());
+ }
+ return QWidget::event(event);
+}
+
+void DolphinSearchBox::emitSearchSignal()
+{
+ emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
+}
+
+#include "dolphinsearchbox.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+#ifndef DOLPHINSEARCHBOX_H
+#define DOLPHINSEARCHBOX_H
+
+#include <QWidget>
+
+class KLineEdit;
+class KUrl;
+class QToolButton;
+
+/**
+ * @brief Input box for searching files with Nepomuk.
+ */
+class DolphinSearchBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ DolphinSearchBox(QWidget* parent = 0);
+ virtual ~DolphinSearchBox();
+
+protected:
+ virtual bool event(QEvent* event);
+
+signals:
+ /**
+ * Is emitted when the user pressed Return or Enter
+ * and provides the Nepomuk URL that should be used
+ * for searching.
+ */
+ void search(const KUrl& url);
+
+private slots:
+ void emitSearchSignal();
+
+private:
+ QToolButton* m_searchButton;
+ KLineEdit* m_searchInput;
+};
+
+#endif