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

provide views table header

This commit is contained in:
Michail Vourlakos 2021-03-31 11:03:36 +03:00
parent a71c2cc96b
commit 9d68f6b32a
2 changed files with 50 additions and 0 deletions

View File

@ -20,6 +20,8 @@
#include "viewsmodel.h"
// KDE
#include <KLocalizedString>
namespace Latte {
namespace Settings {
@ -84,6 +86,53 @@ void Views::setOriginalData(Latte::Data::ViewsTable &data)
emit rowsInserted();
}
QVariant Views::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation != Qt::Horizontal) {
return QAbstractTableModel::headerData(section, orientation, role);
}
if (role == Qt::FontRole) {
QFont font = qvariant_cast<QFont>(QAbstractTableModel::headerData(section, orientation, role));
font.setBold(true);
return font;
}
switch(section) {
case IDCOLUMN:
if (role == Qt::DisplayRole) {
return QString("#");
}
break;
case SCREENCOLUMN:
if (role == Qt::DisplayRole) {
return QString(i18n("Screen"));
} else if (role == Qt::DecorationRole) {
return QIcon::fromTheme("desktop");
}
break;
case EDGECOLUMN:
if (role == Qt::DisplayRole) {
return QString(i18nc("screen edge", "Edge"));
} else if (role == Qt::DecorationRole) {
return QIcon::fromTheme("transform-move");
}
break;
case ALIGNMENTCOLUMN:
if (role == Qt::DisplayRole) {
return QString(i18n("Alignment"));
} else if (role == Qt::DecorationRole) {
return QIcon::fromTheme("format-justify-center");
}
break;
default:
break;
};
return QAbstractTableModel::headerData(section, orientation, role);
}
QVariant Views::data(const QModelIndex &index, int role) const
{
const int row = index.row();

View File

@ -73,6 +73,7 @@ public:
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
const Latte::Data::ViewsTable &currentViewsData();
const Latte::Data::ViewsTable &originalViewsData();