Skip to content

Commit

Permalink
Added a model/view structure for libraries browser.
Browse files Browse the repository at this point in the history
Better way to generate library icons.
  • Loading branch information
adeas31 committed Aug 25, 2015
1 parent c765b69 commit 485c5f5
Show file tree
Hide file tree
Showing 44 changed files with 3,144 additions and 2,703 deletions.
8 changes: 4 additions & 4 deletions OMEdit/OMEditGUI/Annotations/LineAnnotation.cpp
Expand Up @@ -579,7 +579,7 @@ void LineAnnotation::setShapeFlags(bool enable)
Only set the ItemIsMovable & ItemSendsGeometryChanges flags on Line if the class is not a system library class
AND Line is not an inherited Line AND Line type is not ConnectionType.
*/
bool isSystemLibrary = mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary();
bool isSystemLibrary = mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isSystemLibrary();
if (!isSystemLibrary && !isInheritedShape() && mLineType != LineAnnotation::ConnectionType) {
setFlag(QGraphicsItem::ItemIsMovable, enable);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, enable);
Expand Down Expand Up @@ -646,7 +646,7 @@ void LineAnnotation::handleComponentRotation()
*/
void LineAnnotation::updateConnectionAnnotation()
{
if (mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM) {
if (mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getLibraryType()== LibraryTreeItem::TLM) {
TLMEditor *pTLMEditor = dynamic_cast<TLMEditor*>(mpGraphicsView->getModelWidget()->getEditor());
pTLMEditor->updateTLMConnectiontAnnotation(getStartComponentName(), getEndComponentName(), getTLMShapeAnnotation());

Expand All @@ -656,11 +656,11 @@ void LineAnnotation::updateConnectionAnnotation()
// update the connection
OMCProxy *pOMCProxy = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow()->getOMCProxy();
pOMCProxy->updateConnection(getStartComponentName(), getEndComponentName(),
mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getNameStructure(), annotationString);
mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getNameStructure(), annotationString);
}
// make the model modified
mpGraphicsView->getModelWidget()->setModelModified();
mpGraphicsView->getModelWidget()->updateModelicaText();
mpGraphicsView->getModelWidget()->setModelModified();
}

void LineAnnotation::duplicate()
Expand Down
10 changes: 5 additions & 5 deletions OMEdit/OMEditGUI/Annotations/ShapeAnnotation.cpp
Expand Up @@ -1261,7 +1261,7 @@ void ShapeAnnotation::setShapeFlags(bool enable)
Only set the ItemIsMovable & ItemSendsGeometryChanges flags on shape if the class is not a system library class
AND shape is not an inherited shape.
*/
if (!mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() && !isInheritedShape()) {
if (!mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() && !isInheritedShape()) {
setFlag(QGraphicsItem::ItemIsMovable, enable);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, enable);
}
Expand Down Expand Up @@ -1831,7 +1831,7 @@ bool ShapeAnnotation::isLineStraight(QPointF point1, QPointF point2)
*/
void ShapeAnnotation::showShapeProperties()
{
if (!mpGraphicsView || mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM)
if (!mpGraphicsView || mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getLibraryType()== LibraryTreeItem::TLM)
return;
MainWindow *pMainWindow = mpGraphicsView->getModelWidget()->getModelWidgetContainer()->getMainWindow();
ShapePropertiesDialog *pShapePropertiesDialog = new ShapePropertiesDialog(this, pMainWindow);
Expand All @@ -1855,7 +1855,7 @@ void ShapeAnnotation::contextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)
}

