mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
Stashed data file can be dropped to model view
* utility functions * style changes / renamings / slots -> normal functions * extra flag to enable file drop (and changed signatures) * split view load function into 2 parts, one can use passed file parameter
This commit is contained in:
@@ -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 <QList>
|
||||
#include <QMimeData>
|
||||
#include <QtGlobal>
|
||||
#include <QFileInfo>
|
||||
|
||||
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 <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
@@ -221,12 +223,13 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
bool CListModelBase<ObjectType, ContainerType, UseCompare>::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
bool CListModelBase<ObjectType, ContainerType, UseCompare>::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 <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelBase<ObjectType, ContainerType, UseCompare>::ps_onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||
void CListModelBase<ObjectType, ContainerType, UseCompare>::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||
{
|
||||
// underlying base class changed
|
||||
Q_UNUSED(topLeft);
|
||||
@@ -631,7 +634,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
void CListModelBase<ObjectType, ContainerType, UseCompare>::ps_onChangedDigest()
|
||||
void CListModelBase<ObjectType, ContainerType, UseCompare>::onChangedDigest()
|
||||
{
|
||||
const int n = this->containerOrFilteredContainer().size();
|
||||
emit this->changedDigest();
|
||||
|
||||
@@ -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<int> &roles) = 0;
|
||||
virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &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<IModelFilter<ContainerType> > &filter);
|
||||
|
||||
//! Set the selection model
|
||||
void setSelectionModel(BlackGui::Models::ISelectionModel<ContainerType> *selectionModel)
|
||||
{
|
||||
m_selectionModel = selectionModel;
|
||||
}
|
||||
void setSelectionModel(BlackGui::Models::ISelectionModel<ContainerType> *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<int> &roles) override;
|
||||
virtual void ps_onChangedDigest() override;
|
||||
virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomLeft, const QVector<int> &roles) override;
|
||||
virtual void onChangedDigest() override;
|
||||
//! @}
|
||||
|
||||
//! Update filtered container
|
||||
|
||||
Reference in New Issue
Block a user