File: RosterModel.h

package info (click to toggle)
swift-im 2.0%2Bdev6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,456 kB
  • ctags: 15,521
  • sloc: cpp: 86,078; python: 1,431; xml: 546; sh: 263; ansic: 54; makefile: 42
file content (55 lines) | stat: -rw-r--r-- 1,774 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include "Swift/Controllers/Roster/Roster.h"

#include <QAbstractItemModel>
#include <QList>

namespace Swift {
	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;
		signals:
			void itemExpanded(const QModelIndex& item, bool expanded);
		private:
			void handleDataChanged(RosterItem* item);
			void handleChildrenChanged(GroupRosterItem* item);
			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;
			QString getAvatar(RosterItem* item) const;
			QString getStatusText(RosterItem* item) const;
			QIcon getPresenceIcon(RosterItem* item) const;
			int getChildCount(RosterItem* item) const;
			void reLayout();
			Roster* roster_;
			QtTreeWidget* view_;
	};
}