Don't show stats for pause dirs in GUI

This commit is contained in:
Martchus 2019-02-16 00:55:27 +01:00
parent 646d9363da
commit 700b0d24e0
1 changed files with 9 additions and 7 deletions

View File

@ -102,12 +102,14 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
if (index.parent().isValid()) { if (index.parent().isValid()) {
// dir attributes // dir attributes
if (static_cast<size_t>(index.parent().row()) < m_dirs.size()) { if (static_cast<size_t>(index.parent().row()) < m_dirs.size()) {
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
const auto row = dir.paused && index.row() > 1 ? index.row() + 2 : index.row();
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::EditRole: case Qt::EditRole:
if (index.column() == 0) { if (index.column() == 0) {
// attribute names // attribute names
switch (index.row()) { switch (row) {
case 0: case 0:
return tr("ID"); return tr("ID");
case 1: case 1:
@ -135,8 +137,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
case DirectoryDetail: case DirectoryDetail:
if (index.column() == 1 || role == DirectoryDetail) { if (index.column() == 1 || role == DirectoryDetail) {
// attribute values // attribute values
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())]; switch (row) {
switch (index.row()) {
case 0: case 0:
return dir.id; return dir.id;
case 1: case 1:
@ -183,7 +184,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
switch (index.column()) { switch (index.column()) {
case 1: case 1:
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())]; const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
switch (index.row()) { switch (row) {
case 4: case 4:
if (dir.deviceIds.isEmpty()) { if (dir.deviceIds.isEmpty()) {
return Colors::gray(m_brightColors); return Colors::gray(m_brightColors);
@ -206,7 +207,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
switch (index.column()) { switch (index.column()) {
case 1: case 1:
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())]; const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
switch (index.row()) { switch (row) {
case 3: case 3:
if (dir.deviceNames.isEmpty()) { if (dir.deviceNames.isEmpty()) {
return dir.deviceIds.join(QChar('\n')); return dir.deviceIds.join(QChar('\n'));
@ -329,8 +330,9 @@ int SyncthingDirectoryModel::rowCount(const QModelIndex &parent) const
{ {
if (!parent.isValid()) { if (!parent.isValid()) {
return static_cast<int>(m_dirs.size()); return static_cast<int>(m_dirs.size());
} else if (!parent.parent().isValid()) { } else if (!parent.parent().isValid() && static_cast<size_t>(parent.row()) < m_dirs.size()) {
return 10; const SyncthingDir &dir = m_dirs[static_cast<size_t>(parent.row())];
return dir.paused ? 8 : 10;
} else { } else {
return 0; return 0;
} }