From bd6a6a7c42dabe2d0d86e309a6dc6b04de7c0a10 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 6 Jul 2013 08:06:52 +0200 Subject: 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. --- archiveview.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'archiveview.cpp') diff --git a/archiveview.cpp b/archiveview.cpp index 34fd169..f570751 100644 --- a/archiveview.cpp +++ b/archiveview.cpp @@ -18,9 +18,10 @@ #include #include "archiveview.h" +#include "archivecontroller.h" #include "smglobals.h" -ArchiveView::ArchiveView(QWidget *parent) : QWidget(parent), mConstructing(true) { +ArchiveView::ArchiveView(QWidget *parent) : QWidget(parent) { QSettings s; mArchiveModel = static_cast(SmGlobals::instance()->model("ArchiveModel")); connect(mArchiveModel, SIGNAL(needRefresh()), this, SLOT(refreshArchive())); @@ -74,7 +75,13 @@ ArchiveView::ArchiveView(QWidget *parent) : QWidget(parent), mConstructing(true) treeLayout->addWidget(mTree); QWidget *treeWidget = new QWidget; treeWidget->setLayout(treeLayout); + mFiles = new ArchiveFiles; + mFilesModel = new ArchiveFilesModel(QStringList() << tr("Seriespartid") << tr("Filename") << tr("Md5Sum") << tr("Size") << tr("Dvd") << tr("Type") << tr("No") << tr("Quality") << tr("Fileid") << tr("Pic size") << tr("Duration") << tr("Full Path"), this); + mFilesProxy = new ArchiveFilesProxy; + mFilesProxy->setSourceModel(mFilesModel); + mFiles->setModel(mFilesProxy); + QSplitter *treeSplitter = new QSplitter(Qt::Horizontal); treeSplitter->addWidget(treeWidget); treeSplitter->addWidget(mFiles); @@ -83,6 +90,7 @@ ArchiveView::ArchiveView(QWidget *parent) : QWidget(parent), mConstructing(true) QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(treeSplitter); setLayout(mainLayout); + initController(); } int ArchiveView::currentSortOrder() const { @@ -165,6 +173,14 @@ void ArchiveView::collapseItem(const QModelIndex &idx){ } } +void ArchiveView::initController(){ + mController = new ArchiveController(this); + mController->setArchiveView(mTree, mProxy); + mController->setArchiveFiles(mFiles, mFilesProxy); + mController->setModels(mArchiveModel, mFilesModel); + mController->init(); +} + ArchiveTree::ArchiveTree(QWidget *parent) : SmTreeView(parent) {} void ArchiveTree::setModel(ArchiveProxy *model){ @@ -224,3 +240,5 @@ bool ArchiveProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePare ArchiveModel *model = qobject_cast(sourceModel()); return model->matchRecursive(nameIdx, mFilter); } + +ArchiveFilesProxy::ArchiveFilesProxy(QObject *parent) : QSortFilterProxyModel(parent) {} -- cgit v1.2.3-70-g09d2