Skip to content

Commit

Permalink
Added support for moveClassToTop & moveClassToBottom.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Dec 1, 2015
1 parent efb4e4d commit 1894748
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
20 changes: 12 additions & 8 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1792,16 +1792,20 @@ void LibraryTreeModel::moveClassTopBottom(LibraryTreeItem *pLibraryTreeItem, boo
int row = pLibraryTreeItem->row();
bool update = false;
if (top && row > 0) {
if (beginMoveRows(parentIndex, row, row, parentIndex, 0)) {
pParentLibraryTreeItem->moveChild(row, 0);
endMoveRows();
update = true;
if (mpLibraryWidget->getMainWindow()->getOMCProxy()->moveClassToTop(pLibraryTreeItem->getNameStructure())) {
if (beginMoveRows(parentIndex, row, row, parentIndex, 0)) {
pParentLibraryTreeItem->moveChild(row, 0);
endMoveRows();
update = true;
}
}
} else if (!top && row < pParentLibraryTreeItem->getChildren().size() - 1) {
if (beginMoveRows(parentIndex, row, row, parentIndex, pParentLibraryTreeItem->getChildren().size())) {
pParentLibraryTreeItem->moveChild(row, pParentLibraryTreeItem->getChildren().size() - 1);
endMoveRows();
update = true;
if (mpLibraryWidget->getMainWindow()->getOMCProxy()->moveClassToBottom(pLibraryTreeItem->getNameStructure())) {
if (beginMoveRows(parentIndex, row, row, parentIndex, pParentLibraryTreeItem->getChildren().size())) {
pParentLibraryTreeItem->moveChild(row, pParentLibraryTreeItem->getChildren().size() - 1);
endMoveRows();
update = true;
}
}
}
if (update) {
Expand Down
24 changes: 23 additions & 1 deletion OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -2434,7 +2434,7 @@ void OMCProxy::getNonLinearSolvers(QStringList *methods, QStringList *descriptio

/*!
* \brief OMCProxy::moveClass
* Moves the class.
* Moves the class by offset in its enclosing class.
* \param className
* \param offset
* \return
Expand All @@ -2444,6 +2444,28 @@ bool OMCProxy::moveClass(QString className, int offset)
return mpOMCInterface->moveClass(className, offset);
}

/*!
* \brief OMCProxy::moveClassToTop
* Moves the class to top of its enclosing class.
* \param className
* \return
*/
bool OMCProxy::moveClassToTop(QString className)
{
return mpOMCInterface->moveClassToTop(className);
}

/*!
* \brief OMCProxy::moveClassToBottom
* Moves the class to bottom of its enclosing class.
* \param className
* \return
*/
bool OMCProxy::moveClassToBottom(QString className)
{
return mpOMCInterface->moveClassToBottom(className);
}

/*!
\class CustomExpressionBox
\brief A text box for executing OMC commands.
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/OMC/OMCProxy.h
Expand Up @@ -224,6 +224,8 @@ class OMCProxy : public QObject
void getLinearSolvers(QStringList *methods, QStringList *descriptions);
void getNonLinearSolvers(QStringList *methods, QStringList *descriptions);
bool moveClass(QString className, int offset);
bool moveClassToTop(QString className);
bool moveClassToBottom(QString className);
signals:
void commandFinished();
public slots:
Expand Down

0 comments on commit 1894748

Please sign in to comment.