refs #195, code formatting, renaming, cleanup in the course of action

This commit is contained in:
Klaus Basan
2014-04-20 17:52:39 +02:00
parent f2c05458b1
commit 332a885da1
7 changed files with 52 additions and 126 deletions

View File

@@ -3,10 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*!
\file
*/
#ifndef BLACKGUI_AIRCRAFTLISTMODEL_H #ifndef BLACKGUI_AIRCRAFTLISTMODEL_H
#define BLACKGUI_AIRCRAFTLISTMODEL_H #define BLACKGUI_AIRCRAFTLISTMODEL_H

View File

@@ -21,13 +21,6 @@ precompile_header:!isEmpty(PRECOMPILED_HEADER) {
} }
DEFINES += LOG_IN_FILE DEFINES += LOG_IN_FILE
# RESOURCES += blackgui.qrc
# lupdate (from cmd, e.g. lupdate blackmisc.pro)
# CODECFORTR = UTF-8
# TRANSLATIONS += translations/blackgui_i18n_de.ts \
# translations/blackgui_i18n_fr.ts \
# translations/blackgui_i18n_en.ts
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a else: PRE_TARGETDEPS += ../../lib/libblackmisc.a

View File

@@ -17,9 +17,7 @@
namespace BlackGui namespace BlackGui
{ {
/*! //! Single column
* \brief Single column
*/
class CColumn class CColumn
{ {
public: public:
@@ -40,28 +38,28 @@ namespace BlackGui
*/ */
CColumn(const QString &headerName, int propertyIndex, bool editable); CColumn(const QString &headerName, int propertyIndex, bool editable);
//! \brief Alignment for this column? //! Alignment for this column?
bool hasAlignment() const bool hasAlignment() const
{ {
return this->m_alignment >= 0; return this->m_alignment >= 0;
} }
//! \brief Editable? //! Editable?
bool isEditable() const bool isEditable() const
{ {
return this->m_editable; return this->m_editable;
} }
//! \brief Aligment as QVariant //! Aligment as QVariant
QVariant aligmentAsQVariant() const; QVariant aligmentAsQVariant() const;
//! \brief Column name //! Column name
QString getColumnName(bool i18n = false) const; QString getColumnName(bool i18n = false) const;
//! \brief Property index //! Property index
int getPropertyIndex() const { return this->m_propertyIndex;} int getPropertyIndex() const { return this->m_propertyIndex;}
//! \brief Translation context //! Translation context
void setTranslationContext(const QString &translationContext) void setTranslationContext(const QString &translationContext)
{ {
this->m_translationContext = translationContext; this->m_translationContext = translationContext;
@@ -90,44 +88,42 @@ namespace BlackGui
*/ */
CColumns(const QString &translationContext, QObject *parent = nullptr); CColumns(const QString &translationContext, QObject *parent = nullptr);
//! \brief Add a column //! Add a column
void addColumn(CColumn column); void addColumn(CColumn column);
//! \brief Property index to name //! Property index to name
QString propertyIndexToColumnName(int propertyIndex, bool i18n = false) const; QString propertyIndexToColumnName(int propertyIndex, bool i18n = false) const;
//! \brief Column index to name //! Column index to name
QString columnToName(int column, bool i18n = false) const; QString columnToName(int column, bool i18n = false) const;
//! \brief Column to property index //! Column to property index
int columnToPropertyIndex(int column) const; int columnToPropertyIndex(int column) const;
//! \brief Property index to column //! Property index to column
int propertyIndexToColumn(int propertyIndex) const; int propertyIndexToColumn(int propertyIndex) const;
//! \brief Column index to property index //! Column index to property index
int indexToPropertyIndex(int index) const; int indexToPropertyIndex(int index) const;
//! \brief Column index to name //! Column index to name
int nameToPropertyIndex(const QString &name) const; int nameToPropertyIndex(const QString &name) const;
//! \brief Size (number of columns) //! Size (number of columns)
int size() const; int size() const;
//! \brief Alignment for this column? //! Alignment for this column?
bool hasAlignment(const QModelIndex &index) const; bool hasAlignment(const QModelIndex &index) const;
//! \brief Is this column editable? //! Is this column editable?
bool isEditable(const QModelIndex &index) const; bool isEditable(const QModelIndex &index) const;
//! \brief Aligment as QVariant //! Aligment as QVariant
QVariant aligmentAsQVariant(const QModelIndex &index) const; QVariant aligmentAsQVariant(const QModelIndex &index) const;
//! \brief Column at position //! Column at position
const CColumn &at(int columnNumber) const const CColumn &at(int columnNumber) const { return this->m_columns.at(columnNumber); }
{
return this->m_columns.at(columnNumber);
}
private: private:
QList<CColumn> m_columns; QList<CColumn> m_columns;

View File

@@ -89,11 +89,11 @@ namespace BlackGui
* Update * Update
*/ */
template <typename ObjectType, typename ContainerType> template <typename ObjectType, typename ContainerType>
int CListModelBase<ObjectType, ContainerType>::update(const ContainerType &list) int CListModelBase<ObjectType, ContainerType>::update(const ContainerType &container)
{ {
ContainerType copyList = (list.size() > 1 && this->hasValidSortColumn() ? ContainerType copyList = (container.size() > 1 && this->hasValidSortColumn() ?
this->sortListByColumn(list, this->m_sortedColumn, this->m_sortOrder) : this->sortListByColumn(container, this->m_sortedColumn, this->m_sortOrder) :
list); container);
this->beginResetModel(); this->beginResetModel();
this->m_container.clear(); this->m_container.clear();
foreach(ObjectType object, copyList) foreach(ObjectType object, copyList)

View File

@@ -3,10 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*!
\file
*/
#ifndef BLACKGUI_LISTMODELBASE_H #ifndef BLACKGUI_LISTMODELBASE_H
#define BLACKGUI_LISTMODELBASE_H #define BLACKGUI_LISTMODELBASE_H
@@ -49,39 +45,25 @@ namespace BlackGui
public: public:
/*! //! \brief Destructor
* \brief Destructor
*/
virtual ~CListModelBase() {} virtual ~CListModelBase() {}
/*! //! \copydoc QAbstractListModel::columnCount()
* \copydoc QAbstractListModel::columnCount()
*/
virtual int columnCount(const QModelIndex &modelIndex) const; virtual int columnCount(const QModelIndex &modelIndex) const;
/*! //! \copydoc QAbstractItemModel::headerData()
* \copydoc QAbstractItemModel::headerData()
*/
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
/*! //! Column to property index
* \brief Column to property index
* \param column
*/
virtual int columnToPropertyIndex(int column) const; virtual int columnToPropertyIndex(int column) const;
/*! //! Index to property index
* \brief Index to property index virtual int indexToPropertyIndex(const QModelIndex &index) const
* \param index {
*/
virtual int indexToPropertyIndex(const QModelIndex &index) const {
return this->columnToPropertyIndex(index.column()); return this->columnToPropertyIndex(index.column());
} }
/*! //! Set sort column
* \brief Set sort column
* \param column column index
*/
virtual void setSortColumn(int column) virtual void setSortColumn(int column)
{ {
this->m_sortedColumn = column; this->m_sortedColumn = column;
@@ -96,34 +78,25 @@ namespace BlackGui
this->m_sortedColumn = this->m_columns.propertyIndexToColumn(propertyIndex); this->m_sortedColumn = this->m_columns.propertyIndexToColumn(propertyIndex);
} }
/*! //! Get sort column
* \brief Get sort column
* \return
*/
virtual int getSortColumn() const virtual int getSortColumn() const
{ {
return this->m_sortedColumn; return this->m_sortedColumn;
} }
/*! //! Has valid sort column?
* \brief Has valid sort column?
* \return
*/
virtual bool hasValidSortColumn() const virtual bool hasValidSortColumn() const
{ {
return this->m_sortedColumn >= 0 && this->m_sortedColumn < this->m_columns.size(); return this->m_sortedColumn >= 0 && this->m_sortedColumn < this->m_columns.size();
} }
/*! //! Get sort order
* \brief Get sort column
* \return
*/
virtual Qt::SortOrder getSortOrder() const virtual Qt::SortOrder getSortOrder() const
{ {
return this->m_sortOrder; return this->m_sortOrder;
} }
//! \brief Used container data //! Used container data
virtual const ContainerType &getContainer() const virtual const ContainerType &getContainer() const
{ {
return this->m_container; return this->m_container;
@@ -138,25 +111,13 @@ namespace BlackGui
//! \copydoc QAbstractTableModel::flags //! \copydoc QAbstractTableModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
/*! //! Update by new list
* \brief Update by new list virtual int update(const ContainerType &container);
* \param list
* \return new list size
*/
virtual int update(const ContainerType &list);
/*! //! Update single element
* \brief Update single element
* \param index
* \param object
*/
virtual void update(const QModelIndex &index, const ObjectType &object); virtual void update(const QModelIndex &index, const ObjectType &object);
/*! //! Object at row position
* \brief Object at row position
* \param index
* \return
*/
virtual const ObjectType &at(const QModelIndex &index) const virtual const ObjectType &at(const QModelIndex &index) const
{ {
if (index.row() < 0 || index.row() >= this->m_container.size()) if (index.row() < 0 || index.row() >= this->m_container.size())
@@ -173,13 +134,13 @@ namespace BlackGui
//! \copydoc QAbstractListModel::sort() //! \copydoc QAbstractListModel::sort()
virtual void sort(int column, Qt::SortOrder order); virtual void sort(int column, Qt::SortOrder order);
//! \brief Similar to ContainerType::push_back //! Similar to ContainerType::push_back
virtual void push_back(const ObjectType &object); virtual void push_back(const ObjectType &object);
//! \brief Similar to ContainerType::insert here inserts at first position //! Similar to ContainerType::insert here inserts at first position
virtual void insert(const ObjectType &object); virtual void insert(const ObjectType &object);
//! \brief clear the list //! Clear the list
virtual void clear(); virtual void clear();
}; };
} }

View File

@@ -28,50 +28,31 @@ namespace BlackGui
public: public:
/*! //! Constructor
* \brief Constructor
* \param parent
*/
explicit CServerListModel(QObject *parent = nullptr); explicit CServerListModel(QObject *parent = nullptr);
/*! //! Destructor
* \brief Destructor
*/
virtual ~CServerListModel() {} virtual ~CServerListModel() {}
/*! //! Has selected server?
* \brief Has selected server?
* \return
*/
bool hasSelectedServer() const bool hasSelectedServer() const
{ {
return this->m_selectedServer.isValidForLogin(); return this->m_selectedServer.isValidForLogin();
} }
/*! //! Get selected server
* \brief Get selected server
* \return
*/
const BlackMisc::Network::CServer &getSelectedServer() const const BlackMisc::Network::CServer &getSelectedServer() const
{ {
return this->m_selectedServer; return this->m_selectedServer;
} }
/*! //! Set selected server
* \brief SetSelectedServer
* \param selectedServer
*/
void setSelectedServer(const BlackMisc::Network::CServer &selectedServer) void setSelectedServer(const BlackMisc::Network::CServer &selectedServer)
{ {
this->m_selectedServer = selectedServer; this->m_selectedServer = selectedServer;
} }
/*! //! \copydoc CListModelBase::data
* \brief data
* \param index
* \param role
* \return
*/
virtual QVariant data(const QModelIndex &index, int role) const; virtual QVariant data(const QModelIndex &index, int role) const;
}; };

View File

@@ -16,15 +16,14 @@ namespace BlackGui
public: public:
//! \brief Constructor //! Constructor
explicit CStatusMessageListModel(QObject *parent = nullptr); explicit CStatusMessageListModel(QObject *parent = nullptr);
//! \brief Destructor //! Destructor
virtual ~CStatusMessageListModel() {} virtual ~CStatusMessageListModel() {}
//! \copydoc CListModelBase::data //! \copydoc CListModelBase::data
QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &modelIndex, int role = Qt::DisplayRole) const;
}; };
} }
#endif // guard #endif // guard