From 75d59692658b43dfd7bcd7782d1b7c14c6760a0f Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Wed, 24 Jan 2024 08:50:46 +0100 Subject: [PATCH] rename class and sources GUI/View/Instrument/InstrumentListing -> GUI/View/Instrument/InstrumentsQListView --- GUI/View/Instrument/InstrumentView.cpp | 6 +- GUI/View/Instrument/InstrumentView.h | 4 +- ...ntListing.cpp => InstrumentsQListView.cpp} | 60 +++++++++---------- ...rumentListing.h => InstrumentsQListView.h} | 16 ++--- GUI/styles/Base.stylesheet | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) rename GUI/View/Instrument/{InstrumentListing.cpp => InstrumentsQListView.cpp} (85%) rename GUI/View/Instrument/{InstrumentListing.h => InstrumentsQListView.h} (81%) diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 66fcf259d4c..41237e57d7e 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -19,7 +19,7 @@ #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/DepthprobeInstrumentEditor.h" #include "GUI/View/Instrument/GISASInstrumentEditor.h" -#include "GUI/View/Instrument/InstrumentListing.h" +#include "GUI/View/Instrument/InstrumentsQListView.h" #include "GUI/View/Instrument/OffspecInstrumentEditor.h" #include "GUI/View/Instrument/SpecularInstrumentEditor.h" #include "GUI/View/Layout/ApplicationSettings.h" @@ -30,7 +30,7 @@ #include <QTextEdit> InstrumentView::InstrumentView() - : m_listing(new InstrumentListing) + : m_listing(new InstrumentsQListView) , m_scroll_area(new QScrollArea) { auto* layout = new QVBoxLayout(this); @@ -60,7 +60,7 @@ InstrumentView::InstrumentView() toolbar->addActions(m_listing->toolbarActions()); - connect(m_listing, &InstrumentListing::instrumentSelected, this, + connect(m_listing, &InstrumentsQListView::instrumentSelected, this, &InstrumentView::createWidgetsForCurrentInstrument); // Initial state diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h index c8c4f041300..b33fda46f98 100644 --- a/GUI/View/Instrument/InstrumentView.h +++ b/GUI/View/Instrument/InstrumentView.h @@ -20,7 +20,7 @@ #include <QWidget> class InstrumentItem; -class InstrumentListing; +class InstrumentsQListView; class InstrumentView : public QWidget { Q_OBJECT @@ -39,7 +39,7 @@ private: void onInstrumentChangedFromExternal(const InstrumentItem* instrument); void onSingleInstrumentModeChanged(bool newState); - InstrumentListing* m_listing; + InstrumentsQListView* m_listing; QScrollArea* m_scroll_area; QCheckBox* gisasCheck; QCheckBox* offspecCheck; diff --git a/GUI/View/Instrument/InstrumentListing.cpp b/GUI/View/Instrument/InstrumentsQListView.cpp similarity index 85% rename from GUI/View/Instrument/InstrumentListing.cpp rename to GUI/View/Instrument/InstrumentsQListView.cpp index 959d7d931d8..9002a7b8656 100644 --- a/GUI/View/Instrument/InstrumentListing.cpp +++ b/GUI/View/Instrument/InstrumentsQListView.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Instrument/InstrumentListing.cpp -//! @brief Implements class InstrumentListing. +//! @file GUI/View/Instrument/InstrumentsQListView.cpp +//! @brief Implements class InstrumentsQListView. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,7 +12,7 @@ // // ************************************************************************************************ -#include "GUI/View/Instrument/InstrumentListing.h" +#include "GUI/View/Instrument/InstrumentsQListView.h" #include "GUI/Model/Device/InstrumentLibrary.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/InstrumentLibraryDialog.h" @@ -22,7 +22,7 @@ #include <QMessageBox> #include <QVBoxLayout> -InstrumentListing::InstrumentListing() +InstrumentsQListView::InstrumentsQListView() : m_instrument_library(std::make_unique<InstrumentLibrary>()) , m_model(new InstrumentsQListModel) , m_separator_action1(new QAction(this)) @@ -42,26 +42,26 @@ InstrumentListing::InstrumentListing() m_new_gisas_action = new QAction("New GISAS", this); m_new_gisas_action->setIcon(QIcon(":/images/shape-square-plus.svg")); m_new_gisas_action->setToolTip("Add new GISAS instrument with default settings"); - connect(m_new_gisas_action, &QAction::triggered, this, &InstrumentListing::onNewGisas); + connect(m_new_gisas_action, &QAction::triggered, this, &InstrumentsQListView::onNewGisas); addAction(m_new_gisas_action); m_new_offspec_action = new QAction("New off-specular", this); m_new_offspec_action->setIcon(QIcon(":/images/shape-square-plus.svg")); m_new_offspec_action->setToolTip("Add new off-specular instrument with default settings"); - connect(m_new_offspec_action, &QAction::triggered, this, &InstrumentListing::onNewOffspec); + connect(m_new_offspec_action, &QAction::triggered, this, &InstrumentsQListView::onNewOffspec); addAction(m_new_offspec_action); m_new_specular_action = new QAction("New specular", this); m_new_specular_action->setIcon(QIcon(":/images/shape-square-plus.svg")); m_new_specular_action->setToolTip("Add new specular instrument with default settings"); - connect(m_new_specular_action, &QAction::triggered, this, &InstrumentListing::onNewSpecular); + connect(m_new_specular_action, &QAction::triggered, this, &InstrumentsQListView::onNewSpecular); addAction(m_new_specular_action); m_new_depthprobe_action = new QAction("New depth probe", this); m_new_depthprobe_action->setIcon(QIcon(":/images/shape-square-plus.svg")); m_new_depthprobe_action->setToolTip("Add new depth probe instrument with default settings"); connect(m_new_depthprobe_action, &QAction::triggered, this, - &InstrumentListing::onNewDepthprobe); + &InstrumentsQListView::onNewDepthprobe); addAction(m_new_depthprobe_action); m_separator_action1->setSeparator(true); @@ -70,13 +70,13 @@ InstrumentListing::InstrumentListing() m_remove_action = new QAction("Remove", this); m_remove_action->setIcon(QIcon(":/images/delete.svg")); m_remove_action->setToolTip("Remove selected instrument"); - connect(m_remove_action, &QAction::triggered, this, &InstrumentListing::onRemove); + connect(m_remove_action, &QAction::triggered, this, &InstrumentsQListView::onRemove); addAction(m_remove_action); m_copy_action = new QAction("Copy", this); m_copy_action->setIcon(QIcon(":/images/content-copy.svg")); m_copy_action->setToolTip("Make a copy of the selected instrument"); - connect(m_copy_action, &QAction::triggered, this, &InstrumentListing::onCopy); + connect(m_copy_action, &QAction::triggered, this, &InstrumentsQListView::onCopy); addAction(m_copy_action); m_separator_action2->setSeparator(true); @@ -86,14 +86,14 @@ InstrumentListing::InstrumentListing() m_store_in_library_action->setIcon(QIcon(":/images/library.svg")); m_store_in_library_action->setToolTip("Store instrument in library"); connect(m_store_in_library_action, &QAction::triggered, this, - &InstrumentListing::onStoreInLibrary); + &InstrumentsQListView::onStoreInLibrary); addAction(m_store_in_library_action); m_load_from_library_action = new QAction("Choose from library", this); m_load_from_library_action->setIcon(QIcon(":/images/library.svg")); m_load_from_library_action->setToolTip("Load an instrument from the instrument library"); connect(m_load_from_library_action, &QAction::triggered, this, - &InstrumentListing::onLoadFromLibrary); + &InstrumentsQListView::onLoadFromLibrary); addAction(m_load_from_library_action); setContextMenuPolicy(Qt::ActionsContextMenu); @@ -102,25 +102,25 @@ InstrumentListing::InstrumentListing() restoreSelection(); connect(selectionModel(), &QItemSelectionModel::selectionChanged, this, - &InstrumentListing::onItemSelectionChanged); + &InstrumentsQListView::onItemSelectionChanged); } -InstrumentListing::~InstrumentListing() +InstrumentsQListView::~InstrumentsQListView() { m_instrument_library->saveIfModified(); } -QSize InstrumentListing::sizeHint() const +QSize InstrumentsQListView::sizeHint() const { return {170, 400}; } -QSize InstrumentListing::minimumSizeHint() const +QSize InstrumentsQListView::minimumSizeHint() const { return {96, 200}; } -QList<QAction*> InstrumentListing::toolbarActions() const +QList<QAction*> InstrumentsQListView::toolbarActions() const { return {m_new_gisas_action, m_new_offspec_action, @@ -134,7 +134,7 @@ QList<QAction*> InstrumentListing::toolbarActions() const m_load_from_library_action}; } -InstrumentItem* InstrumentListing::currentInstrumentItem() const +InstrumentItem* InstrumentsQListView::currentInstrumentItem() const { const QModelIndexList indexes = selectionModel()->selectedIndexes(); if (!indexes.empty()) @@ -142,7 +142,7 @@ InstrumentItem* InstrumentListing::currentInstrumentItem() const return nullptr; } -void InstrumentListing::onItemSelectionChanged() +void InstrumentsQListView::onItemSelectionChanged() { updateActions(); @@ -155,32 +155,32 @@ void InstrumentListing::onItemSelectionChanged() emit instrumentSelected(nullptr); } -void InstrumentListing::onNewGisas() +void InstrumentsQListView::onNewGisas() { QModelIndex idx = m_model->addNewGISASInstrument(); selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); } -void InstrumentListing::onNewOffspec() +void InstrumentsQListView::onNewOffspec() { QModelIndex idx = m_model->addNewOffspecInstrument(); selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); } -void InstrumentListing::onNewSpecular() +void InstrumentsQListView::onNewSpecular() { QModelIndex idx = m_model->addNewSpecularInstrument(); selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); } -void InstrumentListing::onNewDepthprobe() +void InstrumentsQListView::onNewDepthprobe() { QModelIndex idx = m_model->addNewDepthprobeInstrument(); selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); } //! Removes currently selected instrument. -void InstrumentListing::onRemove() +void InstrumentsQListView::onRemove() { QModelIndexList indexes = selectionModel()->selectedIndexes(); if (!indexes.empty()) { @@ -191,7 +191,7 @@ void InstrumentListing::onRemove() } //! Makes a copy of the currently selected instrument. -void InstrumentListing::onCopy() +void InstrumentsQListView::onCopy() { QModelIndexList indexes = selectionModel()->selectedIndexes(); if (!indexes.empty()) { @@ -200,7 +200,7 @@ void InstrumentListing::onCopy() } } -void InstrumentListing::onStoreInLibrary() +void InstrumentsQListView::onStoreInLibrary() { if (!selectionModel()->hasSelection()) return; @@ -212,7 +212,7 @@ void InstrumentListing::onStoreInLibrary() dlg.execAdd(*instrument); } -void InstrumentListing::onLoadFromLibrary() +void InstrumentsQListView::onLoadFromLibrary() { if (m_instrument_library->isEmpty()) { QMessageBox::information(GUI::Global::mainWindow, "Select from library", @@ -230,7 +230,7 @@ void InstrumentListing::onLoadFromLibrary() selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); } -void InstrumentListing::updateActions() +void InstrumentsQListView::updateActions() { bool enabled = selectionModel()->hasSelection(); m_remove_action->setEnabled(enabled); @@ -238,7 +238,7 @@ void InstrumentListing::updateActions() m_store_in_library_action->setEnabled(enabled); } -void InstrumentListing::ensureItemSelected() +void InstrumentsQListView::ensureItemSelected() { if (!selectionModel()->hasSelection() && m_model->rowCount()) { QModelIndex last = m_model->index(m_model->rowCount() - 1, 0, QModelIndex()); @@ -246,7 +246,7 @@ void InstrumentListing::ensureItemSelected() } } -void InstrumentListing::restoreSelection() +void InstrumentsQListView::restoreSelection() { int lastUsed = gDoc->instrumentsSet()->selectedIndex(); if (lastUsed >= 0 && lastUsed < m_model->rowCount()) { diff --git a/GUI/View/Instrument/InstrumentListing.h b/GUI/View/Instrument/InstrumentsQListView.h similarity index 81% rename from GUI/View/Instrument/InstrumentListing.h rename to GUI/View/Instrument/InstrumentsQListView.h index 5e741ce0b59..53e89efa133 100644 --- a/GUI/View/Instrument/InstrumentListing.h +++ b/GUI/View/Instrument/InstrumentsQListView.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Instrument/InstrumentListing.h -//! @brief Defines class InstrumentListing. +//! @file GUI/View/Instrument/InstrumentsQListView.h +//! @brief Defines class InstrumentsQListView. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H -#define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H +#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTSQLISTVIEW_H +#define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTSQLISTVIEW_H #include <QListView> @@ -23,11 +23,11 @@ class InstrumentsQListModel; //! Instrument selector on the left side of InstrumentView. -class InstrumentListing : public QListView { +class InstrumentsQListView : public QListView { Q_OBJECT public: - InstrumentListing(); - ~InstrumentListing(); + InstrumentsQListView(); + ~InstrumentsQListView(); QSize sizeHint() const override; QSize minimumSizeHint() const override; @@ -72,4 +72,4 @@ private: QAction* m_load_from_library_action; }; -#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H +#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTSQLISTVIEW_H diff --git a/GUI/styles/Base.stylesheet b/GUI/styles/Base.stylesheet index b0b91ba4e8d..101c6d4a28a 100644 --- a/GUI/styles/Base.stylesheet +++ b/GUI/styles/Base.stylesheet @@ -286,7 +286,7 @@ QListView::item .QWidget { background-color: transparent; } -/* Listing (from InstrumentListing.cpp before 2297966a5 31oct23 11:59) +/* Listing (from InstrumentsQListView.cpp before 2297966a5 31oct23 11:59) " selection-background-color : rgb(98,100,105); \n" " selection-color: rgb(255,255,255);\n" " border: 1px solid rgb(98,100,105);\n" -- GitLab