6 #ifndef SWIFT_GUI_MODELS_LISTMODELBASENONTEMPLATE_H
7 #define SWIFT_GUI_MODELS_LISTMODELBASENONTEMPLATE_H
9 #include <QJsonDocument>
10 #include <QJsonObject>
11 #include <QModelIndex>
12 #include <QStandardItemModel>
14 #include <QStringList>
18 #include "gui/dropbase.h"
41 static constexpr
int asyncThreshold = 50;
49 int columnCount(
const QModelIndex &modelIndex = QModelIndex()) const final;
52 QVariant headerData(
int section, Qt::Orientation orientation,
int role) const final;
55 QModelIndex index(
int row,
int column, const QModelIndex &parent = QModelIndex()) const final;
58 QModelIndex parent(const QModelIndex &child) const final;
61 Qt::ItemFlags flags(const QModelIndex &index) const final;
64 Qt::DropActions supportedDragActions() const final;
67 Qt::DropActions supportedDropActions() const final;
70 QStringList mimeTypes() const final;
74 virtual swift::misc::CPropertyIndex columnToPropertyIndex(
int column) const;
77 virtual
int propertyIndexToColumn(const swift::misc::CPropertyIndex &propertyIndex) const;
80 virtual swift::misc::CPropertyIndex modelIndexToPropertyIndex(const QModelIndex &index) const;
83 virtual
void setSortColumn(
int column) { m_sortColumn = column; }
90 Qt::SortOrder order = Qt::AscendingOrder);
98 Qt::SortOrder order = Qt::AscendingOrder);
107 virtual bool hasValidSortColumn()
const;
116 void markDestroyed();
119 bool isModelDestroyed();
122 virtual void clearHighlighting();
125 virtual bool hasHighlightedRows()
const;
128 void setDropActions(Qt::DropActions dropActions) { m_dropActions = dropActions; }
132 void emitDataChanged(
int startRowIndex,
int endRowIndex);
135 virtual QJsonObject
toJson(
bool selectedOnly =
false)
const = 0;
138 virtual QString
toJsonString(QJsonDocument::JsonFormat format = QJsonDocument::Indented,
139 bool selectedOnly =
false)
const = 0;
171 virtual void onDataChanged(
const QModelIndex &topLeft,
const QModelIndex &bottomRight,
172 const QVector<int> &roles) = 0;
184 bool m_modelDestroyed =
false;
186 Qt::DropActions m_dropActions = Qt::IgnoreAction;
193 std::chrono::milliseconds(500), 10 };
Utilities for dropping swift value objects.
Non templated base class, allows Q_OBJECT and signals to be used.
void setDropActions(Qt::DropActions dropActions)
Drop actions.
bool endsWithEmptyColumn() const
Using void column at the end?
virtual Qt::SortOrder getSortOrder() const
Get sort order.
~CListModelBaseNonTemplate()=default
Destructor.
void objectChanged(const swift::misc::CVariant &object, const swift::misc::CPropertyIndex &changedIndex)
Template free information, that object changed.
virtual void onChangedDigest()=0
Digest signal.
virtual void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)=0
Feedback when QStandardItemModel::dataChanged was called.
void modelDataChangedDigest(int count, bool withFilter)
Data changed, digest version.
void changed()
Model has been changed Triggered with each change, for performance consider using changedDigest.
void modelDataChanged(int count, bool withFilter)
Data changed.
swift::misc::CPropertyIndexList m_sortTieBreakers
how column values are sorted if equal, if no value is given this is random
void asyncUpdateFinished()
Asynchronous update finished.
void changedDigest()
Model has been changed, digest signal.
virtual QString toJsonString(QJsonDocument::JsonFormat format=QJsonDocument::Indented, bool selectedOnly=false) const =0
Convert to JSON string.
int m_sortColumn
currently sorted column
const CColumns & getColumns() const
The columns.
void setNoSorting()
Disable sorting.
virtual QJsonObject toJson(bool selectedOnly=false) const =0
Convert to JSON.
virtual int getSortColumn() const
Get sort column property index.
CColumns m_columns
columns metadata
virtual bool isOrderable() const =0
Orderable, normally use a container swift::misc::IOrderableList.
Qt::SortOrder m_sortOrder
sort order (asc/desc)
Receive 1..n signals, collect them over time, and resend afer n milliseconds.
Value object encapsulating a list of property indexes.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Models to be used with views, mainly QTableView.
Free functions in swift::misc.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.