From bc7afc575ef9b352bd43a28fed0ef5cb854f17a5 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Tue, 30 Jan 2024 16:01:53 +0100 Subject: [PATCH] replace 'selectedIndex' by 'currentIndex' --- GUI/Model/Device/InstrumentsSet.h | 2 +- GUI/Model/Files/DatafilesSet.h | 2 +- GUI/Model/Job/ParameterTreeItems.h | 2 +- GUI/Model/Mask/MasksQModel.cpp | 8 ++++---- GUI/Model/Sample/SamplesSet.h | 2 +- GUI/View/Data/DatafilesSelector.cpp | 2 +- GUI/View/Instrument/InstrumentsQListView.cpp | 12 ++++++------ GUI/View/JobControl/JobListing.cpp | 18 +++++++++--------- GUI/View/Sample/SamplesQListView.cpp | 8 ++++---- GUI/View/Tuning/FitParameterWidget.cpp | 4 ++-- GUI/View/Tuning/ParameterBackupWidget.cpp | 2 +- GUI/View/Tuning/ParameterTuningWidget.cpp | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/GUI/Model/Device/InstrumentsSet.h b/GUI/Model/Device/InstrumentsSet.h index d517efdb12d..cad9bbca1ad 100644 --- a/GUI/Model/Device/InstrumentsSet.h +++ b/GUI/Model/Device/InstrumentsSet.h @@ -62,7 +62,7 @@ public: QString suggestInstrumentName(const QString& baseName) const; QStringList instrumentNames() const; - int selectedIndex() const { return m_current_index; } + int currentIndex() const { return m_current_index; } void setSelectedIndex(int newIndex) { m_current_index = newIndex; } //! Set an instrument's name and emit the respective signal. diff --git a/GUI/Model/Files/DatafilesSet.h b/GUI/Model/Files/DatafilesSet.h index 81ab0e823c7..d1f83a4ae94 100644 --- a/GUI/Model/Files/DatafilesSet.h +++ b/GUI/Model/Files/DatafilesSet.h @@ -52,7 +52,7 @@ public: QStringList realItemNames() const; - int selectedIndex() const { return m_current_index; } + int currentIndex() const { return m_current_index; } void setSelectedIndex(int index) { m_current_index = index; } int selectedRank() const { return m_selected_rank; } diff --git a/GUI/Model/Job/ParameterTreeItems.h b/GUI/Model/Job/ParameterTreeItems.h index 009018a283f..6f027d3d756 100644 --- a/GUI/Model/Job/ParameterTreeItems.h +++ b/GUI/Model/Job/ParameterTreeItems.h @@ -108,7 +108,7 @@ public: QObject* parameterTreeRoot(); - int selectedIndex() const { return m_current_index; } + int currentIndex() const { return m_current_index; } void setSelectedIndex(int i) { m_current_index = i; } private: diff --git a/GUI/Model/Mask/MasksQModel.cpp b/GUI/Model/Mask/MasksQModel.cpp index 85cea887c75..1568f761c8d 100644 --- a/GUI/Model/Mask/MasksQModel.cpp +++ b/GUI/Model/Mask/MasksQModel.cpp @@ -117,7 +117,7 @@ const ProjectionList* MasksQModel::projnItem() const void MasksQModel::moveUp() { - for (const QModelIndex& itemIndex : m_selection_model->selectedIndexes()) { + for (const QModelIndex& itemIndex : m_selection_model->currentIndexes()) { int row = itemIndex.row(); int new_row = row - 1; if (new_row >= 0 && new_row < rowCount({})) @@ -127,7 +127,7 @@ void MasksQModel::moveUp() void MasksQModel::moveDown() { - for (const QModelIndex& itemIndex : m_selection_model->selectedIndexes()) { + for (const QModelIndex& itemIndex : m_selection_model->currentIndexes()) { int row = itemIndex.row(); int new_row = row + 1; if (new_row >= 0 && new_row < rowCount({})) @@ -140,7 +140,7 @@ void MasksQModel::moveDown() void MasksQModel::removeSelected() { while (true) { - QModelIndexList indexes = m_selection_model->selectedIndexes(); + QModelIndexList indexes = m_selection_model->currentIndexes(); if (indexes.empty()) break; removeMaskAt(indexes.back().row()); @@ -149,7 +149,7 @@ void MasksQModel::removeSelected() void MasksQModel::toggleMaskValue() { - for (auto itemIndex : maskSelectionModel()->selectedIndexes()) + for (auto itemIndex : maskSelectionModel()->currentIndexes()) if (MaskItem* item = itemForIndex(itemIndex)) item->setMaskValue(!item->maskValue()); } diff --git a/GUI/Model/Sample/SamplesSet.h b/GUI/Model/Sample/SamplesSet.h index aa5643cbeb5..8ecb328f713 100644 --- a/GUI/Model/Sample/SamplesSet.h +++ b/GUI/Model/Sample/SamplesSet.h @@ -38,7 +38,7 @@ public: void writeTo(QXmlStreamWriter* w) const; void readFrom(QXmlStreamReader* r); - int selectedIndex() const { return m_current_index; } + int currentIndex() const { return m_current_index; } void setSelectedIndex(int newIndex) { m_current_index = newIndex; } private: diff --git a/GUI/View/Data/DatafilesSelector.cpp b/GUI/View/Data/DatafilesSelector.cpp index 95d95c2a679..6293fd3a54a 100644 --- a/GUI/View/Data/DatafilesSelector.cpp +++ b/GUI/View/Data/DatafilesSelector.cpp @@ -168,7 +168,7 @@ void DatafilesSelector::setCurrentDatafileItem(DatafileItem* item) void DatafilesSelector::restoreSelection() { - int lastIndex = gDoc->realModel()->selectedIndex(); + int lastIndex = gDoc->realModel()->currentIndex(); int lastRank = gDoc->realModel()->selectedRank(); QModelIndex lastUsedIndex = m_tree_model->index(lastIndex, 0, m_tree_model->indexOfHeadline(lastRank)); diff --git a/GUI/View/Instrument/InstrumentsQListView.cpp b/GUI/View/Instrument/InstrumentsQListView.cpp index 9db70970258..deef94531b5 100644 --- a/GUI/View/Instrument/InstrumentsQListView.cpp +++ b/GUI/View/Instrument/InstrumentsQListView.cpp @@ -84,7 +84,7 @@ QSize InstrumentsQListView::minimumSizeHint() const InstrumentItem* InstrumentsQListView::currentInstrumentItem() const { - const QModelIndexList indexes = selectionModel()->selectedIndexes(); + const QModelIndexList indexes = selectionModel()->currentIndexes(); if (!indexes.empty()) return m_model->instrumentItemForIndex(indexes.front()); return nullptr; @@ -94,7 +94,7 @@ void InstrumentsQListView::onItemSelectionChanged() { updateActions(); - QModelIndexList indexes = selectionModel()->selectedIndexes(); + QModelIndexList indexes = selectionModel()->currentIndexes(); if (!indexes.empty()) { QModelIndex current = indexes.front(); gDoc->instrumentsSet()->setSelectedIndex(current.row()); @@ -130,7 +130,7 @@ void InstrumentsQListView::onNewDepthprobe() //! Removes currently selected instrument. void InstrumentsQListView::onRemove() { - QModelIndexList indexes = selectionModel()->selectedIndexes(); + QModelIndexList indexes = selectionModel()->currentIndexes(); if (!indexes.empty()) { m_model->removeInstrument(indexes.front()); @@ -141,7 +141,7 @@ void InstrumentsQListView::onRemove() //! Makes a copy of the currently selected instrument. void InstrumentsQListView::onCopy() { - QModelIndexList indexes = selectionModel()->selectedIndexes(); + QModelIndexList indexes = selectionModel()->currentIndexes(); if (!indexes.empty()) { QModelIndex idx = m_model->copyInstrument(indexes.front()); selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); @@ -150,7 +150,7 @@ void InstrumentsQListView::onCopy() void InstrumentsQListView::onStoreInLibrary() const { - QModelIndex idx = selectionModel()->selectedIndexes().front(); + QModelIndex idx = selectionModel()->currentIndexes().front(); InstrumentItem* ii = m_model->instrumentItemForIndex(idx); if (!ii) return; @@ -206,7 +206,7 @@ void InstrumentsQListView::ensureItemSelected() void InstrumentsQListView::restoreSelection() { - int lastUsed = gDoc->instrumentsSet()->selectedIndex(); + int lastUsed = gDoc->instrumentsSet()->currentIndex(); if (lastUsed >= 0 && lastUsed < m_model->rowCount()) { QModelIndex lastUsedIndex = m_model->index(lastUsed, 0, QModelIndex()); selectionModel()->select(lastUsedIndex, QItemSelectionModel::ClearAndSelect); diff --git a/GUI/View/JobControl/JobListing.cpp b/GUI/View/JobControl/JobListing.cpp index 06f40cca7d2..aa3f63cac16 100644 --- a/GUI/View/JobControl/JobListing.cpp +++ b/GUI/View/JobControl/JobListing.cpp @@ -110,7 +110,7 @@ JobListing::JobListing(JobsSet* jobs, QWidget* parent, Qt::WindowFlags f) QVector<JobItem*> JobListing::selectedJobItems() const { QVector<JobItem*> jobs; - for (const QModelIndex& index : m_list_view->selectionModel()->selectedIndexes()) + for (const QModelIndex& index : m_list_view->selectionModel()->currentIndexes()) jobs.push_back(m_model->jobItemForIndex(index)); return jobs; } @@ -118,7 +118,7 @@ QVector<JobItem*> JobListing::selectedJobItems() const void JobListing::selectJob(JobItem* job) { QModelIndex idx = m_model->indexForJob(job); - QModelIndexList selected = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList selected = m_list_view->selectionModel()->currentIndexes(); // Already selected, but we still will emit the signal to notify widgets. // To handle the case, when the job was selected before it completed (and some stack widgets @@ -139,7 +139,7 @@ void JobListing::onItemSelectionChanged() { updateActions(); - QModelIndexList selected = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList selected = m_list_view->selectionModel()->currentIndexes(); if (selected.size() == 1) gDoc->jobsSet()->setJobIndex(selected.first().row()); @@ -157,21 +157,21 @@ void JobListing::onJobsQModelDataChanged(const QModelIndex& topLeft, const QMode void JobListing::onRun() { - for (const QModelIndex& index : m_list_view->selectionModel()->selectedIndexes()) + for (const QModelIndex& index : m_list_view->selectionModel()->currentIndexes()) m_model->launchJob(index); gDoc->setModified(); } void JobListing::onCancel() { - for (const QModelIndex& index : m_list_view->selectionModel()->selectedIndexes()) + for (const QModelIndex& index : m_list_view->selectionModel()->currentIndexes()) m_model->cancelJob(index); gDoc->setModified(); } void JobListing::onRemove() { - QModelIndexList indexes = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_list_view->selectionModel()->currentIndexes(); ASSERT(!indexes.isEmpty()); std::sort(indexes.begin(), indexes.end(), row_descending); for (const QModelIndex& index : indexes) @@ -185,7 +185,7 @@ void JobListing::onRemove() void JobListing::equalizeSelectedToJob(JobItem* srcJob) { - QModelIndexList indexes = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_list_view->selectionModel()->currentIndexes(); Data2DItem* srcData = srcJob->data2DItem(); if (!srcData) @@ -213,7 +213,7 @@ void JobListing::showContextMenu(const QPoint&) menu.addSeparator(); m_equalize_menu->clear(); - QModelIndexList indexes = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_list_view->selectionModel()->currentIndexes(); if (indexes.size() > 1) { std::sort(indexes.begin(), indexes.end(), row_ascending); for (const QModelIndex& index : indexes) { @@ -235,7 +235,7 @@ void JobListing::showContextMenu(const QPoint&) void JobListing::updateActions() { - QModelIndexList indexes = m_list_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_list_view->selectionModel()->currentIndexes(); struct IsRunningOrFitting { JobsQModel* m_model; diff --git a/GUI/View/Sample/SamplesQListView.cpp b/GUI/View/Sample/SamplesQListView.cpp index 0ad13721478..cc73f483dc9 100644 --- a/GUI/View/Sample/SamplesQListView.cpp +++ b/GUI/View/Sample/SamplesQListView.cpp @@ -198,13 +198,13 @@ void SamplesQListView::onCurrentChanged(const QModelIndex& index) void SamplesQListView::restoreSelection() { - int selected = gDoc->sampleModel()->selectedIndex(); + int selected = gDoc->sampleModel()->currentIndex(); if (selected < 0 || selected >= m_model->rowCount()) selected = m_model->rowCount() - 1; - QModelIndex selectedIndex = m_model->index(selected, 0, QModelIndex()); - if (selectedIndex.isValid()) { - selectionModel()->select(selectedIndex, QItemSelectionModel::ClearAndSelect); + QModelIndex currentIndex = m_model->index(selected, 0, QModelIndex()); + if (currentIndex.isValid()) { + selectionModel()->select(currentIndex, QItemSelectionModel::ClearAndSelect); setCurrentSample(gDoc->sampleModel()->sampleItems()[selected]); } } diff --git a/GUI/View/Tuning/FitParameterWidget.cpp b/GUI/View/Tuning/FitParameterWidget.cpp index 216e3f12439..ae0f5741830 100644 --- a/GUI/View/Tuning/FitParameterWidget.cpp +++ b/GUI/View/Tuning/FitParameterWidget.cpp @@ -314,7 +314,7 @@ void FitParameterWidget::setActionsEnabled(bool value) QVector<FitParameterItem*> FitParameterWidget::selectedFitParameterItems() { QVector<FitParameterItem*> result; - QModelIndexList indexes = m_tree_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_tree_view->selectionModel()->currentIndexes(); for (auto index : indexes) { auto* item = static_cast<QObject*>(index.internalPointer()); if (auto* fitParItem = dynamic_cast<FitParameterItem*>(item)) @@ -340,7 +340,7 @@ QVector<FitParameterItem*> FitParameterWidget::emptyFitParameterItems() QStringList FitParameterWidget::selectedFitParameterLinks() { QStringList result; - QModelIndexList indexes = m_tree_view->selectionModel()->selectedIndexes(); + QModelIndexList indexes = m_tree_view->selectionModel()->currentIndexes(); for (QModelIndex index : indexes) { auto* item = static_cast<QObject*>(index.internalPointer()); if (auto* linkItem = dynamic_cast<LinkItem*>(item)) diff --git a/GUI/View/Tuning/ParameterBackupWidget.cpp b/GUI/View/Tuning/ParameterBackupWidget.cpp index 7d022dd57aa..9c611ccb7fc 100644 --- a/GUI/View/Tuning/ParameterBackupWidget.cpp +++ b/GUI/View/Tuning/ParameterBackupWidget.cpp @@ -133,7 +133,7 @@ void ParameterBackupWidget::fillCombo() { disconnect(m_combo, nullptr, nullptr, nullptr); - int index = m_container->selectedIndex(); + int index = m_container->currentIndex(); m_combo->clear(); m_combo->addItems(m_container->backupTitles()); if (index >= 0) { diff --git a/GUI/View/Tuning/ParameterTuningWidget.cpp b/GUI/View/Tuning/ParameterTuningWidget.cpp index 499575ad01b..1082f0de07a 100644 --- a/GUI/View/Tuning/ParameterTuningWidget.cpp +++ b/GUI/View/Tuning/ParameterTuningWidget.cpp @@ -148,7 +148,7 @@ QItemSelectionModel* ParameterTuningWidget::selectionModel() QVector<ParameterItem*> ParameterTuningWidget::selectedParameterItems() { QVector<ParameterItem*> result; - for (auto index : selectionModel()->selectedIndexes()) + for (auto index : selectionModel()->currentIndexes()) if (ParameterItem* parItem = m_parameter_tuning_model->getParameterItem(index)) result.push_back(parItem); -- GitLab