Move Action change dialogs

This commit is contained in:
2024-01-11 22:27:02 +01:00
parent 2e7d6ad6c5
commit 6136280507
20 changed files with 498 additions and 39 deletions
+35 -14
View File
@@ -207,23 +207,12 @@ bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction a
iter = m_actionsContainer->insert(iter, std::move(action));
endInsertRows();
if (!actions.isEmpty())
emit changed();
return true;
}
QMap<int, QVariant> ActionsContainerModel::itemData(const QModelIndex &index) const
{
auto itemData = QAbstractListModel::itemData(index);
qDebug() << index << itemData;
return itemData;
}
bool ActionsContainerModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
{
auto setItemData = QAbstractListModel::setItemData(index, roles);
qDebug() << index << roles << setItemData;
return setItemData;
}
bool ActionsContainerModel::removeRows(int row, int count, const QModelIndex &parent)
{
qDebug() << row << count << parent.isValid();
@@ -251,6 +240,9 @@ bool ActionsContainerModel::removeRows(int row, int count, const QModelIndex &pa
m_actionsContainer->erase(begin, end);
endRemoveRows();
if (count)
emit changed();
return true;
}
@@ -272,6 +264,7 @@ bool ActionsContainerModel::moveRows(const QModelIndex &sourceParent, int source
m_actionsContainer->splice(std::next(std::begin(*m_actionsContainer), destinationChild), *m_actionsContainer, std::next(std::begin(*m_actionsContainer), sourceRow));
endMoveRows();
emit changed();
return true;
}
@@ -338,3 +331,31 @@ const Action *ActionsContainerModel::getAction(int row) const
return &*std::next(std::cbegin(*m_actionsContainer), row);
}
void ActionsContainerModel::appendAction(Action &&action)
{
if (!m_actionsContainer)
{
qWarning() << "invalid actions container";
return;
}
beginInsertRows({}, m_actionsContainer->size(), m_actionsContainer->size());
m_actionsContainer->push_back(std::move(action));
endInsertRows();
emit changed();
}
void ActionsContainerModel::appendAction(const Action &action)
{
if (!m_actionsContainer)
{
qWarning() << "invalid actions container";
return;
}
beginInsertRows({}, m_actionsContainer->size(), m_actionsContainer->size());
m_actionsContainer->push_back(action);
endInsertRows();
emit changed();
}
+6 -3
View File
@@ -25,9 +25,6 @@ public:
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
QMap<int, QVariant> itemData(const QModelIndex &index) const override;
bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
bool removeRows(int row, int count, const QModelIndex &parent) override;
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
@@ -39,6 +36,12 @@ public:
Action *getAction(int row);
const Action *getAction(int row) const;
void appendAction(Action &&action);
void appendAction(const Action &action);
signals:
void changed();
private:
ActionsContainer *m_actionsContainer{};
};