From e7e9cf2849d0000acf47ecde86e4853687a03409 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Thu, 7 Oct 2010 16:56:12 +0200 Subject: 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 --- src/sessiontreemodel.cpp | 51 ++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'src/sessiontreemodel.cpp') 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(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(index.internalPointer()); + SessionTreeItem *childItem = + static_cast(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& sessions, const QString& section) -{ +void SessionTreeModel::addItems(const QList& sessions, + const QString& section) { SessionTreeItem* parentItem; bool sectionExists = false; -- cgit v1.2.3-55-g7522