Skip to content

Commit b4b4986

Browse files
committed
Fixed a small problem with component's context menu.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7139 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 42a1391 commit b4b4986

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

OMEdit/OMEditGUI/Component.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ Component::~Component()
199199
foreach(ShapeAnnotation *shape, mpShapesList)
200200
delete shape;
201201

202-
// delete the list of all components
203-
foreach(Component *component, mpComponentsList)
204-
delete component;
202+
// // delete the list of all components
203+
// foreach(Component *component, mpComponentsList)
204+
// delete component;
205205

206-
// delete the list of all inherited components
207-
foreach(Component *component, mpInheritanceList)
208-
delete component;
206+
// // delete the list of all inherited components
207+
// foreach(Component *component, mpInheritanceList)
208+
// delete component;
209209
}
210210

211211
//! Parses the result of getIconAnnotation command.
@@ -348,6 +348,9 @@ void Component::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
348348

349349
void Component::mousePressEvent(QGraphicsSceneMouseEvent *event)
350350
{
351+
// if user is viewing the component in Icon View
352+
if (mpGraphicsView->mIconType == StringHandler::DIAGRAM)
353+
return;
351354
// if we are creating the connector then make sure user can not select and move components
352355
if ((mpGraphicsView->mIsCreatingConnector) and !mpParentComponent)
353356
{
@@ -394,6 +397,10 @@ void Component::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
394397

395398
void Component::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
396399
{
400+
// if we are viewing some readonly component then don't show the contextmenu
401+
if (mpGraphicsView->mpParentProjectTab->isReadOnly())
402+
return;
403+
397404
// get the root component, it could be either icon or diagram
398405
Component *pComponent = getRootParentComponent();
399406

OMEdit/OMEditGUI/ProjectTabWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class GraphicsView : public QGraphicsView
7070
Q_OBJECT
7171
private:
7272
Connector *mpConnector;
73-
int mIconType;
7473
void createActions();
7574
void createMenus();
7675
public:
@@ -82,6 +81,7 @@ class GraphicsView : public QGraphicsView
8281
bool checkComponentName(QString iconName);
8382

8483
QList<Component*> mComponentsList;
84+
int mIconType;
8585
bool mIsCreatingConnector;
8686
QVector<Connector*> mConnectorsVector;
8787
ProjectTab *mpParentProjectTab;

0 commit comments

Comments
 (0)