• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Engines

tasksengine.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2007 Robert Knight <robertknight@gmail.com>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License version 2 as
00006  *   published by the Free Software Foundation
00007  *
00008  *   This program is distributed in the hope that it will be useful,
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *   GNU General Public License for more details
00012  *
00013  *   You should have received a copy of the GNU Library General Public
00014  *   License along with this program; if not, write to the
00015  *   Free Software Foundation, Inc.,
00016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  */
00018 
00019 #include "tasksengine.h"
00020 
00021 #include <KDebug>
00022 #include <KLocale>
00023 
00024 #include <plasma/datacontainer.h>
00025 
00026 using namespace Plasma;
00027 
00028 TasksEngine::TasksEngine(QObject* parent, const QVariantList& args)
00029     : Plasma::DataEngine(parent)
00030 {
00031     Q_UNUSED(args);
00032 }
00033 
00034 void TasksEngine::connectTask(TaskPtr task)
00035 {
00036         connect( task.constData() , SIGNAL(changed()) , this , SLOT(taskChanged()) );
00037 }
00038 
00039 void TasksEngine::init()
00040 {
00041     foreach(TaskPtr task , TaskManager::TaskManager::self()->tasks().values() ) {
00042         connectTask(task);
00043         setDataForTask(task);
00044     }
00045 
00046     connect(TaskManager::TaskManager::self(), SIGNAL(taskAdded(TaskPtr)),
00047             this, SLOT(taskAdded(TaskPtr)));
00048     connect(TaskManager::TaskManager::self(), SIGNAL(taskRemoved(TaskPtr)),
00049             this, SLOT(taskRemoved(TaskPtr)));
00050 }
00051 
00052 void TasksEngine::taskAdded(TaskPtr task)
00053 {
00054     connectTask(task);
00055     setDataForTask(task);
00056 }
00057 
00058 void TasksEngine::taskRemoved(TaskPtr task)
00059 {
00060     removeSource( QString::number(task->window()) );
00061 }
00062 
00063 void TasksEngine::taskChanged()
00064 {
00065     TaskManager::Task* task = qobject_cast<TaskManager::Task*>(sender());
00066 
00067     Q_ASSERT(task);
00068 
00069     setDataForTask(TaskPtr(task));
00070 }
00071 
00072 void TasksEngine::setDataForTask(TaskPtr task)
00073 {
00074     Q_ASSERT( task );
00075 
00076     QString name = QString::number(task->window());
00077 
00078     const QMetaObject* metaObject = task->metaObject();
00079 
00080     for ( int i = 0 ; i < metaObject->propertyCount() ; i++ ) {
00081         QMetaProperty property = metaObject->property(i);
00082 
00083         setData(name,property.name(),property.read(task.constData()));
00084     }
00085 }
00086 
00087 #include "tasksengine.moc"

Engines

Skip menu "Engines"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal