diff options
Diffstat (limited to 'src/model.cpp')
-rw-r--r-- | src/model.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/model.cpp b/src/model.cpp deleted file mode 100644 index 672f91e..0000000 --- a/src/model.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "model.h" -#include <QIcon> -#include <QPixmap> - -Model::Model(QList<Session*> e, QObject *parent) - : QAbstractListModel(parent), - rowCount_(e.size()), entries_(e) -{ - printf("model with %d entries created\n", this->entries_.size()); -} - -Model::~Model() -{ -} - -int Model::rowCount(const QModelIndex &parent) const -{ - return (parent.isValid() && parent.column() != 0) ? 0 : rowCount_; -} - -QVariant Model::data(const QModelIndex &index, int role) const -{ - printf("request for model row %d role %d\n", index.row(), role); - if (!index.isValid()) - return QVariant(); - if (role == Qt::DisplayRole) - return this->entries_.at(index.row())->shortDescription(); - if (role == Qt::ToolTipRole) - return this->entries_.at(index.row())->description(); - if (role == Qt::DecorationRole) { - // TODO: use cache for icons - if (index.column() == 0) { - const Session* e(this->entries_.at(index.row())); - - QString icon(e->icon()); - - if (QFileInfo(icon).isAbsolute()) { - // try to load icon from file - return QIcon(icon); - } else { - // try to load icon from QResource - return QIcon(":" + icon.toLower()); - } - } - } - return QVariant(); -} |