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

Applets

abstracttaskitem.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>          *
00003  *   Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com>           *
00004  *   Copyright (C) 2008 by Marco Martin <notmart@gmail.com>                *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
00020  ***************************************************************************/
00021 
00022 
00023 #ifndef ABSTRACTTASKITEM_H
00024 #define ABSTRACTTASKITEM_H
00025 
00026 // KDE
00027 #include <KColorScheme>
00028 // Own
00029 #include <taskmanager/taskgroup.h>
00030 
00031 // Qt
00032 #include <QTime>
00033 #include <QIcon>
00034 #include <QGraphicsWidget>
00035 
00036 class QTextOption;
00037 class QTextLayout;
00038 class QString;
00039 
00040 
00041 // Plasma
00042 #include <Plasma/Animator>
00043 
00044 class Tasks;
00045 class TaskGroupItem;
00046 class LayoutWidget;
00047 
00051 class AbstractTaskItem : public QGraphicsWidget
00052 {
00053     Q_OBJECT
00054 
00055 public:
00057     AbstractTaskItem(QGraphicsWidget *parent, Tasks *applet, const bool showTooltip);
00058 
00060     ~AbstractTaskItem();
00061 
00063     void setShowTooltip(const bool showit);
00064 
00066     void setText(const QString &text);
00067 
00069     void setIcon(const QIcon &icon);
00070 
00075     enum TaskFlag
00076     {
00081         TaskWantsAttention = 1,
00085         TaskHasFocus       = 2,
00089         TaskIsMinimized    = 4
00090     };
00091     Q_DECLARE_FLAGS(TaskFlags, TaskFlag)
00092 
00093     
00094     void setTaskFlags(const TaskFlags flags);
00095 
00097     TaskFlags taskFlags() const;
00098 
00100     QString text() const;
00101 
00103     QIcon icon() const;
00104 
00105     virtual void close() = 0;
00106 
00108     virtual void publishIconGeometry() const;
00109     virtual void publishIconGeometry(const QRect &rect) const;
00110     QRect iconGeometry() const; // helper for above
00111 
00113     void setGeometry(const QRectF& geometry);
00114 
00117     bool isGrouped() const;
00118     bool isGroupMember(const TaskGroupItem *group) const;
00119     TaskGroupItem *parentGroup() const;
00120 
00121     virtual bool isWindowItem() const = 0;
00122     virtual bool isActive() const = 0;
00123 
00124     virtual void setAdditionalMimeData(QMimeData* mimeData) = 0;
00125 
00126     void setLayoutWidget(LayoutWidget* widget);
00127     TaskManager::AbstractItemPtr abstractItem();
00128 
00130     QSize basicPreferredSize() const;
00131 
00132 Q_SIGNALS:
00133     void activated(AbstractTaskItem *);
00134 
00135 public Q_SLOTS:
00136     virtual void activate() = 0;
00137     void toolTipAboutToShow();
00138     void toolTipHidden();
00139 
00140 protected:
00141     void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00142     void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00143     void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
00144 
00145     // reimplemented
00146     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00147     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00148     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00149     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00150     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00151     void timerEvent(QTimerEvent *event);
00152     void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
00153 
00155     virtual void drawBackground(QPainter *painter,const QStyleOptionGraphicsItem *option,
00156                                 QWidget *widget);
00158     virtual void drawTask(QPainter *painter,const QStyleOptionGraphicsItem *option,
00159                           QWidget *widget);
00160 
00162     QTextOption textOption() const;
00163 
00171     QSize layoutText(QTextLayout &layout, const QString &text, const QSize &constraints) const;
00172 
00178     void drawTextLayout(QPainter *painter, const QTextLayout &layout, const QRect &rect) const;
00179 
00180     virtual void updateTask(::TaskManager::TaskChanges changes) = 0; // pure virtual function
00181     virtual void updateToolTip() = 0; // pure virtual function
00182     QString expanderElement() const;
00183 
00184 protected Q_SLOTS:
00186     void queueUpdate();
00187 
00188     void animationUpdate(qreal progress);
00189     void syncActiveRect();
00190     void checkSettings();
00191 
00192 protected:
00193     // area of item occupied by task's icon
00194     QRectF iconRect(const QRectF &bounds) const;
00195     // area for the expander arrow for group items
00196     QRectF expanderRect(const QRectF &b) const;
00197     // area of item occupied by task's text
00198     QRectF textRect(const QRectF &bounds) const;
00199     // start an animation to chnge the task background
00200     void fadeBackground(const QString &newBackground, int duration, bool fadeIn);
00201     // text color, use this because it could be animated
00202     QColor textColor() const;
00203 
00204     TaskManager::AbstractItemPtr m_abstractItem;
00205     LayoutWidget *m_layoutWidget;
00206 
00207     Tasks *m_applet;
00208     LayoutWidget *m_parentWidget;
00209     QTimer* m_activateTimer;
00210 
00211 
00212     TaskFlags m_flags;
00213 
00214     QIcon m_icon;
00215     QString m_text;
00216 
00217     int m_animId;
00218     qreal m_alpha;
00219     QString m_oldBackgroundPrefix;
00220     QString m_backgroundPrefix;
00221     QRectF m_activeRect;
00222 
00223     QPointF _dragOffset;
00224     QTime m_lastUpdate;
00225     int m_updateTimerId;
00226     int m_attentionTimerId;
00227     int m_attentionTicks;
00228 
00229     bool m_fadeIn : 1;
00230     bool m_showTooltip : 1;
00231     bool m_showingTooltip : 1;
00232     // distance (in pixels) between a task's icon and its text
00233     static const int IconTextSpacing = 4;
00234 
00235     static const int TaskItemHorizontalMargin = 4;
00236     static const int TaskItemVerticalMargin = 4;
00237 };
00238 
00239 #endif

Applets

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

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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