1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

viewsdialog:hide ids for temporary view records

This commit is contained in:
Michail Vourlakos 2021-04-09 11:53:28 +03:00
parent 4d5986a7ff
commit 961ae8f431
2 changed files with 29 additions and 4 deletions

View File

@ -26,6 +26,7 @@
#include "viewshandler.h"
#include "viewsmodel.h"
#include "delegates/singleoptiondelegate.h"
#include "delegates/singletextdelegate.h"
#include "../generic/generictools.h"
// Qt
@ -93,9 +94,11 @@ void Views::init()
m_view->sortByColumn(m_viewSortColumn, m_viewSortOrder);
m_view->setItemDelegateForColumn(Model::Views::IDCOLUMN, new Settings::View::Delegate::SingleText(this));
m_view->setItemDelegateForColumn(Model::Views::SCREENCOLUMN, new Settings::View::Delegate::SingleOption(this));
m_view->setItemDelegateForColumn(Model::Views::EDGECOLUMN, new Settings::View::Delegate::SingleOption(this));
m_view->setItemDelegateForColumn(Model::Views::ALIGNMENTCOLUMN, new Settings::View::Delegate::SingleOption(this));
m_view->setItemDelegateForColumn(Model::Views::SUBCONTAINMENTSCOLUMN, new Settings::View::Delegate::SingleText(this));
applyColumnWidths();

View File

@ -29,6 +29,8 @@
// KDE
#include <KLocalizedString>
#define TEMPIDDISPLAY "#"
namespace Latte {
namespace Settings {
namespace Model {
@ -412,7 +414,7 @@ QVariant Views::data(const QModelIndex &index, int role) const
}
if (role == IDROLE) {
return m_viewsTable[row].id;
return (m_viewsTable[row].state() == Data::View::IsCreated ? m_viewsTable[row].id : "#");
} else if (role == ISACTIVEROLE) {
return m_viewsTable[row].isActive;
} else if (role == CHOICESROLE) {
@ -443,7 +445,9 @@ QVariant Views::data(const QModelIndex &index, int role) const
switch (column) {
case IDCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
if (role == Qt::DisplayRole){
return (m_viewsTable[row].state() == Data::View::IsCreated ? m_viewsTable[row].id : "#");
} else if (role == Qt::UserRole) {
return m_viewsTable[row].id;
}
break;
@ -507,8 +511,26 @@ QVariant Views::data(const QModelIndex &index, int role) const
}
break;
case SUBCONTAINMENTSCOLUMN:
if (role == Qt::DisplayRole || role == Qt::UserRole){
return m_viewsTable[row].subcontainments.rowCount()>0 ? QString("{" + m_viewsTable[row].subcontainments + "}") : QString();
if (role == Qt::DisplayRole){
if (m_viewsTable[row].subcontainments.rowCount()>0) {
QString result = "{";
for (int i=0; i<m_viewsTable[row].subcontainments.rowCount(); ++i) {
if (i>0) {
result += " ";
}
result += (m_viewsTable[row].state() == Data::View::IsCreated ? m_viewsTable[row].subcontainments[i].id : TEMPIDDISPLAY);
if (i<m_viewsTable[row].subcontainments.rowCount()-1) {
result += ",";
}
}
result += "}";
return result;
}
return QString();
}
};