Skip to content

Commit

Permalink
Fixes 3620. Allow deleting classes through del key.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jan 26, 2016
1 parent e1abbec commit 05b12e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -2193,10 +2193,12 @@ void LibraryTreeView::createActions()
connect(mpDuplicateClassAction, SIGNAL(triggered()), SLOT(duplicateClass()));
// unload Action
mpUnloadClassAction = new QAction(QIcon(":/Resources/icons/delete.svg"), Helper::unloadClass, this);
mpUnloadClassAction->setShortcut(QKeySequence::Delete);
mpUnloadClassAction->setStatusTip(Helper::unloadClassTip);
connect(mpUnloadClassAction, SIGNAL(triggered()), SLOT(unloadClass()));
// unload TLM/Text file Action
mpUnloadTLMFileAction = new QAction(QIcon(":/Resources/icons/delete.svg"), Helper::unloadClass, this);
mpUnloadTLMFileAction->setShortcut(QKeySequence::Delete);
mpUnloadTLMFileAction->setStatusTip(Helper::unloadTLMOrTextTip);
connect(mpUnloadTLMFileAction, SIGNAL(triggered()), SLOT(unloadTLMOrTextFile()));
// Export FMU Action
Expand Down Expand Up @@ -2712,6 +2714,26 @@ void LibraryTreeView::startDrag(Qt::DropActions supportedActions)
}
}

/*!
* \brief LibraryTreeView::keyPressEvent
* Reimplementation of keypressevent.
* \param event
*/
void LibraryTreeView::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Delete) {
LibraryTreeItem *pLibraryTreeItem = getSelectedLibraryTreeItem();
if (pLibraryTreeItem) {
if (pLibraryTreeItem->getLibraryType() == LibraryTreeItem::Modelica) {
unloadClass();
} else {
unloadTLMOrTextFile();
}
}
}
QTreeView::keyPressEvent(event);
}

/*!
* \class LibraryWidget
* \brief A widget for Libraries Browser.
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -332,6 +332,7 @@ public slots:
protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void startDrag(Qt::DropActions supportedActions);
virtual void keyPressEvent(QKeyEvent *event);
};

class MainWindow;
Expand Down

0 comments on commit 05b12e1

Please sign in to comment.