summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-22 18:48:02 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-22 19:00:05 (GMT)
commit182bdd709a57ab4d17f163ae28c5663fb3dd4287 (patch)
tree0633db17aba8df03d35405a7f102dc6eb6572cbc /Swift/Controllers/Roster/TableRoster.cpp
parentfabf140dcbefc420653406e602a521fd0fcba66d (diff)
downloadswift-182bdd709a57ab4d17f163ae28c5663fb3dd4287.zip
swift-182bdd709a57ab4d17f163ae28c5663fb3dd4287.tar.bz2
Added TableRoster.
Diffstat (limited to 'Swift/Controllers/Roster/TableRoster.cpp')
-rw-r--r--Swift/Controllers/Roster/TableRoster.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp
new file mode 100644
index 0000000..fda7de8
--- /dev/null
+++ b/Swift/Controllers/Roster/TableRoster.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swift/Controllers/Roster/TableRoster.h>
+
+#include <boost/cast.hpp>
+
+#include <Swift/Controllers/Roster/Roster.h>
+#include <Swift/Controllers/Roster/GroupRosterItem.h>
+
+using namespace Swift;
+
+TableRoster::TableRoster(Roster* model) : model(model) {
+}
+
+size_t TableRoster::getNumberOfSections() const {
+ return model ? model->getRoot()->getDisplayedChildren().size() : 0;
+}
+
+size_t TableRoster::getNumberOfRowsInSection(size_t section) const {
+ return boost::polymorphic_downcast<Swift::GroupRosterItem*>(model->getRoot()->getDisplayedChildren()[section])->getDisplayedChildren().size();
+}
+
+const std::string& TableRoster::getSectionTitle(size_t section) {
+ return model->getRoot()->getDisplayedChildren()[section]->getDisplayName();
+}
+
+TableRoster::Item TableRoster::getItem(const Index& index) const {
+ Item item;
+ item.name = boost::polymorphic_downcast<Swift::GroupRosterItem*>(model->getRoot()->getDisplayedChildren().at(index.section))->getDisplayedChildren().at(index.row)->getDisplayName();
+ item.description = "My Status";
+ return item;
+}