summaryrefslogtreecommitdiffstats
path: root/src/sessiontreeitem.cpp
diff options
context:
space:
mode:
authorJan Darmochwal2010-10-03 18:39:42 +0200
committerJan Darmochwal2010-10-03 18:39:42 +0200
commitee3f7eafae9e2e570c95e1afa9bea156ba3bf736 (patch)
tree7ffcb71280a344bde5249069991a1b5b841474df /src/sessiontreeitem.cpp
parentQt port is almost complete (at least it compiles) (diff)
downloadvmchooser-ee3f7eafae9e2e570c95e1afa9bea156ba3bf736.tar.gz
vmchooser-ee3f7eafae9e2e570c95e1afa9bea156ba3bf736.tar.xz
vmchooser-ee3f7eafae9e2e570c95e1afa9bea156ba3bf736.zip
TreeView for sessions (replaces ListView)
TreeView with SessionTreeModel replaces the old List View Other changes: * fixed bad copy and paste in CMakeLists.txt * added make clean to build.sh * removed moc_ and ui_ files from src
Diffstat (limited to 'src/sessiontreeitem.cpp')
-rw-r--r--src/sessiontreeitem.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/sessiontreeitem.cpp b/src/sessiontreeitem.cpp
new file mode 100644
index 0000000..5e07ad4
--- /dev/null
+++ b/src/sessiontreeitem.cpp
@@ -0,0 +1,60 @@
+#include "sessiontreeitem.h"
+
+SessionTreeItem::SessionTreeItem(const Session* session, SessionTreeItem *parent) :
+ parent_(parent), session_(session)
+{
+}
+
+SessionTreeItem::SessionTreeItem(const QString& text, SessionTreeItem *parent) :
+ parent_(parent), session_(NULL), text_(text)
+{
+}
+
+SessionTreeItem::~SessionTreeItem()
+{
+ qDeleteAll(children_);
+}
+
+void SessionTreeItem::appendChild(SessionTreeItem *item)
+{
+ children_.append(item);
+}
+
+SessionTreeItem *SessionTreeItem::child(int row)
+{
+ return children_.value(row);
+}
+
+int SessionTreeItem::childCount() const
+{
+ return children_.count();
+}
+
+int SessionTreeItem::columnCount() const
+{
+ return 1;
+}
+
+SessionTreeItem *SessionTreeItem::parent()
+{
+ return parent_;
+}
+
+int SessionTreeItem::row() const
+{
+ if (parent_) {
+ return parent_->children_.indexOf(const_cast<SessionTreeItem*>(this));
+ }
+
+ return 0;
+}
+
+const Session* SessionTreeItem::session() const
+{
+ return session_;
+}
+
+const QString SessionTreeItem::text() const
+{
+ return text_;
+}