refs #538, Formatting, minor tweaks, comments

* new slot syntax in ATC station component
* formatting, comments
* tab order
* utility function for severity in status message
* null checks in threadutils
* invalidKey function in datastore
* changed data object keys (cached objets)
* added missing value object compare cases
* renamed timer in context network
* finder function for model list
* renamed getContainer to container (as it is just a reference)
This commit is contained in:
Klaus Basan
2015-12-05 16:39:54 +01:00
parent 66ff1803cf
commit 8f85c54989
24 changed files with 90 additions and 45 deletions

View File

@@ -20,7 +20,6 @@ namespace BlackGui
{
namespace Models
{
class ActionItem;
/*!
@@ -31,7 +30,6 @@ namespace BlackGui
Q_OBJECT
public:
//! User roles
enum ItemRole
{
@@ -63,12 +61,12 @@ namespace BlackGui
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
private:
//! Init model data
void setupModelData();
QScopedPointer<ActionItem> m_rootItem;
};
}
}
} // ns
#endif // guard

View File

@@ -94,14 +94,14 @@ namespace BlackGui
QStandardItemModel *model = new QStandardItemModel();
if (this->isEmpty()) { return model; }
model->setColumnCount(4);
QMap<QString, int> types = this->getContainer().getSuffixes();
QMap<QString, int> types = this->container().getSuffixes();
for (const QString &type : types.keys())
{
// ownership of QStandardItem is taken by model
QStandardItem *typeFolderFirstColumn = new QStandardItem(CCallsign::atcSuffixToIcon(type).toQIcon(), type);
QList<QStandardItem *> typeFolderRow { typeFolderFirstColumn };
model->invisibleRootItem()->appendRow(typeFolderRow);
CAtcStationList stations = this->getContainer().findBySuffix(type);
CAtcStationList stations = this->container().findBySuffix(type);
for (const CAtcStation &station : stations)
{
QList<QStandardItem *> stationRow;

View File

@@ -200,7 +200,7 @@ namespace BlackGui
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
{
if (!isValidColumn(index)) return nullptr;
if (!isValidColumn(index)) { return nullptr; }
return this->m_columns.at(index.column()).getFormatter();
}

View File

@@ -184,7 +184,7 @@ namespace BlackGui
// check / init
if (!this->isValidIndex(index)) { return QVariant(); }
const CDefaultFormatter *formatter = this->m_columns.getFormatter(index);
Q_ASSERT(formatter);
Q_ASSERT_X(formatter, Q_FUNC_INFO, "Missing formatter");
if (!formatter) { return QVariant(); }
//! Formatted data
@@ -372,7 +372,7 @@ namespace BlackGui
}
template <typename ObjectType, typename ContainerType, bool UseCompare>
const ContainerType &CListModelBase<ObjectType, ContainerType, UseCompare>::getContainer() const
const ContainerType &CListModelBase<ObjectType, ContainerType, UseCompare>::container() const
{
return this->m_container;
}
@@ -507,7 +507,7 @@ namespace BlackGui
{
this->sort(); // make sure container is sorted
}
ContainerType container(this->getContainer());
ContainerType container(this->container());
container.truncate(maxNumber);
this->updateContainerMaybeAsync(container, false);
}

View File

@@ -138,7 +138,7 @@ namespace BlackGui
virtual bool isValidIndex(const QModelIndex &index) const;
//! Used container data
virtual const ContainerType &getContainer() const;
const ContainerType &container() const;
//! \copydoc QAbstractItemModel::data()
virtual QVariant data(const QModelIndex &index, int role) const override;
@@ -226,9 +226,7 @@ namespace BlackGui
protected:
std::unique_ptr<IModelFilter<ContainerType> > m_filter; //!< Used filter
//! Constructor
//! \param translationContext I18N context
//! \param parent
//! \copydoc CListModelBaseNonTemplate::CListModelBaseNonTemplate
CListModelBase(const QString &translationContext, QObject *parent = nullptr)
: CListModelBaseNonTemplate(translationContext, parent)
{ }
@@ -268,7 +266,6 @@ namespace BlackGui
BlackMisc::CVariant bQv = b.propertyByIndex(index);
return (order == Qt::AscendingOrder) ? (aQv < bQv) : (bQv < aQv);
}
} // namespace
} // namespace
} // namespace