summaryrefslogtreecommitdiffstats
path: root/archivecontroller.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-07-06 08:06:52 +0200
committerArno <am@disconnect.de>2013-07-06 08:06:52 +0200
commitbd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10 (patch)
treeb4a3cf4db50c84c08419562484e9016b7d4af5f6 /archivecontroller.cpp
parent04d9dcbe2139109e00d07488f6e45d0353a676e2 (diff)
downloadSheMov-bd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10.tar.gz
SheMov-bd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10.tar.bz2
SheMov-bd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10.zip
Basic ArchiveFilesModel and ArchiveController
Implement a new file model for the archive. It's quite basic at this stage, but finally something happens when clicking the archive tree. Also, implement the interaction (signal -> slot) between the views and models in an explicit controller to prevent the mess from the old archive.
Diffstat (limited to 'archivecontroller.cpp')
-rw-r--r--archivecontroller.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/archivecontroller.cpp b/archivecontroller.cpp
new file mode 100644
index 0000000..0c67ef7
--- /dev/null
+++ b/archivecontroller.cpp
@@ -0,0 +1,54 @@
+/*
+ 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);
+}
+
+QModelIndexList ArchiveController::mapToSource(const QSortFilterProxyModel *proxy, const QModelIndexList idxs) const{
+ QModelIndexList retval;
+ foreach(QModelIndex idx, idxs){
+ retval << proxy->mapToSource(idx);
+ }
+ return retval;
+}