aboutsummaryrefslogtreecommitdiffstats
path: root/attachmenttablemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'attachmenttablemodel.cpp')
-rw-r--r--attachmenttablemodel.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/attachmenttablemodel.cpp b/attachmenttablemodel.cpp
index ef30f84..8aac394 100644
--- a/attachmenttablemodel.cpp
+++ b/attachmenttablemodel.cpp
@@ -14,13 +14,20 @@ AttachmentTableModel::AttachmentTableModel(QList<MimePart> mimeparts, QObject *p
listOfMimeparts = mimeparts;
}
+AttachmentTableModel::AttachmentTableModel(QString iconpath, QObject *parent) :
+ QAbstractTableModel(parent)
+{
+ iconPath = iconpath;
+}
+
+
void AttachmentTableModel::add(MimePart mp) {
listOfMimeparts.append(mp);
//QModelIndex changedIndex0 = createIndex(listOfMimeparts.size(), 0);
//QModelIndex changedIndex1 = createIndex(listOfMimeparts.size(), 1);
//emit(dataChanged(changedIndex0, changedIndex1));
- // TODO: check the data-changed function
+ // TODO: check the data-changed signal
reset();
}
@@ -70,7 +77,24 @@ QVariant AttachmentTableModel::data(const QModelIndex &index, int role) const
return mp.getParam("Content-Type", "name");
if (index.column() == 1)
return mp.getValue("Content-Type");
+
}
+
+ // set icon
+ // TODO more generic matching, e.g. for audio
+ if (role == Qt::DecorationRole && index.column() == 0) {
+ MimePart mp = listOfMimeparts.at(index.row());
+ QString icon;
+ if(mp.getValue("Content-Type").startsWith("image")) {
+ icon = iconPath + "/mimetypes/image-x-generic.png";
+ } else {
+ icon = mp.getValue("Content-Type").replace("/", "-");
+ icon = iconPath + "/mimetypes/" + icon + ".png";
+ }
+ if(!QFile::exists(icon)) icon = iconPath + "/mimetypes/unknown.png";
+ return QIcon(icon);
+ }
+
return QVariant();
}