This commit is contained in:
Klaus Basan
2019-10-29 23:52:29 +01:00
committed by Mat Sutcliffe
parent a520145a6a
commit 7beed0225c
6 changed files with 25 additions and 40 deletions

View File

@@ -11,10 +11,10 @@
#ifndef BLACKGUI_MODELS_AIRPORTLISTMODEL_H
#define BLACKGUI_MODELS_AIRPORTLISTMODEL_H
#include "blackgui/blackguiexport.h"
#include "blackgui/models/listmodelbase.h"
#include "blackmisc/aviation/airport.h"
#include "blackgui/blackguiexport.h"
#include "blackmisc/aviation/airportlist.h"
#include "blackmisc/aviation/airport.h"
class QObject;

View File

@@ -35,17 +35,17 @@ namespace BlackGui
template <typename T, bool UseCompare>
int CListModelBase<T, UseCompare>::rowCount(const QModelIndex &parentIndex) const
{
Q_UNUSED(parentIndex);
Q_UNUSED(parentIndex)
return this->containerOrFilteredContainer().size();
}
template <typename T, bool UseCompare>
bool CListModelBase<T, UseCompare>::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(action);
Q_UNUSED(row);
Q_UNUSED(column);
Q_UNUSED(parent);
Q_UNUSED(action)
Q_UNUSED(row)
Q_UNUSED(column)
Q_UNUSED(parent)
if (!this->isDropAllowed()) { return false; }
if (!this->acceptDrop(data)) { return false; }
return true;
@@ -54,8 +54,8 @@ namespace BlackGui
template <typename T, bool UseCompare>
bool CListModelBase<T, UseCompare>::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
Q_UNUSED(row);
Q_UNUSED(column);
Q_UNUSED(row)
Q_UNUSED(column)
if (!this->isOrderable() || !this->acceptDrop(mimeData)) { return false; }
const CVariant valueVariant(this->toCVariant(mimeData));
@@ -191,7 +191,8 @@ namespace BlackGui
}
const int newSize = m_container.size();
Q_UNUSED(oldSize);
Q_UNUSED(oldSize)
// I have to update even with same size because I cannot tell what/if data are changed
this->emitModelDataChanged();
return newSize;
@@ -218,7 +219,7 @@ namespace BlackGui
template <typename T, bool UseCompare>
CWorker *CListModelBase<T, UseCompare>::updateAsync(const ContainerType &container, bool sort)
{
Q_UNUSED(sort);
Q_UNUSED(sort)
if (m_modelDestroyed) { return nullptr; }
const auto sortColumn = this->getSortColumn();
const auto sortOrder = this->getSortOrder();
@@ -474,9 +475,9 @@ namespace BlackGui
void CListModelBase<T, UseCompare>::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
// underlying base class changed
Q_UNUSED(topLeft);
Q_UNUSED(bottomRight);
Q_UNUSED(roles);
Q_UNUSED(topLeft)
Q_UNUSED(bottomRight)
Q_UNUSED(roles)
this->emitModelDataChanged();
}
@@ -492,8 +493,8 @@ namespace BlackGui
void CListModelBase<T, UseCompare>::moveItems(const ContainerType &items, int position)
{
// overridden in specialized class
Q_UNUSED(items);
Q_UNUSED(position);
Q_UNUSED(items)
Q_UNUSED(position)
}
template <typename T, bool UseCompare>

View File

@@ -44,7 +44,7 @@ namespace BlackGui
using ObjectType = typename T::value_type;
//! Destructor
virtual ~CListModelBase() {}
virtual ~CListModelBase() override {}
//! \name Functions from QStandardItemModel
//! @{
@@ -222,4 +222,5 @@ namespace BlackGui
} // namespace
} // namespace
} // namespace
#endif // guard

View File

@@ -9,25 +9,8 @@
// Drag and drop docu:
// http://doc.qt.io/qt-5/model-view-programming.html#using-drag-and-drop-with-item-views
//#include "blackgui/models/columnformatters.h"
#include "blackgui/models/listmodelbasenontemplate.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"
//#include "blackmisc/worker.h"
//#include <QFlags>
//#include <QJsonDocument>
//#include <QList>
//#include <QMimeData>
//#include <QtGlobal>
//#include <QFileInfo>
using namespace BlackMisc;
@@ -37,7 +20,7 @@ namespace BlackGui
{
int CListModelBaseNonTemplate::columnCount(const QModelIndex &modelIndex) const
{
Q_UNUSED(modelIndex);
Q_UNUSED(modelIndex)
int c = m_columns.size();
return c;
}
@@ -62,13 +45,13 @@ namespace BlackGui
QModelIndex CListModelBaseNonTemplate::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent);
Q_UNUSED(parent)
return QStandardItemModel::createIndex(row, column);
}
QModelIndex CListModelBaseNonTemplate::parent(const QModelIndex &child) const
{
Q_UNUSED(child);
Q_UNUSED(child)
return QModelIndex();
}

View File

@@ -111,11 +111,11 @@ namespace BlackMisc
int CEcosystem::comparePropertyByIndex(const CPropertyIndex &index, const CEcosystem &compareValue) const
{
if (index.isMyself()) { return Compare::compare(this->m_system, compareValue.m_system); }
if (index.isMyself()) { return Compare::compare(m_system, compareValue.m_system); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexSystem: return Compare::compare(this->m_system, compareValue.m_system);
case IndexSystem: return Compare::compare(m_system, compareValue.m_system);
default: break;
}
BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString()));

View File

@@ -75,7 +75,7 @@ namespace BlackMisc
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
//! Compare by index
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const CEcosystem &compareValue) const;
//! \copydoc BlackMisc::Mixin::String::toQString