summaryrefslogtreecommitdiffstats
path: root/mappingtreewidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2015-06-06 11:53:07 +0200
committerArno <arno@disconnect.de>2015-06-06 11:53:07 +0200
commit9d5f54e04b70b2b7a882c9c8c66b28494ab8e598 (patch)
tree260a4ef00ab4d2c49931d01f5fd018f89ea58c22 /mappingtreewidget.cpp
parent41e54bc5bded308687ad090afef9e5737edbe9b3 (diff)
downloadSheMov-9d5f54e04b70b2b7a882c9c8c66b28494ab8e598.tar.gz
SheMov-9d5f54e04b70b2b7a882c9c8c66b28494ab8e598.tar.bz2
SheMov-9d5f54e04b70b2b7a882c9c8c66b28494ab8e598.zip
More keyboard navigation
Add CTRL+A for new actor to MappingTreeView
Diffstat (limited to 'mappingtreewidget.cpp')
-rw-r--r--mappingtreewidget.cpp29
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()));