diff --git a/src/blackgui/components/dbstashcomponent.cpp b/src/blackgui/components/dbstashcomponent.cpp index f8a4aea94..cbef03d42 100644 --- a/src/blackgui/components/dbstashcomponent.cpp +++ b/src/blackgui/components/dbstashcomponent.cpp @@ -56,10 +56,6 @@ namespace BlackGui ui(new Ui::CDbStashComponent) { ui->setupUi(this); - ui->tvp_StashAircraftModels->setAircraftModelMode(CAircraftModelListModel::StashModel); - ui->tvp_StashAircraftModels->allowDragDrop(false, true); - ui->tvp_StashAircraftModels->setAcceptedMetaTypeIds(); - ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuLoadAndSave); connect(ui->pb_Unstash, &QPushButton::pressed, this, &CDbStashComponent::onUnstashPressed); connect(ui->pb_Validate, &QPushButton::pressed, this, &CDbStashComponent::onValidatePressed); @@ -75,6 +71,10 @@ namespace BlackGui connect(ui->pb_Distributor, &QPushButton::pressed, this, &CDbStashComponent::copyOverValuesToSelectedModels); connect(ui->pb_Model, &QPushButton::pressed, this, &CDbStashComponent::modifyModelDialog); + ui->tvp_StashAircraftModels->setAircraftModelMode(CAircraftModelListModel::StashModel); + ui->tvp_StashAircraftModels->allowDragDrop(false, true, true); + ui->tvp_StashAircraftModels->setAcceptedMetaTypeIds(); + ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuLoadAndSave); ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows); ui->tvp_StashAircraftModels->setHighlightModelStrings(true); ui->tvp_StashAircraftModels->setHighlightModelStringsColor(Qt::red); @@ -381,6 +381,7 @@ namespace BlackGui ui->pb_Validate->setEnabled(e); ui->pb_RemoveInvalid->setEnabled(e); ui->pb_Model->setEnabled(e); + ui->pb_Publish->setEnabled(e); this->onUserChanged(); } diff --git a/src/blackgui/dropbase.cpp b/src/blackgui/dropbase.cpp index 08bea1ce2..9dcaad5c7 100644 --- a/src/blackgui/dropbase.cpp +++ b/src/blackgui/dropbase.cpp @@ -12,6 +12,7 @@ #include #include +#include using namespace BlackMisc; @@ -30,24 +31,22 @@ namespace BlackGui m_acceptedMetaTypes.append(id); } - bool CDropBase::isDropAllowed() const - { - return m_allowDrop; - } - - void CDropBase::allowDrop(bool allowed) - { - this->m_allowDrop = allowed; - } - bool CDropBase::acceptDrop(const QMimeData *mime) const { - Q_ASSERT_X(!this->m_acceptedMetaTypes.isEmpty(), Q_FUNC_INFO, "no accepted meta type ids"); + if (!mime) { return false; } + if (!m_allowDrop) { return false; } if (m_acceptedMetaTypes.isEmpty()) { return false; } - if (!m_allowDrop || !CGuiUtility::hasSwiftVariantMimeType(mime)) { return false; } + + if (m_acceptJsonFile && CGuiUtility::isMimeRepresentingReadableJsonFile(mime)) + { + // further checks could go here + return true; + } + + if (!CGuiUtility::hasSwiftVariantMimeType(mime)) { return false; } const int metaTypeId = CGuiUtility::metaTypeIdFromSwiftDragAndDropData(mime); if (metaTypeId == QMetaType::UnknownType) { return false; } - const bool accept = m_acceptedMetaTypes.contains(metaTypeId); + const bool accept = m_acceptedMetaTypes.contains(metaTypeId); return accept; } @@ -55,5 +54,4 @@ namespace BlackGui { return CGuiUtility::fromSwiftDragAndDropData(mime); } - } // ns diff --git a/src/blackgui/dropbase.h b/src/blackgui/dropbase.h index 1d9f9a68b..97434e921 100644 --- a/src/blackgui/dropbase.h +++ b/src/blackgui/dropbase.h @@ -13,8 +13,8 @@ #include "blackgui/blackguiexport.h" #include "blackmisc/variant.h" #include - -class QMimeData; +#include +#include namespace BlackGui { @@ -30,11 +30,17 @@ namespace BlackGui //! Accepted ids void addAcceptedMetaTypeId(int id); - //! Drop allowed - virtual bool isDropAllowed() const; + //! Drop allowed? + virtual bool isDropAllowed() const { return m_allowDrop; } + + //! File drop allowed? + virtual bool isJsonFileDropAllowed() const { return m_acceptJsonFile; } //! Drop allowed - virtual void allowDrop(bool allowed); + virtual void allowDrop(bool allowed) { m_allowDrop = allowed; } + + //! Allow JSON file drop + virtual void allowFileDrop(bool allow) { m_acceptJsonFile = allow; } //! Accept drop? bool acceptDrop(const QMimeData *mime) const; @@ -42,12 +48,17 @@ namespace BlackGui //! Mime data to CVariant (normally encapsulating a value object) BlackMisc::CVariant toCVariant(const QMimeData *mime) const; + //! Dtor + virtual ~CDropBase() {} + protected: + //! Ctor CDropBase(); private: - bool m_allowDrop = true; //!< dropping allowed? - QList m_acceptedMetaTypes; //!< accepted meta types + bool m_allowDrop = true; //!< dropping allowed? + bool m_acceptJsonFile = false; //!< accept JSON files + QList m_acceptedMetaTypes; //!< accepted meta types }; } // ns diff --git a/src/blackgui/dropsite.cpp b/src/blackgui/dropsite.cpp index 613614105..cd9661317 100644 --- a/src/blackgui/dropsite.cpp +++ b/src/blackgui/dropsite.cpp @@ -32,13 +32,13 @@ namespace BlackGui this->setAcceptDrops(true); this->setTextFormat(Qt::RichText); this->setInfoText("drop data here"); - this->ps_onStyleSheetsChanged(); - connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDropSite::ps_onStyleSheetsChanged); + this->onStyleSheetsChanged(); + connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDropSite::onStyleSheetsChanged); } void CDropSite::setInfoText(const QString &dropSiteText) { - this->m_infoText = dropSiteText; + m_infoText = dropSiteText; this->resetText(); } @@ -51,7 +51,7 @@ namespace BlackGui void CDropSite::resetText() { - const QString html = "  " + this->m_infoText.toHtmlEscaped(); + const QString html = "  " + m_infoText.toHtmlEscaped(); setText(html); } @@ -87,7 +87,7 @@ namespace BlackGui this->resetText(); } - void CDropSite::ps_onStyleSheetsChanged() + void CDropSite::onStyleSheetsChanged() { // style sheet changes go here } diff --git a/src/blackgui/dropsite.h b/src/blackgui/dropsite.h index 23a9ebc65..a63cb6eb0 100644 --- a/src/blackgui/dropsite.h +++ b/src/blackgui/dropsite.h @@ -67,11 +67,10 @@ namespace BlackGui //! \copydoc QWidget::dropEvent virtual void dropEvent(QDropEvent *event) override; - private slots: - //! Style has been changed - void ps_onStyleSheetsChanged(); - private: + //! Style has been changed + void onStyleSheetsChanged(); + //! Clear void resetText(); diff --git a/src/blackgui/guiutility.cpp b/src/blackgui/guiutility.cpp index 7bb39d730..997b51c59 100644 --- a/src/blackgui/guiutility.cpp +++ b/src/blackgui/guiutility.cpp @@ -10,6 +10,7 @@ #include "blackgui/enableforframelesswindow.h" #include "blackgui/guiutility.h" #include "blackgui/overlaymessagesframe.h" +#include "blackmisc/icon.h" #include "blackmisc/verify.h" #include @@ -225,6 +226,31 @@ namespace BlackGui return m; } + QFileInfo CGuiUtility::representedMimeFile(const QMimeData *mime) + { + if (!mime->hasText()) { return QFileInfo(); } + const QString candidate = mime->text(); + if (candidate.isEmpty()) { return QFileInfo(); } + if (!candidate.contains("://")) { return QFileInfo(candidate); } + QUrl url(candidate); + const QString localFile = url.toLocalFile(); + return QFileInfo(localFile); + } + + bool CGuiUtility::isMimeRepresentingReadableFile(const QMimeData *mime) + { + const QFileInfo fi = CGuiUtility::representedMimeFile(mime); + return fi.isReadable(); + } + + bool CGuiUtility::isMimeRepresentingReadableJsonFile(const QMimeData *mime) + { + const QFileInfo fi = CGuiUtility::representedMimeFile(mime); + if (!fi.isReadable()) { return false; } + const QString fn = fi.fileName(); + return fn.endsWith("json", Qt::CaseInsensitive); + } + void CGuiUtility::checkBoxReadOnly(QCheckBox *checkBox, bool readOnly) { static const QCheckBox defaultBox; @@ -519,4 +545,26 @@ namespace BlackGui w->setMinimumWidth(qMin(minW, w->minimumWidth())); w->setMinimumHeight(qMin(minH, w->minimumHeight())); } + + QString CGuiUtility::asSimpleHtmlImageWidth(const CIcon &icon, int width) + { + if (!icon.hasFileResourcePath()) return QStringLiteral(""); + const QString p = icon.getFileResourcePath(); + + static const QString htmlNoWidth(""); + static const QString htmlWidth(""); + + if (width < 0) { return htmlNoWidth.arg(p); } + return htmlWidth.arg(p, QString::number(width)); + } + + QString CGuiUtility::asSimpleHtmlImageHeight(const CIcon &icon, int height) + { + if (height < 0) { return CGuiUtility::asSimpleHtmlImageWidth(icon); } + if (!icon.hasFileResourcePath()) return QStringLiteral(""); + const QString p = icon.getFileResourcePath(); + + static const QString htmlHeight(""); + return htmlHeight.arg(p, QString::number(height)); + } } // ns diff --git a/src/blackgui/guiutility.h b/src/blackgui/guiutility.h index 7ea258550..9338f8ac7 100644 --- a/src/blackgui/guiutility.h +++ b/src/blackgui/guiutility.h @@ -33,6 +33,7 @@ class QMimeData; class QTabWidget; class QGraphicsOpacityEffect; +namespace BlackMisc { class CIcon; } namespace BlackGui { class CEnableForFramelessWindow; @@ -92,6 +93,15 @@ namespace BlackGui //! Meta type id from dropped data static int metaTypeIdFromSwiftDragAndDropData(const QMimeData *mime); + //! Represented file if any + static QFileInfo representedMimeFile(const QMimeData *mime); + + //! Is representing existing file + static bool isMimeRepresentingReadableFile(const QMimeData *mime); + + //! Is representing existing JSON file + static bool isMimeRepresentingReadableJsonFile(const QMimeData *mime); + //! Find next BlackGui::COverlayMessages QFrame static COverlayMessagesFrame *nextOverlayMessageFrame(QWidget *widget, int maxLevels = 10); @@ -173,6 +183,12 @@ namespace BlackGui //! Make sure that the min.sizes to not exceed the screen resolution static void superviseMainWindowMinSizes(qreal wRatio = 0.85, qreal hRatio = 0.85); + //! CIcon as simple HTML image code segment + static QString asSimpleHtmlImageWidth(const BlackMisc::CIcon &icon, int width = -1); + + //! CIcon as simple HTML image code segment + static QString asSimpleHtmlImageHeight(const BlackMisc::CIcon &icon, int height = -1); + private: //! No constructor, use static functions only CGuiUtility() {} diff --git a/src/blackgui/models/listmodelbase.cpp b/src/blackgui/models/listmodelbase.cpp index 801db6252..611652514 100644 --- a/src/blackgui/models/listmodelbase.cpp +++ b/src/blackgui/models/listmodelbase.cpp @@ -10,13 +10,14 @@ // Drag and drop docu: // http://doc.qt.io/qt-5/model-view-programming.html#using-drag-and-drop-with-item-views -#include "blackgui/guiutility.h" #include "blackgui/models/columnformatters.h" #include "blackgui/models/listmodelbase.h" #include "blackgui/models/allmodelcontainers.h" +#include "blackgui/guiutility.h" #include "blackmisc/compare.h" #include "blackmisc/predicates.h" #include "blackmisc/propertyindex.h" +#include "blackmisc/fileutils.h" #include "blackmisc/sequence.h" #include "blackmisc/variant.h" #include "blackmisc/verify.h" @@ -27,6 +28,7 @@ #include #include #include +#include using namespace BlackMisc; using namespace BlackMisc::Aviation; @@ -193,7 +195,7 @@ namespace BlackGui this->setObjectName(translationContext); // connect - connect(this, &CListModelBaseNonTemplate::dataChanged, this, &CListModelBaseNonTemplate::ps_onDataChanged); + connect(this, &CListModelBaseNonTemplate::dataChanged, this, &CListModelBaseNonTemplate::onDataChanged); } template @@ -221,12 +223,13 @@ namespace BlackGui } template - bool CListModelBase::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) + bool CListModelBase::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) { Q_UNUSED(row); Q_UNUSED(column); - if (!this->isOrderable() || !this->acceptDrop(data)) { return false; } - const CVariant valueVariant(this->toCVariant(data)); + + if (!this->isOrderable() || !this->acceptDrop(mimeData)) { return false; } + const CVariant valueVariant(this->toCVariant(mimeData)); if (valueVariant.isValid()) { if (action == Qt::MoveAction) @@ -621,7 +624,7 @@ namespace BlackGui } template - void CListModelBase::ps_onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) + void CListModelBase::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { // underlying base class changed Q_UNUSED(topLeft); @@ -631,7 +634,7 @@ namespace BlackGui } template - void CListModelBase::ps_onChangedDigest() + void CListModelBase::onChangedDigest() { const int n = this->containerOrFilteredContainer().size(); emit this->changedDigest(); diff --git a/src/blackgui/models/listmodelbase.h b/src/blackgui/models/listmodelbase.h index 3f0eb0f51..14b30385f 100644 --- a/src/blackgui/models/listmodelbase.h +++ b/src/blackgui/models/listmodelbase.h @@ -152,14 +152,13 @@ namespace BlackGui //! Template free information, that object changed void objectChanged(const BlackMisc::CVariant &object, const BlackMisc::CPropertyIndex &changedIndex); - protected slots: + protected: //! Feedback when QStandardItemModel::dataChanged was called - virtual void ps_onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) = 0; + virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) = 0; //! Digest signal - virtual void ps_onChangedDigest() = 0; + virtual void onChangedDigest() = 0; - protected: //! Constructor //! \param translationContext I18N context //! \param parent @@ -172,7 +171,7 @@ namespace BlackGui Qt::DropActions m_dropActions = Qt::IgnoreAction; //!< drop actions private: - BlackMisc::CDigestSignal m_dsModelsChanged { this, &CListModelBaseNonTemplate::changed, &CListModelBaseNonTemplate::ps_onChangedDigest, 500, 10 }; + BlackMisc::CDigestSignal m_dsModelsChanged { this, &CListModelBaseNonTemplate::changed, &CListModelBaseNonTemplate::onChangedDigest, 500, 10 }; }; //! List model @@ -190,7 +189,7 @@ namespace BlackGui virtual void sort(int column, Qt::SortOrder order) final override; virtual int rowCount(const QModelIndex &parentIndex = QModelIndex()) const final override; virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const final override; - virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) final override; + virtual bool dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) final override; //! @} //! \name Functions from CListModelBaseNonTemplate @@ -295,10 +294,7 @@ namespace BlackGui void takeFilterOwnership(std::unique_ptr > &filter); //! Set the selection model - void setSelectionModel(BlackGui::Models::ISelectionModel *selectionModel) - { - m_selectionModel = selectionModel; - } + void setSelectionModel(BlackGui::Models::ISelectionModel *selectionModel) { m_selectionModel = selectionModel; } protected: //! Constructor @@ -306,8 +302,8 @@ namespace BlackGui //! \name Base class overrides //! @{ - virtual void ps_onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomLeft, const QVector &roles) override; - virtual void ps_onChangedDigest() override; + virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomLeft, const QVector &roles) override; + virtual void onChangedDigest() override; //! @} //! Update filtered container diff --git a/src/blackgui/views/aircraftmodelview.cpp b/src/blackgui/views/aircraftmodelview.cpp index aaae73b69..2cc237859 100644 --- a/src/blackgui/views/aircraftmodelview.cpp +++ b/src/blackgui/views/aircraftmodelview.cpp @@ -277,7 +277,11 @@ namespace BlackGui emit requestHandlingOfStashDrop(airline); // I need to convert to stanard livery, which I can`t do here } } - } // valid mime? + } + else + { + CViewBase::dropEvent(event); + } } void CAircraftModelView::customMenu(CMenuActions &menuActions) diff --git a/src/blackgui/views/viewbase.cpp b/src/blackgui/views/viewbase.cpp index 5785dccdf..a523ca123 100644 --- a/src/blackgui/views/viewbase.cpp +++ b/src/blackgui/views/viewbase.cpp @@ -1264,7 +1264,7 @@ namespace BlackGui } template - void CViewBase::allowDragDrop(bool allowDrag, bool allowDrop) + void CViewBase::allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile) { Q_ASSERT(m_model); @@ -1273,6 +1273,7 @@ namespace BlackGui this->setDragEnabled(allowDrag); this->setDropIndicatorShown(allowDrag || allowDrop); m_model->allowDrop(allowDrop); + m_model->allowFileDrop(allowDropJsonFile); } template @@ -1282,6 +1283,19 @@ namespace BlackGui return m_model->isDropAllowed(); } + template + void CViewBase::dropEvent(QDropEvent *event) + { + if (m_model && m_model->isJsonFileDropAllowed() && CGuiUtility::isMimeRepresentingReadableJsonFile(event->mimeData())) + { + const QFileInfo fi = CGuiUtility::representedMimeFile(event->mimeData()); + const CStatusMessage msgs = this->loadJsonFile(fi.absoluteFilePath()); + Q_UNUSED(msgs); + return; + } + CViewBaseNonTemplate::dropEvent(event); + } + template bool CViewBase::acceptDrop(const QMimeData *mimeData) const { @@ -1500,15 +1514,12 @@ namespace BlackGui } } - template - CStatusMessage CViewBase::ps_loadJson() + template + CStatusMessage CViewBase::loadJsonFile(const QString &fileName) { CStatusMessage m; do { - const QString fileName = QFileDialog::getOpenFileName(nullptr, - tr("Load data file"), this->getFileDialogFileName(true), - tr("swift (*.json *.txt)")); if (fileName.isEmpty()) { m = CStatusMessage(this).error("Load canceled, no file name"); @@ -1569,6 +1580,15 @@ namespace BlackGui return m; } + template + CStatusMessage CViewBase::ps_loadJson() + { + const QString fileName = QFileDialog::getOpenFileName(nullptr, + tr("Load data file"), this->getFileDialogFileName(true), + tr("swift (*.json *.txt)")); + return this->loadJsonFile(fileName); + } + template CStatusMessage CViewBase::ps_saveJson() { diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h index 2975e5e7e..fb33112c9 100644 --- a/src/blackgui/views/viewbase.h +++ b/src/blackgui/views/viewbase.h @@ -74,7 +74,7 @@ namespace BlackGui //! Non templated base class, allows Q_OBJECT and signals / slots to be used class BLACKGUI_EXPORT CViewBaseNonTemplate : public QTableView, - public BlackGui::Components::CEnableForDockWidgetInfoArea + public Components::CEnableForDockWidgetInfoArea { Q_OBJECT @@ -164,7 +164,7 @@ namespace BlackGui virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) = 0; //! Allow to drag and/or drop value objects - virtual void allowDragDrop(bool allowDrag, bool allowDrop) = 0; + virtual void allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile = false) = 0; //! Drop allowed? virtual bool isDropAllowed() const = 0; @@ -444,6 +444,9 @@ namespace BlackGui //! Load JSON for action/menu, void return signatur void loadJsonAction(); + //! Load JSON file + virtual BlackMisc::CStatusMessage loadJsonFile(const QString &filePath) = 0; + //! Display the filter dialog void displayFilterDialog(); @@ -667,8 +670,9 @@ namespace BlackGui virtual int rowCount() const override; virtual bool isEmpty() const override; virtual bool isOrderable() const override; - virtual void allowDragDrop(bool allowDrag, bool allowDrop) override; + virtual void allowDragDrop(bool allowDrag, bool allowDrop, bool allowDropJsonFile = false) override; virtual bool isDropAllowed() const override; + virtual void dropEvent(QDropEvent *event) override; virtual bool acceptDrop(const QMimeData *mimeData) const override; virtual void setSorting(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override; virtual void sortByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex, Qt::SortOrder order = Qt::AscendingOrder) override; @@ -739,6 +743,9 @@ namespace BlackGui //! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu virtual void customMenu(Menus::CMenuActions &menuActions) override; + //! \copydoc BlackGui::Views::CViewBaseNonTemplate::customMenu + virtual BlackMisc::CStatusMessage loadJsonFile(const QString &fileName) override; + // --------------------------------------------- SLOTS start here ----------------------------------------- //! \name Slot overrides from base class diff --git a/src/blackgui/views/viewdbobjects.cpp b/src/blackgui/views/viewdbobjects.cpp index 9223e099a..027200bfd 100644 --- a/src/blackgui/views/viewdbobjects.cpp +++ b/src/blackgui/views/viewdbobjects.cpp @@ -162,7 +162,7 @@ namespace BlackGui this->m_leOrder->setValidator(this->m_validator); QWidgetAction *orderAction = new QWidgetAction(this); orderAction->setDefaultWidget(this->m_frame); - QObject::connect(this->m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects::ps_orderToLineEdit); + QObject::connect(this->m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects::orderToLineEdit); this->m_menuActions[0] = orderAction; } } @@ -171,9 +171,9 @@ namespace BlackGui this->m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder)); menuActions.addAction(this->m_menuActions[0], CMenuAction::pathViewOrder()); - this->m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::ps_orderToTop }); - this->m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::ps_orderToBottom }); - this->m_menuActions[3] = menuActions.addAction(CIcons::arrowMediumWest16(), "Freeze current order", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::ps_freezeCurrentOrder }); + this->m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::orderToTop }); + this->m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::orderToBottom }); + this->m_menuActions[3] = menuActions.addAction(CIcons::arrowMediumWest16(), "Freeze current order", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects::freezeCurrentOrder }); } CViewWithDbObjects::customMenu(menuActions); } @@ -197,13 +197,13 @@ namespace BlackGui } template - void COrderableViewWithDbObjects::ps_orderToTop() + void COrderableViewWithDbObjects::orderToTop() { this->moveSelectedItems(0); } template - void COrderableViewWithDbObjects::ps_orderToBottom() + void COrderableViewWithDbObjects::orderToBottom() { int c = this->model()->rowCount() - 1; if (c >= 0) @@ -213,7 +213,7 @@ namespace BlackGui } template - void COrderableViewWithDbObjects::ps_orderToLineEdit() + void COrderableViewWithDbObjects::orderToLineEdit() { if (this->isEmpty()) { return; } QLineEdit *le = qobject_cast(QObject::sender()); @@ -223,7 +223,7 @@ namespace BlackGui } template - void COrderableViewWithDbObjects::ps_freezeCurrentOrder() + void COrderableViewWithDbObjects::freezeCurrentOrder() { ContainerType objects = this->container(); objects.freezeOrder(); diff --git a/src/blackgui/views/viewdbobjects.h b/src/blackgui/views/viewdbobjects.h index ceb78c50a..9d628616b 100644 --- a/src/blackgui/views/viewdbobjects.h +++ b/src/blackgui/views/viewdbobjects.h @@ -80,18 +80,17 @@ namespace BlackGui //! Move selected items void moveSelectedItems(int order); - protected slots: //! Order to top - void ps_orderToTop(); + void orderToTop(); //! Order to bottom - void ps_orderToBottom(); + void orderToBottom(); //! Order to line edit - void ps_orderToLineEdit(); + void orderToLineEdit(); //! Current order set as order - void ps_freezeCurrentOrder(); + void freezeCurrentOrder(); private: QList m_menuActions;