[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasmoids/applets/lancelot
From: Ivan Čukić <ivan.cukic+kde () gmail ! com>
Date: 2008-06-30 22:20:03
Message-ID: 1214864403.751469.21786.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 826539 by ivan:
Search is returned to L
M +27 -18 app/src/LancelotWindow.cpp
M +7 -0 app/src/LancelotWindow.h
M +37 -53 app/src/models/Runner.cpp
M +4 -3 app/src/models/Runner.h
M +3 -3 app/src/ui/LancelotWindowBase.xml
M +0 -2 libs/lancelot/widgets/ExtenderButton.cpp
--- trunk/KDE/kdeplasmoids/applets/lancelot/app/src/LancelotWindow.cpp #826538:826539
@@ -47,6 +47,9 @@
#include <lancelot/widgets/ResizeBordersPanel.h>
+#include <KLineEdit>
+#include <Plasma/LineEdit>
+
#define sectionsWidth 128
#define windowHeightDefault 500
#define mainWidthDefault 422
@@ -212,10 +215,16 @@
setupModels();
- /* Dirty hack to get an edit box before Qt 4.4 :: begin */
- // editSearch->setParent(this);
- // editSearch->installEventFilter(this);
- /* Dirty hack to get an edit box before Qt 4.4 :: end */
+ /* TODO: Convert this to PUCK generated code */
+ editSearch = new Plasma::LineEdit();
+ editSearch->setParentItem(m_root);
+ editSearch->nativeWidget()->setClearButtonShown(true);
+ editSearch->nativeWidget()->setClickMessage(i18n("Search"));
+ editSearch->show();
+ layoutSearch->addItem(editSearch,
+ Lancelot::NodeLayout::NodeCoordinate(0.0, 0.5, 0, 0),
+ Lancelot::NodeLayout::NodeCoordinate(1.0, 0.5, 0, INFINITY)
+ );
instance->activateAll();
@@ -237,10 +246,10 @@
connect(buttonSystemLogout, SIGNAL(activated()), this, SLOT(systemLogout()));
connect(buttonSystemSwitchUser, SIGNAL(activated()), this, SLOT(systemSwitchUser()));
- //connect(editSearch,
- // SIGNAL(textChanged(const QString &)),
- // this, SLOT(search(const QString &))
- //);
+ connect(editSearch->widget(),
+ SIGNAL(textChanged(const QString &)),
+ this, SLOT(search(const QString &))
+ );
loadConfig();
}
@@ -401,9 +410,9 @@
void LancelotWindow::search(const QString & string)
{
- // if (editSearch->text() != string) {
- // editSearch->setText(string);
- // }
+ if (editSearch->text() != string) {
+ editSearch->setText(string);
+ }
m_searchString = string;
@@ -594,13 +603,13 @@
bool LancelotWindow::eventFilter(QObject * object, QEvent * event)
{
-// if ((object == editSearch) && (event->type() == QEvent::KeyPress)) {
-// QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
-// if (keyEvent->key() == Qt::Key_Escape) {
-// lancelotHide(true);
-// return true;
-// }
-// }
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent * keyEvent = static_cast<QKeyEvent *>(event);
+ if (keyEvent->key() == Qt::Key_Escape) {
+ lancelotHide(true);
+ return true;
+ }
+ }
return QWidget::eventFilter(object, event);
}
--- trunk/KDE/kdeplasmoids/applets/lancelot/app/src/LancelotWindow.h #826538:826539
@@ -36,6 +36,11 @@
class ResizeBordersPanel;
}
+namespace Plasma
+{
+ class LineEdit;
+}
+
class LancelotWindow: public QWidget, public Ui::LancelotWindowBase
{
Q_OBJECT
@@ -154,6 +159,8 @@
Plasma::Corona * m_corona;
QVBoxLayout * m_layout;
+ Plasma::LineEdit * editSearch;
+
QTimer m_hideTimer;
QString m_searchString;
--- trunk/KDE/kdeplasmoids/applets/lancelot/app/src/models/Runner.cpp #826538:826539
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
- * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser/Library General Public License version 2,
@@ -21,6 +20,7 @@
#include "Runner.h"
#include <KRun>
#include <KDebug>
+#include <KIcon>
#include <KLocalizedString>
#include <plasma/abstractrunner.h>
@@ -32,7 +32,12 @@
{
// m_runners = Plasma::AbstractRunner::load(this);
- load();
+ m_runnerManager = new Plasma::RunnerManager(this);
+ connect(
+ m_runnerManager, SIGNAL(matchesChanged(const QList<Plasma::QueryMatch>&)),
+ this, SLOT(setQueryMatches(const QList<Plasma::QueryMatch>&))
+ );
+ setSearchString(QString());
}
Runner::~Runner()
@@ -47,69 +52,48 @@
void Runner::setSearchString(const QString & search)
{
m_searchString = search.trimmed();
- load();
-}
-void Runner::load()
-{/*
- m_items.clear();
-
- int matchCount = 0;
-
if (m_searchString.isEmpty()) {
+ m_items.clear();
add(
- "Search string is empty",
- "Enter something to search for",
- NULL,
+ i18n("Search string is empty"),
+ i18n("Enter something to search for"),
+ KIcon("help-hint"),
QVariant()
);
- return;
+ } else {
+ m_runnerManager->launchQuery(search);
}
+}
- m_context.resetSearchTerm(m_searchString);
- //m_context.addStringCompletions(m_executions);
+// Code taken from KRunner Runner::setQueryMatches
+void Runner::setQueryMatches(const QList< Plasma::QueryMatch > & m)
+{
+ m_items.clear();
- foreach (Plasma::AbstractRunner* runner, m_runners) {
- runner->match(&m_context);
- }
+ QList < Plasma::QueryMatch > matches = m;
+ QMutableListIterator < Plasma::QueryMatch > newMatchIt(matches);
- QList < QList < Plasma::SearchMatch * > > matchLists;
- matchLists << m_context.matches();
- // << m_context.exactMatches()
- // << m_context.possibleMatches();
-
- foreach (QList < Plasma::SearchMatch * > matchList, matchLists) {
- foreach (Plasma::SearchMatch * action, matchList) {
- add(
- action->text(),
- action->runner()->objectName(),
- action->icon(),
- qVariantFromValue((void *)action)
- );
-
- ++matchCount;
- }
+ // first pass: we try and match up items with existing ids (match persisitence)
+ while (newMatchIt.hasNext()) {
+ Plasma::QueryMatch match = newMatchIt.next();
+ add(
+ match.text(),
+ match.subtext(),
+ match.icon(),
+ match.id()
+ );
}
-*/}
+}
-void Runner::activate(int index)
-{/*
- Plasma::SearchMatch * action = (Plasma::SearchMatch *)
- m_items[index].data.value< void * >();
+void Runner::load()
+{
+}
- Q_ASSERT(action);
-
- if (!action->isEnabled()) {
- return;
- }
-
- if (action->type() == Plasma::SearchMatch::InformationalMatch) {
- changeLancelotSearchString(action->data().toString());
- } else {
- action->exec(&m_context);
- hideLancelotWindow();
- }
-*/
+void Runner::activate(int index)
+{
+ m_runnerManager->run(m_items[index].data.value< QString >());
+ hideLancelotWindow();
}
} // namespace Models
--- trunk/KDE/kdeplasmoids/applets/lancelot/app/src/models/Runner.h #826538:826539
@@ -21,7 +21,8 @@
#define LANCELOTAPP_MODELS_RUNNER_H_
#include "BaseModel.h"
-#include <plasma/abstractrunner.h>
+#include <plasma/runnermanager.h>
+#include <plasma/querymatch.h>
namespace Models {
@@ -35,6 +36,7 @@
public Q_SLOTS:
void setSearchString(const QString & search);
+ void setQueryMatches(const QList<Plasma::QueryMatch> &matches);
protected:
void activate(int index);
@@ -42,8 +44,7 @@
private:
QString m_searchString;
- Plasma::AbstractRunner::List m_runners;
- Plasma::RunnerContext m_context;
+ Plasma::RunnerManager * m_runnerManager;
};
} // namespace Models
--- trunk/KDE/kdeplasmoids/applets/lancelot/app/src/ui/LancelotWindowBase.xml #826538:826539
@@ -225,7 +225,7 @@
Lancelot__CardLayout:cardName="documents"
>
- <item:layout name="layoutDocumentsComputer" type="Lancelot::NodeLayout">
+ <item:layout name="layoutPanelDocuments" type="Lancelot::NodeLayout">
<item:widget
name="listDocumentsLeft" type="Lancelot::ActionListView"
itemsGroup="ActionListView-Left-Items" extenderPosition="Left"
@@ -246,13 +246,13 @@
name="panelSearch" type="Lancelot::Panel"
title="Search"
- icon="find"
+ icon="edit-find"
iconSize="22, 22"
group="InnerPanel"
Lancelot__CardLayout:cardName="search"
>
- <item:layout name="layoutSearchComputer" type="Lancelot::NodeLayout">
+ <item:layout name="layoutPanelSearch" type="Lancelot::NodeLayout">
<item:widget
name="listSearchLeft" type="Lancelot::ActionListView"
itemsGroup="ActionListView-Left-Items" extenderPosition="Left"
--- trunk/KDE/kdeplasmoids/applets/lancelot/libs/lancelot/widgets/ExtenderButton.cpp #826538:826539
@@ -369,8 +369,6 @@
void ExtenderButton::toggle()
{
- kDebug() << "### " << (void *) this;
-
if (!d->checkable) return;
d->checked = !d->checked;
update();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic