Commit f7c123e6 authored by Karel Slaný's avatar Karel Slaný

Added DataboxListModel::selectEntries().

parent 1dea16cd
......@@ -337,6 +337,27 @@ bool DataboxListModel::selectEntry(const QString &boxId, bool selected)
return false;
}
bool DataboxListModel::selectEntries(const QStringList &boxIds,
bool selected)
{
if (Q_UNLIKELY(boxIds.size() == 0)) {
return false;
}
bool ret = false;
foreach (const QString &boxId, boxIds) {
/* Beware of short-circuit evaluation. */
ret = selectEntry(boxId, selected) || ret;
}
return ret;
}
QStringList DataboxListModel::boxIds(void) const
{
return m_boxIds;
}
int DataboxListModel::setQuery(QSqlQuery &query, const QString &dbId,
bool isAppend)
{
......
......@@ -59,6 +59,9 @@ public:
*/
DataboxModelEntry(const DataboxModelEntry &dme);
/*!
* @brief Constructor.
*/
DataboxModelEntry(const QString &dbID, const QString &dbType,
const QString &dbName, const QString &dbAddress, const QString &dbIC,
const QString &dbEffectiveOVM, const QString &dbSendOptions);
......@@ -118,7 +121,7 @@ private:
QString m_dbAddress; /*!< Databox owner address. */
QString m_dbIC; /*!< Databox owner IC. */
QString m_dbEffectiveOVM; /*!< Flag effective OVM (see IDSD documentation). */
QString m_dbSendOptions; /*!< Flag send otption (see IDSD documentation). */
QString m_dbSendOptions; /*!< Flag send option (see IDSD documentation). */
};
/* QML passes its arguments via QVariant. */
......@@ -139,7 +142,7 @@ public:
ROLE_DB_IC,
ROLE_DB_EFFECTIVE_OVM,
ROLE_DB_SEND_OPTION,
ROLE_DB_SELECTED /* TODO -- See whether ItemSelectionModel can be used. */
ROLE_DB_SELECTED /* TODO -- See whether ItemSelectionModel can be used instead. */
};
Q_ENUM(Roles)
......@@ -223,8 +226,10 @@ public:
* @brief Return entry at given row.
*
* @note http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
* Use this method only inside QML code.
*
* @param[in] boxId Data box identifier.
* @return Newly allocated model entry.
*/
Q_INVOKABLE
DataboxModelEntry *entry(const QString &boxId) const;
......@@ -239,6 +244,24 @@ public:
Q_INVOKABLE
bool selectEntry(const QString &boxId, bool selected);
/*!
* @brief Assign selection state for box entries.
*
* @param[in] boxIds Data box identifiers.
* @param[in] selected Selection state.
* @return true if at least one selection state was successfully set.
*/
Q_INVOKABLE
bool selectEntries(const QStringList &boxIds, bool selected);
/*!
* @brief Return data box identifiers held within the model.
*
* @return List of data box identifiers.
*/
Q_INVOKABLE
QStringList boxIds(void) const;
/*!
* @brief Sets the content of the model according to the supplied query.
*
......@@ -294,8 +317,8 @@ private:
{
}
DataboxModelEntry entry;
bool selected;
DataboxModelEntry entry; /*!< Sata box entry. */
bool selected; /*!< Selection information. */
};
QList<QString> m_boxIds; /*!< List of box identifiers (map keys). */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment