provide append/removeView in dialog views model

work/spdx
Michail Vourlakos 4 years ago
parent 2bb170fba8
commit 5dde3fdfc5

@ -131,6 +131,52 @@ void Views::resetData()
setOriginalData(o_viewsTable);
}
void Views::appendView(const Latte::Data::View &view)
{
//int newRow = m_layoutsTable.sortedPosForName(layout.name);
Data::View newview = view;
if (!newview.isCreated()) {
}
beginInsertRows(QModelIndex(), m_viewsTable.rowCount(), m_viewsTable.rowCount());
m_viewsTable << view;
endInsertRows();
emit rowsInserted();
}
void Views::removeView(const QString &id)
{
int index = m_viewsTable.indexOf(id);
if (index >= 0) {
removeRows(index, 1);
}
}
bool Views::removeRows(int row, int count, const QModelIndex &parent)
{
Q_UNUSED(parent)
int firstRow = row;
int lastRow = row+count-1;
if (count > 0 && m_viewsTable.rowExists(firstRow) && (m_viewsTable.rowExists(lastRow))) {
beginRemoveRows(QModelIndex(), firstRow, lastRow);
for(int i=0; i<count; ++i) {
m_viewsTable.remove(firstRow);
}
endRemoveRows();
return true;
}
return false;
}
bool Views::isVertical(const Plasma::Types::Location &location) const
{
return (location == Plasma::Types::LeftEdge || location == Plasma::Types::RightEdge);

@ -77,6 +77,9 @@ public:
//! all original data will become also current
void resetData();
void appendView(const Latte::Data::View &view);
void removeView(const QString &id);
int rowCount() const;
static int columnCount();
int rowCount(const QModelIndex &parent) const override;
@ -86,6 +89,7 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
const Latte::Data::ViewsTable &currentViewsData();
const Latte::Data::ViewsTable &originalViewsData();

Loading…
Cancel
Save