mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-11 13:18:13 +03:00
fix sharedcolumn and introduce some editable items
This commit is contained in:
parent
bab5564d0a
commit
4874b254dd
@ -76,7 +76,7 @@ int Layouts::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
return SHAREDCOLUMN;
|
||||
return SHAREDCOLUMN+1;
|
||||
}
|
||||
|
||||
void Layouts::clear()
|
||||
@ -136,7 +136,7 @@ QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role)
|
||||
return QString("#hidden_text");
|
||||
}
|
||||
break;
|
||||
case COLORCOLUMN:
|
||||
case BACKGROUNDCOLUMN:
|
||||
if (role == Qt::DisplayRole) {
|
||||
return QString(i18nc("column for layout background", "Background"));
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
@ -179,6 +179,40 @@ QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role)
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags Layouts::flags(const QModelIndex &index) const
|
||||
{
|
||||
const int column = index.column();
|
||||
const int row = index.column();
|
||||
|
||||
auto flags = QAbstractTableModel::flags(index);
|
||||
|
||||
bool isShared = m_inMultipleMode && m_layoutsTable[row].isShared();
|
||||
|
||||
if (column == MENUCOLUMN || column == BORDERSCOLUMN) {
|
||||
if (isShared) {
|
||||
flags &= ~Qt::ItemIsEnabled;
|
||||
} else {
|
||||
flags |= Qt::ItemIsUserCheckable;
|
||||
}
|
||||
}
|
||||
|
||||
if (column == ACTIVITYCOLUMN) {
|
||||
if (isShared) {
|
||||
flags &= ~Qt::ItemIsEnabled;
|
||||
} else {
|
||||
flags |= Qt::ItemIsEditable;
|
||||
}
|
||||
}
|
||||
|
||||
if (column == BACKGROUNDCOLUMN
|
||||
|| column == NAMECOLUMN
|
||||
|| column == SHAREDCOLUMN) {
|
||||
flags |= Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVariant Layouts::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
const int row = index.row();
|
||||
@ -206,7 +240,7 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
case HIDDENTEXTCOLUMN:
|
||||
return QVariant{};
|
||||
case COLORCOLUMN:
|
||||
case BACKGROUNDCOLUMN:
|
||||
return m_layoutsTable[row].background.isEmpty() ? m_layoutsTable[row].color : m_layoutsTable[row].background;
|
||||
break;
|
||||
case NAMECOLUMN:
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
{
|
||||
IDCOLUMN = 0,
|
||||
HIDDENTEXTCOLUMN,
|
||||
COLORCOLUMN,
|
||||
BACKGROUNDCOLUMN,
|
||||
NAMECOLUMN,
|
||||
MENUCOLUMN,
|
||||
BORDERSCOLUMN,
|
||||
@ -75,8 +75,11 @@ public:
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
const Data::Layout &at(const int &row);
|
||||
|
||||
|
||||
|
||||
void appendLayout(const Settings::Data::Layout &layout);
|
||||
void clear();
|
||||
void removeLayout(const QString &id);
|
||||
|
Loading…
Reference in New Issue
Block a user