mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:35:10 +00:00
UI: ZonesWindow: Checkable zones.
This commit is contained in:
parent
8873904492
commit
318d6759bd
@ -199,6 +199,12 @@ const char * const sqlUpdateZoneName =
|
|||||||
" WHERE zone_id = ?1;"
|
" WHERE zone_id = ?1;"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
const char * const sqlUpdateZoneEnabled =
|
||||||
|
"UPDATE zone"
|
||||||
|
" SET enabled = ?2"
|
||||||
|
" WHERE zone_id = ?1;"
|
||||||
|
;
|
||||||
|
|
||||||
const char * const sqlUpdateZoneResult =
|
const char * const sqlUpdateZoneResult =
|
||||||
"UPDATE zone"
|
"UPDATE zone"
|
||||||
" SET checksum = ?2, last_run = ?3, last_success = ?4"
|
" SET checksum = ?2, last_run = ?3, last_success = ?4"
|
||||||
@ -701,6 +707,23 @@ bool ConfManager::updateZoneName(qint64 zoneId, const QString &zoneName)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfManager::updateZoneEnabled(qint64 zoneId, bool enabled)
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
|
||||||
|
const auto vars = QVariantList()
|
||||||
|
<< zoneId
|
||||||
|
<< enabled
|
||||||
|
;
|
||||||
|
|
||||||
|
m_sqliteDb->executeEx(sqlUpdateZoneEnabled, vars, 0, &ok);
|
||||||
|
if (!ok) {
|
||||||
|
showErrorMessage(m_sqliteDb->errorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
bool ConfManager::updateZoneResult(qint64 zoneId, const QString &checksum,
|
bool ConfManager::updateZoneResult(qint64 zoneId, const QString &checksum,
|
||||||
const QDateTime &lastRun,
|
const QDateTime &lastRun,
|
||||||
const QDateTime &lastSuccess)
|
const QDateTime &lastSuccess)
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
const QString &sourceCode, const QString &url,
|
const QString &sourceCode, const QString &url,
|
||||||
const QString &formData, bool enabled, bool customUrl);
|
const QString &formData, bool enabled, bool customUrl);
|
||||||
bool updateZoneName(qint64 zoneId, const QString &zoneName);
|
bool updateZoneName(qint64 zoneId, const QString &zoneName);
|
||||||
|
bool updateZoneEnabled(qint64 zoneId, bool enabled);
|
||||||
bool updateZoneResult(qint64 zoneId, const QString &checksum,
|
bool updateZoneResult(qint64 zoneId, const QString &checksum,
|
||||||
const QDateTime &lastRun,
|
const QDateTime &lastRun,
|
||||||
const QDateTime &lastSuccess);
|
const QDateTime &lastSuccess);
|
||||||
|
@ -280,8 +280,8 @@ void ZonesWindow::setupTableZonesHeader()
|
|||||||
header->setSectionResizeMode(2, QHeaderView::Stretch);
|
header->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||||
header->setSectionResizeMode(3, QHeaderView::Stretch);
|
header->setSectionResizeMode(3, QHeaderView::Stretch);
|
||||||
|
|
||||||
header->resizeSection(0, 500);
|
header->resizeSection(0, 350);
|
||||||
header->resizeSection(1, 140);
|
header->resizeSection(1, 290);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZonesWindow::setupTableZonesChanged()
|
void ZonesWindow::setupTableZonesChanged()
|
||||||
|
@ -84,9 +84,8 @@ int AppListModel::columnCount(const QModelIndex &parent) const
|
|||||||
QVariant AppListModel::headerData(int section, Qt::Orientation orientation,
|
QVariant AppListModel::headerData(int section, Qt::Orientation orientation,
|
||||||
int role) const
|
int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal
|
||||||
switch (role) {
|
&& role == Qt::DisplayRole) {
|
||||||
case Qt::DisplayRole: {
|
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0: return tr("Program");
|
case 0: return tr("Program");
|
||||||
case 1: return tr("Group");
|
case 1: return tr("Group");
|
||||||
@ -94,9 +93,6 @@ QVariant AppListModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
case 3: return tr("End Time");
|
case 3: return tr("End Time");
|
||||||
case 4: return tr("Creation Time");
|
case 4: return tr("Creation Time");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -36,18 +36,14 @@ int ZoneListModel::columnCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
QVariant ZoneListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant ZoneListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal
|
||||||
switch (role) {
|
&& role == Qt::DisplayRole) {
|
||||||
case Qt::DisplayRole: {
|
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0: return tr("Zone");
|
case 0: return tr("Zone");
|
||||||
case 1: return tr("Source");
|
case 1: return tr("Source");
|
||||||
case 2: return tr("Last Run");
|
case 2: return tr("Last Run");
|
||||||
case 3: return tr("Last Success");
|
case 3: return tr("Last Success");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -79,11 +75,45 @@ QVariant ZoneListModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Qt::CheckStateRole:
|
||||||
|
if (index.column() == 0) {
|
||||||
|
const auto zoneRow = zoneRowAt(index.row());
|
||||||
|
return zoneRow.enabled;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZoneListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
Q_UNUSED(value)
|
||||||
|
|
||||||
|
if (!index.isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case Qt::CheckStateRole:
|
||||||
|
const auto zoneRow = zoneRowAt(index.row());
|
||||||
|
return updateZoneEnabled(zoneRow.zoneId, !zoneRow.enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags ZoneListModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
|
const int column = index.column();
|
||||||
|
|
||||||
|
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren
|
||||||
|
| (column == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags);
|
||||||
|
}
|
||||||
|
|
||||||
const ZoneRow &ZoneListModel::zoneRowAt(int row) const
|
const ZoneRow &ZoneListModel::zoneRowAt(int row) const
|
||||||
{
|
{
|
||||||
updateRowCache(row);
|
updateRowCache(row);
|
||||||
@ -128,6 +158,16 @@ bool ZoneListModel::updateZoneName(qint64 zoneId, const QString &zoneName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZoneListModel::updateZoneEnabled(qint64 zoneId, bool enabled)
|
||||||
|
{
|
||||||
|
if (confManager()->updateZoneEnabled(zoneId, enabled)) {
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ZoneListModel::updateZoneResult(qint64 zoneId, const QString &checksum,
|
bool ZoneListModel::updateZoneResult(qint64 zoneId, const QString &checksum,
|
||||||
const QDateTime &lastRun,
|
const QDateTime &lastRun,
|
||||||
const QDateTime &lastSuccess)
|
const QDateTime &lastSuccess)
|
||||||
|
@ -45,6 +45,9 @@ public:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const override;
|
int role = Qt::DisplayRole) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||||
|
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
|
||||||
const ZoneRow &zoneRowAt(int row) const;
|
const ZoneRow &zoneRowAt(int row) const;
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ public:
|
|||||||
const QString &formData, bool enabled, bool customUrl,
|
const QString &formData, bool enabled, bool customUrl,
|
||||||
bool updateDriver = true);
|
bool updateDriver = true);
|
||||||
bool updateZoneName(qint64 zoneId, const QString &zoneName);
|
bool updateZoneName(qint64 zoneId, const QString &zoneName);
|
||||||
|
bool updateZoneEnabled(qint64 zoneId, bool enabled);
|
||||||
bool updateZoneResult(qint64 zoneId, const QString &checksum,
|
bool updateZoneResult(qint64 zoneId, const QString &checksum,
|
||||||
const QDateTime &lastRun,
|
const QDateTime &lastRun,
|
||||||
const QDateTime &lastSuccess);
|
const QDateTime &lastSuccess);
|
||||||
|
Loading…
Reference in New Issue
Block a user