[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/presence
From: George Goldberg <grundleborg () googlemail ! com>
Date: 2008-07-12 5:47:39
Message-ID: 1215841659.693277.26147.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 831203 by gberg:
Draw icon in view for the status type of each account.
M +6 -9 presence.cpp
M +0 -2 presence.h
M +53 -2 presenceitemdelegate.cpp
--- trunk/playground/base/plasma/applets/presence/presence.cpp #831202:831203
@@ -19,6 +19,8 @@
#include "presence.h"
+#include "presenceitemdelegate.h"
+
#include <plasma/theme.h>
#include <plasma/widgets/icon.h>
@@ -27,7 +29,6 @@
#include <KColorScheme>
#include <KDebug>
#include <KIcon>
-#include <KLineEdit>
#include <QtTapioca/PresenceState>
@@ -44,7 +45,6 @@
: PlasmaAppletDialog(parent, args),
m_engine(0),
m_colorScheme(0),
- m_messageEdit(0),
m_masterStatusLayout(0),
m_masterIconLabel(0),
m_masterStatusMessageLabel(0),
@@ -83,11 +83,11 @@
m_accountsModel->setColumnCount(4);
m_accountsModel->setHeaderData(1, Qt::Horizontal,
- QVariant("online?"), Qt::DisplayRole);
+ QVariant("status-type"), Qt::DisplayRole);
m_accountsModel->setHeaderData(2, Qt::Horizontal,
- QVariant("status"), Qt::DisplayRole);
+ QVariant("status-name"), Qt::DisplayRole);
m_accountsModel->setHeaderData(3, Qt::Horizontal,
- QVariant("message"), Qt::DisplayRole);
+ QVariant("status-message"), Qt::DisplayRole);
Q_ASSERT(!m_engine); // Pointer should still be assigned to 0.
m_engine = dataEngine("presence");
@@ -112,6 +112,7 @@
// Set up the accounts view.
Q_ASSERT(!m_accountsView); // Pointer should still be assigned to 0.
m_accountsView = new QTreeView;
+ m_accountsView->setItemDelegate(new PresenceItemDelegate);
m_accountsView->setModel(m_accountsModel);
m_accountsView->header()->setVisible(true);
m_accountsView->setColumnHidden(0, true); //Hide the source id column
@@ -133,16 +134,12 @@
masterStatusMessageChanged(m_masterStatusMessage);
// Set up the rest of the view/layout etc. stuff.
- Q_ASSERT(!m_messageEdit); // Pointer should still be assigned to 0.
- m_messageEdit = new KLineEdit;
-
Q_ASSERT(!m_widget); // Pointer should still be assigned to 0.
Q_ASSERT(!m_layout); // Pointer should still be assigned to 0.
m_widget = new QWidget();
m_layout = new QVBoxLayout(m_widget);
m_layout->addLayout(m_masterStatusLayout);
m_layout->addWidget(m_accountsView);
- m_layout->addWidget(m_messageEdit);
m_widget->setLayout(m_layout);
// Apply the theme's color scheme to the widget.
--- trunk/playground/base/plasma/applets/presence/presence.h #831202:831203
@@ -27,7 +27,6 @@
#include <QtCore/QString>
class KColorScheme;
-class KLineEdit;
class QHBoxLayout;
class QLabel;
@@ -64,7 +63,6 @@
Plasma::DataEngine * m_engine;
KColorScheme * m_colorScheme;
- KLineEdit * m_messageEdit;
QHBoxLayout * m_masterStatusLayout;
QLabel * m_masterIconLabel;
--- trunk/playground/base/plasma/applets/presence/presenceitemdelegate.cpp \
#831202:831203 @@ -19,6 +19,13 @@
#include "presenceitemdelegate.h"
+#include <kdebug.h>
+#include <kicon.h>
+
+#include <QtGui/QPainter>
+
+#include <QtTapioca/PresenceState>
+
PresenceItemDelegate::PresenceItemDelegate(QWidget * parent)
: QStyledItemDelegate(parent)
{ }
@@ -28,14 +35,58 @@
const QStyleOptionViewItem & option,
const QModelIndex & index) const
{
- // TODO: Implement me!
+
+ if(option.state & QStyle::State_Selected)
+ {
+ painter->fillRect(option.rect, option.palette.highlight());
+ }
+
+ if(index.column() == 1)
+ {
+ // We are painting the icon.
+ QtTapioca::PresenceState::Type type = \
static_cast<QtTapioca::PresenceState::Type>(index.model()->data(index).toInt()); +
+ KIcon icon;
+ switch(type)
+ {
+ case QtTapioca::PresenceState::AvailableType:
+ icon = KIcon("user-online");
+ break;
+ case QtTapioca::PresenceState::AwayType:
+ icon = KIcon("user-away");
+ break;
+ case QtTapioca::PresenceState::ExtendedAwayType:
+ icon = KIcon("user-away-extended");
+ break;
+ case QtTapioca::PresenceState::HiddenType:
+ icon = KIcon("user-invisible");
+ break;
+ case QtTapioca::PresenceState::BusyType:
+ icon = KIcon("user-busy");
+ break;
+ default:
+ icon = KIcon("user-offline");
+ break;
+ }
+ icon.paint(painter, option.rect);
+
+ return;
+ }
+
+ return QStyledItemDelegate::paint(painter, option, index);
}
QSize
PresenceItemDelegate::sizeHint(const QStyleOptionViewItem & option,
const QModelIndex & index) const
{
- // TODO: Implement me!
+ if(index.column() == 1)
+ {
+ // Icon column.
+ return QSize(24, 24);
+ }
+
+ return QStyledItemDelegate::sizeHint(option, index);
}
#include "presenceitemdelegate.moc"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic