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
|
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
*/
#include "archivecontroller.h"
#include "archivemodel.h"
#include "archiveview.h"
ArchiveController::ArchiveController(QObject *parent) : QObject(parent) {}
void ArchiveController::setArchiveView(ArchiveTree *atree, ArchiveProxy *aproxy){
mArchiveTree = atree;
mArchiveProxy = aproxy;
mArchiveSelection = mArchiveTree->selectionModel();
}
void ArchiveController::setArchiveFiles(ArchiveFiles *afiles, ArchiveFilesProxy *afilesproxy){
mArchiveFiles = afiles;
mArchiveFilesProxy = afilesproxy;
}
void ArchiveController::setModels(ArchiveModel *amodel, ArchiveFilesModel *afilesmodel){
mArchiveModel = amodel;
mArchiveFilesModel = afilesmodel;
}
void ArchiveController::init(){
connect(mArchiveSelection, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(treeSelectionChanged(QItemSelection,QItemSelection)));
}
void ArchiveController::treeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected){
Q_UNUSED(selected);
Q_UNUSED(deselected);
QModelIndexList sel = mapToSource(mArchiveProxy, mArchiveSelection->selectedRows());
if(sel.isEmpty()){
return;
}
QSet<int> ids;
foreach(QModelIndex idx, sel){
ids.unite(mArchiveModel->seriesPartIds(idx));
}
mArchiveFilesModel->populate(ids);
mArchiveFiles->expandAll();
}
QModelIndexList ArchiveController::mapToSource(const QSortFilterProxyModel *proxy, const QModelIndexList idxs) const{
QModelIndexList retval;
foreach(QModelIndex idx, idxs){
retval << proxy->mapToSource(idx);
}
return retval;
}
|