swift
|
List model. More...
Public Types | |
using | ContainerType = T |
Container type. | |
using | ObjectType = typename T::value_type |
Container element type. | |
Public Member Functions | |
~CListModelBase ()=default | |
Destructor. | |
virtual bool | isValidIndex (const QModelIndex &index) const |
Valid index (in range) | |
const ContainerType & | container () const |
Used container data. | |
const ContainerType & | containerFiltered () const |
Used container data. | |
const ContainerType & | containerOrFilteredContainer (bool *filtered=nullptr) const |
Full container or cached filtered container as approproiate. | |
bool | setInContainer (const QModelIndex &index, const ObjectType &obj) |
Simple set of data in container, using class is responsible for firing signals etc. More... | |
virtual int | update (const ContainerType &container, bool sort=true) |
Update by new container. More... | |
virtual swift::misc::CWorker * | updateAsync (const ContainerType &container, bool sort=true) |
Asynchronous update. | |
virtual void | updateContainerMaybeAsync (const ContainerType &container, bool sort=true) |
Update by new container. | |
virtual void | update (const QModelIndex &index, const ObjectType &object) |
Update single element. | |
virtual void | update (int rowIndex, const ObjectType &object) |
Update single element. | |
virtual void | moveItems (const ContainerType &items, int position) |
Move items to position, normally called from dropMimeData. More... | |
virtual const ObjectType & | at (const QModelIndex &index) const |
Object at row position. | |
void | sort () |
Sort by given sort order. More... | |
void | resort () |
Sort by given sort order. More... | |
void | truncate (int maxNumber, bool forceSort=false) |
Truncate to given number. | |
ContainerType | sortContainerByColumn (const ContainerType &container, int column, Qt::SortOrder order) const |
Sort container by given column / order. This is used by sort() but als for asynchronous updates in the views. More... | |
virtual void | push_back (const ObjectType &object) |
Similar to ContainerType::push_back. | |
virtual void | push_back (const ContainerType &container) |
Similar to ContainerType::push_back. | |
virtual void | insert (const ObjectType &object) |
Similar to ContainerType::insert here inserts at first position. | |
virtual void | insert (const ContainerType &container) |
Similar to ContainerType::insert here inserts at first position. | |
virtual void | remove (const ObjectType &object) |
Remove object. | |
template<class K0 , class V0 , class... KeysValues> | |
int | removeIf (K0 k0, V0 v0, KeysValues... keysValues) |
Remove elements matching some particular key/value pair(s). More... | |
virtual void | clear () |
Clear the list. | |
virtual bool | isEmpty () const |
Empty? | |
bool | hasFilter () const |
Filter available. | |
void | removeFilter () |
Remove filter. | |
void | takeFilterOwnership (std::unique_ptr< IModelFilter< ContainerType >> &filter) |
Set the filter. | |
void | setSelectionModel (swift::gui::models::ISelectionModel< ContainerType > *selectionModel) |
Set the selection model. | |
Functions from QStandardItemModel | |
QVariant | data (const QModelIndex &index, int role) const |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) final |
QMimeData * | mimeData (const QModelIndexList &indexes) const final |
void | sort (int column, Qt::SortOrder order) final |
int | rowCount (const QModelIndex &parentIndex=QModelIndex()) const final |
bool | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const final |
bool | dropMimeData (const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) final |
Functions from CListModelBaseNonTemplate | |
QJsonObject | toJson (bool selectedOnly=false) const |
Convert to JSON. More... | |
QString | toJsonString (QJsonDocument::JsonFormat format=QJsonDocument::Indented, bool selectedOnly=false) const |
Convert to JSON string. More... | |
bool | isOrderable () const |
Orderable, normally use a container swift::misc::IOrderableList. More... | |
![]() | |
~CListModelBaseNonTemplate ()=default | |
Destructor. | |
virtual swift::misc::CPropertyIndex | columnToPropertyIndex (int column) const |
Column to property index. | |
virtual int | propertyIndexToColumn (const swift::misc::CPropertyIndex &propertyIndex) const |
Property index to column number. | |
virtual swift::misc::CPropertyIndex | modelIndexToPropertyIndex (const QModelIndex &index) const |
Index to property index. | |
virtual void | setSortColumn (int column) |
Set sort column. | |
void | setNoSorting () |
Disable sorting. | |
void | sortByPropertyIndex (const swift::misc::CPropertyIndex &propertyIndex, Qt::SortOrder order=Qt::AscendingOrder) |
Sort by index. | |
virtual bool | setSortColumnByPropertyIndex (const swift::misc::CPropertyIndex &propertyIndex) |
Set column for sorting. More... | |
virtual bool | setSorting (const swift::misc::CPropertyIndex &propertyIndex, Qt::SortOrder order=Qt::AscendingOrder) |
Sorting. | |
virtual int | getSortColumn () const |
Get sort column property index. | |
swift::misc::CPropertyIndex | getSortProperty () const |
Sorted by property. | |
virtual bool | hasValidSortColumn () const |
Has valid sort column? | |
virtual Qt::SortOrder | getSortOrder () const |
Get sort order. | |
void | markDestroyed () |
Mark as about to be destroyed, normally marked from view. | |
bool | isModelDestroyed () |
Model about to be destroyed? | |
virtual void | clearHighlighting () |
Remove all highlighting. | |
virtual bool | hasHighlightedRows () const |
Has highlighted rows? | |
void | setDropActions (Qt::DropActions dropActions) |
Drop actions. | |
void | emitDataChanged (int startRowIndex, int endRowIndex) |
Send signal that data have been changed. More... | |
const CColumns & | getColumns () const |
The columns. | |
bool | endsWithEmptyColumn () const |
Using void column at the end? | |
int | columnCount (const QModelIndex &modelIndex=QModelIndex()) const final |
QVariant | headerData (int section, Qt::Orientation orientation, int role) const final |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const final |
QModelIndex | parent (const QModelIndex &child) const final |
Qt::ItemFlags | flags (const QModelIndex &index) const final |
Qt::DropActions | supportedDragActions () const final |
Qt::DropActions | supportedDropActions () const final |
QStringList | mimeTypes () const final |
![]() | |
virtual | ~CDropBase () |
Dtor. | |
void | setAcceptedMetaTypeIds (const QList< int > &ids) |
Accepted ids. | |
void | addAcceptedMetaTypeId (int id) |
Accepted ids. | |
virtual bool | isDropAllowed () const |
Drop allowed? | |
virtual bool | isJsonFileDropAllowed () const |
File drop allowed? | |
virtual void | allowDrop (bool allowed) |
Drop allowed. | |
virtual void | allowJsonFileDrop (bool allow) |
Allow JSON file drop. | |
bool | acceptDrop (const QMimeData *mime) const |
Accept drop? | |
swift::misc::CVariant | toCVariant (const QMimeData *mime) const |
Mime data to CVariant (normally encapsulating a value object) | |
Protected Member Functions | |
CListModelBase (const QString &translationContext, QObject *parent=nullptr) | |
Constructor. | |
void | updateFilteredContainer () |
Update filtered container. | |
void | emitModelDataChanged () |
Model changed. | |
Base class overrides | |
void | onDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomLeft, const QVector< int > &roles) |
Feedback when QStandardItemModel::dataChanged was called. More... | |
void | onChangedDigest () |
Feedback when QStandardItemModel::dataChanged was called. More... | |
![]() | |
CListModelBaseNonTemplate (const QString &translationContext, QObject *parent=nullptr) | |
Constructor. More... | |
![]() | |
CDropBase () | |
Ctor. | |
Protected Attributes | |
ContainerType | m_container |
used container | |
ContainerType | m_containerFiltered |
cache for filtered container data | |
std::unique_ptr< IModelFilter< ContainerType > > | m_filter |
used filter | |
ISelectionModel< ContainerType > * | m_selectionModel = nullptr |
selection model | |
![]() | |
CColumns | m_columns |
columns metadata | |
int | m_sortColumn |
currently sorted column | |
bool | m_modelDestroyed = false |
Qt::SortOrder | m_sortOrder |
sort order (asc/desc) | |
Qt::DropActions | m_dropActions = Qt::IgnoreAction |
drop actions | |
swift::misc::CPropertyIndexList | m_sortTieBreakers |
how column values are sorted if equal, if no value is given this is random | |
Additional Inherited Members | |
![]() | |
void | asyncUpdateFinished () |
Asynchronous update finished. | |
void | modelDataChanged (int count, bool withFilter) |
Data changed. More... | |
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 | changedDigest () |
Model has been changed, digest signal. | |
void | objectChanged (const swift::misc::CVariant &object, const swift::misc::CPropertyIndex &changedIndex) |
Template free information, that object changed. | |
![]() | |
static constexpr int | asyncThreshold = 50 |
Number of elements when to use asynchronous updates. | |
List model.
Definition at line 34 of file listmodelbase.h.
|
final |
Definition at line 36 of file listmodelbase.cpp.
QVariant swift::gui::models::CListModelBase< T, UseCompare >::data | ( | const QModelIndex & | index, |
int | role | ||
) | const |
Definition at line 79 of file listmodelbase.cpp.
|
final |
Definition at line 49 of file listmodelbase.cpp.
|
virtual |
Orderable, normally use a container swift::misc::IOrderableList.
Implements swift::gui::models::CListModelBaseNonTemplate.
Definition at line 586 of file listmodelbase.cpp.
|
final |
Definition at line 543 of file listmodelbase.cpp.
|
virtual |
Move items to position, normally called from dropMimeData.
Reimplemented in swift::gui::models::COrderableListModelDbObjects< T, K, UseCompare >, swift::gui::models::COrderableListModelDbObjects< swift::misc::simulation::CAircraftModelList, int, true >, and swift::gui::models::COrderableListModelDbObjects< swift::misc::simulation::CDistributorList, QString, true >.
Definition at line 462 of file listmodelbase.cpp.
|
protectedvirtual |
Feedback when QStandardItemModel::dataChanged was called.
Implements swift::gui::models::CListModelBaseNonTemplate.
Definition at line 454 of file listmodelbase.cpp.
|
protectedvirtual |
Feedback when QStandardItemModel::dataChanged was called.
Implements swift::gui::models::CListModelBaseNonTemplate.
Definition at line 443 of file listmodelbase.cpp.
|
inline |
Remove elements matching some particular key/value pair(s).
k0 | A pointer to a member function of T. |
v0 | A value to compare against the value returned by k0. |
keysValues | Zero or more additional pairs of { pointer to member function of T, value to compare it against }. |
Definition at line 162 of file listmodelbase.h.
void swift::gui::models::CListModelBase< T, UseCompare >::resort |
Sort by given sort order.
Definition at line 476 of file listmodelbase.cpp.
|
final |
Definition at line 29 of file listmodelbase.cpp.
|
final |
Definition at line 112 of file listmodelbase.cpp.
bool swift::gui::models::CListModelBase< T, UseCompare >::setInContainer | ( | const QModelIndex & | index, |
const ObjectType & | obj | ||
) |
Simple set of data in container, using class is responsible for firing signals etc.
Definition at line 144 of file listmodelbase.cpp.
void swift::gui::models::CListModelBase< T, UseCompare >::sort |
Sort by given sort order.
Definition at line 470 of file listmodelbase.cpp.
|
final |
Definition at line 483 of file listmodelbase.cpp.
CListModelBase< T, UseCompare >::ContainerType swift::gui::models::CListModelBase< T, UseCompare >::sortContainerByColumn | ( | const ContainerType & | container, |
int | column, | ||
Qt::SortOrder | order | ||
) | const |
Sort container by given column / order. This is used by sort() but als for asynchronous updates in the views.
container | used list |
column | column inder |
order | sort order (ascending / descending) |
Definition at line 514 of file listmodelbase.cpp.
|
virtual |
Convert to JSON.
Implements swift::gui::models::CListModelBaseNonTemplate.
Definition at line 570 of file listmodelbase.cpp.
|
virtual |
Convert to JSON string.
Implements swift::gui::models::CListModelBaseNonTemplate.
Definition at line 578 of file listmodelbase.cpp.
|
virtual |
Update by new container.
Reimplemented in swift::gui::models::COrderableListModelDbObjects< T, K, UseCompare >, swift::gui::models::COrderableListModelDbObjects< swift::misc::simulation::CAircraftModelList, int, true >, and swift::gui::models::COrderableListModelDbObjects< swift::misc::simulation::CDistributorList, QString, true >.
Definition at line 154 of file listmodelbase.cpp.