Merge lp:~smartboyhw/ubuntu/raring/homerun/0.2.1-0ubuntu1-version-1 into lp:ubuntu/raring/homerun

Proposed by Howard Chan
Status: Merged
Merge reported by: Philip Muškovac
Merged at revision: not available
Proposed branch: lp:~smartboyhw/ubuntu/raring/homerun/0.2.1-0ubuntu1-version-1
Merge into: lp:ubuntu/raring/homerun
Diff against target: 12832 lines (+6090/-4867)
128 files modified
CMakeLists.txt (+2/-14)
ExtraDesktop.sh (+0/-6)
NEWS (+24/-0)
README.md (+22/-4)
applet/plasma-applet-homerunlauncher.desktop.cmake (+13/-0)
components/CMakeLists.txt (+28/-15)
components/componentsplugin.cpp (+4/-0)
components/dirconfigurationwidget.cpp (+0/-67)
components/dirconfigurationwidget.h (+0/-48)
components/dirconfigurationwidget.ui (+0/-83)
components/dirmodel.cpp (+0/-240)
components/dirmodel.h (+0/-111)
components/favoriteappsmodel.cpp (+0/-215)
components/favoriteappsmodel.h (+0/-81)
components/favoriteplacesmodel.cpp (+0/-138)
components/favoriteplacesmodel.h (+0/-75)
components/groupedinstalledappsmodel.cpp (+0/-134)
components/groupedinstalledappsmodel.h (+0/-75)
components/installedappsconfigurationwidget.cpp (+0/-145)
components/installedappsconfigurationwidget.h (+0/-63)
components/installedappsconfigurationwidget.ui (+0/-50)
components/installedappsmodel.cpp (+0/-319)
components/installedappsmodel.h (+0/-159)
components/messagebox.cpp (+45/-0)
components/messagebox.h (+60/-0)
components/powermodel.cpp (+0/-143)
components/powermodel.h (+0/-75)
components/qml/Label.qml (+68/-0)
components/qml/TabButton.qml (+28/-2)
components/qml/qmldir (+1/-0)
components/runnerconfigurationwidget.cpp (+0/-105)
components/runnerconfigurationwidget.h (+0/-48)
components/runnerconfigurationwidget.ui (+0/-48)
components/runnermodel.cpp (+0/-408)
components/runnermodel.h (+0/-150)
components/sessionmodel.cpp (+0/-137)
components/sessionmodel.h (+0/-72)
components/shadoweffect.cpp (+222/-0)
components/shadoweffect.h (+87/-0)
components/sourceid.cpp (+0/-163)
components/sourceid.h (+0/-66)
components/sourceregistry.cpp (+32/-9)
components/sources/dir/dirconfigurationwidget.cpp (+67/-0)
components/sources/dir/dirconfigurationwidget.h (+48/-0)
components/sources/dir/dirconfigurationwidget.ui (+83/-0)
components/sources/dir/dirmodel.cpp (+259/-0)
components/sources/dir/dirmodel.h (+113/-0)
components/sources/favorites/favoriteappsmodel.cpp (+215/-0)
components/sources/favorites/favoriteappsmodel.h (+81/-0)
components/sources/favorites/favoriteplacesmodel.cpp (+162/-0)
components/sources/favorites/favoriteplacesmodel.h (+77/-0)
components/sources/installedapps/groupedinstalledappsmodel.cpp (+134/-0)
components/sources/installedapps/groupedinstalledappsmodel.h (+75/-0)
components/sources/installedapps/installedappsconfigurationwidget.cpp (+145/-0)
components/sources/installedapps/installedappsconfigurationwidget.h (+63/-0)
components/sources/installedapps/installedappsconfigurationwidget.ui (+50/-0)
components/sources/installedapps/installedappsmodel.cpp (+319/-0)
components/sources/installedapps/installedappsmodel.h (+159/-0)
components/sources/power/powermodel.cpp (+108/-0)
components/sources/power/powermodel.h (+40/-0)
components/sources/runners/querymatchmodel.cpp (+194/-0)
components/sources/runners/querymatchmodel.h (+84/-0)
components/sources/runners/runnerconfigurationwidget.cpp (+105/-0)
components/sources/runners/runnerconfigurationwidget.h (+48/-0)
components/sources/runners/runnerconfigurationwidget.ui (+48/-0)
components/sources/runners/runnermodel.cpp (+295/-0)
components/sources/runners/runnermodel.h (+134/-0)
components/sources/runners/singlerunnermodel.cpp (+131/-0)
components/sources/runners/singlerunnermodel.h (+87/-0)
components/sources/session/openedsessionsmodel.cpp (+92/-0)
components/sources/session/openedsessionsmodel.h (+53/-0)
components/sources/session/sessionmodel.cpp (+118/-0)
components/sources/session/sessionmodel.h (+45/-0)
components/sources/session/sessionswatcher.cpp (+92/-0)
components/sources/session/sessionswatcher.h (+53/-0)
components/standarditemmodel.cpp (+90/-0)
components/standarditemmodel.h (+79/-0)
components/tabmodel.cpp (+64/-111)
components/tabmodel.h (+5/-0)
config/homerunrc (+4/-1)
debian/changelog (+10/-0)
debian/control (+1/-1)
debian/libhomerun-dev.install (+1/-0)
debian/libhomerun0.symbols (+7/-0)
debian/plasma-widget-homerun.install (+4/-5)
devdoc/helloworld/homerun-source-helloworld.desktop (+18/-0)
devdoc/release_howto.md (+6/-5)
fixes/CMakeLists.txt (+0/-1)
fixes/README.md (+2/-29)
fixes/datamodel.cpp (+0/-171)
fixes/datamodel.h (+0/-119)
fixes/fixesplugin.cpp (+4/-5)
fixes/qml/Label.qml (+0/-69)
fixes/qml/ScrollArea.qml (+0/-248)
fixes/qml/TextField.qml (+196/-149)
fixes/qml/private/IconLoader.qml (+0/-140)
fixes/qml/qmldir (+0/-2)
homerun_config.h.in (+0/-3)
internal/i18nconfig.cpp (+34/-0)
lib/CMakeLists.txt (+3/-0)
lib/actionlist.cpp (+116/-0)
lib/actionlist.h (+63/-0)
lib/homerun-source.desktop (+9/-0)
lib/homerunmodel.dox (+38/-3)
package/contents/config/main.xml (+22/-10)
package/contents/ui/ActionMenu.qml (+102/-0)
package/contents/ui/FavoriteFeedback.qml (+0/-55)
package/contents/ui/Page.qml (+12/-12)
package/contents/ui/Result.qml (+90/-55)
package/contents/ui/ResultsView.qml (+69/-46)
package/contents/ui/SourceItem.qml (+10/-1)
package/contents/ui/TabContent.qml (+24/-19)
package/contents/ui/config.ui (+108/-0)
package/contents/ui/main.qml (+37/-29)
package/metadata.desktop.cmake (+15/-0)
plugins/recentdocuments/homerun-source-recentdocuments.desktop (+19/-0)
plugins/recentdocuments/recentdocuments.cpp (+64/-6)
plugins/recentdocuments/recentdocuments.h (+13/-1)
shell/fullview.cpp (+23/-11)
shell/fullview.h (+2/-0)
shell/homerunviewer.desktop (+13/-0)
shell/main.cpp (+30/-2)
tests/auto/CMakeLists.txt (+19/-10)
tests/auto/i18nconfigtest.cpp (+52/-0)
tests/auto/i18nconfigtest.h (+37/-0)
tests/auto/tabmodeltest.cpp (+151/-79)
tests/auto/tabmodeltest.h (+1/-1)
tests/manual/keyboard-navigation.md (+10/-0)
To merge this branch: bzr merge lp:~smartboyhw/ubuntu/raring/homerun/0.2.1-0ubuntu1-version-1
Reviewer Review Type Date Requested Status
Philip Muškovac (community) Approve
Review via email: mp+151266@code.launchpad.net

Description of the change

New upstream version 0.2.1.

To post a comment you must log in.
6. By Howard Chan

Added watch file

Revision history for this message
Philip Muškovac (yofel) wrote :

Great, thanks!
I fixed one additional thing:
W: libhomerun-dev: wrong-section-according-to-package-name libhomerun-dev => libdevel

review: Approve
Revision history for this message
Philip Muškovac (yofel) wrote :