QMenu menu(mpGraphicsView);
if(mpGraphicsView->getModelWidget()->getLibraryTreeNode()->getLibraryType()== LibraryTreeNode::TLM){
if(mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getLibraryType()== LibraryTreeItem::TLM){
menu.addAction(mpGraphicsView->getDeleteConnectionAction());
} else {
menu.addAction(mpShapePropertiesAction);
Expand Down Expand Up @@ -1910,7 +1910,7 @@ QVariant ShapeAnnotation::itemChange(GraphicsItemChange change, const QVariant &
setCornerItemsActive();
setCursor(Qt::SizeAllCursor);
/* Only allow manipulations on shapes if the class is not a system library class OR shape is not an inherited component. */
if (!mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() && !isInheritedShape()) {
if (!mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() && !isInheritedShape()) {
if (lineType == LineAnnotation::ConnectionType) {
connect(mpGraphicsView->getDeleteConnectionAction(), SIGNAL(triggered()), SLOT(deleteConnection()), Qt::UniqueConnection);
connect(mpGraphicsView, SIGNAL(keyPressDelete()), SLOT(deleteConnection()), Qt::UniqueConnection);
Expand Down Expand Up @@ -1946,7 +1946,7 @@ QVariant ShapeAnnotation::itemChange(GraphicsItemChange change, const QVariant &
setCornerItemsPassive();
unsetCursor();
/* Only allow manipulations on shapes if the class is not a system library class OR shape is not an inherited component. */
if (!mpGraphicsView->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() && !isInheritedShape()) {
if (!mpGraphicsView->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() && !isInheritedShape()) {
if (lineType == LineAnnotation::ConnectionType) {
disconnect(mpGraphicsView->getDeleteConnectionAction(), SIGNAL(triggered()), this, SLOT(deleteConnection()));
disconnect(mpGraphicsView, SIGNAL(keyPressDelete()), this, SLOT(deleteConnection()));
Expand Down
16 changes: 8 additions & 8 deletions OMEdit/OMEditGUI/Annotations/ShapePropertiesDialog.cpp
Expand Up @@ -436,7 +436,7 @@ ShapePropertiesDialog::ShapePropertiesDialog(ShapeAnnotation *pShapeAnnotation,
mpApplyButton = new QPushButton(Helper::apply);
mpApplyButton->setAutoDefault(false);
connect(mpApplyButton, SIGNAL(clicked()), this, SLOT(applyShapeProperties()));
if (mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeNode()->isSystemLibrary() || mpShapeAnnotation->isInheritedShape())
if (mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->isSystemLibrary() || mpShapeAnnotation->isInheritedShape())
{
mpOkButton->setDisabled(true);
mpApplyButton->setDisabled(true);
Expand Down Expand Up @@ -798,7 +798,7 @@ bool ShapePropertiesDialog::applyShapeProperties()
{
QUrl fileUrl(mpFileTextBox->text());
QFileInfo fileInfo(mpFileTextBox->text());
QFileInfo classFileInfo(mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeNode()->getFileName());
QFileInfo classFileInfo(mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getFileName());
MainWindow *pMainWindow = mpShapeAnnotation->getGraphicsView()->getModelWidget()->getModelWidgetContainer()->getMainWindow();
/* if its a modelica:// link then make it absolute path */
QString fileName;
Expand All @@ -821,14 +821,14 @@ bool ShapePropertiesDialog::applyShapeProperties()
{
/* find the class to create a relative path */
MainWindow *pMainWindow = mpShapeAnnotation->getGraphicsView()->getModelWidget()->getModelWidgetContainer()->getMainWindow();
LibraryTreeNode *pLibraryTreeNode;
pLibraryTreeNode = mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeNode();
pLibraryTreeNode = pMainWindow->getLibraryTreeWidget()->getLibraryTreeNode(StringHandler::getFirstWordBeforeDot(pLibraryTreeNode->getNameStructure()));
LibraryTreeItem *pLibraryTreeItem = mpShapeAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeItem();
QString nameStructure = StringHandler::getFirstWordBeforeDot(pLibraryTreeItem->getNameStructure());
pLibraryTreeItem = pMainWindow->getLibraryWidget()->getLibraryTreeModel()->findLibraryTreeItem(nameStructure);
/* get the class directory path and use it to get the relative path of the choosen bitmap file */
QFileInfo classFileInfo(pLibraryTreeNode->getFileName());
QFileInfo classFileInfo(pLibraryTreeItem->getFileName());
QDir classDirectory = classFileInfo.absoluteDir();
QString relativeImagePath = classDirectory.relativeFilePath(mpFileTextBox->text());
mpShapeAnnotation->setFileName(QString("modelica://").append(pLibraryTreeNode->getNameStructure()).append("/").append(relativeImagePath));
mpShapeAnnotation->setFileName(QString("modelica://").append(pLibraryTreeItem->getNameStructure()).append("/").append(relativeImagePath));
mpShapeAnnotation->setImageSource("");
mpShapeAnnotation->setImage(mpPreviewImageLabel->pixmap()->toImage());
}
Expand Down Expand Up @@ -876,7 +876,7 @@ void ShapePropertiesDialog::storeImageInModelToggled(bool checked)
if (!checked)
{
MainWindow *pMainWindow = mpBitmapAnnotation->getGraphicsView()->getModelWidget()->getModelWidgetContainer()->getMainWindow();
if (mpBitmapAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeNode()->getFileName().isEmpty())
if (mpBitmapAnnotation->getGraphicsView()->getModelWidget()->getLibraryTreeItem()->getFileName().isEmpty())
{
if (pMainWindow->getOptionsDialog()->getNotificationsPage()->getSaveModelForBitmapInsertionCheckBox()->isChecked())
{
Expand Down
3 changes: 3 additions & 0 deletions OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp
Expand Up @@ -198,6 +198,9 @@ void TextAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
{
Q_UNUSED(option);
Q_UNUSED(widget);
if (mpGraphicsView && mpGraphicsView->isRenderingLibraryPixmap()) {
return;
}
if (mVisible) {
drawTextAnnotaion(painter);
}
Expand Down

0 comments on commit 485c5f5

Please sign in to comment.