summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-06 08:00:44 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-06 10:49:49 (GMT)
commit081fc03556708447610e9697a57235fa191a4f0d (patch)
tree505c8cc9129d2b44968d183a180f0ccddaa08810 /Swift/QtUI/Roster/RosterModel.h
parent8c53236875d2ca77f1b463449918458f6b424ab1 (diff)
downloadswift-081fc03556708447610e9697a57235fa191a4f0d.zip
swift-081fc03556708447610e9697a57235fa191a4f0d.tar.bz2
Rewrite of large amounts of roster code.
Now keeps widgets out of Swiften, keeps sorting inside Swiften, and keeps track of presences to show the correct presence per roster item. Resolves: #316 Resolves: #81 Resolves: #239
Diffstat (limited to 'Swift/QtUI/Roster/RosterModel.h')
-rw-r--r--Swift/QtUI/Roster/RosterModel.h58
1 files changed, 38 insertions, 20 deletions
diff --git a/Swift/QtUI/Roster/RosterModel.h b/Swift/QtUI/Roster/RosterModel.h
index 998f879..17fdd3e 100644
--- a/Swift/QtUI/Roster/RosterModel.h
+++ b/Swift/QtUI/Roster/RosterModel.h
@@ -6,30 +6,48 @@
#pragma once
-#include "Swift/QtUI/Roster/QtTreeWidgetItem.h"
+#include "Swiften/Roster/Roster.h"
#include <QAbstractItemModel>
#include <QList>
namespace Swift {
-class RosterModel : public QAbstractItemModel {
-Q_OBJECT
-public:
- RosterModel();
- ~RosterModel();
- void setRoot(QtTreeWidgetItem* tree);
- int columnCount(const QModelIndex& parent = QModelIndex()) const;
- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
- QModelIndex index(QtTreeWidgetItem* item) const;
- QModelIndex parent(const QModelIndex& index) const;
- int rowCount(const QModelIndex& parent = QModelIndex()) const;
-signals:
- void itemExpanded(const QModelIndex& item, bool expanded);
-private slots:
- void handleItemChanged(QtTreeWidgetItem* item);
-private:
- QtTreeWidgetItem* tree_;
-};
+ enum RosterRoles {
+ StatusTextRole = Qt::UserRole,
+ AvatarRole = Qt::UserRole + 1,
+ PresenceIconRole = Qt::UserRole + 2,
+ StatusShowTypeRole = Qt::UserRole + 3,
+ ChildCountRole = Qt::UserRole + 4,
+ };
+ class QtTreeWidget;
+
+ class RosterModel : public QAbstractItemModel {
+ Q_OBJECT
+ public:
+ RosterModel(QtTreeWidget* view);
+ ~RosterModel();
+ void setRoster(Roster* swiftRoster);
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
+ QModelIndex index(RosterItem* item) const;
+ QModelIndex parent(const QModelIndex& index) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ private:
+ void handleDataChanged(RosterItem* item);
+ void handleChildrenChanged(GroupRosterItem* item);
+ void handleGroupAdded(GroupRosterItem* group);
+ RosterItem* getItem(const QModelIndex& index) const;
+ QColor intToColor(int color) const;
+ QColor getTextColor(RosterItem* item) const;
+ QColor getBackgroundColor(RosterItem* item) const;
+ QString getToolTip(RosterItem* item) const;
+ QIcon getAvatar(RosterItem* item) const;
+ QString getStatusText(RosterItem* item) const;
+ QIcon getPresenceIcon(RosterItem* item) const;
+ int getChildCount(RosterItem* item) const;
+ Roster* roster_;
+ QtTreeWidget* view_;
+ };
}