2 * Copyright 2008 Alain Boyer <alainboyer@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "tasksource.h"
22 #include "tasksengine.h"
23 #include "taskservice.h"
25 TaskSource::TaskSource(StartupPtr startup
, QObject
*parent
) :
26 Plasma::DataContainer(parent
),
31 setObjectName(TasksEngine::getStartupName(m_startup
));
32 setData("startup", true);
33 setData("task", false);
34 updateStartup(TaskManager::TaskUnchanged
);
37 TaskSource::TaskSource(TaskPtr task
, QObject
*parent
) :
38 Plasma::DataContainer(parent
),
43 setObjectName(TasksEngine::getTaskName(m_task
));
44 setData("startup", false);
45 setData("task", true);
46 updateTask(TaskManager::EverythingChanged
);
49 TaskSource::~TaskSource()
53 Plasma::Service
*TaskSource::createService()
55 return new TaskService(this);
58 TaskPtr
TaskSource::getTask()
63 bool TaskSource::isTask()
68 void TaskSource::updateStartup(::TaskManager::TaskChanges startupChanges
)
70 switch (startupChanges
) {
71 case TaskManager::TaskUnchanged
:
72 setData("text", m_startup
->text());
73 setData("bin", m_startup
->bin());
74 setData("icon", m_startup
->icon());
79 void TaskSource::updateTask(::TaskManager::TaskChanges taskChanges
)
81 // only a subset of task information is exported
82 switch (taskChanges
) {
83 case TaskManager::EverythingChanged
:
84 setData("name", m_task
->name());
85 setData("visibleName", m_task
->visibleName());
86 setData("visibleNameWithState", m_task
->visibleNameWithState());
87 setData("maximized", m_task
->isMaximized());
88 setData("minimized", m_task
->isMinimized());
89 setData("shaded", m_task
->isShaded());
90 setData("fullScreen", m_task
->isFullScreen());
91 setData("alwaysOnTop", m_task
->isAlwaysOnTop());
92 setData("keptBelowOthers", m_task
->isKeptBelowOthers());
93 setData("active", m_task
->isActive());
94 setData("onTop", m_task
->isOnTop());
95 setData("onCurrentDesktop", m_task
->isOnCurrentDesktop());
96 setData("onAllDesktops", m_task
->isOnAllDesktops());
97 setData("desktop", m_task
->desktop());
99 case TaskManager::NameChanged
:
100 setData("name", m_task
->name());
101 setData("visibleName", m_task
->visibleName());
102 setData("visibleNameWithState", m_task
->visibleNameWithState());
104 case TaskManager::StateChanged
:
105 setData("maximized", m_task
->isMaximized());
106 setData("minimized", m_task
->isMinimized());
107 setData("shaded", m_task
->isShaded());
108 setData("fullScreen", m_task
->isFullScreen());
109 setData("alwaysOnTop", m_task
->isAlwaysOnTop());
110 setData("keptBelowOthers", m_task
->isKeptBelowOthers());
111 setData("active", m_task
->isActive());
112 setData("onTop", m_task
->isOnTop());
114 case TaskManager::DesktopChanged
:
115 setData("onCurrentDesktop", m_task
->isOnCurrentDesktop());
116 setData("onAllDesktops", m_task
->isOnAllDesktops());
117 setData("desktop", m_task
->desktop());
125 void TaskSource::updateDesktop(int desktop
)
128 bool onCurrentDesktop
= m_task
->isOnCurrentDesktop();
129 if (data()["onCurrentDesktop"].toBool() != onCurrentDesktop
) {
130 setData("onCurrentDesktop", onCurrentDesktop
);
135 #include "tasksource.moc"