diff options
author | Sebastian Schmelzer | 2011-11-03 15:53:13 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2011-11-03 15:53:13 +0100 |
commit | 7b4db583fe0ae4cccb483a0d56c4559d3a2f1961 (patch) | |
tree | 7e798252cbb0e9d5462ef17b4a5ca9d6fd73e489 | |
parent | some doku (diff) | |
download | libChooser-7b4db583fe0ae4cccb483a0d56c4559d3a2f1961.tar.gz libChooser-7b4db583fe0ae4cccb483a0d56c4559d3a2f1961.tar.xz libChooser-7b4db583fe0ae4cccb483a0d56c4559d3a2f1961.zip |
remove sessiontree
-rw-r--r-- | src/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/SessionTreeItem.cpp | 65 | ||||
-rw-r--r-- | src/SessionTreeItem.h | 49 | ||||
-rw-r--r-- | src/SessionTreeModel.cpp | 179 | ||||
-rw-r--r-- | src/SessionTreeModel.h | 50 |
5 files changed, 10 insertions, 350 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb6e99e..4248fc9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,12 +20,13 @@ set(QT_USE_QTSVG TRUE) include(${QT_USE_FILE}) -QT4_WRAP_CPP(LCHOOSER_MOC_SOURCES ${LCHOOSER_MOC_HEADERS}) -set(LCHOOSER_MOC_HEADERS "SessionTreeModel.h") -set(LCHOOSER_MOC_SOURCES "SessionTreeModel.cpp") -set(LCHOOSER_HEADERS "Session.h" "SessionTreeItem.h" "VSession.h" "VSessionHandler.h" "XSession.h" "XSessionHandler.h") -set(LCHOOSER_SOURCES "SessionTreeItem.cpp" "VSession.cpp" "VSessionHandler.cpp" "XSession.cpp" "XSessionHandler.cpp") +#set(LCHOOSER_MOC_HEADERS "SessionTreeModel.h") +#set(LCHOOSER_MOC_SOURCES "SessionTreeModel.cpp") +#QT4_WRAP_CPP(LCHOOSER_MOC_SOURCES ${LCHOOSER_MOC_HEADERS}) + +set(LCHOOSER_HEADERS "Session.h" "VSession.h" "VSessionHandler.h" "XSession.h" "XSessionHandler.h") +set(LCHOOSER_SOURCES "VSession.cpp" "VSessionHandler.cpp" "XSession.cpp" "XSessionHandler.cpp") set(LCHOOSER_CONFIG_HEADERS "Version.h" "Config.h") @@ -35,6 +36,7 @@ set(LCHOOSER_CONFIG_HEADERS "Version.h" "Config.h") add_library (Chooser_static STATIC ${LCHOOSER_SOURCES} ${LCHOOSER_MOC_SOURCES} ${LCHOOSER_HEADERS} ${LCHOOSER_MOC_HEADERS} ${LCHOOSER_CONFIG_HEADERS}) set_target_properties (Chooser_static PROPERTIES OUTPUT_NAME Chooser) add_library (Chooser_shared SHARED ${LCHOOSER_SOURCES} ${LCHOOSER_MOC_SOURCES} ${LCHOOSER_HEADERS} ${LCHOOSER_MOC_HEADERS} ${LCHOOSER_CONFIG_HEADERS}) +target_link_libraries(Chooser_shared ${QT_LIBRARIES}) set_target_properties (Chooser_shared PROPERTIES OUTPUT_NAME Chooser) @@ -68,8 +70,9 @@ set(CPACK_COMPONENT_DEV_GROUP "dev") set(CPACK_COMPONENT_DEV_DEPENDS libs) execute_process(COMMAND lsb_release -cs OUTPUT_VARIABLE distro_shortname OUTPUT_STRIP_TRAILING_WHITESPACE) -execute_process(COMMAND arch OUTPUT_VARIABLE distro_arch OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE distro_arch OUTPUT_STRIP_TRAILING_WHITESPACE) +set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") set(CPACK_GENERATOR "DEB") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sebastian Schmelzer <ssc@xss.nu>") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library for vmchooser and emuchooser..") @@ -84,4 +87,4 @@ set(CPACK_PACKAGE_FILE_NAME "libChooser_${CPACK_PACKAGE_VERSION}_${distro_short set(CPACK_SOURCE_PACKAGE_FILE_NAME "libChooser_${CPACK_PACKAGE_VERSION}") INCLUDE(CPack) -################################################################################
\ No newline at end of file +################################################################################ diff --git a/src/SessionTreeItem.cpp b/src/SessionTreeItem.cpp deleted file mode 100644 index ed7ead7..0000000 --- a/src/SessionTreeItem.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2010,2011 - RZ Uni Freiburg - * Copyright (c) 2010,2011 - OpenSLX Project - * - * This program/file is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your feedback to feedback@openslx.org - * - * General information about OpenSLX - libChooser can be found under - * http://openslx.org - * - */ - -#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_; -} diff --git a/src/SessionTreeItem.h b/src/SessionTreeItem.h deleted file mode 100644 index 1c41195..0000000 --- a/src/SessionTreeItem.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2010,2011 - RZ Uni Freiburg - * Copyright (c) 2010,2011 - OpenSLX Project - * - * This program/file is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your feedback to feedback@openslx.org - * - * General information about OpenSLX - libChooser can be found under - * http://openslx.org - * - */ - -#ifndef SESSIONTREEITEM_H -#define SESSIONTREEITEM_H - -#include <QList> -#include <QVariant> - -// class ... instead of include? -#include "Session.h" -#include <QString> - -class SessionTreeItem { - public: - SessionTreeItem(const Session* session, SessionTreeItem *parent = 0); - SessionTreeItem(const QString& text, SessionTreeItem *parent = 0); - ~SessionTreeItem(); - - void appendChild(SessionTreeItem *child); - - SessionTreeItem *child(int row); - int childCount() const; - int columnCount() const; - int row() const; - SessionTreeItem *parent(); - const Session* session() const; - const QString text() const; - - private: - QList<SessionTreeItem*> children_; - SessionTreeItem *parent_; - const Session *session_; - const QString text_; -}; - -#endif // SESSIONTREEITEM_H diff --git a/src/SessionTreeModel.cpp b/src/SessionTreeModel.cpp deleted file mode 100644 index 273d050..0000000 --- a/src/SessionTreeModel.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2010,2011 - RZ Uni Freiburg - * Copyright (c) 2010,2011 - OpenSLX Project - * - * This program/file is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your feedback to feedback@openslx.org - * - * General information about OpenSLX - libChooser can be found under - * http://openslx.org - * - */ - -#include <QFileInfo> -#include <QIcon> -#include <QResource> -#include <QString> - -#include "SessionTreeItem.h" -#include "SessionTreeModel.h" - - -SessionTreeModel::SessionTreeModel(QObject *parent) - : QAbstractItemModel(parent) { - root_ = new SessionTreeItem("dummy"); -} - -SessionTreeModel::~SessionTreeModel() { - delete root_; -} - -int SessionTreeModel::columnCount(const QModelIndex& /*parent*/) const { - return 1; -} - -int SessionTreeModel::rowCount(const QModelIndex &parent) const { - SessionTreeItem* parentItem; - if (parent.column() > 0) { - return 0; - } - - if (!parent.isValid()) { - parentItem = root_; - } else { - parentItem = static_cast<SessionTreeItem*>(parent.internalPointer()); - } - - return parentItem->childCount(); -} - -QVariant SessionTreeModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) { - return QVariant(); - } - - SessionTreeItem* item = - static_cast<SessionTreeItem*>(index.internalPointer()); - - const Session* s = item->session(); - if (s) { - if (role == Qt::DisplayRole) - return s->shortDescription(); - if (role == Qt::ToolTipRole) - return s->description(); - if (role == Qt::DecorationRole) { - // TODO: use cache for icons - if (index.column() == 0) { // TODO: is this line needed? - QString icon(s->icon()); - - if (QFileInfo(icon).isAbsolute()) { - // try to load icon from file - return QIcon(icon); - } else { - // try to load icon from QResource - if (QResource(":" + icon.toLower() + ".svg").isValid()) { - return QIcon(":" + icon.toLower() + ".svg"); - } else if (QResource(":icons/" + icon.toLower()).isValid()) { - return QIcon(":icons/" + icon.toLower()); - } else if (QResource(":" + icon.toLower()).isValid()) { - return QIcon(":" + icon.toLower()); - } else { - return QIcon(":none"); - } - } - } - } - } else if (role == Qt::DisplayRole) { - // this is a section item (X Sessions / Virtual Sessions) - return item->text(); - } - - return QVariant(); -} - -Qt::ItemFlags SessionTreeModel::flags(const QModelIndex &index) const { - if (!index.isValid()) { - return 0; - } - - SessionTreeItem* item = - static_cast<SessionTreeItem*>(index.internalPointer()); - - if (item->session()) { - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; - } else { - return Qt::ItemIsEnabled; - } -} - -QVariant SessionTreeModel::headerData(int /*section*/, - Qt::Orientation /*orientation*/, - int /*role*/) const { - return QVariant(); -} - -QModelIndex SessionTreeModel::index(int row, int column, - const QModelIndex &parent) const { - if (!hasIndex(row, column, parent)) { - return QModelIndex(); - } - - SessionTreeItem *parentItem; - - if (!parent.isValid()) { - parentItem = root_; - } else { - parentItem = static_cast<SessionTreeItem*>(parent.internalPointer()); - } - - SessionTreeItem *childItem = parentItem->child(row); - if (childItem) { - return createIndex(row, column, childItem); - } else { - return QModelIndex(); - } -} - -QModelIndex SessionTreeModel::parent(const QModelIndex &index) const { - if (!index.isValid()) { - return QModelIndex(); - } - - SessionTreeItem *childItem = - static_cast<SessionTreeItem*>(index.internalPointer()); - SessionTreeItem *parentItem = childItem->parent(); - - if (parentItem == root_) { - return QModelIndex(); - } - - return createIndex(parentItem->row(), 0, parentItem); -} - -void SessionTreeModel::addItems(const QList<Session*>& sessions, - const QString& section) { - SessionTreeItem* parentItem; - - bool sectionExists = false; - - for (int i = 0; i < root_->childCount(); ++i) { - SessionTreeItem* item = root_->child(i); - if (item->text() == section) { - parentItem = item; - sectionExists = true; - break; - } - } - - if (!sectionExists) { - parentItem = new SessionTreeItem(section, root_); - root_->appendChild(parentItem); - } - - foreach (Session* s, sessions) { - parentItem->appendChild(new SessionTreeItem(s, parentItem)); - } -} diff --git a/src/SessionTreeModel.h b/src/SessionTreeModel.h deleted file mode 100644 index 34b830e..0000000 --- a/src/SessionTreeModel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2010,2011 - RZ Uni Freiburg - * Copyright (c) 2010,2011 - OpenSLX Project - * - * This program/file is free software distributed under the GPL version 2. - * See http://gpl.openslx.org/ - * - * If you have any feedback please consult http://feedback.openslx.org/ and - * send your feedback to feedback@openslx.org - * - * General information about OpenSLX - libChooser can be found under - * http://openslx.org - * - */ - -#ifndef VMCHOOSER_SESSIONTREEMODEL_H -#define VMCHOOSER_SESSIONTREEMODEL_H - -#include <QAbstractItemModel> -#include <QModelIndex> -#include <QVariant> - -class SessionTreeItem; -class Session; - -class SessionTreeModel : public QAbstractItemModel { - Q_OBJECT - - public: - explicit SessionTreeModel(QObject *parent = 0); - ~SessionTreeModel(); - - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - void addItems(const QList<Session*>& sessions, const QString& section); - - - private: - SessionTreeItem* root_; -}; - -#endif // VMCHOOSER_SESSIONTREEMODEL_H |