From 6feaac3d6f28f560ac25f8a8e1dbe977e5f59c19 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet Date: Wed, 8 Jun 2011 17:40:39 +0200 Subject: [PATCH] Removed isChecked function, can be done with less code --- apps/launcher/datafilespage.cpp | 23 +++++++++-------------- apps/launcher/datafilespage.hpp | 1 - 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 8fd99c3cc..4d608a784 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -584,7 +584,15 @@ void DataFilesPage::showContextMenu(const QPoint &point) foreach (const QModelIndex ¤tIndex, selectedIndexes) { if (currentIndex.isValid()) { - if (isChecked(currentIndex)) { + const QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(currentIndex); + + if (!sourceIndex.isValid()) { + return; + } + + const QStandardItem *currentItem = mPluginsModel->itemFromIndex(sourceIndex); + + if (currentItem->checkState() == Qt::Checked) { mUncheckAction->setEnabled(true); } else { mCheckAction->setEnabled(true); @@ -746,19 +754,6 @@ void DataFilesPage::setCheckState(QModelIndex index) } } -bool DataFilesPage::isChecked(const QModelIndex &index) -{ - - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(index); - - if (mPluginsModel->data(sourceModelIndex, Qt::CheckStateRole) == Qt::Checked) { - return true; - } else { - return false; - } - -} - const QStringList DataFilesPage::selectedMasters() { QStringList masters; diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index f9fb8528e..1e418e3d4 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -86,7 +86,6 @@ private: void uncheckPlugins(); void createActions(); - bool isChecked(const QModelIndex &index); }; #endif