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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*!
\file
*/
#ifndef BLACKGUI_AIRCRAFTLISTMODEL_H
#define BLACKGUI_AIRCRAFTLISTMODEL_H

View File

@@ -21,13 +21,6 @@ precompile_header:!isEmpty(PRECOMPILED_HEADER) {
}
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
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a

View File

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

View File

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

View File

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

View File

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