diff options
author | Arno <am@disconnect.de> | 2012-03-02 20:57:55 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-03-02 20:57:55 +0100 |
commit | 8b0aca608140c72fb7d60f7b821f78a86848a70a (patch) | |
tree | a6bf1ccef9f4b2021e92695c7459ae72859a86b7 /mappingtreewidget.cpp | |
parent | 6e03469151a2a3eae6e54dd1e138a2628d51eab3 (diff) | |
download | SheMov-8b0aca608140c72fb7d60f7b821f78a86848a70a.tar.gz SheMov-8b0aca608140c72fb7d60f7b821f78a86848a70a.tar.bz2 SheMov-8b0aca608140c72fb7d60f7b821f78a86848a70a.zip |
Make add mapping item a context menu entry
Remove the QLineEdit and QPushButtons from the bottom of
MappingTreeWidget and make adding mapping items available in the context
menu.
Diffstat (limited to 'mappingtreewidget.cpp')
-rw-r--r-- | mappingtreewidget.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index 41aa6e2..ba175ba 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -49,18 +49,9 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ connect(mAddType, SIGNAL(clicked()), this, SLOT(addType())); mDeleteType = new QPushButton(tr("Delete type")); connect(mDeleteType, SIGNAL(clicked()), this, SLOT(deleteType())); - mEdit = new QLineEdit; - mAddChild = new QPushButton(tr("&Add")); - connect(mAddChild, SIGNAL(clicked()), this, SLOT(addChild())); - mDeleteChild = new QPushButton(tr("Delete")); - connect(mDeleteChild, SIGNAL(clicked()), this, SLOT(deleteChild())); QHBoxLayout *typesButtonLayout = new QHBoxLayout; typesButtonLayout->addWidget(mDeleteType); typesButtonLayout->addWidget(mAddType); - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(); - buttonLayout->addWidget(mDeleteChild); - buttonLayout->addWidget(mAddChild); //select type and populate model QSettings s; @@ -78,6 +69,9 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ } //setup actions + mAddChildA = new QAction(tr("Add..."), this); + connect(mAddChildA, SIGNAL(triggered()), this, SLOT(addChild())); + mTree->addAction(mAddChildA); mDeleteChildA = new QAction(tr("Delete"), this); connect(mDeleteChildA, SIGNAL(triggered()), this, SLOT(deleteChild())); mTree->addAction(mDeleteChildA); @@ -93,11 +87,7 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ mainLayout->addWidget(mTypeBox); mainLayout->addLayout(typesButtonLayout); mainLayout->addWidget(mTree); - mainLayout->addWidget(mEdit); - mainLayout->addLayout(buttonLayout); setLayout(mainLayout); - mEdit->setFocus(); - setTabOrder(mEdit, mAddChild); } MappingData MappingTreeWidget::selectedItem() const { @@ -127,11 +117,7 @@ MappingData MappingTreeWidget::selectedItem() const { void MappingTreeWidget::addChild(){ QModelIndex sel = selected(); - if(!sel.isValid()){ - QMessageBox::critical(this, tr("Error"), tr("No parent item selected!")); - return; - } - QString value = mEdit->text().toLower().trimmed(); + QString value = QInputDialog::getText(this, tr("Mapping name"), tr("Enter mapping name")); if(value.isEmpty()){ return; } |