1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
index 196bc90ac..e09c5020b 100644
--- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
+++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp
@@ -966,7 +966,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
QString fileName = QString::fromUtf8(fileInfo.fname.c_str());
DLListModel->setData(DLListModel->index(row, COLUMN_NAME), fileName);
- DLListModel->setData(DLListModel->index(row, COLUMN_NAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole);
+ DLListModel->setData(DLListModel->index(row, COLUMN_NAME), icon_cache.get_icon(fileName), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, COLUMN_COMPLETED), QVariant((qlonglong)completed));
DLListModel->setData(DLListModel->index(row, COLUMN_DLSPEED), QVariant((double)fileDlspeed));
@@ -1166,7 +1166,7 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
//ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL));
ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), fileName);
- ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole);
+ ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), icon_cache.get_icon((fileName)), Qt::DecorationRole);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash);
ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), fileHash, Qt::UserRole);
}
@@ -2288,3 +2288,65 @@ void TransfersDialog::filterChanged(const QString& /*text*/)
DLLFilterModel->setFilterKeyColumn(filterColumn);
DLLFilterModel->setFilterRegExp(text);
}
+
+//shitcode begin
+
+TransfersDialog_dirty_icon_cache::TransfersDialog_dirty_icon_cache() :
+ FileTypePicture(":/images/FileTypePicture.png"), FileTypeVideo(":/images/FileTypeVideo.png"), FileTypeAudio(":/images/FileTypeAudio.png"),
+ FileTypeArchive(":/images/FileTypeArchive.png"), FileTypeProgram(":/images/FileTypeProgram.png"), FileTypeCDImage(":/images/FileTypeCDImage.png"),
+ FileTypeDocument(":/images/FileTypeDocument.png"), pdf(":/images/mimetypes/pdf.png"), rscollection_16(":/images/mimetypes/rscollection-16.png"),
+ FileTypeAny(":/images/FileTypeAny.png"), patch(":/images/mimetypes/patch.png"), source_cpp(":/images/mimetypes/source_cpp.png"),
+ source_h(":/images/mimetypes/source_h.png"), source_c(":/images/mimetypes/source_c.png")
+{
+}
+
+QIcon& TransfersDialog_dirty_icon_cache::get_icon(const QString& filename)
+{
+ //mostly copypaste from static QString getInfoFromFilename(const QString& filename, bool anyForUnknown, bool image)
+ QString ext = QFileInfo(filename).suffix().toLower();
+
+ if (ext == "jpg" || ext == "jpeg" || ext == "tif" || ext == "tiff" || ext == "png" || ext == "gif" || ext == "bmp" || ext == "ico" || ext == "svg") {
+ return FileTypePicture;
+ } else if (ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "divx" || ext == "ts" ||
+ ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov" || ext == "asf" || ext == "xvid" ||
+ ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp" || ext == "ogm") {
+ return FileTypeVideo;
+ } else if (ext == "ogg" || ext == "mp3" || ext == "mp1" || ext == "mp2" || ext == "wav" || ext == "wma" || ext == "m4a" || ext == "flac" ||ext == "xpm") {
+ return FileTypeAudio;
+ } else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z" || ext == "msi" ||
+ ext == "rar" || ext == "rpm" || ext == "ace" || ext == "jar" || ext == "tgz" || ext == "lha" ||
+ ext == "cab" || ext == "cbz"|| ext == "cbr" || ext == "alz" || ext == "sit" || ext == "arj" || ext == "deb") {
+ return FileTypeArchive;
+ } else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com" ||
+ ext == "exe" || ext == "js" || ext == "pif" ||
+ ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws") {
+ return FileTypeProgram;
+ } else if (ext == "iso" || ext == "nrg" || ext == "mdf" || ext == "img" || ext == "dmg" || ext == "bin" || ext == "uif") {
+ return FileTypeCDImage;
+ } else if (ext == "txt" || ext == "ui" ||
+ ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls" || ext == "pps" || ext == "xml" || ext == "nfo" ||
+ ext == "reg" || ext == "sxc" || ext == "odt" || ext == "ods" || ext == "dot" || ext == "ppt" || ext == "css" || ext == "crt" ||
+ ext == "html" || ext == "htm" || ext == "php") {
+ return FileTypeDocument;
+ } else if (ext == "pdf") {
+ return pdf;
+ } else if (ext == RsCollection::ExtensionString) {
+ return rscollection_16;
+ } else if (ext == "sub" || ext == "srt") {
+ return FileTypeAny;
+ } else if (ext == "nds") {
+ return FileTypeAny;
+ } else if (ext == "patch" || ext == "diff") {
+ return patch;
+ } else if (ext == "cpp") {
+ return source_cpp;
+ } else if (ext == "h") {
+ return source_h;
+ } else if (ext == "c") {
+ return source_c;
+ }
+
+ return FileTypeAny;
+}
+
+//shitcode end
diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
index 30efe212d..2cb5877f2 100644
--- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
+++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.h
@@ -45,6 +45,20 @@ class SearchDialog;
class LocalSharedFilesDialog;
class RemoteSharedFilesDialog;
+
+//shitcode begin
+class TransfersDialog_dirty_icon_cache
+{
+public:
+ TransfersDialog_dirty_icon_cache();
+ QIcon& get_icon(const QString& filename);
+private:
+ QIcon FileTypePicture, FileTypeVideo, FileTypeAudio, FileTypeArchive, FileTypeProgram, FileTypeCDImage, FileTypeDocument, \
+ pdf, rscollection_16, FileTypeAny, patch, source_cpp, source_h, source_c;
+};
+
+//shitcode end
+
class TransfersDialog : public RsAutoUpdatePage
{
Q_OBJECT
@@ -247,6 +261,8 @@ private:
QTreeView *downloadList;
+ TransfersDialog_dirty_icon_cache icon_cache;
+
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
|