Skip to content
Permalink
Browse files

add icon.(refs #78)

  • Loading branch information...
haraki committed Jun 11, 2019
1 parent 35d9074 commit 1a59b08e713ef02df844f4d528df31153a8929e8
Showing with 14 additions and 0 deletions.
  1. +12 −0 storagefavoriteinfomodel.cpp
  2. +2 −0 storagefavoriteinfomodel.h
@@ -9,10 +9,16 @@ namespace Farman

StorageFavoriteInfoModel::StorageFavoriteInfoModel(QObject *parent/*= Q_NULLPTR*/)
: QAbstractListModel(parent)
, m_fileSystemModel(new QFileSystemModel(this))
{
initialize();
}

StorageFavoriteInfoModel::~StorageFavoriteInfoModel()
{
delete m_fileSystemModel;
}

int StorageFavoriteInfoModel::initialize()
{
qDebug() << "StorageFavoriteInfoModel::initialize()";
@@ -109,6 +115,12 @@ QVariant StorageFavoriteInfoModel::data(const QModelIndex &index, int role) cons
return info.getPath();
}
break;
case Qt::DecorationRole:
if(index.column() == 0)
{
return m_fileSystemModel->fileIcon(m_fileSystemModel->index(info.getPath()));
}
break;
case TypeRole:
return info.getTypeName();
case NameRole:
@@ -2,6 +2,7 @@
#define STORAGEFAVORITEINFOMODEL_H

#include <QAbstractListModel>
#include <QFileSystemModel>
#include <QStorageInfo>

namespace Farman
@@ -51,6 +52,7 @@ class StorageFavoriteInfoModel : public QAbstractListModel
};

explicit StorageFavoriteInfoModel(QObject *parent = Q_NULLPTR);
~StorageFavoriteInfoModel() Q_DECL_OVERRIDE;

// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;

0 comments on commit 1a59b08

Please sign in to comment.
You can’t perform that action at this time.