diff --git a/app/settings/controllers/layoutscontroller.cpp b/app/settings/controllers/layoutscontroller.cpp index 4a0a3bc53..548cfab61 100644 --- a/app/settings/controllers/layoutscontroller.cpp +++ b/app/settings/controllers/layoutscontroller.cpp @@ -633,9 +633,13 @@ bool Layouts::importLayoutsFromV1ConfigFile(QString file) return false; } -void Layouts::on_sharedToInEditChanged(const int &row, const bool &inEdit) +void Layouts::on_sharedToInEditChanged(const QString &id, const bool &inEdit) { - m_model->setData(m_model->index(row, Model::Layouts::SHAREDCOLUMN), inEdit, Model::Layouts::SHAREDTOINEDIT); + int row = m_model->rowForId(id); + + if (row >= 0) { + m_model->setData(m_model->index(row, Model::Layouts::SHAREDCOLUMN), inEdit, Model::Layouts::SHAREDTOINEDITROLE); + } } void Layouts::reset() diff --git a/app/settings/controllers/layoutscontroller.h b/app/settings/controllers/layoutscontroller.h index 72b62be1f..24045fea9 100644 --- a/app/settings/controllers/layoutscontroller.h +++ b/app/settings/controllers/layoutscontroller.h @@ -96,7 +96,7 @@ signals: public slots: //! needed for Delegate::Shared - void on_sharedToInEditChanged(const int &row, const bool &inEdit); + void on_sharedToInEditChanged(const QString &row, const bool &inEdit); private slots: void loadConfig(); diff --git a/app/settings/delegates/activitiesdelegate.cpp b/app/settings/delegates/activitiesdelegate.cpp index 6ea1e3c0e..09babf110 100644 --- a/app/settings/delegates/activitiesdelegate.cpp +++ b/app/settings/delegates/activitiesdelegate.cpp @@ -244,7 +244,7 @@ void Activities::paint(QPainter *painter, const QStyleOptionViewItem &option, co painter->restore(); } else { - bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDIT).toBool(); + bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDITROLE).toBool(); // Disabled bool isSelected{Latte::isSelected(option)}; diff --git a/app/settings/delegates/shareddelegate.cpp b/app/settings/delegates/shareddelegate.cpp index b0d161674..ec18bdf5f 100644 --- a/app/settings/delegates/shareddelegate.cpp +++ b/app/settings/delegates/shareddelegate.cpp @@ -90,7 +90,7 @@ QWidget *Shared::createEditor(QWidget *parent, const QStyleOptionViewItem &optio updateButtonText(button, index); - m_controller->on_sharedToInEditChanged(index.row(), true); + m_controller->on_sharedToInEditChanged(layoutId, true); return button; } @@ -114,7 +114,8 @@ void Shared::setModelData(QWidget *editor, QAbstractItemModel *model, const QMod model->setData(index, assignedLayouts, Qt::UserRole); - m_controller->on_sharedToInEditChanged(index.row(), false); + QString layoutId = index.data(Model::Layouts::IDROLE).toString(); + m_controller->on_sharedToInEditChanged(layoutId, false); } void Shared::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -126,7 +127,7 @@ void Shared::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &o void Shared::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDIT).toBool(); + bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDITROLE).toBool(); Data::LayoutsTable allLayouts = qvariant_cast(index.data(Model::Layouts::ALLLAYOUTSROLE)); QStringList assignedIds = index.data(Qt::UserRole).toStringList(); QStringList originalIds = index.data(Model::Layouts::ORIGINALSHARESROLE).toStringList(); @@ -144,7 +145,7 @@ void Shared::paint(QPainter *painter, const QStyleOptionViewItem &option, const myOptions.state = (myOptions.state & ~QStyle::State_HasFocus); painter->save(); - if (assignedLayouts.rowCount() > 0) { + if (assignedLayouts.rowCount() > 0 && !sharedInEdit) { //! indicator if (!sharedInEdit) { paintSharedToIndicator(painter, myOptions, index); diff --git a/app/settings/models/layoutsmodel.cpp b/app/settings/models/layoutsmodel.cpp index 276444899..04af61dc8 100644 --- a/app/settings/models/layoutsmodel.cpp +++ b/app/settings/models/layoutsmodel.cpp @@ -476,7 +476,7 @@ QVariant Layouts::data(const QModelIndex &index, int role) const QVariant layouts; layouts.setValue(m_layoutsTable); return layouts; - } else if (role == SHAREDTOINEDIT) { + } else if (role == SHAREDTOINEDITROLE) { return (m_sharedToInEditRow == row); } else if (role == ISNEWLAYOUTROLE) { return isNewLayout; @@ -884,11 +884,12 @@ bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role) setShares(row, value.toStringList()); emit dataChanged(this->index(row, NAMECOLUMN), this->index(row,NAMECOLUMN), roles); return true; - } else if (role == SHAREDTOINEDIT) { + } else if (role == SHAREDTOINEDITROLE) { bool inEdit = value.toBool(); m_sharedToInEditRow = inEdit ? row : -1; roles << Qt::DisplayRole; roles << Qt::UserRole; + roles << SHAREDTOINEDITROLE; emit dataChanged(this->index(row, ACTIVITYCOLUMN), this->index(row, SHAREDCOLUMN), roles); emit dataChanged(this->index(row, NAMECOLUMN), this->index(row,NAMECOLUMN), roles); return true; diff --git a/app/settings/models/layoutsmodel.h b/app/settings/models/layoutsmodel.h index b2df9a4c5..c4b38f85e 100644 --- a/app/settings/models/layoutsmodel.h +++ b/app/settings/models/layoutsmodel.h @@ -67,7 +67,7 @@ public: ALLACTIVITIESSORTEDROLE, ALLACTIVITIESDATAROLE, ALLLAYOUTSROLE, - SHAREDTOINEDIT, + SHAREDTOINEDITROLE, SORTINGROLE, ISNEWLAYOUTROLE, LAYOUTHASCHANGESROLE, @@ -173,7 +173,7 @@ private: //! break MVC only when a SharedTo editor is created //! because we want to move the dot indicator in the Activities delegate //! when that happens - int m_sharedToInEditRow{-1}; + int m_sharedToInEditRow; QString m_iconsPath;