summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorJan Darmochwal2010-10-07 16:56:12 +0200
committerJan Darmochwal2010-10-07 16:56:12 +0200
commite7e9cf2849d0000acf47ecde86e4853687a03409 (patch)
treeaa811c315fa49eccf3691f932ebbc8b28d67fa14 /src/sessiontreemodel.cpp
parentAdded files to parse command line options (diff)
downloadvmchooser-e7e9cf2849d0000acf47ecde86e4853687a03409.tar.gz
vmchooser-e7e9cf2849d0000acf47ecde86e4853687a03409.tar.xz
vmchooser-e7e9cf2849d0000acf47ecde86e4853687a03409.zip
Tidy up the code
* fixed compiler warnings, added -Werror to CMakeLists.txt * removed LibXml2 and boost stuff from CMakeLists.txt * fixed some things cpplint.py complains about: * make single-argument constructors explicit * add space before if/for/while/... * don't put { on a line of its own * remove space after ! operator * add space between // and comment * remove extra space before ( in function call * remove extra space before ) * shorten lines to <= 80 characters * remove blank lines at the start of a code block * maybe others
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index a5088d2..6ebe11c 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -5,44 +5,34 @@
#include "sessiontreeitem.h"
SessionTreeModel::SessionTreeModel(QObject *parent)
- : QAbstractItemModel(parent)
-{
+ : QAbstractItemModel(parent) {
root_ = new SessionTreeItem("dummy");
}
-SessionTreeModel::~SessionTreeModel()
-{
+SessionTreeModel::~SessionTreeModel() {
delete root_;
}
-int SessionTreeModel::columnCount(const QModelIndex &parent) const
- {
- //TODO: check if this is right for invalid parent of root_
+int SessionTreeModel::columnCount(const QModelIndex& /*parent*/) const {
return 1;
- }
+}
-int SessionTreeModel::rowCount(const QModelIndex &parent) const
-{
+int SessionTreeModel::rowCount(const QModelIndex &parent) const {
SessionTreeItem* parentItem;
- if (parent.column() > 0)
- {
+ if (parent.column() > 0) {
return 0;
}
- if (!parent.isValid())
- {
+ if (!parent.isValid()) {
parentItem = root_;
- }
- else
- {
+ } else {
parentItem = static_cast<SessionTreeItem*>(parent.internalPointer());
}
return parentItem->childCount();
}
-QVariant SessionTreeModel::data(const QModelIndex &index, int role) const
-{
+QVariant SessionTreeModel::data(const QModelIndex &index, int role) const {
if (!index.isValid()) {
return QVariant();
}
@@ -78,8 +68,7 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const
return QVariant();
}
-Qt::ItemFlags SessionTreeModel::flags(const QModelIndex &index) const
-{
+Qt::ItemFlags SessionTreeModel::flags(const QModelIndex &index) const {
if (!index.isValid()) {
return 0;
}
@@ -94,16 +83,14 @@ Qt::ItemFlags SessionTreeModel::flags(const QModelIndex &index) const
}
}
-QVariant SessionTreeModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
+QVariant SessionTreeModel::headerData(int /*section*/,
+ Qt::Orientation /*orientation*/,
+ int /*role*/) const {
return QVariant();
}
QModelIndex SessionTreeModel::index(int row, int column,
- const QModelIndex &parent)
-const
-{
+ const QModelIndex &parent) const {
if (!hasIndex(row, column, parent)) {
return QModelIndex();
}
@@ -124,13 +111,13 @@ const
}
}
-QModelIndex SessionTreeModel::parent(const QModelIndex &index) const
-{
+QModelIndex SessionTreeModel::parent(const QModelIndex &index) const {
if (!index.isValid()) {
return QModelIndex();
}
- SessionTreeItem *childItem = static_cast<SessionTreeItem*>(index.internalPointer());
+ SessionTreeItem *childItem =
+ static_cast<SessionTreeItem*>(index.internalPointer());
SessionTreeItem *parentItem = childItem->parent();
if (parentItem == root_) {
@@ -140,8 +127,8 @@ QModelIndex SessionTreeModel::parent(const QModelIndex &index) const
return createIndex(parentItem->row(), 0, parentItem);
}
-void SessionTreeModel::addItems(const QList<Session*>& sessions, const QString& section)
-{
+void SessionTreeModel::addItems(const QList<Session*>& sessions,
+ const QString& section) {
SessionTreeItem* parentItem;
bool sectionExists = false;