mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-11 13:18:13 +03:00
make Shared button proxy model aware
This commit is contained in:
parent
a7ecd549b0
commit
4deaa3bc0b
@ -283,36 +283,36 @@ void Layouts::toggleLockedForSelected()
|
||||
}
|
||||
|
||||
void Layouts::toggleSharedForSelected()
|
||||
{
|
||||
{
|
||||
if (m_view->currentIndex().row() < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int row = m_view->currentIndex().row();
|
||||
|
||||
Data::Layout selected = selectedLayout();
|
||||
|
||||
if (selected.isShared()) {
|
||||
m_proxyModel->setData(m_proxyModel->index(m_view->currentIndex().row(), Model::Layouts::SHAREDCOLUMN), QStringList(), Qt::UserRole);
|
||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), QStringList(), Qt::UserRole);
|
||||
} else {
|
||||
/* bool assigned{false};
|
||||
QStringList assignedList;
|
||||
QStringList assignedIds;
|
||||
QStringList availableShareIds = m_model->availableShareIdsFor(selected.id);
|
||||
|
||||
QStringList availableShares = availableSharesFor(row);
|
||||
for (const auto &id : availableShareIds) {
|
||||
int iRow = m_model->rowForId(id);
|
||||
Data::Layout iLayout = m_model->at(iRow);
|
||||
|
||||
for (const auto &id : availableShares) {
|
||||
QString name = nameForId(id);
|
||||
if (m_corona->layoutsManager()->synchronizer()->layout(name)) {
|
||||
assignedList << id;
|
||||
m_model->setData(m_model->index(row, Model::Layouts::SHAREDCOLUMN), assignedList, Qt::UserRole);
|
||||
assigned = true;
|
||||
if (m_corona->layoutsManager()->synchronizer()->layout(iLayout.originalName())) {
|
||||
assignedIds << id;
|
||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), assignedIds, Qt::UserRole);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!assigned && availableShares.count()>0) {
|
||||
assignedList << availableShares[0];
|
||||
m_model->setData(m_model->index(row, Model::Layouts::SHAREDCOLUMN), assignedList, Qt::UserRole);
|
||||
assigned = true;
|
||||
}*/
|
||||
if (assignedIds.isEmpty() && availableShareIds.count()>0) {
|
||||
assignedIds << availableShareIds[0];
|
||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), assignedIds, Qt::UserRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,6 +498,21 @@ void Layouts::setId(const int &row, const QString &newId)
|
||||
}
|
||||
}
|
||||
|
||||
QStringList Layouts::availableShareIdsFor(const QString id) const
|
||||
{
|
||||
QStringList shares;
|
||||
|
||||
for(int i=0; i<rowCount(); ++i) {
|
||||
if (m_layoutsTable[i].id == id || m_layoutsTable[i].isShared()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
shares << m_layoutsTable[i].id;
|
||||
}
|
||||
|
||||
return shares;
|
||||
}
|
||||
|
||||
void Layouts::setShares(const int &row, const QStringList &shares)
|
||||
{
|
||||
if (!m_layoutsTable.rowExists(row) || m_layoutsTable[row].shares == shares) {
|
||||
@ -509,7 +524,7 @@ void Layouts::setShares(const int &row, const QStringList &shares)
|
||||
roles << Qt::UserRole;
|
||||
|
||||
m_layoutsTable[row].shares = shares;
|
||||
emit dataChanged(index(row,SHAREDCOLUMN), index(row,SHAREDCOLUMN), roles);
|
||||
emit dataChanged(index(row,IDCOLUMN), index(row,SHAREDCOLUMN), roles);
|
||||
|
||||
for(int i=0; i<rowCount(); ++i) {
|
||||
if (i == row) {
|
||||
@ -519,7 +534,7 @@ void Layouts::setShares(const int &row, const QStringList &shares)
|
||||
auto cleaned = cleanStrings(m_layoutsTable[i].shares, shares);
|
||||
if (cleaned != m_layoutsTable[i].shares) {
|
||||
m_layoutsTable[i].shares = cleaned;
|
||||
emit dataChanged(index(i,SHAREDCOLUMN), index(i,SHAREDCOLUMN), roles);
|
||||
emit dataChanged(index(i,IDCOLUMN), index(i,SHAREDCOLUMN), roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
QString layoutNameForFreeActivities() const;
|
||||
void setLayoutNameForFreeActivities(const QString &name);
|
||||
|
||||
QStringList availableShareIdsFor(const QString id) const;
|
||||
|
||||
const Data::LayoutsTable ¤tData();
|
||||
void setCurrentData(Data::LayoutsTable &data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user