[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/applets/tasks
From:       Robert Knight <robertknight () gmail ! com>
Date:       2007-08-01 1:34:44
Message-ID: 1185932084.781386.5285.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 694896 by knight:

Add representation of newly started tasks.

 M  +47 -0     tasks.cpp  
 M  +36 -0     tasks.h  


--- trunk/playground/base/plasma/applets/tasks/tasks.cpp #694895:694896
@@ -22,6 +22,7 @@
 #include "tasks.h"
 
 // KDE
+#include <KIcon>
 #include <KIconLoader>
 
 // Qt
@@ -42,6 +43,7 @@
 
     // add representations of existing running tasks
     registerWindowTasks();
+    registerStartingTasks();
 
     setFlag(QGraphicsItem::ItemIsMovable);
 }
@@ -55,6 +57,37 @@
     // and sub-items?
     return childrenBoundingRect().size();
 }
+void Tasks::registerStartingTasks()
+{
+    // listen for addition and removal of starting tasks
+    connect(TaskManager::self() , SIGNAL(startupAdded(Startup::StartupPtr)) , this , \
SLOT(addStartingTask(Startup::StartupPtr)) ); +    connect(TaskManager::self() , \
SIGNAL(startupRemoved(Startup::StartupPtr)) , this , \
SLOT(removeStartingTask(Startup::StartupPtr))); +}
+void Tasks::addStartingTask(Startup::StartupPtr task)
+{
+    prepareGeometryChange();
+
+    StartupTaskItem* item = new StartupTaskItem(_rootTaskGroup);
+    _startupTaskItems.insert(task,item);
+
+    item->setStartupTask(task);
+    item->setFlag(QGraphicsItem::ItemIsSelectable);
+
+    _rootTaskGroup->relayout();
+}
+void Tasks::removeStartingTask(Startup::StartupPtr task)
+{
+    prepareGeometryChange();
+
+    AbstractTaskItem* item = _startupTaskItems[task];
+
+    Q_ASSERT( item );
+    
+    scene()->removeItem(item);
+    item->deleteLater();
+
+    _rootTaskGroup->relayout();
+}
 void Tasks::registerWindowTasks()
 {
     TaskManager* manager = TaskManager::self();
@@ -362,6 +395,20 @@
 }
 #endif
 
+StartupTaskItem::StartupTaskItem(QGraphicsItem* parent)
+    : AbstractTaskItem(parent)
+{
+}
+
+void StartupTaskItem::setStartupTask(Startup::StartupPtr task) 
+{ 
+    _task = task;
+
+    setText( task->text() );
+    setIcon( KIcon(task->icon()) );
+}
+Startup::StartupPtr StartupTaskItem::startupTask() const { return _task; }
+
 WindowTaskItem::WindowTaskItem(QGraphicsItem* parent)
     : AbstractTaskItem(parent)
 {
--- trunk/playground/base/plasma/applets/tasks/tasks.h #694895:694896
@@ -71,16 +71,27 @@
         void addWindowTask(Task::TaskPtr);
         void removeWindowTask(Task::TaskPtr);
 
+        void addStartingTask(Startup::StartupPtr);
+        void removeStartingTask(Startup::StartupPtr);
+
 private:
         // creates task representations for existing windows
         // and sets up connections to listen for addition or removal
         // of windows
         void registerWindowTasks();
 
+        // creates task representations for tasks which are in
+        // the process of being started
+        // this allows some indication that the task is loading 
+        // to be displayed until the window associated with the task
+        // appears 
+        void registerStartingTasks();
+
         TaskGroupItem* _rootTaskGroup;
         AbstractGroupingStrategy* _strategy;
 
         QHash<Task::TaskPtr,AbstractTaskItem*> _windowTaskItems;
+        QHash<Startup::StartupPtr,AbstractTaskItem*> _startupTaskItems;
 };
 
 /** 
@@ -246,6 +257,31 @@
 };
 
 /** 
+ * A task item which represents a newly started task which does not yet have
+ * a window visible on screen.
+ *
+ * Startup tasks are short-lived and disappear if 
+ */
+class StartupTaskItem : public AbstractTaskItem
+{
+public:
+    /** Constructs a new representation for a starting task. */
+    StartupTaskItem( QGraphicsItem* parent );
+
+    /** Sets the starting task represented by this item. */
+    void setStartupTask( Startup::StartupPtr task );
+    /** Returns the starting task represented by this item. */
+    Startup::StartupPtr startupTask() const;
+
+protected:
+    // reimplemented, does nothing because there is no window to show
+    virtual void activate() {};
+
+private:
+    Startup::StartupPtr _task;
+};
+
+/** 
  * A graphics item which holds a group of tasks. 
  * To add a task to a group, set the AbstractTaskItem's parent
  * to the TaskGroupItem instance.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic