Skip to content

Commit

Permalink
Update room editor on proto changes (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundies committed Sep 14, 2021
1 parent 7b5ef37 commit 60ae5f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions MainWindow.cpp
Expand Up @@ -445,6 +445,8 @@ void MainWindow::openProject(std::unique_ptr<buffers::Project> openedProject) {
connect(treeModel.get(), &TreeModel::TreeChanged, resourceMap.get(), &ResourceModelMap::TreeChanged);
connect(treeModel.get(), &TreeModel::ItemRemoved, resourceMap.get(), &ResourceModelMap::ResourceRemoved,
Qt::DirectConnection);
connect(pm, &ProtoModel::dataChanged, resourceMap.get(), &ResourceModelMap::dataChanged,
Qt::DirectConnection);
connect(treeModel.get(), &TreeModel::ModelAboutToBeDeleted, this, &MainWindow::ResourceModelDeleted,
Qt::DirectConnection);
}
Expand Down
6 changes: 4 additions & 2 deletions Models/ResourceModelMap.cpp
Expand Up @@ -43,6 +43,10 @@ static void TreeChangedHelper(MessageModel* model, ResourceModelMap* rm) {
}
}

void ResourceModelMap::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) {
emit DataChanged();
}

void ResourceModelMap::TreeChanged(MessageModel* model) {
_resources.clear();
TreeChangedHelper(model, this);
Expand Down Expand Up @@ -195,8 +199,6 @@ void ResourceModelMap::ResourceRenamed(TypeCase type, const QString& oldName, co
if (oldName == newName || !_resources[type].contains(oldName)) return;
_resources[type][newName] = _resources[type][oldName];

//MainWindow::

emit ResourceRenamed(ResTypeAsString(type), oldName, newName);
_resources[type].remove(oldName);

Expand Down
1 change: 1 addition & 0 deletions Models/ResourceModelMap.h
Expand Up @@ -21,6 +21,7 @@ class ResourceModelMap : public QObject {
bool ValidName(TypeCase type, const QString& name);

public slots:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
void TreeChanged(MessageModel* model);
void ResourceRenamed(TypeCase type, const QString& oldName, const QString& newName);
void ResourceRemoved(TypeCase type, const QString& name,
Expand Down

0 comments on commit 60ae5f5

Please sign in to comment.