From e8edacfc5175e91d27d6fcba8e3ffa1b1c80754c Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 12 Jul 2013 17:23:33 +0200 Subject: Dis/enable QActions for ContextMenu Handle actions dependent on type node. --- archivecontroller.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'archivecontroller.cpp') diff --git a/archivecontroller.cpp b/archivecontroller.cpp index 50e9982..869ffb0 100644 --- a/archivecontroller.cpp +++ b/archivecontroller.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "archivecontroller.h" #include "archivemodel.h" @@ -162,6 +163,11 @@ void ArchiveController::editFileNo(){ } } +void ArchiveController::addActionForTree(QAction *a){ + mActionsForTree << a; + mArchiveTree->addAction(a); +} + void ArchiveController::treeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected){ Q_UNUSED(selected); Q_UNUSED(deselected); @@ -190,6 +196,10 @@ void ArchiveController::treeSelectionChanged(const QItemSelection &selected, con } QString metaData = mArchiveModel->metadata(*ids.begin()); mMetadataView->setHtml(metaData); + int nodeType = sel.first().data(ArchiveModel::TypeRole).toInt(); + foreach(QAction *a, mActionsForTree){ + a->setEnabled(a->data().toInt() & nodeType); + } } void ArchiveController::fileDoubleClicked(const QModelIndex &idx){ -- cgit v1.2.3-70-g09d2