Meh, noticed one thing too late: the watch file is missing.
Can you please file a new request for ubuntu2 that actually adds it? I'll upload it asap then.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2012-12-18 19:55:12 +0000
3+++ CMakeLists.txt 2013-03-01 15:15:27 +0000
4@@ -3,7 +3,7 @@
5 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
6
7 # Packaging
8-set(HOMERUN_VERSION "0.1.1")
9+set(HOMERUN_VERSION "0.2.1")
10
11 set(HOMERUN_SOURCE_VERSION "")
12 set(HOMERUN_SOURCE_DATE "")
13@@ -23,23 +23,11 @@
14 message(STATUS "Source date: ${HOMERUN_SOURCE_DATE}")
15
16 # Dependencies
17-find_package(KDE4 ${KDE_MIN_VERSION} REQUIRED)
18+find_package(KDE4 4.9.97 REQUIRED)
19 include(KDE4Defaults)
20 find_package(KDE4Workspace REQUIRED)
21 find_package(KDeclarative REQUIRED)
22
23-# Check whether KDeclarative::setupQmlJsDebugger() exists
24-set(CMAKE_REQUIRED_INCLUDES "${KDE4_INCLUDES}")
25-set(CMAKE_REQUIRED_LIBRARIES "${KDECLARATIVE_LIBRARIES}")
26-check_cxx_source_compiles("
27-#include <kdeclarative.h>
28-int main()
29-{
30- KDeclarative::setupQmlJsDebugger();
31- return 0;
32-}
33-" HAVE_KDECLARATIVE_SETUPQMLJSDEBUGGER)
34-
35 # Compile options
36 add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
37 add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
38
39=== removed file 'ExtraDesktop.sh'
40--- ExtraDesktop.sh 2012-11-14 21:30:06 +0000
41+++ ExtraDesktop.sh 1970-01-01 00:00:00 +0000
42@@ -1,6 +0,0 @@
43-#! /bin/sh
44-#This file outputs in a separate line each file with a .desktop syntax
45-#that needs to be translated but has a non .desktop extension
46-
47-#We output homerunrc because we want the title of Homerun tabs to be translated
48-echo ./config/homerunrc
49
50=== modified file 'NEWS'
51--- NEWS 2012-12-18 19:55:12 +0000
52+++ NEWS 2013-03-01 15:15:27 +0000
53@@ -1,3 +1,27 @@
54+# 2013.02.27 - 0.2.1
55+
56+- Fix shutdown and halt items in the Power source
57+- Improve appearance of header titles
58+
59+# 2013.02.26 - 0.2.0
60+
61+- Support for single runners
62+- Items can now have more than one action. The other actions are accessible
63+ through a context menu, which can be triggered by:
64+ - Left-clicking the arrow in the top-right corner of the item
65+ - Long-clicking the item
66+ - Right-clicking the item
67+ - Pressing M or the "Menu" key
68+- Some sources expose more actions:
69+ - Recent documents can now forget items
70+ - Items from the Dir and FavoritePlaces sources show the relevant "Open with" actions
71+- Add a "Reset tabs to default" action to the configuration menu
72+- Fix window not showing on correct desktop at startup
73+- Improved session handling: opened sessions are now listed in the "Power" tab
74+- Hide unavailable sleep modes in Power source
75+- No more border around full view
76+- Show a shadow behind text in containment mode
77+
78 # 2012.12.18 - 0.1.1
79
80 - Add support for selecting the launcher icon
81
82=== modified file 'README.md'
83--- README.md 2012-11-14 21:30:06 +0000
84+++ README.md 2013-03-01 15:15:27 +0000
85@@ -21,16 +21,34 @@
86
87 ## Dependencies
88
89-kdelibs 4.8
90-
91-## Package Manager integration
92+kdelibs 4.10
93+
94+## Build instructions
95+
96+Homerun currently requires kdelibs and kde-runtime 4.10.
97+
98+To build it, do the following:
99+
100+ mkdir build
101+ cd build
102+ cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
103+
104+Assuming cmake did not complain about missing dependencies, run:
105+
106+ make
107+
108+Then to install it, run as root:
109+
110+ make install
111+
112+## For packagers: Package manager integration
113
114 You can integrate your package manager with Homerun.
115
116 When browsing installed applications by category, Homerun can provide an item to
117 install more applications from this category. To do so you need to:
118
119-First, Create a .desktop file whose Exec= line contains a "@category" placeholder.
120+First, create a .desktop file whose Exec= line contains a "@category" placeholder.
121 This placeholder will be replaced by the category Homerun is browsing.
122
123 For example, here is muon-discover-category.desktop:
124
125=== modified file 'applet/plasma-applet-homerunlauncher.desktop.cmake'
126--- applet/plasma-applet-homerunlauncher.desktop.cmake 2012-12-18 19:55:12 +0000
127+++ applet/plasma-applet-homerunlauncher.desktop.cmake 2013-03-01 15:15:27 +0000
128@@ -4,32 +4,45 @@
129 Name=KDE Homerun Launcher
130 Name[da]=KDE Homerun-startmenu
131 Name[el]=Εκτελεστής KDE Homerun
132+Name[es]=Lanzador Homerun de KDE
133 Name[et]=KDE Homeruni käivitaja
134+Name[fi]=KDE Homerun -käynnistin
135 Name[fr]=Lanceur Homerun pour KDE
136+Name[gl]=Lanzador de KDE Homerun
137 Name[hu]=KDE Homerun indító
138+Name[lt]=KDE Homerun leidiklis
139 Name[nl]=Programmastarter van KDE Homerun
140 Name[pa]=ਕੇਡੀਈ ਹੋਮਰਨ ਲਾਂਚਰ
141 Name[pt]=Lançador Homerun do KDE
142 Name[pt_BR]=Lançador Homerun do KDE
143+Name[ro]=Lansator KDE Homerun
144 Name[sk]=Spúšťač KDE Homerun
145 Name[sv]=KDE Homerun startprogram
146 Name[uk]=Засіб запуску KDE Homerun
147 Name[x-test]=xxKDE Homerun Launcherxx
148+Name[zh_CN]=KDE Homerun 启动器
149
150 Comment=An application launcher
151 Comment[da]=Programstarter
152+Comment[de]=Ein Anwendungsstarter
153 Comment[el]=Ένας εκτελεστής εφαρμογών
154+Comment[es]=Un lanzador de aplicaciones
155 Comment[et]=Rakenduste käivitaja
156+Comment[fi]=Sovelluskäynnistin
157 Comment[fr]=Un lanceur d'applications
158+Comment[gl]=Un lanzador de aplicativos
159 Comment[hu]=Egy alkalmazásindító
160+Comment[lt]=Programų leidiklis
161 Comment[nl]=Een programmastarter
162 Comment[pa]=ਐਪਲੀਕੇਸ਼ਨ ਲਾਂਚਰ
163 Comment[pt]=Um lançador de aplicações
164 Comment[pt_BR]=Um lançador de aplicativos
165+Comment[ro]=Lansator de aplicații
166 Comment[sk]=Spúšťač aplikácií
167 Comment[sv]=Ett startprogram
168 Comment[uk]=Засіб для запуску програм
169 Comment[x-test]=xxAn application launcherxx
170+Comment[zh_CN]=一个应用程序启动器
171
172 Type=Service
173 ServiceTypes=Plasma/Applet
174
175=== modified file 'components/CMakeLists.txt'
176--- components/CMakeLists.txt 2012-11-14 21:30:06 +0000
177+++ components/CMakeLists.txt 2013-03-01 15:15:27 +0000
178@@ -4,30 +4,36 @@
179 ${CMAKE_SOURCE_DIR}/internal/aboutdata.cpp
180 abstractsourceregistry.cpp
181 componentsplugin.cpp
182- dirconfigurationwidget.cpp
183- dirmodel.cpp
184- favoriteappsmodel.cpp
185- favoriteplacesmodel.cpp
186- groupedinstalledappsmodel.cpp
187 helpmenuactions.cpp
188 icondialog.cpp
189- installedappsconfigurationwidget.cpp
190- installedappsmodel.cpp
191- powermodel.cpp
192- runnerconfigurationwidget.cpp
193- runnermodel.cpp
194- sessionmodel.cpp
195+ messagebox.cpp
196+ shadoweffect.cpp
197 sourceconfigurationdialog.cpp
198- sourceid.cpp
199 sourcemodel.cpp
200 sourceregistry.cpp
201+ sources/dir/dirconfigurationwidget.cpp
202+ sources/dir/dirmodel.cpp
203+ sources/favorites/favoriteappsmodel.cpp
204+ sources/favorites/favoriteplacesmodel.cpp
205+ sources/installedapps/groupedinstalledappsmodel.cpp
206+ sources/installedapps/installedappsconfigurationwidget.cpp
207+ sources/installedapps/installedappsmodel.cpp
208+ sources/power/powermodel.cpp
209+ sources/runners/querymatchmodel.cpp
210+ sources/runners/singlerunnermodel.cpp
211+ sources/runners/runnerconfigurationwidget.cpp
212+ sources/runners/runnermodel.cpp
213+ sources/session/openedsessionsmodel.cpp
214+ sources/session/sessionmodel.cpp
215+ sources/session/sessionswatcher.cpp
216+ standarditemmodel.cpp
217 tabmodel.cpp
218 )
219
220 kde4_add_ui_files(components_SRCS
221- dirconfigurationwidget.ui
222- installedappsconfigurationwidget.ui
223- runnerconfigurationwidget.ui
224+ sources/dir/dirconfigurationwidget.ui
225+ sources/installedapps/installedappsconfigurationwidget.ui
226+ sources/runners/runnerconfigurationwidget.ui
227 )
228
229 qt4_automoc(${components_SRCS})
230@@ -36,6 +42,12 @@
231 ${lib_BINARY_DIR}
232 ${lib_SOURCE_DIR}
233 ${CMAKE_SOURCE_DIR}/internal
234+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/dir
235+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/favorites
236+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/installedapps
237+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/power
238+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/runners
239+ ${CMAKE_CURRENT_SOURCE_DIR}/sources/session
240 )
241
242 kde4_add_library(componentsplugin SHARED ${components_SRCS})
243@@ -46,6 +58,7 @@
244 ${KDE4_PLASMA_LIBS}
245 ${KDE4_KIO_LIBS}
246 ${KDE4_KFILE_LIBS}
247+ ${KDE4_SOLID_LIBS}
248 ${KDE4WORKSPACE_KWORKSPACE_LIBS}
249 homerun
250 )
251
252=== modified file 'components/componentsplugin.cpp'
253--- components/componentsplugin.cpp 2012-11-14 21:30:06 +0000
254+++ components/componentsplugin.cpp 2013-03-01 15:15:27 +0000
255@@ -24,14 +24,18 @@
256
257 #include <helpmenuactions.h>
258 #include <icondialog.h>
259+#include <messagebox.h>
260+#include <shadoweffect.h>
261 #include <sourceregistry.h>
262 #include <tabmodel.h>
263
264 void ComponentsPlugin::registerTypes(const char *uri)
265 {
266 Q_ASSERT(uri == QLatin1String("org.kde.homerun.components"));
267+ qmlRegisterType<ShadowEffect>(uri, 0, 1, "ShadowEffect");
268 qmlRegisterType<HelpMenuActions>(uri, 0, 1, "HelpMenuActions");
269 qmlRegisterType<IconDialog>(uri, 0, 1, "IconDialog");
270+ qmlRegisterType<MessageBox>(uri, 0, 1, "MessageBox");
271 qmlRegisterType<Homerun::AbstractSourceRegistry>(uri, 0, 1, "AbstractSourceRegistry");
272 qmlRegisterType<Homerun::SourceRegistry>(uri, 0, 1, "SourceRegistry");
273 qmlRegisterType<TabModel>(uri, 0, 1, "TabModel");
274
275=== removed file 'components/dirconfigurationwidget.cpp'
276--- components/dirconfigurationwidget.cpp 2012-11-14 21:30:06 +0000
277+++ components/dirconfigurationwidget.cpp 1970-01-01 00:00:00 +0000
278@@ -1,67 +0,0 @@
279-/*
280-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
281-
282-This library is free software; you can redistribute it and/or
283-modify it under the terms of the GNU Lesser General Public
284-License as published by the Free Software Foundation; either
285-version 2.1 of the License, or (at your option) version 3, or any
286-later version accepted by the membership of KDE e.V. (or its
287-successor approved by the membership of KDE e.V.), which shall
288-act as a proxy defined in Section 6 of version 3 of the license.
289-
290-This library is distributed in the hope that it will be useful,
291-but WITHOUT ANY WARRANTY; without even the implied warranty of
292-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
293-Lesser General Public License for more details.
294-
295-You should have received a copy of the GNU Lesser General Public
296-License along with this library. If not, see <http://www.gnu.org/licenses/>.
297-*/
298-// Self
299-#include <dirconfigurationwidget.h>
300-
301-// Local
302-#include <ui_dirconfigurationwidget.h>
303-
304-// KDE
305-#include <KGlobalSettings>
306-#include <KUrlRequester>
307-
308-// Qt
309-#include <QDir>
310-#include <QVBoxLayout>
311-
312-using namespace Homerun;
313-
314-DirConfigurationWidget::DirConfigurationWidget(const KConfigGroup &group)
315-: SourceConfigurationWidget(group)
316-, m_ui(new Ui_DirConfigurationWidget)
317-{
318- m_ui->setupUi(this);
319-
320- QFont helpFont = KGlobalSettings::smallestReadableFont();
321- m_ui->titleHelpLabel->setFont(helpFont);
322-
323- KUrl url = group.readPathEntry("rootUrl", QDir::homePath());
324- if (url.isValid()) {
325- m_ui->urlRequester->setUrl(url);
326- }
327-
328- m_ui->titleLineEdit->setText(group.readEntry("rootName", QString()));
329-}
330-
331-DirConfigurationWidget::~DirConfigurationWidget()
332-{
333- delete m_ui;
334-}
335-
336-void DirConfigurationWidget::save()
337-{
338- KUrl url = m_ui->urlRequester->url().url();
339- QString title = m_ui->titleLineEdit->text();
340-
341- configGroup().writePathEntry("rootUrl", url.url());
342- configGroup().writeEntry("rootName", title);
343-}
344-
345-#include <dirconfigurationwidget.moc>
346
347=== removed file 'components/dirconfigurationwidget.h'
348--- components/dirconfigurationwidget.h 2012-11-14 21:30:06 +0000
349+++ components/dirconfigurationwidget.h 1970-01-01 00:00:00 +0000
350@@ -1,48 +0,0 @@
351-/*
352-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
353-
354-This library is free software; you can redistribute it and/or
355-modify it under the terms of the GNU Lesser General Public
356-License as published by the Free Software Foundation; either
357-version 2.1 of the License, or (at your option) version 3, or any
358-later version accepted by the membership of KDE e.V. (or its
359-successor approved by the membership of KDE e.V.), which shall
360-act as a proxy defined in Section 6 of version 3 of the license.
361-
362-This library is distributed in the hope that it will be useful,
363-but WITHOUT ANY WARRANTY; without even the implied warranty of
364-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
365-Lesser General Public License for more details.
366-
367-You should have received a copy of the GNU Lesser General Public
368-License along with this library. If not, see <http://www.gnu.org/licenses/>.
369-*/
370-#ifndef DIRCONFIGURATIONWIDGET_H
371-#define DIRCONFIGURATIONWIDGET_H
372-
373-// Local
374-#include <sourceconfigurationwidget.h>
375-
376-// Qt
377-
378-// KDE
379-
380-class Ui_DirConfigurationWidget;
381-
382-/**
383- * Configuration widget for the Dir source
384- */
385-class DirConfigurationWidget : public Homerun::SourceConfigurationWidget
386-{
387- Q_OBJECT
388-public:
389- DirConfigurationWidget(const KConfigGroup &group);
390- ~DirConfigurationWidget();
391-
392- void save(); // reimp
393-
394-private:
395- Ui_DirConfigurationWidget *m_ui;
396-};
397-
398-#endif /* DIRCONFIGURATIONWIDGET_H */
399
400=== removed file 'components/dirconfigurationwidget.ui'
401--- components/dirconfigurationwidget.ui 2012-11-14 21:30:06 +0000
402+++ components/dirconfigurationwidget.ui 1970-01-01 00:00:00 +0000
403@@ -1,83 +0,0 @@
404-<?xml version="1.0" encoding="UTF-8"?>
405-<ui version="4.0">
406- <class>DirConfigurationWidget</class>
407- <widget class="QWidget" name="DirConfigurationWidget">
408- <property name="geometry">
409- <rect>
410- <x>0</x>
411- <y>0</y>
412- <width>400</width>
413- <height>85</height>
414- </rect>
415- </property>
416- <property name="sizePolicy">
417- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
418- <horstretch>0</horstretch>
419- <verstretch>0</verstretch>
420- </sizepolicy>
421- </property>
422- <property name="minimumSize">
423- <size>
424- <width>400</width>
425- <height>0</height>
426- </size>
427- </property>
428- <property name="windowTitle">
429- <string/>
430- </property>
431- <layout class="QFormLayout" name="formLayout">
432- <item row="1" column="0">
433- <widget class="QLabel" name="label_2">
434- <property name="text">
435- <string>Folder to show:</string>
436- </property>
437- <property name="buddy">
438- <cstring>urlRequester</cstring>
439- </property>
440- </widget>
441- </item>
442- <item row="1" column="1">
443- <widget class="KUrlRequester" name="urlRequester">
444- <property name="mode">
445- <set>KFile::Directory|KFile::ExistingOnly</set>
446- </property>
447- </widget>
448- </item>
449- <item row="2" column="1">
450- <widget class="QLineEdit" name="titleLineEdit"/>
451- </item>
452- <item row="2" column="0">
453- <widget class="QLabel" name="label">
454- <property name="text">
455- <string>Title:</string>
456- </property>
457- <property name="buddy">
458- <cstring>titleLineEdit</cstring>
459- </property>
460- </widget>
461- </item>
462- <item row="3" column="1">
463- <widget class="QLabel" name="titleHelpLabel">
464- <property name="sizePolicy">
465- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
466- <horstretch>0</horstretch>
467- <verstretch>0</verstretch>
468- </sizepolicy>
469- </property>
470- <property name="text">
471- <string>If title is left empty, the folder name will be used</string>
472- </property>
473- </widget>
474- </item>
475- </layout>
476- </widget>
477- <customwidgets>
478- <customwidget>
479- <class>KUrlRequester</class>
480- <extends>QFrame</extends>
481- <header>kurlrequester.h</header>
482- </customwidget>
483- </customwidgets>
484- <resources/>
485- <connections/>
486-</ui>
487
488=== removed file 'components/dirmodel.cpp'
489--- components/dirmodel.cpp 2012-12-18 19:55:12 +0000
490+++ components/dirmodel.cpp 1970-01-01 00:00:00 +0000
491@@ -1,240 +0,0 @@
492-/*
493-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
494-
495-This library is free software; you can redistribute it and/or
496-modify it under the terms of the GNU Lesser General Public
497-License as published by the Free Software Foundation; either
498-version 2.1 of the License, or (at your option) version 3, or any
499-later version accepted by the membership of KDE e.V. (or its
500-successor approved by the membership of KDE e.V.), which shall
501-act as a proxy defined in Section 6 of version 3 of the license.
502-
503-This library is distributed in the hope that it will be useful,
504-but WITHOUT ANY WARRANTY; without even the implied warranty of
505-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
506-Lesser General Public License for more details.
507-
508-You should have received a copy of the GNU Lesser General Public
509-License along with this library. If not, see <http://www.gnu.org/licenses/>.
510-*/
511-// Self
512-#include <dirmodel.h>
513-
514-// Local
515-#include <dirconfigurationwidget.h>
516-#include <pathmodel.h>
517-#include <favoriteplacesmodel.h>
518-
519-// KDE
520-#include <KConfigGroup>
521-#include <KDebug>
522-#include <KDirModel>
523-#include <KDirLister>
524-
525-// Qt
526-#include <QDir>
527-
528-namespace Homerun
529-{
530-
531-static const char *SOURCE_ID = "Dir";
532-
533-static inline KFileItem itemForIndex(const QModelIndex &index)
534-{
535- return index.data(KDirModel::FileItemRole).value<KFileItem>();
536-}
537-
538-//- DirModel ------------------------------------------------------
539-QVariantMap DirModel::sourceArguments(const KUrl &rootUrl, const QString &rootName, const KUrl &url)
540-{
541- QVariantMap args;
542- args.insert("rootUrl", rootUrl.url());
543- args.insert("rootName", rootName);
544- args.insert("url", url.url());
545- return args;
546-}
547-
548-
549-DirModel::DirModel(QObject *parent)
550-: KDirSortFilterProxyModel(parent)
551-, m_pathModel(new PathModel(this))
552-{
553- setSourceModel(new KDirModel(this));
554- setSortFoldersFirst(true);
555-
556- QHash<int, QByteArray> roles;
557- roles.insert(Qt::DisplayRole, "display");
558- roles.insert(Qt::DecorationRole, "decoration");
559- roles.insert(DirModel::FavoriteIdRole, "favoriteId");
560- setRoleNames(roles);
561-
562- dirLister()->setDelayedMimeTypes(true);
563- connect(dirLister(), SIGNAL(started(KUrl)), SLOT(emitRunningChanged()));
564- connect(dirLister(), SIGNAL(completed()), SLOT(emitRunningChanged()));
565-}
566-
567-void DirModel::init(const KUrl &rootUrl, const QString &rootName, const KUrl &url)
568-{
569- m_rootUrl = rootUrl;
570- m_rootName = rootName;
571- initPathModel(url);
572- dirLister()->openUrl(url);
573-}
574-
575-void DirModel::initPathModel(const KUrl &openedUrl)
576-{
577- QVariantMap args = sourceArguments(m_rootUrl, m_rootName, m_rootUrl);
578- m_pathModel->addPath(m_rootName, SOURCE_ID, args);
579-
580- KUrl rootUrl = m_rootUrl;
581- // Needed for KUrl::relativeUrl
582- rootUrl.adjustPath(KUrl::AddTrailingSlash);
583- QString relativePath = KUrl::relativeUrl(rootUrl, openedUrl);
584- if (relativePath == "./") {
585- return;
586- }
587- KUrl url = m_rootUrl;
588- Q_FOREACH(const QString &token, relativePath.split('/')) {
589- if (token.isEmpty()) {
590- // Just in case relativePath ends with '/'
591- continue;
592- }
593- url.addPath(token);
594- args["url"] = url.url();
595- m_pathModel->addPath(token, SOURCE_ID, args);
596- }
597-}
598-
599-KDirLister *DirModel::dirLister() const
600-{
601- return static_cast<KDirModel *>(sourceModel())->dirLister();
602-}
603-
604-QVariant DirModel::data(const QModelIndex &index, int role) const
605-{
606- if (role != FavoriteIdRole) {
607- return QSortFilterProxyModel::data(index, role);
608- }
609- if (index.row() < 0 || index.row() >= rowCount()) {
610- return QVariant();
611- }
612-
613- KFileItem item = itemForIndex(index);
614- if (item.isDir()) {
615- return FavoritePlacesModel::favoriteIdFromUrl(item.url());
616- } else {
617- return QString();
618- }
619-}
620-
621-int DirModel::count() const
622-{
623- return rowCount(QModelIndex());
624-}
625-
626-QString DirModel::name() const
627-{
628- return m_rootName;
629-}
630-
631-bool DirModel::running() const
632-{
633- return !dirLister()->isFinished();
634-}
635-
636-PathModel *DirModel::pathModel() const
637-{
638- return m_pathModel;
639-}
640-
641-QString DirModel::query() const
642-{
643- return filterRegExp().pattern();
644-}
645-
646-void DirModel::setQuery(const QString &value)
647-{
648- if (value == query()) {
649- return;
650- }
651- setFilterRegExp(QRegExp(value, Qt::CaseInsensitive));
652- queryChanged(value);
653-}
654-
655-void DirModel::emitRunningChanged()
656-{
657- runningChanged(running());
658-}
659-
660-bool DirModel::trigger(int row)
661-{
662- bool closed = false;
663- QModelIndex idx = index(row, 0);
664-
665- KFileItem item = itemForIndex(idx);
666- if (item.isDir()) {
667- openSourceRequested(SOURCE_ID, sourceArguments(m_rootUrl, m_rootName, item.url()));
668- } else {
669- item.run();
670- closed = true;
671- }
672- return closed;
673-}
674-
675-//- DirSource -------------------------------------------------------
676-DirSource::DirSource(QObject *parent)
677-: AbstractSource(parent)
678-{}
679-
680-QAbstractItemModel *DirSource::createModelFromArguments(const QVariantMap &args)
681-{
682- KUrl rootUrl = args.value("rootUrl").toString();
683- QString rootName = args.value("rootName").toString();
684- KUrl url = args.value("url").toString();
685- return createModel(rootUrl, rootName, url);
686-}
687-
688-QAbstractItemModel *DirSource::createModelFromConfigGroup(const KConfigGroup &group)
689-{
690- KUrl rootUrl = group.readPathEntry("rootUrl", QDir::homePath());
691- QString rootName = group.readEntry("rootName", QString());
692- return createModel(rootUrl, rootName, KUrl());
693-}
694-
695-QAbstractItemModel *DirSource::createModel(const KUrl &rootUrl_, const QString &rootName_, const KUrl &url_)
696-{
697- KUrl rootUrl = rootUrl_;
698- QString rootName = rootName_;
699- KUrl url = url_;
700- if (!rootUrl.isValid()) {
701- rootUrl = KUrl::fromPath(QDir::homePath());
702- }
703-
704- if (rootName.isEmpty()) {
705- rootName = rootUrl.fileName();
706- if (rootName.isEmpty()) {
707- rootName = rootUrl.prettyUrl();
708- }
709- }
710- if (!url.isValid()) {
711- url = rootUrl;
712- }
713-
714- DirModel *model = new DirModel;
715- model->init(rootUrl, rootName, url);
716- return model;
717-}
718-
719-bool DirSource::isConfigurable() const
720-{
721- return true;
722-}
723-
724-SourceConfigurationWidget *DirSource::createConfigurationWidget(const KConfigGroup &group)
725-{
726- return new DirConfigurationWidget(group);
727-}
728-
729-} // namespace Homerun
730-
731-#include <dirmodel.moc>
732
733=== removed file 'components/dirmodel.h'
734--- components/dirmodel.h 2012-11-14 21:30:06 +0000
735+++ components/dirmodel.h 1970-01-01 00:00:00 +0000
736@@ -1,111 +0,0 @@
737-/*
738-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
739-
740-This library is free software; you can redistribute it and/or
741-modify it under the terms of the GNU Lesser General Public
742-License as published by the Free Software Foundation; either
743-version 2.1 of the License, or (at your option) version 3, or any
744-later version accepted by the membership of KDE e.V. (or its
745-successor approved by the membership of KDE e.V.), which shall
746-act as a proxy defined in Section 6 of version 3 of the license.
747-
748-This library is distributed in the hope that it will be useful,
749-but WITHOUT ANY WARRANTY; without even the implied warranty of
750-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
751-Lesser General Public License for more details.
752-
753-You should have received a copy of the GNU Lesser General Public
754-License along with this library. If not, see <http://www.gnu.org/licenses/>.
755-*/
756-#ifndef DIRMODEL_H
757-#define DIRMODEL_H
758-
759-// Local
760-#include <abstractsource.h>
761-
762-// Qt
763-
764-// KDE
765-#include <KDirSortFilterProxyModel>
766-#include <KUrl>
767-
768-class KDirLister;
769-
770-namespace Homerun {
771-
772-class PathModel;
773-
774-/**
775- * Internal
776- */
777-class DirModel : public KDirSortFilterProxyModel
778-{
779- Q_OBJECT
780- Q_PROPERTY(int count READ count NOTIFY countChanged)
781- Q_PROPERTY(QString name READ name CONSTANT)
782-
783- Q_PROPERTY(bool running READ running NOTIFY runningChanged)
784- Q_PROPERTY(QObject *pathModel READ pathModel CONSTANT)
785- Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
786-public:
787- explicit DirModel(QObject *parent = 0);
788-
789- void init(const KUrl &rootUrl, const QString &rootName, const KUrl &url);
790-
791- enum {
792- FavoriteIdRole = Qt::UserRole + 1,
793- };
794-
795- Q_INVOKABLE bool trigger(int row);
796-
797- KDirLister *dirLister() const;
798-
799- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; // reimp
800-
801- PathModel *pathModel() const;
802-
803- int count() const;
804-
805- QString name() const;
806-
807- bool running() const;
808-
809- QString query() const;
810-
811- void setQuery(const QString &query);
812-
813- static QVariantMap sourceArguments(const KUrl &rootUrl, const QString &rootName, const KUrl &url);
814-
815-Q_SIGNALS:
816- void countChanged();
817- void runningChanged(bool);
818- void openSourceRequested(const QString &sourceId, const QVariantMap &sourceArguments);
819- void queryChanged(const QString &);
820-
821-private Q_SLOTS:
822- void emitRunningChanged();
823-
824-private:
825- PathModel *m_pathModel;
826- KUrl m_rootUrl;
827- QString m_rootName;
828-
829- void initPathModel(const KUrl &url);
830-};
831-
832-class DirSource : public AbstractSource
833-{
834-public:
835- DirSource(QObject *parent);
836- QAbstractItemModel *createModelFromConfigGroup(const KConfigGroup &group);
837- QAbstractItemModel *createModelFromArguments(const QVariantMap &args);
838- bool isConfigurable() const;
839- SourceConfigurationWidget *createConfigurationWidget(const KConfigGroup &group);
840-
841-private:
842- QAbstractItemModel *createModel(const KUrl &rootUrl, const QString &rootName, const KUrl &url);
843-};
844-
845-} // namespace Homerun
846-
847-#endif /* DIRMODEL_H */
848
849=== removed file 'components/favoriteappsmodel.cpp'
850--- components/favoriteappsmodel.cpp 2012-11-14 21:30:06 +0000
851+++ components/favoriteappsmodel.cpp 1970-01-01 00:00:00 +0000
852@@ -1,215 +0,0 @@
853-/*
854- Copyright 2009 Ivan Cukic <ivan.cukic+kde@gmail.com>
855- Copyright 2010 Marco Martin <notmart@gmail.com>
856- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
857-
858- This library is free software; you can redistribute it and/or
859- modify it under the terms of the GNU Library General Public
860- License as published by the Free Software Foundation; either
861- version 2 of the License, or (at your option) any later version.
862-
863- This library is distributed in the hope that it will be useful,
864- but WITHOUT ANY WARRANTY; without even the implied warranty of
865- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
866- Library General Public License for more details.
867-
868- You should have received a copy of the GNU Library General Public License
869- along with this library; see the file COPYING.LIB. If not, write to
870- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
871- Boston, MA 02110-1301, USA.
872-*/
873-
874-// Own
875-#include "favoriteappsmodel.h"
876-
877-// Qt
878-
879-// KDE
880-#include <KDebug>
881-#include <KIcon>
882-#include <KConfigGroup>
883-#include <KLocale>
884-#include <KRun>
885-#include <KService>
886-
887-namespace Homerun {
888-
889-static QString serviceIdFromFavoriteId(const QString &favoriteId)
890-{
891- if (!favoriteId.startsWith("app:")) {
892- kWarning() << "Wrong favoriteId" << favoriteId;
893- return QString();
894- }
895- return favoriteId.mid(4);
896-}
897-
898-FavoriteAppsModel::FavoriteAppsModel(QObject *parent)
899-: QAbstractListModel(parent)
900-{
901- QHash<int, QByteArray> roles;
902- roles.insert(Qt::DisplayRole, "display");
903- roles.insert(Qt::DecorationRole, "decoration");
904- roles.insert(FavoriteIdRole, "favoriteId");
905- setRoleNames(roles);
906- setConfig(KSharedConfig::openConfig("homerunrc"));
907-}
908-
909-FavoriteAppsModel::~FavoriteAppsModel()
910-{
911-}
912-
913-void FavoriteAppsModel::setConfig(const KSharedConfig::Ptr &ptr)
914-{
915- m_config = ptr;
916-
917- KConfigGroup baseGroup(m_config, "favorites");
918-
919- // get all the favorites
920- QMap<int, KService::Ptr> favoriteMap;
921- foreach (const QString &favoriteGroup, baseGroup.groupList()) {
922- if (favoriteGroup.startsWith("favorite-")) {
923- KConfigGroup favoriteConfig(&baseGroup, favoriteGroup);
924- int rank = favoriteGroup.split("-").last().toInt();
925- QString id = favoriteConfig.readEntry("serviceId");
926- KService::Ptr service = KService::serviceByStorageId(id);
927- if (!service.isNull()) {
928- favoriteMap.insert(rank, service);
929- }
930- }
931- }
932-
933- beginResetModel();
934- m_favoriteList.clear();
935- auto it = favoriteMap.constBegin(), end = favoriteMap.constEnd();
936- for (; it != end; ++it) {
937- FavoriteInfo info = { it.key(), it.value() };
938- m_favoriteList << info;
939- }
940- endResetModel();
941- countChanged();
942-}
943-
944-void FavoriteAppsModel::addFavorite(const QString &favoriteId)
945-{
946- QString serviceId = serviceIdFromFavoriteId(favoriteId);
947- if (serviceId.isEmpty()) {
948- return;
949- }
950- KService::Ptr service = KService::serviceByStorageId(serviceId);
951- if (service.isNull()) {
952- kWarning() << "Could not find a service for" << serviceId;
953- return;
954- }
955- int rank;
956- if (!m_favoriteList.isEmpty()) {
957- rank = m_favoriteList.last().rank + 1;
958- } else {
959- rank = 0;
960- }
961- FavoriteInfo info = { rank, service };
962-
963- int row = m_favoriteList.count();
964- beginInsertRows(QModelIndex(), row, row);
965- m_favoriteList << info;
966- endInsertRows();
967- countChanged();
968-
969- KConfigGroup baseGroup(m_config, "favorites");
970- KConfigGroup group(&baseGroup, QString("favorite-%1").arg(rank));
971- group.writeEntry("serviceId", serviceId);
972- baseGroup.sync();
973-}
974-
975-void FavoriteAppsModel::removeFavorite(const QString &favoriteId)
976-{
977- int row = rowForFavoriteId(favoriteId);
978- if (row == -1) {
979- kWarning() << "Could not find favorite" << favoriteId;
980- return;
981- }
982- beginRemoveRows(QModelIndex(), row, row);
983- FavoriteInfo info = m_favoriteList.takeAt(row);
984- endRemoveRows();
985- countChanged();
986-
987- KConfigGroup baseGroup(m_config, "favorites");
988- KConfigGroup group(&baseGroup, QString("favorite-%1").arg(info.rank));
989- group.deleteGroup();
990- baseGroup.sync();
991-}
992-
993-bool FavoriteAppsModel::isFavorite(const QString &favoriteId) const
994-{
995- return rowForFavoriteId(favoriteId) != -1;
996-}
997-
998-int FavoriteAppsModel::rowForFavoriteId(const QString& favoriteId) const
999-{
1000- QString serviceId = serviceIdFromFavoriteId(favoriteId);
1001- if (serviceId.isEmpty()) {
1002- return -1;
1003- }
1004-
1005- for (int row = m_favoriteList.count() - 1; row >= 0; --row) {
1006- const FavoriteInfo& info = m_favoriteList.at(row);
1007- if (info.service->storageId() == serviceId) {
1008- return row;
1009- }
1010- }
1011- return -1;
1012-}
1013-
1014-int FavoriteAppsModel::count() const
1015-{
1016- return m_favoriteList.count();
1017-}
1018-
1019-QString FavoriteAppsModel::name() const
1020-{
1021- return i18n("Favorite Applications");
1022-}
1023-
1024-QString FavoriteAppsModel::favoritePrefix() const
1025-{
1026- return "app";
1027-}
1028-
1029-int FavoriteAppsModel::rowCount(const QModelIndex &index) const
1030-{
1031- if (index.isValid()) {
1032- return 0;
1033- }
1034- return m_favoriteList.count();
1035-}
1036-
1037-QVariant FavoriteAppsModel::data(const QModelIndex &index, int role) const
1038-{
1039- KService::Ptr service = m_favoriteList.value(index.row()).service;
1040- if (service.isNull()) {
1041- return QVariant();
1042- }
1043- if (role == Qt::DisplayRole) {
1044- return service->name();
1045- } else if (role == Qt::DecorationRole) {
1046- return KIcon(service->icon());
1047- } else if (role == FavoriteIdRole) {
1048- return QVariant("app:" + service->storageId());
1049- } else {
1050- kWarning() << "Unhandled role" << role;
1051- return QVariant();
1052- }
1053-}
1054-
1055-bool FavoriteAppsModel::trigger(int row)
1056-{
1057- KService::Ptr service = m_favoriteList.value(row).service;
1058- if (service.isNull()) {
1059- kWarning() << "Invalid row";
1060- return false;
1061- }
1062- return KRun::run(*service, KUrl::List(), 0);
1063-}
1064-
1065-} // namespace Homerun
1066-
1067-#include "favoriteappsmodel.moc"
1068
1069=== removed file 'components/favoriteappsmodel.h'
1070--- components/favoriteappsmodel.h 2012-11-14 21:30:06 +0000
1071+++ components/favoriteappsmodel.h 1970-01-01 00:00:00 +0000
1072@@ -1,81 +0,0 @@
1073-/*
1074- Copyright 2009 Ivan Cukic <ivan.cukic+kde@gmail.com>
1075- Copyright 2010 Marco Martin <notmart@gmail.com>
1076- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1077-
1078- This library is free software; you can redistribute it and/or
1079- modify it under the terms of the GNU Library General Public
1080- License as published by the Free Software Foundation; either
1081- version 2 of the License, or (at your option) any later version.
1082-
1083- This library is distributed in the hope that it will be useful,
1084- but WITHOUT ANY WARRANTY; without even the implied warranty of
1085- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1086- Library General Public License for more details.
1087-
1088- You should have received a copy of the GNU Library General Public License
1089- along with this library; see the file COPYING.LIB. If not, write to
1090- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1091- Boston, MA 02110-1301, USA.
1092-*/
1093-
1094-#ifndef FAVORITEAPPSMODEL_H
1095-#define FAVORITEAPPSMODEL_H
1096-
1097-#include <QAbstractListModel>
1098-
1099-#include <KService>
1100-#include <KSharedConfig>
1101-
1102-namespace Homerun {
1103-
1104-struct FavoriteInfo
1105-{
1106- int rank;
1107- KService::Ptr service;
1108-};
1109-
1110-class FavoriteAppsModel : public QAbstractListModel
1111-{
1112- Q_OBJECT
1113- Q_PROPERTY(QString name READ name CONSTANT)
1114- Q_PROPERTY(int count READ count NOTIFY countChanged)
1115-
1116- Q_PROPERTY(QString favoritePrefix READ favoritePrefix CONSTANT)
1117-
1118-public:
1119- FavoriteAppsModel(QObject *parent = 0);
1120- ~FavoriteAppsModel();
1121-
1122- enum {
1123- FavoriteIdRole = Qt::UserRole + 1
1124- };
1125-
1126- int count() const;
1127- QString name() const;
1128- QString favoritePrefix() const;
1129-
1130- void setConfig(const KSharedConfig::Ptr &);
1131-
1132- int rowCount(const QModelIndex & = QModelIndex()) const;
1133- QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const;
1134-
1135- Q_INVOKABLE bool isFavorite(const QString &favoriteId) const;
1136- Q_INVOKABLE void addFavorite(const QString &favoriteId);
1137- Q_INVOKABLE void removeFavorite(const QString &favoriteId);
1138-
1139- Q_INVOKABLE bool trigger(int row);
1140-
1141-Q_SIGNALS:
1142- void countChanged();
1143-
1144-private:
1145- KSharedConfig::Ptr m_config;
1146- QList<FavoriteInfo> m_favoriteList;
1147-
1148- int rowForFavoriteId(const QString &favoriteId) const;
1149-};
1150-
1151-} // namespace Homerun
1152-
1153-#endif // FAVORITEAPPSMODEL_H
1154
1155=== removed file 'components/favoriteplacesmodel.cpp'
1156--- components/favoriteplacesmodel.cpp 2012-11-14 21:30:06 +0000
1157+++ components/favoriteplacesmodel.cpp 1970-01-01 00:00:00 +0000
1158@@ -1,138 +0,0 @@
1159-/*
1160-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1161-
1162-This library is free software; you can redistribute it and/or
1163-modify it under the terms of the GNU Lesser General Public
1164-License as published by the Free Software Foundation; either
1165-version 2.1 of the License, or (at your option) version 3, or any
1166-later version accepted by the membership of KDE e.V. (or its
1167-successor approved by the membership of KDE e.V.), which shall
1168-act as a proxy defined in Section 6 of version 3 of the license.
1169-
1170-This library is distributed in the hope that it will be useful,
1171-but WITHOUT ANY WARRANTY; without even the implied warranty of
1172-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1173-Lesser General Public License for more details.
1174-
1175-You should have received a copy of the GNU Lesser General Public
1176-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1177-*/
1178-#include "favoriteplacesmodel.h"
1179-
1180-// Local
1181-#include <dirmodel.h>
1182-
1183-// KDE
1184-#include <KDebug>
1185-#include <KLocale>
1186-
1187-// Qt
1188-
1189-namespace Homerun {
1190-
1191-KUrl FavoritePlacesModel::urlFromFavoriteId(const QString &favoriteId)
1192-{
1193- if (!favoriteId.startsWith("place:")) {
1194- kWarning() << "Wrong favoriteId" << favoriteId;
1195- return QString();
1196- }
1197- return KUrl(favoriteId.mid(6));
1198-}
1199-
1200-QString FavoritePlacesModel::favoriteIdFromUrl(const KUrl &url)
1201-{
1202- return "place:" + url.url();
1203-}
1204-
1205-//- FavoritePlacesModel ------------------------------------------------
1206-FavoritePlacesModel::FavoritePlacesModel(QObject *parent)
1207-: KFilePlacesModel(parent)
1208-{
1209- QHash<int, QByteArray> roles;
1210- roles.insert(Qt::DisplayRole, "display");
1211- roles.insert(Qt::DecorationRole, "decoration");
1212- roles.insert(FavoritePlacesModel::FavoriteIdRole, "favoriteId");
1213- setRoleNames(roles);
1214-}
1215-
1216-QString FavoritePlacesModel::favoritePrefix() const
1217-{
1218- return "place";
1219-}
1220-
1221-bool FavoritePlacesModel::isFavorite(const QString &favoriteId) const
1222-{
1223- return indexForFavoriteId(favoriteId).isValid();
1224-}
1225-
1226-void FavoritePlacesModel::addFavorite(const QString &favoriteId)
1227-{
1228- KUrl favoriteUrl = urlFromFavoriteId(favoriteId);
1229- if (favoriteUrl.isEmpty()) {
1230- return;
1231- }
1232- addPlace(favoriteUrl.fileName(), favoriteUrl);
1233-}
1234-
1235-void FavoritePlacesModel::removeFavorite(const QString &favoriteId)
1236-{
1237- QModelIndex index = indexForFavoriteId(favoriteId);
1238- if (!index.isValid()) {
1239- kWarning() << "No favorite place for" << favoriteId;
1240- return;
1241- }
1242- removePlace(index);
1243-}
1244-
1245-QModelIndex FavoritePlacesModel::indexForFavoriteId(const QString &favoriteId) const
1246-{
1247- KUrl favoriteUrl = urlFromFavoriteId(favoriteId);
1248- if (favoriteUrl.isEmpty()) {
1249- return QModelIndex();
1250- }
1251- for (int row = rowCount() - 1; row >= 0; --row) {
1252- QModelIndex idx = index(row, 0);
1253- if (url(idx).equals(favoriteUrl, KUrl::CompareWithoutTrailingSlash)) {
1254- return idx;
1255- }
1256- }
1257- return QModelIndex();
1258-}
1259-
1260-QVariant FavoritePlacesModel::data(const QModelIndex &index, int role) const
1261-{
1262- if (role != FavoriteIdRole) {
1263- return KFilePlacesModel::data(index, role);
1264- }
1265-
1266- if (index.row() < 0 || index.row() >= rowCount()) {
1267- return QVariant();
1268- }
1269- return QVariant(favoriteIdFromUrl(url(index)));
1270-}
1271-
1272-bool FavoritePlacesModel::trigger(int row)
1273-{
1274- QModelIndex idx = index(row, 0);
1275-
1276- KUrl theUrl = idx.data(KFilePlacesModel::UrlRole).value<QUrl>();
1277- theUrl.adjustPath(KUrl::AddTrailingSlash);
1278- QString rootName = idx.data(Qt::DisplayRole).toString();
1279- openSourceRequested("Dir", DirModel::sourceArguments(theUrl, rootName, theUrl));
1280-
1281- return false;
1282-}
1283-
1284-QString FavoritePlacesModel::name() const
1285-{
1286- return i18n("Favorite Places");
1287-}
1288-
1289-int FavoritePlacesModel::count() const
1290-{
1291- return rowCount(QModelIndex());
1292-}
1293-
1294-} // namespace Homerun
1295-
1296-#include "favoriteplacesmodel.moc"
1297
1298=== removed file 'components/favoriteplacesmodel.h'
1299--- components/favoriteplacesmodel.h 2012-11-14 21:30:06 +0000
1300+++ components/favoriteplacesmodel.h 1970-01-01 00:00:00 +0000
1301@@ -1,75 +0,0 @@
1302-/*
1303-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1304-
1305-This library is free software; you can redistribute it and/or
1306-modify it under the terms of the GNU Lesser General Public
1307-License as published by the Free Software Foundation; either
1308-version 2.1 of the License, or (at your option) version 3, or any
1309-later version accepted by the membership of KDE e.V. (or its
1310-successor approved by the membership of KDE e.V.), which shall
1311-act as a proxy defined in Section 6 of version 3 of the license.
1312-
1313-This library is distributed in the hope that it will be useful,
1314-but WITHOUT ANY WARRANTY; without even the implied warranty of
1315-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1316-Lesser General Public License for more details.
1317-
1318-You should have received a copy of the GNU Lesser General Public
1319-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1320-*/
1321-#ifndef PLACESMODEL_H
1322-#define PLACESMODEL_H
1323-
1324-// Local
1325-
1326-// Qt
1327-
1328-// KDE
1329-#include <KFilePlacesModel>
1330-
1331-namespace Homerun {
1332-
1333-/**
1334- * Adapts KFilePlacesModel to make it usable as a Homerun favorite model
1335- */
1336-class FavoritePlacesModel : public KFilePlacesModel
1337-{
1338- Q_OBJECT
1339- Q_PROPERTY(QString favoritePrefix READ favoritePrefix CONSTANT)
1340- Q_PROPERTY(int count READ count NOTIFY countChanged)
1341- Q_PROPERTY(QString name READ name CONSTANT)
1342-
1343-public:
1344- enum {
1345- FavoriteIdRole = Qt::UserRole + 1,
1346- };
1347-
1348- FavoritePlacesModel(QObject *parent = 0);
1349-
1350- Q_INVOKABLE bool isFavorite(const QString &favoriteId) const;
1351- Q_INVOKABLE void addFavorite(const QString &favoriteId);
1352- Q_INVOKABLE void removeFavorite(const QString &favoriteId);
1353- Q_INVOKABLE bool trigger(int row);
1354-
1355- QString favoritePrefix() const;
1356-
1357- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; // reimp
1358-
1359- QString name() const;
1360-
1361- int count() const;
1362-
1363- static KUrl urlFromFavoriteId(const QString &favoriteId);
1364- static QString favoriteIdFromUrl(const KUrl &url);
1365-
1366-Q_SIGNALS:
1367- void openSourceRequested(const QString &sourceId, const QVariantMap &sourceArguments);
1368- void countChanged();
1369-
1370-private:
1371- QModelIndex indexForFavoriteId(const QString &favoriteId) const;
1372-};
1373-
1374-} // namespace Homerun
1375-
1376-#endif /* PLACESMODEL_H */
1377
1378=== removed file 'components/groupedinstalledappsmodel.cpp'
1379--- components/groupedinstalledappsmodel.cpp 2012-11-14 21:30:06 +0000
1380+++ components/groupedinstalledappsmodel.cpp 1970-01-01 00:00:00 +0000
1381@@ -1,134 +0,0 @@
1382-/*
1383-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1384-
1385-This library is free software; you can redistribute it and/or
1386-modify it under the terms of the GNU Lesser General Public
1387-License as published by the Free Software Foundation; either
1388-version 2.1 of the License, or (at your option) version 3, or any
1389-later version accepted by the membership of KDE e.V. (or its
1390-successor approved by the membership of KDE e.V.), which shall
1391-act as a proxy defined in Section 6 of version 3 of the license.
1392-
1393-This library is distributed in the hope that it will be useful,
1394-but WITHOUT ANY WARRANTY; without even the implied warranty of
1395-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1396-Lesser General Public License for more details.
1397-
1398-You should have received a copy of the GNU Lesser General Public
1399-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1400-*/
1401-// Self
1402-#include <groupedinstalledappsmodel.h>
1403-
1404-// Local
1405-#include <abstractsourceregistry.h>
1406-#include <installedappsmodel.h>
1407-
1408-// KDE
1409-#include <KConfigGroup>
1410-#include <KDebug>
1411-
1412-// Qt
1413-
1414-namespace Homerun {
1415-
1416-GroupedInstalledAppsModel::GroupedInstalledAppsModel(const QString &installer, QObject *parent)
1417-: QAbstractListModel(parent)
1418-, m_installer(installer)
1419-{
1420- loadRootEntries();
1421-}
1422-
1423-GroupedInstalledAppsModel::~GroupedInstalledAppsModel()
1424-{
1425-}
1426-
1427-QObject *GroupedInstalledAppsModel::modelForRow(int row) const
1428-{
1429- if (row < 0 || row >= m_models.count()) {
1430- kWarning() << "No model for row" << row << "!";
1431- return 0;
1432- }
1433- return m_models.value(row);
1434-}
1435-
1436-void GroupedInstalledAppsModel::loadRootEntries()
1437-{
1438- KServiceGroup::Ptr group = KServiceGroup::root();
1439- KServiceGroup::List list = group->entries(false /* sorted: set to false as it does not seem to work */);
1440-
1441- QMap<QString, KServiceGroup::Ptr> groupMap;
1442- for( KServiceGroup::List::ConstIterator it = list.constBegin(); it != list.constEnd(); it++) {
1443- const KSycocaEntry::Ptr p = (*it);
1444-
1445- if (p->isType(KST_KServiceGroup)) {
1446- KServiceGroup::Ptr subGroup = KServiceGroup::Ptr::staticCast(p);
1447-
1448- if (!subGroup->noDisplay() && subGroup->childCount() > 0) {
1449- groupMap.insert(subGroup->caption().toLower(), subGroup);
1450- }
1451- }
1452- }
1453- m_pendingGroupList = groupMap.values();
1454- QMetaObject::invokeMethod(this, "loadNextGroup", Qt::QueuedConnection);
1455-}
1456-
1457-void GroupedInstalledAppsModel::loadNextGroup()
1458-{
1459- if (m_pendingGroupList.isEmpty()) {
1460- return;
1461- }
1462- KServiceGroup::Ptr group = m_pendingGroupList.takeFirst();
1463- InstalledAppsModel *model = createInstalledAppsModel(group);
1464- beginInsertRows(QModelIndex(), m_models.count(), m_models.count());
1465- m_models << model;
1466- endInsertRows();
1467- QMetaObject::invokeMethod(this, "loadNextGroup", Qt::QueuedConnection);
1468-}
1469-
1470-int GroupedInstalledAppsModel::rowCount(const QModelIndex &parent) const
1471-{
1472- if (parent.isValid()) {
1473- return 0;
1474- }
1475- return m_models.count();
1476-}
1477-
1478-QVariant GroupedInstalledAppsModel::data(const QModelIndex &index, int role) const
1479-{
1480- if (index.parent().isValid()) {
1481- return QVariant();
1482- }
1483-
1484- InstalledAppsModel *model = m_models.value(index.row());
1485- if (!model) {
1486- return QVariant();
1487- }
1488-
1489- if (role == Qt::DisplayRole) {
1490- return model->name();
1491- } else {
1492- return QVariant();
1493- }
1494-}
1495-
1496-InstalledAppsModel *GroupedInstalledAppsModel::createInstalledAppsModel(KServiceGroup::Ptr group)
1497-{
1498- return new InstalledAppsModel(group->entryPath(), m_installer, this);
1499-}
1500-
1501-//- GroupedInstalledAppsSource --------------------------------------
1502-GroupedInstalledAppsSource::GroupedInstalledAppsSource(QObject *parent)
1503-: AbstractSource(parent)
1504-{}
1505-
1506-QAbstractItemModel *GroupedInstalledAppsSource::createModelFromConfigGroup(const KConfigGroup &)
1507-{
1508- KConfigGroup group(config(), "PackageManagement");
1509- QString installer = group.readEntry("categoryInstaller");
1510- return new GroupedInstalledAppsModel(installer);
1511-}
1512-
1513-} // namespace Homerun
1514-
1515-#include <groupedinstalledappsmodel.moc>
1516
1517=== removed file 'components/groupedinstalledappsmodel.h'
1518--- components/groupedinstalledappsmodel.h 2012-11-14 21:30:06 +0000
1519+++ components/groupedinstalledappsmodel.h 1970-01-01 00:00:00 +0000
1520@@ -1,75 +0,0 @@
1521-/*
1522-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1523-
1524-This library is free software; you can redistribute it and/or
1525-modify it under the terms of the GNU Lesser General Public
1526-License as published by the Free Software Foundation; either
1527-version 2.1 of the License, or (at your option) version 3, or any
1528-later version accepted by the membership of KDE e.V. (or its
1529-successor approved by the membership of KDE e.V.), which shall
1530-act as a proxy defined in Section 6 of version 3 of the license.
1531-
1532-This library is distributed in the hope that it will be useful,
1533-but WITHOUT ANY WARRANTY; without even the implied warranty of
1534-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1535-Lesser General Public License for more details.
1536-
1537-You should have received a copy of the GNU Lesser General Public
1538-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1539-*/
1540-#ifndef GROUPEDINSTALLEDAPPSMODEL_H
1541-#define GROUPEDINSTALLEDAPPSMODEL_H
1542-
1543-// Local
1544-#include <abstractsource.h>
1545-
1546-// Qt
1547-#include <QAbstractListModel>
1548-
1549-// KDE
1550-#include <KServiceGroup>
1551-
1552-namespace Homerun {
1553-
1554-class InstalledAppsModel;
1555-
1556-/**
1557- * A model which returns all services in grouped sub-models
1558- */
1559-class GroupedInstalledAppsModel : public QAbstractListModel
1560-{
1561- Q_OBJECT
1562-public:
1563- explicit GroupedInstalledAppsModel(const QString &installer, QObject *parent = 0);
1564- ~GroupedInstalledAppsModel();
1565-
1566- int rowCount(const QModelIndex &parent = QModelIndex()) const; // reimp
1567- QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const; // reimp
1568-
1569- Q_INVOKABLE QObject *modelForRow(int row) const;
1570-
1571-Q_SIGNALS:
1572- void installerChanged(const QString &);
1573-
1574-private Q_SLOTS:
1575- void loadRootEntries();
1576- void loadNextGroup();
1577-
1578-private:
1579- QString m_installer;
1580- QList<KServiceGroup::Ptr> m_pendingGroupList;
1581- QList<InstalledAppsModel *> m_models;
1582-
1583- InstalledAppsModel *createInstalledAppsModel(KServiceGroup::Ptr group);
1584-};
1585-
1586-class GroupedInstalledAppsSource : public AbstractSource
1587-{
1588-public:
1589- GroupedInstalledAppsSource(QObject *parent);
1590- QAbstractItemModel *createModelFromConfigGroup(const KConfigGroup &);
1591-};
1592-
1593-} // namespace Homerun
1594-
1595-#endif /* GROUPEDINSTALLEDAPPSMODEL_H */
1596
1597=== removed file 'components/installedappsconfigurationwidget.cpp'
1598--- components/installedappsconfigurationwidget.cpp 2012-11-14 21:30:06 +0000
1599+++ components/installedappsconfigurationwidget.cpp 1970-01-01 00:00:00 +0000
1600@@ -1,145 +0,0 @@
1601-/*
1602-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1603-
1604-This library is free software; you can redistribute it and/or
1605-modify it under the terms of the GNU Lesser General Public
1606-License as published by the Free Software Foundation; either
1607-version 2.1 of the License, or (at your option) version 3, or any
1608-later version accepted by the membership of KDE e.V. (or its
1609-successor approved by the membership of KDE e.V.), which shall
1610-act as a proxy defined in Section 6 of version 3 of the license.
1611-
1612-This library is distributed in the hope that it will be useful,
1613-but WITHOUT ANY WARRANTY; without even the implied warranty of
1614-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1615-Lesser General Public License for more details.
1616-
1617-You should have received a copy of the GNU Lesser General Public
1618-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1619-*/
1620-// Self
1621-#include <installedappsconfigurationwidget.h>
1622-
1623-// Local
1624-#include <ui_installedappsconfigurationwidget.h>
1625-
1626-// KDE
1627-#include <KDebug>
1628-#include <KIcon>
1629-#include <KServiceGroup>
1630-#include <KSycocaEntry>
1631-
1632-// Qt
1633-#include <QStandardItem>
1634-#include <QStandardItemModel>
1635-
1636-enum {
1637- EntryPathRole = Qt::UserRole + 1,
1638- SortRole,
1639-};
1640-
1641-namespace Homerun
1642-{
1643-
1644-InstalledAppsConfigurationWidget::InstalledAppsConfigurationWidget(const KConfigGroup &group)
1645-: SourceConfigurationWidget(group)
1646-, m_ui(new Ui_InstalledAppsConfigurationWidget)
1647-, m_model(new QStandardItemModel(this))
1648-{
1649- // Init model
1650- QStandardItem *defaultItem = fillModel(group.readEntry("entryPath"));
1651- m_model->setSortRole(SortRole);
1652- m_model->sort(0);
1653-
1654- m_ui->setupUi(this);
1655- m_ui->treeView->setModel(m_model);
1656-
1657- // Select currently configured item
1658- Q_ASSERT(defaultItem);
1659- QModelIndex index = defaultItem->index();
1660- m_ui->treeView->selectionModel()->select(index, QItemSelectionModel::Select);
1661-
1662- // Expand up to the configured item
1663- index = index.parent();
1664- for (; index.isValid(); index = index.parent()) {
1665- m_ui->treeView->setExpanded(index, true);
1666- }
1667-
1668- // Always expand top level
1669- m_ui->treeView->setExpanded(m_model->index(0, 0), true);
1670-}
1671-
1672-InstalledAppsConfigurationWidget::~InstalledAppsConfigurationWidget()
1673-{
1674- delete m_ui;
1675-}
1676-
1677-void InstalledAppsConfigurationWidget::save()
1678-{
1679- QModelIndex index = m_ui->treeView->selectionModel()->currentIndex();
1680- if (!index.isValid()) {
1681- kWarning() << "No item selected!";
1682- return;
1683- }
1684- QString entryPath = index.data(EntryPathRole).toString();
1685- configGroup().writeEntry("entryPath", entryPath);
1686-}
1687-
1688-
1689-// Helper struct for fillModel
1690-struct ItemCreator
1691-{
1692- ItemCreator()
1693- : m_item(0)
1694- {}
1695- QString m_entryPath;
1696- QStandardItem *m_item;
1697-
1698- void createItemChildren(QStandardItem *parent, KServiceGroup::Ptr parentGroup)
1699- {
1700- KServiceGroup::List list = parentGroup->entries(false /* sorted: set to false as it does not seem to work */);
1701-
1702- Q_FOREACH(const KSycocaEntry::Ptr entry, list) {
1703- if (!entry->isType(KST_KServiceGroup)) {
1704- continue;
1705- }
1706- KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(entry);
1707-
1708- if (group->noDisplay() || group->childCount() == 0) {
1709- continue;
1710- }
1711- QString entryPath = group->entryPath();
1712-
1713- QStandardItem *item = new QStandardItem;
1714- item->setText(group->caption());
1715- item->setIcon(KIcon(group->icon()));
1716- item->setData(entryPath, EntryPathRole);
1717- item->setData(group->caption().toLower(), SortRole);
1718-
1719- parent->appendRow(item);
1720- createItemChildren(item, group);
1721-
1722- if (m_entryPath == entryPath) {
1723- m_item = item;
1724- }
1725- }
1726- }
1727-};
1728-
1729-QStandardItem *InstalledAppsConfigurationWidget::fillModel(const QString &entryPath)
1730-{
1731- KServiceGroup::Ptr group = KServiceGroup::root();
1732- QStandardItem *rootItem = new QStandardItem;
1733- rootItem->setText(i18n("All Applications"));
1734- rootItem->setData(QString(), EntryPathRole);
1735- m_model->appendRow(rootItem);
1736-
1737- ItemCreator creator;
1738- creator.m_entryPath = entryPath;
1739- creator.createItemChildren(rootItem, group);
1740- return creator.m_item ? creator.m_item : rootItem;
1741-}
1742-
1743-} // namespace Homerun
1744-
1745-#include <installedappsconfigurationwidget.moc>
1746
1747=== removed file 'components/installedappsconfigurationwidget.h'
1748--- components/installedappsconfigurationwidget.h 2012-11-14 21:30:06 +0000
1749+++ components/installedappsconfigurationwidget.h 1970-01-01 00:00:00 +0000
1750@@ -1,63 +0,0 @@
1751-/*
1752-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1753-
1754-This library is free software; you can redistribute it and/or
1755-modify it under the terms of the GNU Lesser General Public
1756-License as published by the Free Software Foundation; either
1757-version 2.1 of the License, or (at your option) version 3, or any
1758-later version accepted by the membership of KDE e.V. (or its
1759-successor approved by the membership of KDE e.V.), which shall
1760-act as a proxy defined in Section 6 of version 3 of the license.
1761-
1762-This library is distributed in the hope that it will be useful,
1763-but WITHOUT ANY WARRANTY; without even the implied warranty of
1764-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1765-Lesser General Public License for more details.
1766-
1767-You should have received a copy of the GNU Lesser General Public
1768-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1769-*/
1770-#ifndef INSTALLEDAPPSCONFIGURATIONWIDGET_H
1771-#define INSTALLEDAPPSCONFIGURATIONWIDGET_H
1772-
1773-// Local
1774-#include <sourceconfigurationwidget.h>
1775-
1776-// Qt
1777-
1778-// KDE
1779-#include <KServiceGroup>
1780-
1781-class QStandardItem;
1782-class QStandardItemModel;
1783-
1784-class Ui_InstalledAppsConfigurationWidget;
1785-
1786-namespace Homerun
1787-{
1788-
1789-/**
1790- * Configuration widget for the InstalledApps source
1791- */
1792-class InstalledAppsConfigurationWidget : public SourceConfigurationWidget
1793-{
1794- Q_OBJECT
1795-public:
1796- explicit InstalledAppsConfigurationWidget(const KConfigGroup &group);
1797- ~InstalledAppsConfigurationWidget();
1798-
1799- void save(); // reimp
1800-
1801-private:
1802- Ui_InstalledAppsConfigurationWidget *m_ui;
1803- QStandardItemModel *m_model;
1804-
1805- /**
1806- * Fill m_model, returns the item which corresponds to defaultEntryPath
1807- */
1808- QStandardItem *fillModel(const QString &defaultEntryPath);
1809-};
1810-
1811-} // namespace Homerun
1812-
1813-#endif /* INSTALLEDAPPSCONFIGURATIONWIDGET_H */
1814
1815=== removed file 'components/installedappsconfigurationwidget.ui'
1816--- components/installedappsconfigurationwidget.ui 2012-11-14 21:30:06 +0000
1817+++ components/installedappsconfigurationwidget.ui 1970-01-01 00:00:00 +0000
1818@@ -1,50 +0,0 @@
1819-<?xml version="1.0" encoding="UTF-8"?>
1820-<ui version="4.0">
1821- <class>InstalledAppsConfigurationWidget</class>
1822- <widget class="QWidget" name="InstalledAppsConfigurationWidget">
1823- <property name="geometry">
1824- <rect>
1825- <x>0</x>
1826- <y>0</y>
1827- <width>408</width>
1828- <height>327</height>
1829- </rect>
1830- </property>
1831- <layout class="QVBoxLayout" name="verticalLayout">
1832- <item>
1833- <widget class="QLabel" name="label">
1834- <property name="text">
1835- <string>Pick the application folder to display:</string>
1836- </property>
1837- <property name="buddy">
1838- <cstring>treeView</cstring>
1839- </property>
1840- </widget>
1841- </item>
1842- <item>
1843- <widget class="QTreeView" name="treeView">
1844- <property name="minimumSize">
1845- <size>
1846- <width>400</width>
1847- <height>300</height>
1848- </size>
1849- </property>
1850- <property name="editTriggers">
1851- <set>QAbstractItemView::NoEditTriggers</set>
1852- </property>
1853- <property name="showDropIndicator" stdset="0">
1854- <bool>false</bool>
1855- </property>
1856- <property name="rootIsDecorated">
1857- <bool>false</bool>
1858- </property>
1859- <property name="headerHidden">
1860- <bool>true</bool>
1861- </property>
1862- </widget>
1863- </item>
1864- </layout>
1865- </widget>
1866- <resources/>
1867- <connections/>
1868-</ui>
1869
1870=== removed file 'components/installedappsmodel.cpp'
1871--- components/installedappsmodel.cpp 2012-11-14 21:30:06 +0000
1872+++ components/installedappsmodel.cpp 1970-01-01 00:00:00 +0000
1873@@ -1,319 +0,0 @@
1874-/*
1875-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
1876-
1877-This library is free software; you can redistribute it and/or
1878-modify it under the terms of the GNU Lesser General Public
1879-License as published by the Free Software Foundation; either
1880-version 2.1 of the License, or (at your option) version 3, or any
1881-later version accepted by the membership of KDE e.V. (or its
1882-successor approved by the membership of KDE e.V.), which shall
1883-act as a proxy defined in Section 6 of version 3 of the license.
1884-
1885-This library is distributed in the hope that it will be useful,
1886-but WITHOUT ANY WARRANTY; without even the implied warranty of
1887-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1888-Lesser General Public License for more details.
1889-
1890-You should have received a copy of the GNU Lesser General Public
1891-License along with this library. If not, see <http://www.gnu.org/licenses/>.
1892-*/
1893-// Local
1894-#include <pathmodel.h>
1895-#include <installedappsmodel.h>
1896-#include <installedappsconfigurationwidget.h>
1897-#include <sourceregistry.h>
1898-
1899-// Qt
1900-#include <QIcon>
1901-#include <QAction>
1902-#include <QTimer>
1903-
1904-// KDE
1905-#include <KDebug>
1906-#include <KLocale>
1907-#include <kmacroexpander.h>
1908-#include <KRun>
1909-#include <KService>
1910-#include <KServiceTypeTrader>
1911-#include <KSycocaEntry>
1912-
1913-#include <Plasma/RunnerManager>
1914-
1915-namespace Homerun {
1916-
1917-static const char *SOURCE_ID = "InstalledApps";
1918-
1919-//- AbstractNode ---------------------------------------------------------------
1920-AbstractNode::~AbstractNode()
1921-{
1922-}
1923-
1924-bool AbstractNode::lessThan(AbstractNode *n1, AbstractNode *n2)
1925-{
1926- Q_ASSERT(n1);
1927- Q_ASSERT(n2);
1928- return n1->m_sortKey < n2->m_sortKey;
1929-}
1930-
1931-//- GroupNode ------------------------------------------------------------------
1932-GroupNode::GroupNode(KServiceGroup::Ptr group, InstalledAppsModel *model)
1933-: m_model(model)
1934-{
1935- m_icon = group->icon();
1936- m_name = group->caption();
1937- m_entryPath = group->entryPath();
1938- m_sortKey = m_name.toLower();
1939-}
1940-
1941-bool GroupNode::trigger()
1942-{
1943- QVariantMap args;
1944- args.insert("entryPath", m_entryPath);
1945- m_model->openSourceRequested(SOURCE_ID, args);
1946- return false;
1947-}
1948-
1949-//- AppNode --------------------------------------------------------------------
1950-AppNode::AppNode(KService::Ptr service)
1951-: m_service(service)
1952-{
1953- m_icon = service->icon();
1954- m_name = service->name();
1955- m_service = service;
1956- m_sortKey = m_name.toLower();
1957-}
1958-
1959-bool AppNode::trigger()
1960-{
1961- return KRun::run(*m_service, KUrl::List(), 0);
1962-}
1963-
1964-QString AppNode::favoriteId() const
1965-{
1966- return QString("app:") + m_service->storageId();
1967-}
1968-
1969-//- InstallerNode --------------------------------------------------------------
1970-InstallerNode::InstallerNode(KServiceGroup::Ptr group, KService::Ptr installerService)
1971-: m_group(group)
1972-, m_service(installerService)
1973-{
1974- m_icon = m_service->icon();
1975- m_name = m_service->name();
1976-}
1977-
1978-bool InstallerNode::trigger()
1979-{
1980- QHash<QString, QString> map;
1981- QString category = m_group->entryPath();
1982- if (category.endsWith('/')) {
1983- category.truncate(category.length() - 1);
1984- }
1985- map.insert("category", category);
1986-
1987- QString command = KMacroExpander::expandMacros(m_service->exec(), map, '@');
1988- return KRun::run(command, KUrl::List(), 0, m_service->name(), m_service->icon());
1989-}
1990-
1991-//- InstalledAppsModel ------------------------------------------------------------
1992-InstalledAppsModel::InstalledAppsModel(const QString &entryPath, const QString &installer, QObject *parent)
1993-: QAbstractListModel(parent)
1994-, m_pathModel(new PathModel(this))
1995-, m_installer(installer)
1996-{
1997- QHash<int, QByteArray> roles;
1998- roles.insert(Qt::DisplayRole, "display");
1999- roles.insert(Qt::DecorationRole, "decoration");
2000- roles.insert(FavoriteIdRole, "favoriteId");
2001-
2002- setRoleNames(roles);
2003-
2004- load(entryPath);
2005-}
2006-
2007-InstalledAppsModel::~InstalledAppsModel()
2008-{
2009- qDeleteAll(m_nodeList);
2010-}
2011-
2012-int InstalledAppsModel::rowCount(const QModelIndex& index) const
2013-{
2014- return index.isValid() ? 0 : m_nodeList.count();
2015-}
2016-
2017-int InstalledAppsModel::count() const
2018-{
2019- return m_nodeList.count();
2020-}
2021-
2022-QVariant InstalledAppsModel::data(const QModelIndex &index, int role) const
2023-{
2024- if (!index.isValid() || index.row() >= m_nodeList.count()) {
2025- return QVariant();
2026- }
2027-
2028- const AbstractNode *node = m_nodeList.at(index.row());
2029- if (role == Qt::DisplayRole) {
2030- return node->name();
2031- } else if (role == Qt::DecorationRole) {
2032- // at least show the oxygen question-mark, otherwise it looks weird blank.
2033- return node->icon().isEmpty() ? QLatin1String("unknown") : node->icon();
2034- } else if (role == FavoriteIdRole) {
2035- return node->favoriteId();
2036- }
2037-
2038- return QVariant();
2039-}
2040-
2041-bool InstalledAppsModel::trigger(int row)
2042-{
2043- return m_nodeList.at(row)->trigger();
2044-}
2045-
2046-void InstalledAppsModel::load(const QString &entryPath)
2047-{
2048- m_pathModel->clear();
2049- beginResetModel();
2050- qDeleteAll(m_nodeList);
2051- m_nodeList.clear();
2052-
2053- if (entryPath.isEmpty()) {
2054- loadRootEntries();
2055- } else {
2056- KServiceGroup::Ptr group = KServiceGroup::group(entryPath);
2057- loadServiceGroup(group);
2058- QVariantMap args;
2059- args.insert("entryPath", entryPath);
2060- m_pathModel->addPath(group->caption(), SOURCE_ID, args);
2061- }
2062-
2063- endResetModel();
2064-
2065- emit countChanged();
2066-}
2067-
2068-void InstalledAppsModel::loadRootEntries()
2069-{
2070- KServiceGroup::Ptr group = KServiceGroup::root();
2071- KServiceGroup::List list = group->entries(false /* sorted: set to false as it does not seem to work */);
2072-
2073- for( KServiceGroup::List::ConstIterator it = list.constBegin(); it != list.constEnd(); it++) {
2074- const KSycocaEntry::Ptr p = (*it);
2075-
2076- if (p->isType(KST_KServiceGroup)) {
2077- KServiceGroup::Ptr subGroup = KServiceGroup::Ptr::staticCast(p);
2078-
2079- if (!subGroup->noDisplay() && subGroup->childCount() > 0) {
2080- m_nodeList << new GroupNode(subGroup, this);
2081- }
2082- }
2083- }
2084- qSort(m_nodeList.begin(), m_nodeList.end(), AbstractNode::lessThan);
2085-}
2086-
2087-void InstalledAppsModel::loadServiceGroup(KServiceGroup::Ptr group)
2088-{
2089- doLoadServiceGroup(group);
2090-
2091- qSort(m_nodeList.begin(), m_nodeList.end(), AbstractNode::lessThan);
2092-
2093- if (!m_installer.isEmpty()) {
2094- KService::Ptr service = KService::serviceByDesktopName(m_installer);
2095- if (service) {
2096- m_nodeList << new InstallerNode(group, service);
2097- } else {
2098- kWarning() << "Could not find service for" << m_installer;
2099- }
2100- }
2101-}
2102-
2103-void InstalledAppsModel::doLoadServiceGroup(KServiceGroup::Ptr group)
2104-{
2105- /* This method is separate from loadServiceGroup so that
2106- * - only one installer node is added at the end
2107- * - sorting is done only once
2108- */
2109- if (!group || !group->isValid()) {
2110- return;
2111- }
2112-
2113- KServiceGroup::List list = group->entries(false /* see above */);
2114-
2115- for( KServiceGroup::List::ConstIterator it = list.constBegin();
2116- it != list.constEnd(); it++) {
2117- const KSycocaEntry::Ptr p = (*it);
2118-
2119- if (p->isType(KST_KService)) {
2120- const KService::Ptr service = KService::Ptr::staticCast(p);
2121-
2122- if (!service->noDisplay()) {
2123- QString genericName = service->genericName();
2124- if (genericName.isNull()) {
2125- genericName = service->comment();
2126- }
2127- m_nodeList << new AppNode(service);
2128- }
2129-
2130- } else if (p->isType(KST_KServiceGroup)) {
2131- const KServiceGroup::Ptr subGroup = KServiceGroup::Ptr::staticCast(p);
2132-
2133- if (!subGroup->noDisplay() && subGroup->childCount() > 0) {
2134- doLoadServiceGroup(subGroup);
2135- }
2136- }
2137- }
2138-}
2139-
2140-PathModel *InstalledAppsModel::pathModel() const
2141-{
2142- return m_pathModel;
2143-}
2144-
2145-QString InstalledAppsModel::name() const
2146-{
2147- if (m_pathModel->count() > 0) {
2148- QModelIndex index = m_pathModel->index(m_pathModel->count() - 1, 0);
2149- return index.data().toString();
2150- } else {
2151- return i18n("Applications");
2152- }
2153-}
2154-
2155-//- InstalledAppsSource ---------------------------------------------
2156-InstalledAppsSource::InstalledAppsSource(QObject *parent)
2157-: AbstractSource(parent)
2158-{}
2159-
2160-QAbstractItemModel *InstalledAppsSource::createModelFromConfigGroup(const KConfigGroup &group)
2161-{
2162- QString entryPath = group.readEntry("entryPath");
2163- return createModel(entryPath);
2164-}
2165-
2166-QAbstractItemModel *InstalledAppsSource::createModelFromArguments(const QVariantMap &arguments)
2167-{
2168- QString entryPath = arguments.value("entryPath").toString();
2169- return createModel(entryPath);
2170-}
2171-
2172-QAbstractItemModel *InstalledAppsSource::createModel(const QString &entryPath)
2173-{
2174- KConfigGroup group(config(), "PackageManagement");
2175- QString installer = group.readEntry("categoryInstaller");
2176-
2177- return new InstalledAppsModel(entryPath, installer);
2178-}
2179-
2180-bool InstalledAppsSource::isConfigurable() const
2181-{
2182- return true;
2183-}
2184-
2185-SourceConfigurationWidget *InstalledAppsSource::createConfigurationWidget(const KConfigGroup &group)
2186-{
2187- return new InstalledAppsConfigurationWidget(group);
2188-}
2189-
2190-} // namespace Homerun
2191-
2192-#include "installedappsmodel.moc"
2193
2194=== removed file 'components/installedappsmodel.h'
2195--- components/installedappsmodel.h 2012-11-14 21:30:06 +0000
2196+++ components/installedappsmodel.h 1970-01-01 00:00:00 +0000
2197@@ -1,159 +0,0 @@
2198-/*
2199-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
2200-
2201-This library is free software; you can redistribute it and/or
2202-modify it under the terms of the GNU Lesser General Public
2203-License as published by the Free Software Foundation; either
2204-version 2.1 of the License, or (at your option) version 3, or any
2205-later version accepted by the membership of KDE e.V. (or its
2206-successor approved by the membership of KDE e.V.), which shall
2207-act as a proxy defined in Section 6 of version 3 of the license.
2208-
2209-This library is distributed in the hope that it will be useful,
2210-but WITHOUT ANY WARRANTY; without even the implied warranty of
2211-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2212-Lesser General Public License for more details.
2213-
2214-You should have received a copy of the GNU Lesser General Public
2215-License along with this library. If not, see <http://www.gnu.org/licenses/>.
2216-*/
2217-#ifndef INSTALLEDAPPSMODEL_H
2218-#define INSTALLEDAPPSMODEL_H
2219-
2220-// Local
2221-#include <abstractsource.h>
2222-
2223-// Qt
2224-#include <QAbstractListModel>
2225-#include <QStringList>
2226-
2227-// KDE
2228-#include <KIcon>
2229-#include <KService>
2230-#include <KServiceGroup>
2231-#include <KUrl>
2232-
2233-namespace Homerun {
2234-
2235-class PathModel;
2236-
2237-class InstalledAppsModel;
2238-class InstalledAppsSource;
2239-
2240-class AbstractNode
2241-{
2242-public:
2243- virtual ~AbstractNode();
2244-
2245- virtual bool trigger() = 0;
2246- virtual QString favoriteId() const { return QString(); }
2247-
2248- QString icon() const { return m_icon; }
2249- QString name() const { return m_name; }
2250-
2251- static bool lessThan(AbstractNode *n1, AbstractNode *n2);
2252-
2253-protected:
2254- QString m_sortKey;
2255- QString m_icon;
2256- QString m_name;
2257-};
2258-
2259-class GroupNode : public AbstractNode
2260-{
2261-public:
2262- GroupNode(KServiceGroup::Ptr group, InstalledAppsModel *model);
2263-
2264- bool trigger(); // reimp
2265-
2266-private:
2267- InstalledAppsModel *m_model;
2268- QString m_entryPath;
2269-};
2270-
2271-class AppNode : public AbstractNode
2272-{
2273-public:
2274- AppNode(KService::Ptr service);
2275-
2276- bool trigger(); // reimp;
2277- QString favoriteId() const; // reimp
2278-
2279-private:
2280- KService::Ptr m_service;
2281-};
2282-
2283-class InstallerNode : public AbstractNode
2284-{
2285-public:
2286- InstallerNode(KServiceGroup::Ptr group, KService::Ptr installerService);
2287-
2288- bool trigger(); // reimp
2289-
2290-private:
2291- InstalledAppsModel *m_model;
2292- KServiceGroup::Ptr m_group;
2293- KService::Ptr m_service;
2294-};
2295-
2296-class InstalledAppsModel : public QAbstractListModel
2297-{
2298- Q_OBJECT
2299- Q_PROPERTY(int count READ count NOTIFY countChanged)
2300- Q_PROPERTY(QObject* pathModel READ pathModel CONSTANT)
2301- Q_PROPERTY(QString name READ name CONSTANT)
2302-
2303-public:
2304- enum Roles {
2305- FavoriteIdRole = Qt::UserRole + 1,
2306- };
2307-
2308- InstalledAppsModel(const QString &entryPath, const QString &installer, QObject *parent = 0);
2309- ~InstalledAppsModel();
2310-
2311- int rowCount(const QModelIndex&) const;
2312- int count() const;
2313- QVariant data(const QModelIndex&, int) const;
2314-
2315- PathModel *pathModel() const;
2316-
2317- Q_INVOKABLE bool trigger(int row);
2318-
2319- QString name() const;
2320-
2321-Q_SIGNALS:
2322- void countChanged();
2323- void openSourceRequested(const QString &sourceId, const QVariantMap &args);
2324-
2325-private:
2326- void loadRootEntries();
2327- void loadServiceGroup(KServiceGroup::Ptr group);
2328- void doLoadServiceGroup(KServiceGroup::Ptr group);
2329-
2330- PathModel *m_pathModel;
2331- QList<AbstractNode *> m_nodeList;
2332- QString m_installer;
2333- QString m_arguments;
2334-
2335- void load(const QString &entryPath);
2336-
2337- friend class GroupNode;
2338-};
2339-
2340-class InstalledAppsSource : public AbstractSource
2341-{
2342-public:
2343- InstalledAppsSource(QObject *parent);
2344- QAbstractItemModel *createModelFromConfigGroup(const KConfigGroup &group); // reimp
2345- QAbstractItemModel *createModelFromArguments(const QVariantMap &arguments); // reimp
2346-
2347- bool isConfigurable() const; // reimp
2348- SourceConfigurationWidget *createConfigurationWidget(const KConfigGroup &group); // reimp
2349-
2350-private:
2351- QAbstractItemModel *createModel(const QString &entryPath);
2352-};
2353-
2354-} // namespace Homerun
2355-
2356-#endif
2357
2358=== added file 'components/messagebox.cpp'
2359--- components/messagebox.cpp 1970-01-01 00:00:00 +0000
2360+++ components/messagebox.cpp 2013-03-01 15:15:27 +0000
2361@@ -0,0 +1,45 @@
2362+/*
2363+Copyright 2013 Aurélien Gâteau <agateau@kde.org>
2364+
2365+This program is free software; you can redistribute it and/or
2366+modify it under the terms of the GNU General Public License as
2367+published by the Free Software Foundation; either version 2 of
2368+the License or (at your option) version 3 or any later version
2369+accepted by the membership of KDE e.V. (or its successor approved
2370+by the membership of KDE e.V.), which shall act as a proxy
2371+defined in Section 14 of version 3 of the license.
2372+
2373+This program is distributed in the hope that it will be useful,
2374+but WITHOUT ANY WARRANTY; without even the implied warranty of
2375+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2376+GNU General Public License for more details.
2377+
2378+You should have received a copy of the GNU General Public License
2379+along with this program. If not, see <http://www.gnu.org/licenses/>.
2380+*/
2381+// Self
2382+#include <messagebox.h>
2383+
2384+// Local
2385+
2386+// KDE
2387+
2388+// Qt
2389+#include <QApplication>
2390+
2391+MessageBox::MessageBox(QObject *parent)
2392+: QObject(parent)
2393+{
2394+}
2395+
2396+int MessageBox::warningContinueCancel(const QString& text, const QString& caption, const QString& continueText, const QString& cancelText)
2397+{
2398+ KGuiItem cont = continueText.isEmpty() ? KStandardGuiItem::cont() : KGuiItem(continueText);
2399+ KGuiItem cancel = cancelText.isEmpty() ? KStandardGuiItem::cancel() : KGuiItem(cancelText);
2400+ int ret = KMessageBox::warningContinueCancel(QApplication::activeWindow(),
2401+ text, caption, cont, cancel);
2402+
2403+ return ret;
2404+}
2405+
2406+#include <messagebox.moc>
2407
2408=== added file 'components/messagebox.h'
2409--- components/messagebox.h 1970-01-01 00:00:00 +0000
2410+++ components/messagebox.h 2013-03-01 15:15:27 +0000
2411@@ -0,0 +1,60 @@
2412+/*
2413+Copyright 2013 Aurélien Gâteau <agateau@kde.org>
2414+
2415+This program is free software; you can redistribute it and/or
2416+modify it under the terms of the GNU General Public License as
2417+published by the Free Software Foundation; either version 2 of
2418+the License or (at your option) version 3 or any later version
2419+accepted by the membership of KDE e.V. (or its successor approved
2420+by the membership of KDE e.V.), which shall act as a proxy
2421+defined in Section 14 of version 3 of the license.
2422+
2423+This program is distributed in the hope that it will be useful,
2424+but WITHOUT ANY WARRANTY; without even the implied warranty of
2425+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2426+GNU General Public License for more details.
2427+
2428+You should have received a copy of the GNU General Public License
2429+along with this program. If not, see <http://www.gnu.org/licenses/>.
2430+*/
2431+#ifndef MESSAGEBOX_H
2432+#define MESSAGEBOX_H
2433+
2434+// Local
2435+
2436+// Qt
2437+#include <QObject>
2438+
2439+// KDE
2440+#include <KMessageBox>
2441+
2442+/**
2443+ * Wrapper around KMessageBox
2444+ */
2445+class MessageBox : public QObject
2446+{
2447+ Q_OBJECT
2448+ Q_ENUMS(ButtonCode)
2449+public:
2450+ explicit MessageBox(QObject *parent = 0);
2451+
2452+ enum ButtonCode {
2453+ Ok = KMessageBox::Ok,
2454+ Cancel = KMessageBox::Cancel,
2455+ Yes = KMessageBox::Yes,
2456+ No = KMessageBox::No,
2457+ Continue = KMessageBox::Continue,
2458+ };
2459+
2460+ /**
2461+ * Return value is a MessageBox::ButtonCode
2462+ */
2463+ Q_INVOKABLE int warningContinueCancel(
2464+ const QString &text,
2465+ const QString &caption = QString(),
2466+ const QString &continueText = QString(),
2467+ const QString &cancelText = QString()
2468+ );
2469+};
2470+
2471+#endif /* MESSAGEBOX_H */
2472
2473=== removed file 'components/powermodel.cpp'
2474--- components/powermodel.cpp 2012-12-18 19:55:12 +0000
2475+++ components/powermodel.cpp 1970-01-01 00:00:00 +0000
2476@@ -1,143 +0,0 @@
2477-/*
2478- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
2479- Copyright (C) 2012 Shaun Reich <shaun.reich@blue-systems.com>
2480-
2481- This library is free software; you can redistribute it and/or
2482- modify it under the terms of the GNU Library General Public
2483- License as published by the Free Software Foundation; either
2484- version 2 of the License, or (at your option) any later version.
2485-
2486- This library is distributed in the hope that it will be useful,
2487- but WITHOUT ANY WARRANTY; without even the implied warranty of
2488- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2489- Library General Public License for more details.
2490-
2491- You should have received a copy of the GNU Library General Public License
2492- along with this library; see the file COPYING.LIB. If not, write to
2493- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2494- Boston, MA 02110-1301, USA.
2495-*/
2496-
2497-// Own
2498-#include "powermodel.h"
2499-
2500-//Qt
2501-#include <QDBusMessage>
2502-#include <QDBusConnection>
2503-#include <QDBusPendingCall>
2504-
2505-// KDE
2506-#include <KDebug>
2507-#include <KIcon>
2508-#include <KLocale>
2509-#include <KRun>
2510-#include <KService>
2511-#include <kworkspace/kworkspace.h>
2512-
2513-//Plasma
2514-#include <Plasma/AbstractRunner>
2515-#include <Plasma/RunnerManager>
2516-
2517-namespace Homerun {
2518-
2519-PowerModel::PowerModel(QObject *parent)
2520-: QAbstractListModel(parent)
2521-{
2522- PowerAction suspend;
2523- suspend.name = i18nc("an action", "Suspend");
2524- suspend.type = Suspend;
2525- suspend.iconName = "system-suspend";
2526- m_powerList.append(suspend);
2527-
2528- PowerAction hibernate;
2529- hibernate.name = i18nc("an action", "Hibernate");
2530- hibernate.type = Hibernate;
2531- hibernate.iconName = "system-suspend-hibernate";
2532- m_powerList.append(hibernate);
2533-
2534- PowerAction restart;
2535- restart.name = i18nc("an action", "Restart");
2536- restart.type = Restart;
2537- restart.iconName = "system-reboot";
2538- m_powerList.append(restart);
2539-
2540- PowerAction shutdown;
2541- shutdown.name = i18nc("an action", "Shutdown");
2542- shutdown.type = Shutdown;
2543- shutdown.iconName = "system-shutdown";
2544- m_powerList.append(shutdown);
2545-}
2546-
2547-PowerModel::~PowerModel()
2548-{
2549-}
2550-
2551-int PowerModel::count() const
2552-{
2553- return m_powerList.count();
2554-}
2555-
2556-QString PowerModel::name() const
2557-{
2558- return i18n("Power");
2559-}
2560-
2561-int PowerModel::rowCount(const QModelIndex &index) const
2562-{
2563- if (index.isValid()) {
2564- return 0;
2565- }
2566- return m_powerList.count();
2567-}
2568-
2569-QVariant PowerModel::data(const QModelIndex &index, int role) const
2570-{
2571- PowerAction action = m_powerList.value(index.row());
2572-
2573- if (role == Qt::DisplayRole) {
2574- return action.name;
2575- } else if (role == Qt::DecorationRole) {
2576- return KIcon(action.iconName);
2577- } else {
2578- kWarning() << "Unhandled role" << role;
2579- return QVariant();
2580- }
2581-}
2582-
2583-bool PowerModel::trigger(int row)
2584-{
2585- PowerAction action = m_powerList.value(row);
2586-
2587- switch (action.type) {
2588- case Shutdown:
2589- KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt);
2590- break;
2591-
2592- case Restart:
2593- KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot);
2594- break;
2595-
2596- case Suspend:
2597- suspend("suspendToRam");
2598- break;
2599-
2600- case Hibernate:
2601- suspend("suspendToDisk");
2602- break;
2603- }
2604-
2605- return true;
2606-}
2607-
2608-void PowerModel::suspend(const QString& type)
2609-{
2610- QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.Solid.PowerManagement",
2611- "/org/kde/Solid/PowerManagement",
2612- "org.kde.Solid.PowerManagement",
2613- type);
2614- QDBusConnection::sessionBus().asyncCall(msg);
2615-}
2616-
2617-} // namespace Homerun
2618-
2619-#include "powermodel.moc"
2620
2621=== removed file 'components/powermodel.h'
2622--- components/powermodel.h 2012-11-14 21:30:06 +0000
2623+++ components/powermodel.h 1970-01-01 00:00:00 +0000
2624@@ -1,75 +0,0 @@
2625-/*
2626- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
2627- Copyright 2012 (C) Shaun Reich <shaun.reich@blue-systems.com>
2628-
2629- This library is free software; you can redistribute it and/or
2630- modify it under the terms of the GNU Library General Public
2631- License as published by the Free Software Foundation; either
2632- version 2 of the License, or (at your option) any later version.
2633-
2634- This library is distributed in the hope that it will be useful,
2635- but WITHOUT ANY WARRANTY; without even the implied warranty of
2636- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2637- Library General Public License for more details.
2638-
2639- You should have received a copy of the GNU Library General Public License
2640- along with this library; see the file COPYING.LIB. If not, write to
2641- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2642- Boston, MA 02110-1301, USA.
2643-*/
2644-
2645-#ifndef POWERMODEL_H
2646-#define POWERMODEL_H
2647-
2648-#include <QAbstractListModel>
2649-
2650-#include <KService>
2651-
2652-class QString;
2653-
2654-namespace Homerun {
2655-
2656-enum PowerType {
2657- Shutdown,
2658- Restart,
2659- Hibernate,
2660- Suspend
2661-};
2662-
2663-struct PowerAction
2664-{
2665- QString name;
2666- QString iconName;
2667- PowerType type;
2668-};
2669-
2670-class PowerModel : public QAbstractListModel
2671-{
2672- Q_OBJECT
2673- Q_PROPERTY(QString name READ name CONSTANT)
2674- Q_PROPERTY(int count READ count NOTIFY countChanged)
2675-
2676-public:
2677- PowerModel(QObject *parent = 0);
2678- ~PowerModel();
2679-
2680- int count() const;
2681- QString name() const;
2682-
2683- int rowCount(const QModelIndex & = QModelIndex()) const;
2684- QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const;
2685-
2686- Q_INVOKABLE bool trigger(int row);
2687-
2688- void suspend(const QString& type);
2689-
2690-Q_SIGNALS:
2691- void countChanged();
2692-
2693-private:
2694- QList<PowerAction> m_powerList;
2695-};
2696-
2697-} // namespace Homerun
2698-
2699-#endif
2700
2701=== added file 'components/qml/Label.qml'
2702--- components/qml/Label.qml 1970-01-01 00:00:00 +0000
2703+++ components/qml/Label.qml 2013-03-01 15:15:27 +0000
2704@@ -0,0 +1,68 @@
2705+/*
2706+Copyright 2013 Aurélien Gâteau <agateau@kde.org>
2707+
2708+This program is free software; you can redistribute it and/or
2709+modify it under the terms of the GNU General Public License as
2710+published by the Free Software Foundation; either version 2 of
2711+the License or (at your option) version 3 or any later version
2712+accepted by the membership of KDE e.V. (or its successor approved
2713+by the membership of KDE e.V.), which shall act as a proxy
2714+defined in Section 14 of version 3 of the license.
2715+
2716+This program is distributed in the hope that it will be useful,
2717+but WITHOUT ANY WARRANTY; without even the implied warranty of
2718+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2719+GNU General Public License for more details.
2720+
2721+You should have received a copy of the GNU General Public License
2722+along with this program. If not, see <http://www.gnu.org/licenses/>.
2723+*/
2724+import QtQuick 1.1
2725+import org.kde.homerun.components 0.1 as HomerunComponents
2726+import org.kde.plasma.components 0.1 as PlasmaComponents
2727+
2728+/**
2729+ * A label which uses Plasma colors by default, but appears differently when
2730+ * run as a containment: it shows a shadow behind itself and both shadow and
2731+ * text colors can be customized.
2732+ */
2733+PlasmaComponents.Label {
2734+ id: main
2735+
2736+ Component {
2737+ id: shadowComponent
2738+ HomerunComponents.ShadowEffect {
2739+ xOffset: 0
2740+ yOffset: 1
2741+ blurRadius: 2
2742+ }
2743+ }
2744+
2745+ Component.onCompleted: {
2746+ var isContainment = "plasmoid" in this;
2747+ if (isContainment) {
2748+ readConfig();
2749+ plasmoid.addEventListener("ConfigChanged", readConfig);
2750+ } else {
2751+ main.color = theme.textColor;
2752+ }
2753+ }
2754+
2755+ function readConfig() {
2756+ main.color = plasmoid.readConfig("textColor");
2757+ if (plasmoid.readConfig("shadowModeNone") == true) {
2758+ if (main.effect) {
2759+ main.effect.destroy();
2760+ }
2761+ return;
2762+ }
2763+ if (!main.effect) {
2764+ main.effect = shadowComponent.createObject(main);
2765+ }
2766+ if (plasmoid.readConfig("shadowModeCustom") == true) {
2767+ main.effect.color = plasmoid.readConfig("shadowColor");
2768+ } else {
2769+ main.effect.resetColor();
2770+ }
2771+ }
2772+}
2773
2774=== modified file 'components/qml/TabButton.qml'
2775--- components/qml/TabButton.qml 2012-11-14 21:30:06 +0000
2776+++ components/qml/TabButton.qml 2013-03-01 15:15:27 +0000
2777@@ -81,7 +81,7 @@
2778 **/
2779
2780 import QtQuick 1.1
2781-import org.kde.plasma.components 0.1
2782+import org.kde.plasma.components 0.1 as PlasmaComponents
2783 import "private" as Private
2784
2785 Item {
2786@@ -127,6 +127,15 @@
2787 }
2788 }
2789
2790+ /*
2791+ HACK: We use a HomerunComponents.Label for the normal text and
2792+ a PlasmaComponents.Label for the current text.
2793+
2794+ This is necessary for containment mode:
2795+ It makes it possible to have custom color + shadow for normal text (to
2796+ ensure it remains readable) and buttonTextColor + no-shadow for button text
2797+ (because it is drawn on top of a button frame)
2798+ */
2799 Label {
2800 id: label
2801
2802@@ -144,7 +153,24 @@
2803 horizontalAlignment: Text.AlignLeft
2804 verticalAlignment: Text.AlignVCenter
2805
2806- color: root.ListView.isCurrentItem ? theme.buttonTextColor : theme.textColor
2807+ color: theme.textColor
2808+ opacity: root.ListView.isCurrentItem ? 0 : 1
2809+ Behavior on opacity { NumberAnimation { duration: 250 }}
2810+ }
2811+
2812+ PlasmaComponents.Label {
2813+ id: currentLabel
2814+ text: label.text
2815+
2816+ anchors.fill: label
2817+
2818+ elide: label.elide
2819+ horizontalAlignment: label.horizontalAlignment
2820+ verticalAlignment: label.verticalAlignment
2821+
2822+ color: theme.buttonTextColor
2823+ opacity: root.ListView.isCurrentItem ? 1 : 0
2824+ Behavior on opacity { NumberAnimation { duration: 250 }}
2825 }
2826
2827 MouseArea {
2828
2829=== modified file 'components/qml/qmldir'
2830--- components/qml/qmldir 2012-11-14 21:30:06 +0000
2831+++ components/qml/qmldir 2013-03-01 15:15:27 +0000
2832@@ -3,3 +3,4 @@
2833 TabBar 0.1 TabBar.qml
2834 TabButton 0.1 TabButton.qml
2835 TabGroup 0.1 TabGroup.qml
2836+Label 0.1 Label.qml
2837
2838=== removed file 'components/runnerconfigurationwidget.cpp'
2839--- components/runnerconfigurationwidget.cpp 2012-11-14 21:30:06 +0000
2840+++ components/runnerconfigurationwidget.cpp 1970-01-01 00:00:00 +0000
2841@@ -1,105 +0,0 @@
2842-/*
2843-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
2844-
2845-This library is free software; you can redistribute it and/or
2846-modify it under the terms of the GNU Lesser General Public
2847-License as published by the Free Software Foundation; either
2848-version 2.1 of the License, or (at your option) version 3, or any
2849-later version accepted by the membership of KDE e.V. (or its
2850-successor approved by the membership of KDE e.V.), which shall
2851-act as a proxy defined in Section 6 of version 3 of the license.
2852-
2853-This library is distributed in the hope that it will be useful,
2854-but WITHOUT ANY WARRANTY; without even the implied warranty of
2855-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2856-Lesser General Public License for more details.
2857-
2858-You should have received a copy of the GNU Lesser General Public
2859-License along with this library. If not, see <http://www.gnu.org/licenses/>.
2860-*/
2861-// Self
2862-#include <runnerconfigurationwidget.h>
2863-
2864-// Local
2865-
2866-// KDE
2867-#include <KDebug>
2868-#include <KPluginInfo>
2869-#include <Plasma/RunnerManager>
2870-
2871-// Qt
2872-#include <QListWidgetItem>
2873-
2874-Q_DECLARE_METATYPE(KPluginInfo)
2875-
2876-static const char *WHITELIST_KEY = "whitelist";
2877-
2878-namespace Homerun
2879-{
2880-
2881-static QListWidgetItem *createWidgetItem(const KPluginInfo &info)
2882-{
2883- QListWidgetItem *item = new QListWidgetItem(info.name());
2884- item->setIcon(KIcon(info.icon()));
2885- item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
2886- item->setData(Qt::UserRole, QVariant::fromValue(info));
2887- return item;
2888-}
2889-
2890-RunnerConfigurationWidget::RunnerConfigurationWidget(const KConfigGroup &group)
2891-: SourceConfigurationWidget(group)
2892-{
2893- setupUi(this);
2894- m_searchLine->setListWidget(m_listWidget);
2895-
2896- // A runner is enabled if there is either a whitelist and it is part of it
2897- // or if there is no whitelist and its EnabledByDefault key is true
2898-
2899- QStringList whiteList = group.readEntry(WHITELIST_KEY, QStringList());
2900- bool hasWhiteList = !whiteList.isEmpty();
2901-
2902- KPluginInfo::List list = Plasma::RunnerManager::listRunnerInfo();
2903- Q_FOREACH(const KPluginInfo &info, list) {
2904- QListWidgetItem *item = createWidgetItem(info);
2905- bool selected;
2906- if (hasWhiteList) {
2907- selected = whiteList.contains(info.pluginName());
2908- } else {
2909- selected = info.isPluginEnabledByDefault();
2910- }
2911- item->setCheckState(selected ? Qt::Checked : Qt::Unchecked);
2912- m_listWidget->addItem(item);
2913- }
2914- m_listWidget->sortItems();
2915-}
2916-
2917-void RunnerConfigurationWidget::save()
2918-{
2919- QStringList whiteList;
2920- bool hasChanges = false;
2921-
2922- // Only write a whiteList if the selected runner list is not the same as
2923- // the list of all EnabledByDefault runners
2924-
2925- for (int idx = 0; idx < m_listWidget->count(); ++idx) {
2926- QListWidgetItem *item = m_listWidget->item(idx);
2927- KPluginInfo info = item->data(Qt::UserRole).value<KPluginInfo>();
2928-
2929- bool selected = item->checkState() == Qt::Checked;
2930- if (selected != info.isPluginEnabledByDefault()) {
2931- hasChanges = true;
2932- }
2933- if (selected) {
2934- whiteList << info.pluginName();
2935- }
2936- }
2937- if (hasChanges) {
2938- configGroup().writeEntry(WHITELIST_KEY, whiteList);
2939- } else {
2940- configGroup().deleteEntry(WHITELIST_KEY);
2941- }
2942-}
2943-
2944-} // namespace Homerun
2945-
2946-#include <runnerconfigurationwidget.moc>
2947
2948=== removed file 'components/runnerconfigurationwidget.h'
2949--- components/runnerconfigurationwidget.h 2012-11-14 21:30:06 +0000
2950+++ components/runnerconfigurationwidget.h 1970-01-01 00:00:00 +0000
2951@@ -1,48 +0,0 @@
2952-/*
2953-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
2954-
2955-This library is free software; you can redistribute it and/or
2956-modify it under the terms of the GNU Lesser General Public
2957-License as published by the Free Software Foundation; either
2958-version 2.1 of the License, or (at your option) version 3, or any
2959-later version accepted by the membership of KDE e.V. (or its
2960-successor approved by the membership of KDE e.V.), which shall
2961-act as a proxy defined in Section 6 of version 3 of the license.
2962-
2963-This library is distributed in the hope that it will be useful,
2964-but WITHOUT ANY WARRANTY; without even the implied warranty of
2965-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2966-Lesser General Public License for more details.
2967-
2968-You should have received a copy of the GNU Lesser General Public
2969-License along with this library. If not, see <http://www.gnu.org/licenses/>.
2970-*/
2971-#ifndef RUNNERCONFIGURATIONWIDGET_H
2972-#define RUNNERCONFIGURATIONWIDGET_H
2973-
2974-// Local
2975-#include <sourceconfigurationwidget.h>
2976-#include <ui_runnerconfigurationwidget.h>
2977-
2978-// Qt
2979-
2980-// KDE
2981-
2982-namespace Homerun
2983-{
2984-
2985-/**
2986- * A configuration widget for the Runner source
2987- */
2988-class RunnerConfigurationWidget : public SourceConfigurationWidget, private Ui_RunnerConfigurationWidget
2989-{
2990- Q_OBJECT
2991-public:
2992- explicit RunnerConfigurationWidget(const KConfigGroup &);
2993-
2994- void save(); // reimp
2995-};
2996-
2997-} // namespace
2998-
2999-#endif /* RUNNERCONFIGURATIONWIDGET_H */
3000
3001=== removed file 'components/runnerconfigurationwidget.ui'
3002--- components/runnerconfigurationwidget.ui 2012-11-14 21:30:06 +0000
3003+++ components/runnerconfigurationwidget.ui 1970-01-01 00:00:00 +0000
3004@@ -1,48 +0,0 @@
3005-<?xml version="1.0" encoding="UTF-8"?>
3006-<ui version="4.0">
3007- <class>RunnerConfigurationWidget</class>
3008- <widget class="QWidget" name="RunnerConfigurationWidget">
3009- <property name="geometry">
3010- <rect>
3011- <x>0</x>
3012- <y>0</y>
3013- <width>400</width>
3014- <height>300</height>
3015- </rect>
3016- </property>
3017- <layout class="QVBoxLayout" name="verticalLayout">
3018- <item>
3019- <widget class="QLabel" name="label">
3020- <property name="text">
3021- <string>Pick the runners you would like to use in this source:</string>
3022- </property>
3023- </widget>
3024- </item>
3025- <item>
3026- <widget class="KListWidgetSearchLine" name="m_searchLine"/>
3027- </item>
3028- <item>
3029- <widget class="KListWidget" name="m_listWidget"/>
3030- </item>
3031- </layout>
3032- </widget>
3033- <customwidgets>
3034- <customwidget>
3035- <class>KListWidgetSearchLine</class>
3036- <extends>KLineEdit</extends>
3037- <header>klistwidgetsearchline.h</header>
3038- </customwidget>
3039- <customwidget>
3040- <class>KLineEdit</class>
3041- <extends>QLineEdit</extends>
3042- <header>klineedit.h</header>
3043- </customwidget>
3044- <customwidget>
3045- <class>KListWidget</class>
3046- <extends>QListWidget</extends>
3047- <header>klistwidget.h</header>
3048- </customwidget>
3049- </customwidgets>
3050- <resources/>
3051- <connections/>
3052-</ui>
3053
3054=== removed file 'components/runnermodel.cpp'
3055--- components/runnermodel.cpp 2012-11-14 21:30:06 +0000
3056+++ components/runnermodel.cpp 1970-01-01 00:00:00 +0000
3057@@ -1,408 +0,0 @@
3058-/*
3059-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
3060-
3061-Based on RunnerModel class. RunnerModel class copyright:
3062-
3063-Copyright 2011 Aaron Seigo <aseigo@kde.org>
3064-
3065-This library is free software; you can redistribute it and/or
3066-modify it under the terms of the GNU Library General Public
3067-License as published by the Free Software Foundation; either
3068-version 2 of the License, or (at your option) any later version.
3069-
3070-This library is distributed in the hope that it will be useful,
3071-but WITHOUT ANY WARRANTY; without even the implied warranty of
3072-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3073-Library General Public License for more details.
3074-
3075-You should have received a copy of the GNU Library General Public License
3076-along with this library; see the file COPYING.LIB. If not, write to
3077-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3078-Boston, MA 02110-1301, USA.
3079-*/
3080-// Self
3081-#include <runnermodel.h>
3082-
3083-// Local
3084-#include <runnerconfigurationwidget.h>
3085-
3086-// KDE
3087-#include <KDebug>
3088-#include <KPluginInfo>
3089-#include <Plasma/AbstractRunner>
3090-#include <Plasma/RunnerManager>
3091-
3092-// Qt
3093-#include <QStandardItemModel>
3094-#include <QTimer>
3095-
3096-static const char *WHITELIST_KEY = "whitelist";
3097-
3098-namespace Homerun {
3099-
3100-RunnerSubModel::RunnerSubModel(const QString &runnerId, const QString &name, QObject *parent)
3101-: QAbstractListModel(parent)
3102-, m_runnerId(runnerId)
3103-, m_name(name)
3104-{
3105- QHash<int, QByteArray> roles;
3106- roles.insert(Qt::DisplayRole, "display");
3107- roles.insert(Qt::DecorationRole, "decoration");
3108- roles.insert(FavoriteIdRole, "favoriteId");
3109- /*
3110- roles.insert(Type, "type");
3111- roles.insert(Relevance, "relevance");
3112- roles.insert(Data, "data");
3113- roles.insert(Id, "id");
3114- roles.insert(SubText, "description");
3115- roles.insert(Enabled, "enabled");
3116- roles.insert(RunnerId, "runnerid");
3117- roles.insert(RunnerName, "runnerName");
3118- roles.insert(Actions, "actions");
3119- */
3120- setRoleNames(roles);
3121-}
3122-
3123-int RunnerSubModel::count() const
3124-{
3125- return m_matches.count();
3126-}
3127-
3128-int RunnerSubModel::rowCount(const QModelIndex& parent) const
3129-{
3130- return parent.isValid() ? 0 : m_matches.count();
3131-}
3132-
3133-QVariant RunnerSubModel::data(const QModelIndex &index, int role) const
3134-{
3135- if (!index.isValid() || index.parent().isValid() ||
3136- index.column() > 0 || index.row() < 0 || index.row() >= m_matches.count()) {
3137- // index requested must be valid, but we have no child items!
3138- //kDebug() << "invalid index requested";
3139- return QVariant();
3140- }
3141-
3142- const Plasma::QueryMatch &match = m_matches.at(index.row());
3143- if (role == Qt::DisplayRole) {
3144- return match.text();
3145- } else if (role == Qt::DecorationRole) {
3146- return match.icon();
3147- } else if (role == FavoriteIdRole) {
3148- QString runnerId = match.runner()->id();
3149- if (runnerId == "services") {
3150- return QVariant("app:" + match.data().toString());
3151- } else if (runnerId == "locations") {
3152- KUrl url(match.data().toString());
3153- return QVariant("place:" + url.url());
3154- } else {
3155- return QString();
3156- }
3157- } /*else if (role == Type) {
3158- return m_matches.at(index.row()).type();
3159- } else if (role == Relevance) {
3160- return m_matches.at(index.row()).relevance();
3161- } else if (role == Data) {
3162- return m_matches.at(index.row()).data();
3163- } else if (role == Id) {
3164- return m_matches.at(index.row()).id();
3165- } else if (role == SubText) {
3166- return m_matches.at(index.row()).subtext();
3167- } else if (role == Enabled) {
3168- return m_matches.at(index.row()).isEnabled();
3169- } else if (role == RunnerId) {
3170- return m_matches.at(index.row()).runner()->id();
3171- } else if (role == RunnerName) {
3172- return m_matches.at(index.row()).runner()->name();
3173- } else if (role == Actions) {
3174- QVariantList actions;
3175- Plasma::QueryMatch amatch = m_matches.at(index.row());
3176- QList<QAction*> theactions = m_manager->actionsForMatch(amatch);
3177- foreach(QAction* action, theactions) {
3178- actions += qVariantFromValue<QObject*>(action);
3179- }
3180- return actions;
3181- }*/
3182-
3183- return QVariant();
3184-}
3185-
3186-void RunnerSubModel::setMatches(const QList<Plasma::QueryMatch> &matches)
3187-{
3188- bool fullReset = false;
3189- int oldCount = m_matches.count();
3190- int newCount = matches.count();
3191- if (newCount > oldCount) {
3192- // We received more matches than we had. If all common matches are the
3193- // same, we can just append new matches instead of resetting the whole
3194- // model
3195- for (int row = 0; row < oldCount; ++row) {
3196- if (!(m_matches.at(row) == matches.at(row))) {
3197- fullReset = true;
3198- break;
3199- }
3200- }
3201- if (!fullReset) {
3202- // Not a full reset, inserting rows
3203- beginInsertRows(QModelIndex(), oldCount, newCount);
3204- m_matches = matches;
3205- endInsertRows();
3206- emit countChanged();
3207- }
3208- } else {
3209- fullReset = true;
3210- }
3211-
3212- if (fullReset) {
3213- beginResetModel();
3214- m_matches = matches;
3215- endResetModel();
3216- emit countChanged();
3217- }
3218-}
3219-
3220-bool RunnerSubModel::trigger(int row)
3221-{
3222- if (row >= 0 && row < m_matches.count()) {
3223- triggerRequested(m_matches.at(row));
3224- }
3225- return true;
3226-}
3227-
3228-//--------------------------------------------------------------------
3229-
3230-RunnerModel::RunnerModel(QObject *parent)
3231-: QAbstractListModel(parent)
3232-, m_manager(0)
3233-, m_startQueryTimer(new QTimer(this))
3234-, m_runningChangedTimeout(new QTimer(this))
3235-, m_running(false)
3236-{
3237- m_startQueryTimer->setSingleShot(true);
3238- m_startQueryTimer->setInterval(10);
3239- connect(m_startQueryTimer, SIGNAL(timeout()), this, SLOT(startQuery()));
3240-
3241- //FIXME: HACK: some runners stay in a running but finished state, not possible to say if it's actually over
3242- m_runningChangedTimeout->setSingleShot(true);
3243- connect(m_runningChangedTimeout, SIGNAL(timeout()), this, SLOT(queryHasFinished()));
3244-}
3245-
3246-RunnerModel::~RunnerModel()
3247-{
3248-}
3249-
3250-int RunnerModel::rowCount(const QModelIndex &parent) const
3251-{
3252- if (parent.isValid()) {
3253- return 0;
3254- }
3255- return m_models.count();
3256-}
3257-
3258-QVariant RunnerModel::data(const QModelIndex &index, int role) const
3259-{
3260- if (index.parent().isValid()) {
3261- return QVariant();
3262- }
3263-
3264- RunnerSubModel *model = m_models.value(index.row());
3265- if (!model) {
3266- return QVariant();
3267- }
3268-
3269- if (role == Qt::DisplayRole) {
3270- return model->name();
3271- } else {
3272- return QVariant();
3273- }
3274-}
3275-
3276-bool RunnerModel::running() const
3277-{
3278- return m_running;
3279-}
3280-
3281-QObject *RunnerModel::modelForRow(int row) const
3282-{
3283- if (row < 0 || row >= m_models.count()) {
3284- kWarning() << "No model for row" << row << "!";
3285- return 0;
3286- }
3287- return m_models.value(row);
3288-}
3289-
3290-void RunnerModel::setAllowedRunners(const QStringList &list)
3291-{
3292- QStringList existingList = m_manager ? m_manager->allowedRunners() : m_pendingRunnersList;
3293-
3294- if (existingList.toSet() == list.toSet()) {
3295- return;
3296- }
3297- m_pendingRunnersList = list;
3298- if (m_manager) {
3299- loadRunners();
3300- }
3301-}
3302-
3303-QString RunnerModel::currentQuery() const
3304-{
3305- return m_manager ? m_manager->query() : QString();
3306-}
3307-
3308-void RunnerModel::scheduleQuery(const QString &query)
3309-{
3310- m_pendingQuery = query;
3311- m_startQueryTimer->start();
3312-}
3313-
3314-void RunnerModel::startQuery()
3315-{
3316- if (m_pendingQuery.isEmpty()) {
3317- clear();
3318- }
3319-
3320- if (!m_manager && m_pendingQuery.isEmpty()) {
3321- // avoid creating a manager just so we can run nothing
3322- return;
3323- }
3324-
3325- createManager();
3326- /* DEBUG
3327- kWarning() << "Start query" << m_pendingQuery << "on runners:";
3328- Q_FOREACH(Plasma::AbstractRunner *runner, m_manager->runners()) {
3329- kWarning() << "-" << runner->name();
3330- }
3331- */
3332- m_manager->launchQuery(m_pendingQuery);
3333- emit queryChanged();
3334- m_running = true;
3335- emit runningChanged(true);
3336-}
3337-
3338-void RunnerModel::createManager()
3339-{
3340- if (!m_manager) {
3341- m_manager = new Plasma::RunnerManager(this);
3342- connect(m_manager, SIGNAL(matchesChanged(QList<Plasma::QueryMatch>)),
3343- this, SLOT(matchesChanged(QList<Plasma::QueryMatch>)));
3344- connect(m_manager, SIGNAL(queryFinished()),
3345- this, SLOT(queryHasFinished()));
3346-
3347- if (!m_pendingRunnersList.isEmpty()) {
3348- loadRunners();
3349- }
3350- //connect(m_manager, SIGNAL(queryFinished()), this, SLOT(queryFinished()));
3351- }
3352-}
3353-
3354-void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
3355-{
3356- // Group matches by runner
3357- // We do not use a QMultiHash here because it keeps values in LIFO order, while we want FIFO.
3358- QHash<QString, QList<Plasma::QueryMatch> > matchesForRunner;
3359- Q_FOREACH(const Plasma::QueryMatch &match, matches) {
3360- QString runnerId = match.runner()->id();
3361- auto it = matchesForRunner.find(runnerId);
3362- if (it == matchesForRunner.end()) {
3363- it = matchesForRunner.insert(runnerId, QList<Plasma::QueryMatch>());
3364- }
3365- it.value().append(match);
3366- }
3367-
3368- // Assign matches to existing models. If there is no match for a model, delete it.
3369- for (int row = m_models.count() - 1; row >= 0; --row) {
3370- RunnerSubModel *subModel = m_models.at(row);
3371- QList<Plasma::QueryMatch> matches = matchesForRunner.take(subModel->runnerId());
3372- if (matches.isEmpty()) {
3373- beginRemoveRows(QModelIndex(), row, row);
3374- m_models.removeAt(row);
3375- delete subModel;
3376- endRemoveRows();
3377- } else {
3378- subModel->setMatches(matches);
3379- }
3380- }
3381-
3382- // At this point, matchesForRunner contains only matches for runners which
3383- // do not have a model yet. Create new models for them.
3384- if (!matchesForRunner.isEmpty()) {
3385- beginInsertRows(QModelIndex(), rowCount(), rowCount() + matchesForRunner.size() - 1);
3386- auto it = matchesForRunner.constBegin();
3387- auto end = matchesForRunner.constEnd();
3388- for (; it != end; ++it) {
3389- QList<Plasma::QueryMatch> matches = it.value();
3390- Q_ASSERT(!matches.isEmpty());
3391- QString name = matches.first().runner()->name();
3392- RunnerSubModel *subModel = new RunnerSubModel(it.key(), name, this);
3393- connect(subModel, SIGNAL(triggerRequested(Plasma::QueryMatch)), SLOT(trigger(Plasma::QueryMatch)));
3394- subModel->setMatches(matches);
3395- m_models.append(subModel);
3396- }
3397- endInsertRows();
3398- }
3399-
3400- m_runningChangedTimeout->start(3000);
3401-}
3402-
3403-void RunnerModel::queryHasFinished()
3404-{
3405- m_running = false;
3406- emit runningChanged(false);
3407-}
3408-
3409-void RunnerModel::clear()
3410-{
3411- if (m_models.isEmpty()) {
3412- return;
3413- }
3414- beginResetModel();
3415- qDeleteAll(m_models);
3416- m_models.clear();
3417- endResetModel();
3418-}
3419-
3420-void RunnerModel::trigger(const Plasma::QueryMatch& match)
3421-{
3422- m_manager->run(match);
3423-}
3424-
3425-void RunnerModel::loadRunners()
3426-{
3427- Q_ASSERT(m_manager);
3428- if (m_pendingRunnersList.count() > 0) {
3429- KPluginInfo::List list = Plasma::RunnerManager::listRunnerInfo();
3430- Q_FOREACH(const KPluginInfo &info, list) {
3431- if (m_pendingRunnersList.contains(info.pluginName())) {
3432- m_manager->loadRunner(info.service());
3433- }
3434- }
3435- }
3436- m_manager->setSingleMode(m_pendingRunnersList.count() == 1);
3437- m_pendingRunnersList.clear();
3438-}
3439-
3440-//- RunnerSource ------------------------------
3441-RunnerSource::RunnerSource(QObject *parent)
3442-: AbstractSource(parent)
3443-{}
3444-
3445-QAbstractItemModel *RunnerSource::createModelFromConfigGroup(const KConfigGroup &group)
3446-{
3447- RunnerModel *model = new RunnerModel;
3448- QStringList lst = group.readEntry(WHITELIST_KEY, QStringList());
3449- model->setAllowedRunners(lst);
3450- return model;
3451-};
3452-
3453-bool RunnerSource::isConfigurable() const
3454-{
3455- return true;
3456-}
3457-
3458-SourceConfigurationWidget *RunnerSource::createConfigurationWidget(const KConfigGroup &group)
3459-{
3460- return new RunnerConfigurationWidget(group);
3461-}
3462-
3463-} // namespace Homerun
3464-
3465-#include <runnermodel.moc>
3466
3467=== removed file 'components/runnermodel.h'
3468--- components/runnermodel.h 2012-11-14 21:30:06 +0000
3469+++ components/runnermodel.h 1970-01-01 00:00:00 +0000
3470@@ -1,150 +0,0 @@
3471-/*
3472-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
3473-
3474-Based on RunnerModel class. RunnerModel class copyright:
3475-
3476-Copyright 2011 Aaron Seigo <aseigo@kde.org>
3477-
3478-This library is free software; you can redistribute it and/or
3479-modify it under the terms of the GNU Library General Public
3480-License as published by the Free Software Foundation; either
3481-version 2 of the License, or (at your option) any later version.
3482-
3483-This library is distributed in the hope that it will be useful,
3484-but WITHOUT ANY WARRANTY; without even the implied warranty of
3485-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3486-Library General Public License for more details.
3487-
3488-You should have received a copy of the GNU Library General Public License
3489-along with this library; see the file COPYING.LIB. If not, write to
3490-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3491-Boston, MA 02110-1301, USA.
3492-*/
3493-#ifndef RUNNERMODEL_H
3494-#define RUNNERMODEL_H
3495-
3496-// Local
3497-#include <abstractsource.h>
3498-
3499-// Qt
3500-#include <QAbstractListModel>
3501-#include <QStringList>
3502-
3503-// KDE
3504-#include <KConfig>
3505-#include <KConfigGroup>
3506-#include <Plasma/QueryMatch>
3507-
3508-class QTimer;
3509-
3510-namespace Plasma {
3511-class RunnerManager;
3512-}
3513-
3514-namespace Homerun {
3515-
3516-class RunnerSubModel : public QAbstractListModel
3517-{
3518- Q_OBJECT
3519- Q_PROPERTY(QString name READ name CONSTANT)
3520- Q_PROPERTY(int count READ count NOTIFY countChanged)
3521-public:
3522- explicit RunnerSubModel(const QString &runnerId, const QString &name, QObject *parent = 0);
3523-
3524- enum {
3525- FavoriteIdRole = Qt::UserRole + 1
3526- };
3527-
3528- QString runnerId() const { return m_runnerId; }
3529- QString name() const { return m_name; }
3530-
3531- void setMatches(const QList<Plasma::QueryMatch> &matches);
3532-
3533- int count() const;
3534-
3535- int rowCount(const QModelIndex &parent = QModelIndex()) const;
3536-
3537- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
3538-
3539- Q_INVOKABLE bool trigger(int row);
3540-
3541-Q_SIGNALS:
3542- void countChanged();
3543-
3544- void triggerRequested(const Plasma::QueryMatch&);
3545-
3546-private:
3547- QString m_runnerId;
3548- QString m_name;
3549-
3550- QList<Plasma::QueryMatch> m_matches;
3551-};
3552-
3553-/**
3554- *
3555- */
3556-class RunnerModel : public QAbstractListModel
3557-{
3558- Q_OBJECT
3559- /**
3560- * @property string set the KRunner query
3561- */
3562- Q_PROPERTY(QString query WRITE scheduleQuery READ currentQuery NOTIFY queryChanged)
3563-
3564- Q_PROPERTY(bool running READ running NOTIFY runningChanged)
3565-
3566-public:
3567- explicit RunnerModel(QObject *parent = 0);
3568- ~RunnerModel();
3569-
3570- Q_INVOKABLE QObject *modelForRow(int row) const;
3571-
3572- void setAllowedRunners(const QStringList &runners);
3573-
3574- int rowCount(const QModelIndex &parent = QModelIndex()) const; // reimp
3575- QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const; // reimp
3576-
3577- bool running() const;
3578-
3579- QString currentQuery() const;
3580-
3581-public Q_SLOTS:
3582- void scheduleQuery(const QString &query);
3583-
3584-Q_SIGNALS:
3585- void queryChanged();
3586- void runningChanged(bool);
3587-
3588-private Q_SLOTS:
3589- void startQuery();
3590- void queryHasFinished();
3591- void matchesChanged(const QList<Plasma::QueryMatch> &matches);
3592- void trigger(const Plasma::QueryMatch&);
3593-
3594-private:
3595- void createManager();
3596- void loadRunners();
3597- void clear();
3598-
3599- Plasma::RunnerManager *m_manager;
3600- QTimer *m_startQueryTimer;
3601- QTimer *m_runningChangedTimeout;
3602-
3603- QList<RunnerSubModel *> m_models;
3604- QStringList m_pendingRunnersList;
3605- bool m_running;
3606- QString m_pendingQuery;
3607-};
3608-
3609-class RunnerSource : public AbstractSource
3610-{
3611-public:
3612- RunnerSource(QObject *parent);
3613- QAbstractItemModel *createModelFromConfigGroup(const KConfigGroup &group);
3614- SourceConfigurationWidget *createConfigurationWidget(const KConfigGroup &group);
3615- bool isConfigurable() const;
3616-};
3617-
3618-} // namespace Homerun
3619-
3620-#endif /* RUNNERMODEL_H */
3621
3622=== removed file 'components/sessionmodel.cpp'
3623--- components/sessionmodel.cpp 2012-11-14 21:30:06 +0000
3624+++ components/sessionmodel.cpp 1970-01-01 00:00:00 +0000
3625@@ -1,137 +0,0 @@
3626-/*
3627- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
3628- Copyright (C) 2012 Shaun Reich <shaun.reich@blue-systems.com>
3629-
3630- This library is free software; you can redistribute it and/or
3631- modify it under the terms of the GNU Library General Public
3632- License as published by the Free Software Foundation; either
3633- version 2 of the License, or (at your option) any later version.
3634-
3635- This library is distributed in the hope that it will be useful,
3636- but WITHOUT ANY WARRANTY; without even the implied warranty of
3637- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3638- Library General Public License for more details.
3639-
3640- You should have received a copy of the GNU Library General Public License
3641- along with this library; see the file COPYING.LIB. If not, write to
3642- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3643- Boston, MA 02110-1301, USA.
3644-*/
3645-
3646-// Own
3647-#include "sessionmodel.h"
3648-
3649-//Qt
3650-#include <QDBusConnection>
3651-#include <QDBusInterface>
3652-#include <QDBusPendingCall>
3653-
3654-// KDE
3655-#include <KAuthorized>
3656-#include <KDebug>
3657-#include <KIcon>
3658-#include <KLocale>
3659-#include <kworkspace/kdisplaymanager.h>
3660-#include <kworkspace/kworkspace.h>
3661-
3662-namespace Homerun {
3663-
3664-SessionModel::SessionModel(QObject *parent)
3665-: QAbstractListModel(parent)
3666-{
3667- //FIXME: instead of just hiding these things..it'd be awesome if we could grey them out and/or provide a reason why they're not there.
3668- //otherwise the user is hunting for the power buttons and for some reason it isn't where it should be.
3669- if (KAuthorized::authorizeKAction("lock_screen")) {
3670- SessionAction lock;
3671- lock.name = i18nc("an action", "Lock");
3672- lock.type = Lock;
3673- lock.iconName = "system-lock-screen";
3674- m_sessionList.append(lock);
3675- }
3676-
3677- if (KDisplayManager().isSwitchable() && KAuthorized::authorize(QLatin1String("switch_user"))) {
3678- SessionAction switchUser;
3679- switchUser.name = i18nc("an action", "Switch User");
3680- switchUser.type = SwitchUser;
3681- switchUser.iconName = "system-switch-user";
3682- m_sessionList.append(switchUser);
3683- }
3684-
3685- const bool canLogout = KAuthorized::authorizeKAction("logout") && KAuthorized::authorize("logout");
3686- if (canLogout) {
3687- SessionAction logout;
3688- logout.name = i18nc("an action", "Logout");
3689- logout.type = Logout;
3690- logout.iconName = "system-log-out";
3691- m_sessionList.append(logout);
3692- }
3693-}
3694-
3695-SessionModel::~SessionModel()
3696-{
3697-}
3698-
3699-int SessionModel::count() const
3700-{
3701- return m_sessionList.count();
3702-}
3703-
3704-QString SessionModel::name() const
3705-{
3706- return i18n("Session");
3707-}
3708-
3709-int SessionModel::rowCount(const QModelIndex &index) const
3710-{
3711- if (index.isValid()) {
3712- return 0;
3713- }
3714- return m_sessionList.count();
3715-}
3716-
3717-QVariant SessionModel::data(const QModelIndex &index, int role) const
3718-{
3719- SessionAction action = m_sessionList.value(index.row());
3720-
3721- if (role == Qt::DisplayRole) {
3722- return action.name;
3723- } else if (role == Qt::DecorationRole) {
3724- return KIcon(action.iconName);
3725- } else {
3726- kWarning() << "Unhandled role" << role;
3727- return QVariant();
3728- }
3729-}
3730-
3731-bool SessionModel::trigger(int row)
3732-{
3733- SessionAction action = m_sessionList.value(row);
3734-
3735- switch (action.type) {
3736- case Logout:
3737- KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeNone);
3738- break;
3739-
3740- case SwitchUser: {
3741- QDBusConnection bus = QDBusConnection::sessionBus();
3742- QDBusInterface interface("org.kde.krunner", "/App", "org.kde.krunner", bus);
3743-
3744- interface.asyncCall("switchUser");
3745- }
3746- break;
3747-
3748- case Lock: {
3749- QDBusConnection bus = QDBusConnection::sessionBus();
3750- QDBusInterface interface("org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", bus);
3751-
3752- interface.asyncCall("Lock");
3753- }
3754- break;
3755- }
3756-
3757- return true;
3758-}
3759-
3760-} // namespace Homerun
3761-
3762-#include "sessionmodel.moc"
3763
3764=== removed file 'components/sessionmodel.h'
3765--- components/sessionmodel.h 2012-11-14 21:30:06 +0000
3766+++ components/sessionmodel.h 1970-01-01 00:00:00 +0000
3767@@ -1,72 +0,0 @@
3768-/*
3769- Copyright 2012 Aurélien Gâteau <agateau@kde.org>
3770- Copyright 2012 (C) Shaun Reich <shaun.reich@blue-systems.com>
3771-
3772- This library is free software; you can redistribute it and/or
3773- modify it under the terms of the GNU Library General Public
3774- License as published by the Free Software Foundation; either
3775- version 2 of the License, or (at your option) any later version.
3776-
3777- This library is distributed in the hope that it will be useful,
3778- but WITHOUT ANY WARRANTY; without even the implied warranty of
3779- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3780- Library General Public License for more details.
3781-
3782- You should have received a copy of the GNU Library General Public License
3783- along with this library; see the file COPYING.LIB. If not, write to
3784- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
3785- Boston, MA 02110-1301, USA.
3786-*/
3787-
3788-#ifndef SESSIONMODEL_H
3789-#define SESSIONMODEL_H
3790-
3791-#include <QAbstractListModel>
3792-
3793-#include <KService>
3794-
3795-class QString;
3796-
3797-namespace Homerun {
3798-
3799-enum ActionType {
3800- Logout,
3801- SwitchUser,
3802- Lock
3803-};
3804-
3805-struct SessionAction
3806-{
3807- QString name;
3808- QString iconName;
3809- ActionType type;
3810-};
3811-
3812-class SessionModel : public QAbstractListModel
3813-{
3814- Q_OBJECT
3815- Q_PROPERTY(QString name READ name CONSTANT)
3816- Q_PROPERTY(int count READ count NOTIFY countChanged)
3817-
3818-public:
3819- SessionModel(QObject *parent = 0);
3820- ~SessionModel();
3821-
3822- int count() const;
3823- QString name() const;
3824-
3825- int rowCount(const QModelIndex & = QModelIndex()) const;
3826- QVariant data(const QModelIndex &, int role = Qt::DisplayRole) const;
3827-
3828- Q_INVOKABLE bool trigger(int row);
3829-
3830-Q_SIGNALS:
3831- void countChanged();
3832-
3833-private:
3834- QList<SessionAction> m_sessionList;
3835-};
3836-
3837-} // namespace Homerun
3838-
3839-#endif
3840
3841=== added file 'components/shadoweffect.cpp'
3842--- components/shadoweffect.cpp 1970-01-01 00:00:00 +0000
3843+++ components/shadoweffect.cpp 2013-03-01 15:15:27 +0000
3844@@ -0,0 +1,222 @@
3845+/*
3846+ * Copyright 2013 Aurélien Gâteau <agateau@kde.org>
3847+ *
3848+ * This program is free software; you can redistribute it and/or modify
3849+ * it under the terms of the GNU Library General Public License as
3850+ * published by the Free Software Foundation; either version 2, or
3851+ * (at your option) any later version.
3852+ *
3853+ * This program is distributed in the hope that it will be useful,
3854+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3855+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3856+ * GNU Library General Public License for more details
3857+ *
3858+ * You should have received a copy of the GNU Library General Public
3859+ * License along with this program; if not, write to the
3860+ * Free Software Foundation, Inc.,
3861+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3862+ */
3863+// Self
3864+#include <shadoweffect.h>
3865+
3866+// Local
3867+
3868+// KDE
3869+#include <KDebug>
3870+#include <Plasma/PaintUtils>
3871+
3872+// Qt
3873+#include <QPainter>
3874+#include <QPaintEngine>
3875+
3876+ShadowEffect::ShadowEffect(QObject *parent)
3877+: QGraphicsEffect(parent)
3878+, m_xOffset(0)
3879+, m_yOffset(1)
3880+, m_blurRadius(3)
3881+{
3882+}
3883+
3884+ShadowEffect::~ShadowEffect()
3885+{
3886+}
3887+
3888+qreal ShadowEffect::xOffset() const
3889+{
3890+ return m_xOffset;
3891+}
3892+
3893+qreal ShadowEffect::yOffset() const
3894+{
3895+ return m_yOffset;
3896+}
3897+
3898+qreal ShadowEffect::blurRadius() const
3899+{
3900+ return m_blurRadius;
3901+}
3902+
3903+QColor ShadowEffect::color() const
3904+{
3905+ return m_color;
3906+}
3907+
3908+#define SETTER(prop) \
3909+ if (prop == value) { \
3910+ return; \
3911+ } \
3912+ prop = value;
3913+
3914+#define SETTER_REAL(prop) \
3915+ if (qFuzzyCompare(prop, value)) { \
3916+ return; \
3917+ } \
3918+ prop = value;
3919+
3920+void ShadowEffect::setXOffset(qreal value)
3921+{
3922+ SETTER_REAL(m_xOffset);
3923+ m_shadow = QImage();
3924+ updateBoundingRect();
3925+ xOffsetChanged(m_xOffset);
3926+}
3927+
3928+void ShadowEffect::setYOffset(qreal value)
3929+{
3930+ SETTER_REAL(m_yOffset);
3931+ m_shadow = QImage();
3932+ updateBoundingRect();
3933+ yOffsetChanged(m_yOffset);
3934+}
3935+
3936+void ShadowEffect::setBlurRadius(qreal value)
3937+{
3938+ SETTER_REAL(m_blurRadius);
3939+ m_shadow = QImage();
3940+ updateBoundingRect();
3941+ blurRadiusChanged(m_blurRadius);
3942+}
3943+
3944+void ShadowEffect::setColor(const QColor &value)
3945+{
3946+ SETTER(m_color);
3947+ m_shadow = QImage();
3948+ update();
3949+ colorChanged(m_color);
3950+}
3951+
3952+void ShadowEffect::resetColor()
3953+{
3954+ setColor(QColor());
3955+}
3956+
3957+QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const
3958+{
3959+ qreal padding = m_blurRadius * 2;
3960+ return rect.united(
3961+ rect.translated(m_xOffset, m_yOffset)
3962+ .adjusted(-padding, -padding, padding, padding)
3963+ );
3964+}
3965+
3966+QImage ShadowEffect::generateShadow(const QPixmap &px) const
3967+{
3968+ if (px.isNull()) {
3969+ return QImage();
3970+ }
3971+
3972+ // Generate shadow in tmp
3973+ QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied);
3974+ tmp.fill(0);
3975+ QPainter tmpPainter(&tmp);
3976+ tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
3977+ tmpPainter.drawPixmap(m_xOffset, m_yOffset, px);
3978+ tmpPainter.end();
3979+ QColor color = m_color.isValid() ? m_color : computeColorFromSource();
3980+ Plasma::PaintUtils::shadowBlur(tmp, m_blurRadius, color);
3981+ return tmp;
3982+}
3983+
3984+void ShadowEffect::draw(QPainter *painter)
3985+{
3986+ if (m_blurRadius <= 0 && qFuzzyIsNull(m_xOffset) && qFuzzyIsNull(m_yOffset)) {
3987+ drawSource(painter);
3988+ return;
3989+ }
3990+
3991+ PixmapPadMode mode = PadToEffectiveBoundingRect;
3992+ if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) {
3993+ mode = NoPad;
3994+ }
3995+
3996+ // Draw pixmap in device coordinates to avoid pixmap scaling.
3997+ QPoint offset;
3998+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
3999+ if (pixmap.isNull()) {
4000+ return;
4001+ }
4002+
4003+ QTransform restoreTransform = painter->worldTransform();
4004+ painter->setWorldTransform(QTransform());
4005+ if (m_shadow.isNull()) {
4006+ m_shadow = generateShadow(pixmap);
4007+ }
4008+ // Draw shadow (draw it twice to darken it)
4009+ painter->drawImage(offset, m_shadow);
4010+ painter->drawImage(offset, m_shadow);
4011+ // Draw the actual pixmap
4012+ painter->drawPixmap(offset, pixmap);
4013+ painter->setWorldTransform(restoreTransform);
4014+}
4015+
4016+void ShadowEffect::sourceChanged(ChangeFlags flags)
4017+{
4018+ switch (flags) {
4019+ case SourceAttached:
4020+ case SourceBoundingRectChanged:
4021+ case SourceInvalidated:
4022+ m_shadow = QImage();
4023+ break;
4024+ case SourceDetached:
4025+ break;
4026+ }
4027+}
4028+
4029+
4030+/**********************************************************
4031+ * UGLYNESS
4032+ * This is a severely trimmed copy of an internal class defined in qt:
4033+ * src/gui/effects/qgraphicseffect_p.h
4034+ *********************************************************/
4035+class QGraphicsEffectSource
4036+{
4037+public:
4038+ const QGraphicsItem *graphicsItem() const;
4039+};
4040+/**********************************************************
4041+ * /UGLYNESS
4042+ *********************************************************/
4043+
4044+
4045+QColor ShadowEffect::computeColorFromSource() const
4046+{
4047+ const QGraphicsItem *item = source()->graphicsItem();
4048+ if (!item) {
4049+ kWarning() << "No source item!";
4050+ return Qt::black;
4051+ }
4052+ const QGraphicsObject *obj = item->toGraphicsObject();
4053+ if (!obj) {
4054+ kWarning() << "Source is not a QGraphicsObject";
4055+ return Qt::black;
4056+ }
4057+ QVariant variant = obj->property("color");
4058+ if (!variant.canConvert<QColor>()) {
4059+ kWarning() << "Source has no 'color' property, or its 'color' property is not a QColor!";
4060+ return Qt::black;
4061+ }
4062+ int value = variant.value<QColor>().value();
4063+ return value > 128 ? Qt::black : Qt::white;
4064+}
4065+
4066+#include <shadoweffect.moc>
4067
4068=== added file 'components/shadoweffect.h'
4069--- components/shadoweffect.h 1970-01-01 00:00:00 +0000
4070+++ components/shadoweffect.h 2013-03-01 15:15:27 +0000
4071@@ -0,0 +1,87 @@
4072+/*
4073+ * Copyright 2013 Aurélien Gâteau <agateau@kde.org>
4074+ *
4075+ * This program is free software; you can redistribute it and/or modify
4076+ * it under the terms of the GNU Library General Public License as
4077+ * published by the Free Software Foundation; either version 2, or
4078+ * (at your option) any later version.
4079+ *
4080+ * This program is distributed in the hope that it will be useful,
4081+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4082+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4083+ * GNU Library General Public License for more details
4084+ *
4085+ * You should have received a copy of the GNU Library General Public
4086+ * License along with this program; if not, write to the
4087+ * Free Software Foundation, Inc.,
4088+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
4089+ */
4090+#ifndef SHADOWEFFECT_H
4091+#define SHADOWEFFECT_H
4092+
4093+// Local
4094+
4095+// Qt
4096+#include <QGraphicsEffect>
4097+
4098+// KDE
4099+
4100+/**
4101+ * An effect which draws a halo
4102+ */
4103+class ShadowEffect : public QGraphicsEffect
4104+{
4105+ Q_OBJECT
4106+ Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY xOffsetChanged)
4107+ Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY yOffsetChanged)
4108+ Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
4109+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
4110+public:
4111+ explicit ShadowEffect(QObject *parent = 0);
4112+ ~ShadowEffect();
4113+
4114+ QRectF boundingRectFor(const QRectF &rect) const; // reimp
4115+
4116+ qreal xOffset() const;
4117+
4118+ qreal yOffset() const;
4119+
4120+ qreal blurRadius() const;
4121+ QColor color() const;
4122+
4123+ /**
4124+ * Use this method if you set the color manually and now want ShadowEffect
4125+ * to pick the color automatically, based on the source object.
4126+ */
4127+ Q_INVOKABLE void resetColor();
4128+
4129+public Q_SLOTS:
4130+ void setXOffset(qreal dx);
4131+ void setYOffset(qreal dy);
4132+ void setBlurRadius(qreal blurRadius);
4133+ void setColor(const QColor &color);
4134+
4135+Q_SIGNALS:
4136+ void xOffsetChanged(qreal);
4137+ void yOffsetChanged(qreal);
4138+ void blurRadiusChanged(qreal blurRadius);
4139+ void colorChanged(const QColor &color);
4140+
4141+protected:
4142+ void draw(QPainter *painter); // reimp
4143+ void sourceChanged(ChangeFlags flags); // reimp
4144+
4145+private:
4146+ qreal m_xOffset;
4147+ qreal m_yOffset;
4148+ qreal m_blurRadius;
4149+ QColor m_color;
4150+
4151+ QImage m_shadow;
4152+
4153+ QImage generateShadow(const QPixmap &px) const;
4154+
4155+ QColor computeColorFromSource() const;
4156+};
4157+
4158+#endif /* SHADOWEFFECT_H */
4159
4160=== removed file 'components/sourceid.cpp'
4161--- components/sourceid.cpp 2012-11-14 21:30:06 +0000
4162+++ components/sourceid.cpp 1970-01-01 00:00:00 +0000
4163@@ -1,163 +0,0 @@
4164-/*
4165-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4166-
4167-This library is free software; you can redistribute it and/or
4168-modify it under the terms of the GNU Lesser General Public
4169-License as published by the Free Software Foundation; either
4170-version 2.1 of the License, or (at your option) version 3, or any
4171-later version accepted by the membership of KDE e.V. (or its
4172-successor approved by the membership of KDE e.V.), which shall
4173-act as a proxy defined in Section 6 of version 3 of the license.
4174-
4175-This library is distributed in the hope that it will be useful,
4176-but WITHOUT ANY WARRANTY; without even the implied warranty of
4177-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4178-Lesser General Public License for more details.
4179-
4180-You should have received a copy of the GNU Lesser General Public
4181-License along with this library. If not, see <http://www.gnu.org/licenses/>.
4182-*/
4183-// Self
4184-#include <sourceid.h>
4185-
4186-// Local
4187-
4188-// KDE
4189-#include <KDebug>
4190-
4191-// Qt
4192-#include <QStringList>
4193-
4194-static const char SOURCE_NAME_SEPARATOR = ':';
4195-
4196-#define ARG_SEPARATOR ';'
4197-#define ARG_SEPARATOR_STR ";"
4198-static const char ARG_KEY_VALUE_SEPARATOR = '=';
4199-
4200-//- SourceId ----------------------------------
4201-QString SourceId::name() const
4202-{
4203- return m_name;
4204-}
4205-
4206-void SourceId::setName(const QString &name)
4207-{
4208- m_name = name;
4209-}
4210-
4211-SourceArguments &SourceId::arguments()
4212-{
4213- return m_arguments;
4214-}
4215-
4216-const SourceArguments &SourceId::arguments() const
4217-{
4218- return m_arguments;
4219-}
4220-
4221-QString SourceId::toString() const
4222-{
4223- if (m_arguments.isEmpty()) {
4224- return m_name;
4225- }
4226- return m_name % SOURCE_NAME_SEPARATOR % m_arguments.toString();
4227-}
4228-
4229-SourceId SourceId::fromString(const QString &sourceString, bool *ok)
4230-{
4231- *ok = true;
4232- SourceId sourceId;
4233-
4234- int idx = sourceString.indexOf(SOURCE_NAME_SEPARATOR);
4235- if (idx == -1) {
4236- sourceId.setName(sourceString);
4237- return sourceId;
4238- }
4239-
4240- sourceId.m_name = sourceString.left(idx);
4241- QString args = sourceString.mid(idx + 1);
4242-
4243- sourceId.m_arguments = SourceArguments::fromString(args, ok);
4244- if (!*ok) {
4245- return SourceId();
4246- }
4247- return sourceId;
4248-}
4249-
4250-bool SourceId::isValid() const
4251-{
4252- return !m_name.isEmpty();
4253-}
4254-
4255-//- SourceArguments ---------------------------
4256-static QString escapeValue(const QString &src)
4257-{
4258- QString dst = src;
4259- dst.replace('\\', "\\\\"); // must be done first
4260- dst.replace(ARG_SEPARATOR, "\\" ARG_SEPARATOR_STR);
4261- return dst;
4262-}
4263-
4264-static QStringList split(const QString &src)
4265-{
4266- bool escaped = false;
4267- QStringList lst;
4268- QString token;
4269- auto it = src.constBegin(), end = src.constEnd();
4270- for (; it != end; ++it) {
4271- const QChar ch = *it;
4272- if (escaped) {
4273- escaped = false;
4274- } else if (ch == '\\') {
4275- escaped = true;
4276- continue;
4277- } else if (ch == ARG_SEPARATOR) {
4278- lst.append(token);
4279- token.clear();
4280- continue;
4281- }
4282- token.append(ch);
4283- }
4284- lst.append(token);
4285- return lst;
4286-}
4287-
4288-SourceArguments SourceArguments::fromString(const QString &str, bool *ok)
4289-{
4290- Q_ASSERT(ok);
4291- *ok = true;
4292- SourceArguments args;
4293- if (str.isEmpty()) {
4294- return args;
4295- }
4296-
4297- QStringList tokens = split(str);
4298- Q_FOREACH(const QString &token, tokens) {
4299- int idx = token.indexOf(ARG_KEY_VALUE_SEPARATOR);
4300- if (idx == -1) {
4301- kWarning() << "Invalid argument" << token << "in" << str;
4302- *ok = false;
4303- return SourceArguments();
4304- }
4305- QString key = token.left(idx);
4306- QString value = token.mid(idx + 1);
4307- args.insert(key, value);
4308- }
4309- return args;
4310-}
4311-
4312-SourceArguments &SourceArguments::add(const QString &key, const QString &value)
4313-{
4314- insert(key, value);
4315- return *this;
4316-}
4317-
4318-QString SourceArguments::toString() const
4319-{
4320- QStringList lst;
4321- auto it = constBegin(), end = constEnd();
4322- for (; it != end ; ++it) {
4323- lst << it.key() % ARG_KEY_VALUE_SEPARATOR % escapeValue(it.value());
4324- }
4325- return lst.join(ARG_SEPARATOR_STR);
4326-}
4327
4328=== removed file 'components/sourceid.h'
4329--- components/sourceid.h 2012-11-14 21:30:06 +0000
4330+++ components/sourceid.h 1970-01-01 00:00:00 +0000
4331@@ -1,66 +0,0 @@
4332-/*
4333-Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4334-
4335-This library is free software; you can redistribute it and/or
4336-modify it under the terms of the GNU Lesser General Public
4337-License as published by the Free Software Foundation; either
4338-version 2.1 of the License, or (at your option) version 3, or any
4339-later version accepted by the membership of KDE e.V. (or its
4340-successor approved by the membership of KDE e.V.), which shall
4341-act as a proxy defined in Section 6 of version 3 of the license.
4342-
4343-This library is distributed in the hope that it will be useful,
4344-but WITHOUT ANY WARRANTY; without even the implied warranty of
4345-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4346-Lesser General Public License for more details.
4347-
4348-You should have received a copy of the GNU Lesser General Public
4349-License along with this library. If not, see <http://www.gnu.org/licenses/>.
4350-*/
4351-#ifndef SOURCEID_H
4352-#define SOURCEID_H
4353-
4354-// Local
4355-
4356-// Qt
4357-#include <QHash>
4358-#include <QString>
4359-
4360-// KDE
4361-
4362-/**
4363- * The arguments of a source. Used within a SourceId instance.
4364- */
4365-class SourceArguments : public QHash<QString, QString>
4366-{
4367-public:
4368- SourceArguments &add(const QString &key, const QString &value);
4369-
4370- QString toString() const;
4371-
4372- static SourceArguments fromString(const QString &, bool *ok);
4373-};
4374-
4375-/**
4376- * Represents a source and its optional arguments
4377- */
4378-class SourceId
4379-{
4380-public:
4381- void setName(const QString &);
4382- QString name() const;
4383- SourceArguments &arguments();
4384- const SourceArguments &arguments() const;
4385-
4386- QString toString() const;
4387-
4388- static SourceId fromString(const QString &, bool *ok);
4389-
4390- bool isValid() const;
4391-
4392-private:
4393- QString m_name;
4394- SourceArguments m_arguments;
4395-};
4396-
4397-#endif /* SOURCEID_H */
4398
4399=== modified file 'components/sourceregistry.cpp'
4400--- components/sourceregistry.cpp 2012-11-14 21:30:06 +0000
4401+++ components/sourceregistry.cpp 2013-03-01 15:15:27 +0000
4402@@ -23,18 +23,20 @@
4403 // Local
4404 #include <abstractsource.h>
4405 #include <customtypes.h>
4406-#include <dirmodel.h>
4407-#include <favoriteappsmodel.h>
4408-
4409-#include <groupedinstalledappsmodel.h>
4410 #include <libhomerun_config.h>
4411-#include <favoriteplacesmodel.h>
4412-#include <powermodel.h>
4413-#include <runnermodel.h>
4414-#include <installedappsmodel.h>
4415-#include <sessionmodel.h>
4416 #include <sourceconfigurationdialog.h>
4417
4418+#include <sources/dir/dirmodel.h>
4419+#include <sources/favorites/favoriteappsmodel.h>
4420+#include <sources/favorites/favoriteplacesmodel.h>
4421+#include <sources/installedapps/installedappsmodel.h>
4422+#include <sources/installedapps/groupedinstalledappsmodel.h>
4423+#include <sources/power/powermodel.h>
4424+#include <sources/runners/singlerunnermodel.h>
4425+#include <sources/runners/runnermodel.h>
4426+#include <sources/session/openedsessionsmodel.h>
4427+#include <sources/session/sessionmodel.h>
4428+
4429 // KDE
4430 #include <KConfigGroup>
4431 #include <KDebug>
4432@@ -42,6 +44,7 @@
4433 #include <KPluginInfo>
4434 #include <KPluginLoader>
4435 #include <KServiceTypeTrader>
4436+#include <Plasma/PluginLoader>
4437
4438 // Qt
4439 #include <QApplication>
4440@@ -218,6 +221,20 @@
4441 }
4442 return sourceInfo->source;
4443 }
4444+
4445+ void registerSingleRunnerSources()
4446+ {
4447+ KPluginInfo::List list = Plasma::PluginLoader::pluginLoader()->listRunnerInfo();
4448+ Q_FOREACH(const KPluginInfo &info, list) {
4449+ if (!info.property("X-Plasma-AdvertiseSingleRunnerQueryMode").toBool()) {
4450+ continue;
4451+ }
4452+ QString runnerId = info.pluginName();
4453+ SingleRunnerSource *source = new SingleRunnerSource(runnerId, q);
4454+ QString name = i18n("Runner: %1", info.name());
4455+ registerSource("SingleRunner/" + runnerId, source, name, info.comment());
4456+ }
4457+ }
4458 };
4459
4460 //- SourceRegistry --------------------------------------------
4461@@ -259,11 +276,17 @@
4462 i18n("Session"),
4463 i18n("Provide buttons to lock the screen, log out, or switch to another user")
4464 );
4465+ d->registerSource("OpenedSessions", new SimpleSource<OpenedSessionsModel>(this),
4466+ i18n("Opened Sessions"),
4467+ i18n("Provide buttons to switch to opened sessions")
4468+ );
4469 d->registerSource("Runner", new RunnerSource(this),
4470 i18n("KRunner"),
4471 i18n("Perform searchs using a selection of runners")
4472 );
4473
4474+ d->registerSingleRunnerSources();
4475+
4476 d->listSourcePlugins();
4477 }
4478
4479
4480=== added directory 'components/sources'
4481=== added directory 'components/sources/dir'
4482=== added file 'components/sources/dir/dirconfigurationwidget.cpp'
4483--- components/sources/dir/dirconfigurationwidget.cpp 1970-01-01 00:00:00 +0000
4484+++ components/sources/dir/dirconfigurationwidget.cpp 2013-03-01 15:15:27 +0000
4485@@ -0,0 +1,67 @@
4486+/*
4487+Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4488+
4489+This library is free software; you can redistribute it and/or
4490+modify it under the terms of the GNU Lesser General Public
4491+License as published by the Free Software Foundation; either
4492+version 2.1 of the License, or (at your option) version 3, or any
4493+later version accepted by the membership of KDE e.V. (or its
4494+successor approved by the membership of KDE e.V.), which shall
4495+act as a proxy defined in Section 6 of version 3 of the license.
4496+
4497+This library is distributed in the hope that it will be useful,
4498+but WITHOUT ANY WARRANTY; without even the implied warranty of
4499+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4500+Lesser General Public License for more details.
4501+
4502+You should have received a copy of the GNU Lesser General Public
4503+License along with this library. If not, see <http://www.gnu.org/licenses/>.
4504+*/
4505+// Self
4506+#include <dirconfigurationwidget.h>
4507+
4508+// Local
4509+#include <ui_dirconfigurationwidget.h>
4510+
4511+// KDE
4512+#include <KGlobalSettings>
4513+#include <KUrlRequester>
4514+
4515+// Qt
4516+#include <QDir>
4517+#include <QVBoxLayout>
4518+
4519+using namespace Homerun;
4520+
4521+DirConfigurationWidget::DirConfigurationWidget(const KConfigGroup &group)
4522+: SourceConfigurationWidget(group)
4523+, m_ui(new Ui_DirConfigurationWidget)
4524+{
4525+ m_ui->setupUi(this);
4526+
4527+ QFont helpFont = KGlobalSettings::smallestReadableFont();
4528+ m_ui->titleHelpLabel->setFont(helpFont);
4529+
4530+ KUrl url = group.readPathEntry("rootUrl", QDir::homePath());
4531+ if (url.isValid()) {
4532+ m_ui->urlRequester->setUrl(url);
4533+ }
4534+
4535+ m_ui->titleLineEdit->setText(group.readEntry("rootName", QString()));
4536+}
4537+
4538+DirConfigurationWidget::~DirConfigurationWidget()
4539+{
4540+ delete m_ui;
4541+}
4542+
4543+void DirConfigurationWidget::save()
4544+{
4545+ KUrl url = m_ui->urlRequester->url().url();
4546+ QString title = m_ui->titleLineEdit->text();
4547+
4548+ configGroup().writePathEntry("rootUrl", url.url());
4549+ configGroup().writeEntry("rootName", title);
4550+}
4551+
4552+#include <dirconfigurationwidget.moc>
4553
4554=== added file 'components/sources/dir/dirconfigurationwidget.h'
4555--- components/sources/dir/dirconfigurationwidget.h 1970-01-01 00:00:00 +0000
4556+++ components/sources/dir/dirconfigurationwidget.h 2013-03-01 15:15:27 +0000
4557@@ -0,0 +1,48 @@
4558+/*
4559+Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4560+
4561+This library is free software; you can redistribute it and/or
4562+modify it under the terms of the GNU Lesser General Public
4563+License as published by the Free Software Foundation; either
4564+version 2.1 of the License, or (at your option) version 3, or any
4565+later version accepted by the membership of KDE e.V. (or its
4566+successor approved by the membership of KDE e.V.), which shall
4567+act as a proxy defined in Section 6 of version 3 of the license.
4568+
4569+This library is distributed in the hope that it will be useful,
4570+but WITHOUT ANY WARRANTY; without even the implied warranty of
4571+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4572+Lesser General Public License for more details.
4573+
4574+You should have received a copy of the GNU Lesser General Public
4575+License along with this library. If not, see <http://www.gnu.org/licenses/>.
4576+*/
4577+#ifndef DIRCONFIGURATIONWIDGET_H
4578+#define DIRCONFIGURATIONWIDGET_H
4579+
4580+// Local
4581+#include <sourceconfigurationwidget.h>
4582+
4583+// Qt
4584+
4585+// KDE
4586+
4587+class Ui_DirConfigurationWidget;
4588+
4589+/**
4590+ * Configuration widget for the Dir source
4591+ */
4592+class DirConfigurationWidget : public Homerun::SourceConfigurationWidget
4593+{
4594+ Q_OBJECT
4595+public:
4596+ DirConfigurationWidget(const KConfigGroup &group);
4597+ ~DirConfigurationWidget();
4598+
4599+ void save(); // reimp
4600+
4601+private:
4602+ Ui_DirConfigurationWidget *m_ui;
4603+};
4604+
4605+#endif /* DIRCONFIGURATIONWIDGET_H */
4606
4607=== added file 'components/sources/dir/dirconfigurationwidget.ui'
4608--- components/sources/dir/dirconfigurationwidget.ui 1970-01-01 00:00:00 +0000
4609+++ components/sources/dir/dirconfigurationwidget.ui 2013-03-01 15:15:27 +0000
4610@@ -0,0 +1,83 @@
4611+<?xml version="1.0" encoding="UTF-8"?>
4612+<ui version="4.0">
4613+ <class>DirConfigurationWidget</class>
4614+ <widget class="QWidget" name="DirConfigurationWidget">
4615+ <property name="geometry">
4616+ <rect>
4617+ <x>0</x>
4618+ <y>0</y>
4619+ <width>400</width>
4620+ <height>85</height>
4621+ </rect>
4622+ </property>
4623+ <property name="sizePolicy">
4624+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
4625+ <horstretch>0</horstretch>
4626+ <verstretch>0</verstretch>
4627+ </sizepolicy>
4628+ </property>
4629+ <property name="minimumSize">
4630+ <size>
4631+ <width>400</width>
4632+ <height>0</height>
4633+ </size>
4634+ </property>
4635+ <property name="windowTitle">
4636+ <string/>
4637+ </property>
4638+ <layout class="QFormLayout" name="formLayout">
4639+ <item row="1" column="0">
4640+ <widget class="QLabel" name="label_2">
4641+ <property name="text">
4642+ <string>Folder to show:</string>
4643+ </property>
4644+ <property name="buddy">
4645+ <cstring>urlRequester</cstring>
4646+ </property>
4647+ </widget>
4648+ </item>
4649+ <item row="1" column="1">
4650+ <widget class="KUrlRequester" name="urlRequester">
4651+ <property name="mode">
4652+ <set>KFile::Directory|KFile::ExistingOnly</set>
4653+ </property>
4654+ </widget>
4655+ </item>
4656+ <item row="2" column="1">
4657+ <widget class="QLineEdit" name="titleLineEdit"/>
4658+ </item>
4659+ <item row="2" column="0">
4660+ <widget class="QLabel" name="label">
4661+ <property name="text">
4662+ <string>Title:</string>
4663+ </property>
4664+ <property name="buddy">
4665+ <cstring>titleLineEdit</cstring>
4666+ </property>
4667+ </widget>
4668+ </item>
4669+ <item row="3" column="1">
4670+ <widget class="QLabel" name="titleHelpLabel">
4671+ <property name="sizePolicy">
4672+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
4673+ <horstretch>0</horstretch>
4674+ <verstretch>0</verstretch>
4675+ </sizepolicy>
4676+ </property>
4677+ <property name="text">
4678+ <string>If title is left empty, the folder name will be used</string>
4679+ </property>
4680+ </widget>
4681+ </item>
4682+ </layout>
4683+ </widget>
4684+ <customwidgets>
4685+ <customwidget>
4686+ <class>KUrlRequester</class>
4687+ <extends>QFrame</extends>
4688+ <header>kurlrequester.h</header>
4689+ </customwidget>
4690+ </customwidgets>
4691+ <resources/>
4692+ <connections/>
4693+</ui>
4694
4695=== added file 'components/sources/dir/dirmodel.cpp'
4696--- components/sources/dir/dirmodel.cpp 1970-01-01 00:00:00 +0000
4697+++ components/sources/dir/dirmodel.cpp 2013-03-01 15:15:27 +0000
4698@@ -0,0 +1,259 @@
4699+/*
4700+Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4701+
4702+This library is free software; you can redistribute it and/or
4703+modify it under the terms of the GNU Lesser General Public
4704+License as published by the Free Software Foundation; either
4705+version 2.1 of the License, or (at your option) version 3, or any
4706+later version accepted by the membership of KDE e.V. (or its
4707+successor approved by the membership of KDE e.V.), which shall
4708+act as a proxy defined in Section 6 of version 3 of the license.
4709+
4710+This library is distributed in the hope that it will be useful,
4711+but WITHOUT ANY WARRANTY; without even the implied warranty of
4712+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4713+Lesser General Public License for more details.
4714+
4715+You should have received a copy of the GNU Lesser General Public
4716+License along with this library. If not, see <http://www.gnu.org/licenses/>.
4717+*/
4718+// Self
4719+#include <dirmodel.h>
4720+
4721+// Local
4722+#include <dirconfigurationwidget.h>
4723+#include <favoriteplacesmodel.h>
4724+
4725+// libhomerun
4726+#include <actionlist.h>
4727+#include <pathmodel.h>
4728+
4729+// KDE
4730+#include <KConfigGroup>
4731+#include <KDebug>
4732+#include <KDirModel>
4733+#include <KDirLister>
4734+
4735+// Qt
4736+#include <QDir>
4737+
4738+namespace Homerun
4739+{
4740+
4741+static const char *SOURCE_ID = "Dir";
4742+
4743+static inline KFileItem itemForIndex(const QModelIndex &index)
4744+{
4745+ return index.data(KDirModel::FileItemRole).value<KFileItem>();
4746+}
4747+
4748+//- DirModel ------------------------------------------------------
4749+QVariantMap DirModel::sourceArguments(const KUrl &rootUrl, const QString &rootName, const KUrl &url)
4750+{
4751+ QVariantMap args;
4752+ args.insert("rootUrl", rootUrl.url());
4753+ args.insert("rootName", rootName);
4754+ args.insert("url", url.url());
4755+ return args;
4756+}
4757+
4758+
4759+DirModel::DirModel(QObject *parent)
4760+: KDirSortFilterProxyModel(parent)
4761+, m_pathModel(new PathModel(this))
4762+{
4763+ setSourceModel(new KDirModel(this));
4764+ setSortFoldersFirst(true);
4765+
4766+ QHash<int, QByteArray> roles;
4767+ roles.insert(Qt::DisplayRole, "display");
4768+ roles.insert(Qt::DecorationRole, "decoration");
4769+ roles.insert(DirModel::FavoriteIdRole, "favoriteId");
4770+ roles.insert(DirModel::HasActionListRole, "hasActionList");
4771+ roles.insert(DirModel::ActionListRole, "actionList");
4772+ setRoleNames(roles);
4773+
4774+ dirLister()->setDelayedMimeTypes(true);
4775+ connect(dirLister(), SIGNAL(started(KUrl)), SLOT(emitRunningChanged()));
4776+ connect(dirLister(), SIGNAL(completed()), SLOT(emitRunningChanged()));
4777+}
4778+
4779+void DirModel::init(const KUrl &rootUrl, const QString &rootName, const KUrl &url)
4780+{
4781+ m_rootUrl = rootUrl;
4782+ m_rootName = rootName;
4783+ initPathModel(url);
4784+ dirLister()->openUrl(url);
4785+}
4786+
4787+void DirModel::initPathModel(const KUrl &openedUrl)
4788+{
4789+ QVariantMap args = sourceArguments(m_rootUrl, m_rootName, m_rootUrl);
4790+ m_pathModel->addPath(m_rootName, SOURCE_ID, args);
4791+
4792+ KUrl rootUrl = m_rootUrl;
4793+ // Needed for KUrl::relativeUrl
4794+ rootUrl.adjustPath(KUrl::AddTrailingSlash);
4795+ QString relativePath = KUrl::relativeUrl(rootUrl, openedUrl);
4796+ if (relativePath == "./") {
4797+ return;
4798+ }
4799+ KUrl url = m_rootUrl;
4800+ Q_FOREACH(const QString &token, relativePath.split('/')) {
4801+ if (token.isEmpty()) {
4802+ // Just in case relativePath ends with '/'
4803+ continue;
4804+ }
4805+ url.addPath(token);
4806+ args["url"] = url.url();
4807+ m_pathModel->addPath(token, SOURCE_ID, args);
4808+ }
4809+}
4810+
4811+KDirLister *DirModel::dirLister() const
4812+{
4813+ return static_cast<KDirModel *>(sourceModel())->dirLister();
4814+}
4815+
4816+QVariant DirModel::data(const QModelIndex &index, int role) const
4817+{
4818+ if (role != FavoriteIdRole && role != HasActionListRole && role != ActionListRole) {
4819+ return QSortFilterProxyModel::data(index, role);
4820+ }
4821+ if (index.row() < 0 || index.row() >= rowCount()) {
4822+ return QVariant();
4823+ }
4824+ if (role == HasActionListRole) {
4825+ return true;
4826+ }
4827+ KFileItem item = itemForIndex(index);
4828+ if (role == FavoriteIdRole) {
4829+ if (item.isDir()) {
4830+ return FavoritePlacesModel::favoriteIdFromUrl(item.url());
4831+ } else {
4832+ return QString();
4833+ }
4834+ } else if (role == ActionListRole) {
4835+ return ActionList::createListForFileItem(item);
4836+ }
4837+ // Never reached
4838+ return QVariant();
4839+}
4840+
4841+int DirModel::count() const
4842+{
4843+ return rowCount(QModelIndex());
4844+}
4845+
4846+QString DirModel::name() const
4847+{
4848+ return m_rootName;
4849+}
4850+
4851+bool DirModel::running() const
4852+{
4853+ return !dirLister()->isFinished();
4854+}
4855+
4856+PathModel *DirModel::pathModel() const
4857+{
4858+ return m_pathModel;
4859+}
4860+
4861+QString DirModel::query() const
4862+{
4863+ return filterRegExp().pattern();
4864+}
4865+
4866+void DirModel::setQuery(const QString &value)
4867+{
4868+ if (value == query()) {
4869+ return;
4870+ }
4871+ setFilterRegExp(QRegExp(value, Qt::CaseInsensitive));
4872+ queryChanged(value);
4873+}
4874+
4875+void DirModel::emitRunningChanged()
4876+{
4877+ runningChanged(running());
4878+}
4879+
4880+bool DirModel::trigger(int row, const QString &actionId, const QVariant &actionArg)
4881+{
4882+ QModelIndex idx = index(row, 0);
4883+ KFileItem item = itemForIndex(idx);
4884+
4885+ if (actionId.isEmpty()) {
4886+ if (item.isDir()) {
4887+ openSourceRequested(SOURCE_ID, sourceArguments(m_rootUrl, m_rootName, item.url()));
4888+ return false;
4889+ } else {
4890+ item.run();
4891+ return true;
4892+ }
4893+ }
4894+ bool close = false;
4895+ if (ActionList::handleFileItemAction(item, actionId, actionArg, &close)) {
4896+ return close;
4897+ }
4898+ return false;
4899+}
4900+
4901+//- DirSource -------------------------------------------------------
4902+DirSource::DirSource(QObject *parent)
4903+: AbstractSource(parent)
4904+{}
4905+
4906+QAbstractItemModel *DirSource::createModelFromArguments(const QVariantMap &args)
4907+{
4908+ KUrl rootUrl = args.value("rootUrl").toString();
4909+ QString rootName = args.value("rootName").toString();
4910+ KUrl url = args.value("url").toString();
4911+ return createModel(rootUrl, rootName, url);
4912+}
4913+
4914+QAbstractItemModel *DirSource::createModelFromConfigGroup(const KConfigGroup &group)
4915+{
4916+ KUrl rootUrl = group.readPathEntry("rootUrl", QDir::homePath());
4917+ QString rootName = group.readEntry("rootName", QString());
4918+ return createModel(rootUrl, rootName, KUrl());
4919+}
4920+
4921+QAbstractItemModel *DirSource::createModel(const KUrl &rootUrl_, const QString &rootName_, const KUrl &url_)
4922+{
4923+ KUrl rootUrl = rootUrl_;
4924+ QString rootName = rootName_;
4925+ KUrl url = url_;
4926+ if (!rootUrl.isValid()) {
4927+ rootUrl = KUrl::fromPath(QDir::homePath());
4928+ }
4929+
4930+ if (rootName.isEmpty()) {
4931+ rootName = rootUrl.fileName();
4932+ if (rootName.isEmpty()) {
4933+ rootName = rootUrl.prettyUrl();
4934+ }
4935+ }
4936+ if (!url.isValid()) {
4937+ url = rootUrl;
4938+ }
4939+
4940+ DirModel *model = new DirModel;
4941+ model->init(rootUrl, rootName, url);
4942+ return model;
4943+}
4944+
4945+bool DirSource::isConfigurable() const
4946+{
4947+ return true;
4948+}
4949+
4950+SourceConfigurationWidget *DirSource::createConfigurationWidget(const KConfigGroup &group)
4951+{
4952+ return new DirConfigurationWidget(group);
4953+}
4954+
4955+} // namespace Homerun
4956+
4957+#include <dirmodel.moc>
4958
4959=== added file 'components/sources/dir/dirmodel.h'
4960--- components/sources/dir/dirmodel.h 1970-01-01 00:00:00 +0000
4961+++ components/sources/dir/dirmodel.h 2013-03-01 15:15:27 +0000
4962@@ -0,0 +1,113 @@
4963+/*
4964+Copyright 2012 Aurélien Gâteau <agateau@kde.org>
4965+
4966+This library is free software; you can redistribute it and/or
4967+modify it under the terms of the GNU Lesser General Public
4968+License as published by the Free Software Foundation; either
4969+version 2.1 of the License, or (at your option) version 3, or any
4970+later version accepted by the membership of KDE e.V. (or its
4971+successor approved by the membership of KDE e.V.), which shall
4972+act as a proxy defined in Section 6 of version 3 of the license.
4973+
4974+This library is distributed in the hope that it will be useful,
4975+but WITHOUT ANY WARRANTY; without even the implied warranty of
4976+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4977+Lesser General Public License for more details.
4978+
4979+You should have received a copy of the GNU Lesser General Public
4980+License along with this library. If not, see <http://www.gnu.org/licenses/>.
4981+*/
4982+#ifndef DIRMODEL_H
4983+#define DIRMODEL_H
4984+
4985+// Local
4986+#include <abstractsource.h>
4987+
4988+// Qt
4989+
4990+// KDE
4991+#include <KDirSortFilterProxyModel>
4992+#include <KUrl>
4993+
4994+class KDirLister;
4995+
4996+namespace Homerun {
4997+
4998+class PathModel;
4999+
5000+/**
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: