diff options
Diffstat (limited to 'mappingtreewidget.cpp')
-rw-r--r-- | mappingtreewidget.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index dcebb02..ebd244e 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -92,9 +92,13 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ filterLayout->addWidget(mClearFilter); //setup actions - mAddChildA = new QAction(tr("Add..."), this); + mAddChildA = new QAction(tr("Add child..."), this); connect(mAddChildA, SIGNAL(triggered()), this, SLOT(addChild())); mTree->addAction(mAddChildA); + mAddActorA = new QAction(tr("Add actor..."), this); + mAddActorA->setShortcut(Qt::CTRL + Qt::Key_A); + connect(mAddActorA, SIGNAL(triggered()), this, SLOT(addActor())); + mTree->addAction(mAddActorA); mDeleteChildA = new QAction(tr("Delete..."), this); connect(mDeleteChildA, SIGNAL(triggered()), this, SLOT(deleteChild())); mTree->addAction(mDeleteChildA); @@ -102,7 +106,7 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ connect(mEditChildA, SIGNAL(triggered()), this, SLOT(editChild())); mTree->addAction(mEditChildA); - //widget layout and tab order + //widget layout and misc QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(mTypeBox); mainLayout->addLayout(filterLayout); @@ -153,6 +157,26 @@ void MappingTreeWidget::addChild(){ } } +void MappingTreeWidget::addActor(){ + QModelIndex actorIndex = mModel->find("actors", MappingTreeModel::Name); + if(!actorIndex.isValid()){ + QMessageBox::critical(this, tr("Error"), tr("Could not find actors!")); + return; + } + QString newActorName = QInputDialog::getText(this, tr("New actor"), tr("Actor")); + if(!newActorName.isEmpty()){ + mModel->addChild(newActorName, actorIndex); + actorIndex = mModel->find("actors", MappingTreeModel::Name); + QModelIndex newIdx = mModel->find(newActorName, MappingTreeModel::Name, actorIndex); + if(newIdx.isValid()){ + QModelIndex newIdxProxy = mProxy->mapFromSource(newIdx); + mTree->scrollTo(newIdxProxy, QAbstractItemView::EnsureVisible); + mTree->selectionModel()->setCurrentIndex(newIdxProxy, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current | QItemSelectionModel::Rows); + } + } +} + + void MappingTreeWidget::addType(){ QString typeName = QInputDialog::getText(this, tr("Enter type name"), tr("Name")).toLower().trimmed(); if(typeName.isEmpty()){ @@ -319,6 +343,7 @@ MappingEditWidget::MappingEditWidget(QWidget *parent) : QWidget(parent){ connect(mMappingTree->mappingTreeView(), SIGNAL(addMapping()), this, SLOT(addMapping())); connect(mMappingTree->mappingTreeView(), SIGNAL(clearMappings()), this, SLOT(clearMapping())); connect(mMappingTree->mappingTreeView(), SIGNAL(shiftFocus()), this, SLOT(shiftFocusResult())); + connect(mMappingTree->mappingTreeView(), SIGNAL(addActor()), this, SLOT(addActor())); connect(mMappingResult, SIGNAL(shiftFocus()), this, SLOT(shiftFocusMappings())); connect(mMappingResult, SIGNAL(removeMapping()), this, SLOT(removeMapping())); |