17
17
#include " mainwindow.h"
18
18
#include " ui_mainwindow.h"
19
19
#include " playbackreader.h"
20
-
20
+ # include " iconproxy.h "
21
21
#include " compositetrailstask.h"
22
22
23
23
MainWindow::MainWindow (QWidget *parent) :
@@ -43,7 +43,6 @@ MainWindow::MainWindow(QWidget *parent) :
43
43
start_path = cmdline_args.first ();
44
44
}
45
45
46
-
47
46
model->setRootPath (start_path);
48
47
model->setReadOnly (true );
49
48
@@ -59,10 +58,15 @@ MainWindow::MainWindow(QWidget *parent) :
59
58
model->setNameFilters (filters);
60
59
model->setNameFilterDisables (false );
61
60
61
+ // icon_provider = new QImageFileIconProvider();
62
+ // model->setIconProvider(icon_provider);
62
63
63
- ui->filesList ->setModel (model);
64
- ui->filesList ->setRootIndex (model->index (start_path));
65
- model->sort (0 );
64
+ icon_proxy = new IconProxy;
65
+ icon_proxy->setSourceModel (model);
66
+
67
+ ui->filesList ->setModel (icon_proxy);
68
+ ui->filesList ->setRootIndex (icon_proxy->mapFromSource (model->index (start_path)));
69
+ icon_proxy->sort (0 );
66
70
67
71
item = new QGraphicsPixmapItem ();
68
72
item->setTransformationMode (Qt::SmoothTransformation);
@@ -124,6 +128,12 @@ MainWindow::~MainWindow()
124
128
delete gl;
125
129
delete model;
126
130
delete preview_each_n_group;
131
+
132
+ if (icon_provider)
133
+ delete icon_provider;
134
+
135
+ if (icon_proxy)
136
+ delete icon_proxy;
127
137
}
128
138
129
139
// void MainWindow::handleFinished()
@@ -166,9 +176,10 @@ void MainWindow::on_filesList_doubleClicked(const QModelIndex &index)
166
176
167
177
if (model->fileInfo (index ).isDir ())
168
178
{
169
- ui->filesList ->setRootIndex (index );
179
+ ui->filesList ->setRootIndex (icon_proxy-> mapFromSource ( index ) );
170
180
model->setRootPath (model->filePath (index ));
171
181
model->sort (0 );
182
+ icon_proxy->sort (0 );
172
183
}
173
184
}
174
185
@@ -177,10 +188,11 @@ void MainWindow::on_actionBack_triggered()
177
188
{
178
189
stopCompositing ();
179
190
180
- QModelIndex parent_index = model ->parent (ui->filesList ->rootIndex ());
181
- ui->filesList ->setRootIndex (parent_index);
191
+ QModelIndex parent_index = icon_proxy ->parent (ui->filesList ->rootIndex ());
192
+ ui->filesList ->setRootIndex (icon_proxy-> mapFromSource ( parent_index) );
182
193
model->setRootPath (model->filePath (parent_index));
183
194
model->sort (0 );
195
+ icon_proxy->sort (0 );
184
196
}
185
197
186
198
@@ -373,9 +385,10 @@ void MainWindow::openDir(QString dir)
373
385
374
386
model->setRootPath (dir);
375
387
376
- ui->filesList ->setModel (model );
377
- ui->filesList ->setRootIndex (model->index (dir));
388
+ ui->filesList ->setModel (icon_proxy );
389
+ ui->filesList ->setRootIndex (icon_proxy-> mapFromSource ( model->index (dir) ));
378
390
model->sort (0 );
391
+ icon_proxy->sort (0 );
379
392
380
393
QuteImage *new_preview_image = new QuteImage ();
381
394
QuteImage *old_preview_image = preview_image;
0 commit comments