Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Visibility conditions added. It is possible to specify one enum prope…

…rty to be a visibility condition to an item of a shape
  • Loading branch information...
commit 0074d26d7500738f393266e94af047ed2ae8be2c 1 parent fccb9af
Tatiana Agapova authored
9 qrgui/editorPluginInterface/elementImpl.h
View
@@ -89,10 +89,11 @@ struct StatLine
class ElementImpl {
public:
virtual ~ElementImpl() {}
- virtual void init(QRectF &contents, QList<StatPoint> &pointPorts,
- QList<StatLine> &linePorts, ElementTitleFactoryInterface &factory,
- QList<ElementTitleInterface*> &titles,
- SdfRendererInterface *renderer, SdfRendererInterface *portRenderer) = 0;
+ virtual void init(QRectF &contents, QList<StatPoint> &pointPorts
+ , QList<StatLine> &linePorts, ElementTitleFactoryInterface &factory
+ , QList<ElementTitleInterface*> &title
+ , SdfRendererInterface *renderer, SdfRendererInterface *portRenderer
+ , ElementRepoInterface *elementRepo = 0) = 0;
virtual void init(ElementTitleFactoryInterface &factory,
QList<ElementTitleInterface*> &titles) = 0;
virtual void paint(QPainter *painter, QRectF &contents) = 0;
3  qrgui/editorPluginInterface/sdfRendererInterface.h
View
@@ -5,11 +5,14 @@
#include <QtGui/QPainter>
#include <QtGui/QIconEngineV2>
+#include "elementRepoInterface.h"
+
class SdfRendererInterface : public QObject
{
public:
virtual bool load (const QString &filename) = 0;
virtual void render(QPainter *painter, const QRectF &bounds) = 0;
+ virtual void setElementRepo(ElementRepoInterface *elementRepo) = 0;
};
class SdfIconEngineV2Interface : public QIconEngineV2
3  qrgui/mainwindow/mainWindow.cpp
View
@@ -910,7 +910,8 @@ void MainWindow::setSceneFont()
void MainWindow::openShapeEditor(QPersistentModelIndex const &index, int role, QString const &propertyValue)
{
- ShapeEdit *shapeEdit = new ShapeEdit(index, role);
+ ShapeEdit *shapeEdit = new ShapeEdit(dynamic_cast<models::details::LogicalModel *>(mModels->logicalModel())
+ , index, role);
if (!propertyValue.isEmpty()) {
shapeEdit->load(propertyValue);
}
3  qrgui/mainwindow/mainwindow.pri
View
@@ -86,6 +86,7 @@ HEADERS += \
mainwindow/shapeEdit/textPicture.h \
mainwindow/shapeEdit/path.h \
mainwindow/shapeEdit/image.h \
+ mainwindow/shapeEdit/visibilityConditionsDialog.h \
SOURCES += \
mainwindow/shapeEdit/shapeEdit.cpp \
@@ -106,6 +107,8 @@ SOURCES += \
mainwindow/shapeEdit/view.cpp \
mainwindow/shapeEdit/textPicture.cpp \
mainwindow/shapeEdit/image.cpp \
+ mainwindow/shapeEdit/visibilityConditionsDialog.cpp \
FORMS += \
mainwindow/shapeEdit/shapeEdit.ui \
+ mainwindow/shapeEdit/visibilityConditionsDialog.ui \
30 qrgui/mainwindow/shapeEdit/item.cpp
View
@@ -220,3 +220,33 @@ void Item::setXandY(QDomElement& dom, QRectF const &rect)
dom.setAttribute("y2", setScaleForDoc(7, rect.toRect()));
dom.setAttribute("x2", setScaleForDoc(3, rect.toRect()));
}
+
+void Item::setVisibilityCondition(VisibilityCondition const &condition)
+{
+ mVisibilityCondition = condition;
+}
+
+void Item::setVisibilityCondition(QString const &property, QString const &value)
+{
+ mVisibilityCondition.property = property;
+ mVisibilityCondition.value = value;
+}
+
+Item::VisibilityCondition Item::visibilityCondition()
+{
+ return mVisibilityCondition;
+}
+
+QPair<QDomElement, Item::DomElementTypes> Item::generateDom(QDomDocument &document, const QPoint &topLeftPicture)
+{
+ QPair<QDomElement, Item::DomElementTypes> result = generateItem(document, topLeftPicture);
+
+ if (mVisibilityCondition.property != QString() && mVisibilityCondition.value != QString()) {
+ QDomElement visibility = document.createElement("showIf");
+ result.first.appendChild(visibility);
+ visibility.setAttribute("property", mVisibilityCondition.property);
+ visibility.setAttribute("value", mVisibilityCondition.value);
+ }
+
+ return result;
+}
13 qrgui/mainwindow/shapeEdit/item.h
View
@@ -31,6 +31,12 @@ class Item : public graphicsUtils::AbstractItem
bottomRightY
};
+ struct VisibilityCondition
+ {
+ QString property;
+ QString value;
+ };
+
Item(graphicsUtils::AbstractItem* parent = 0);
virtual Item* clone() = 0;
virtual void setItemZValue(int zValue);
@@ -58,12 +64,19 @@ class Item : public graphicsUtils::AbstractItem
QString setScaleForDoc(int i, QRect const &rect);
QString setSingleScaleForDoc(int i, int x, int y);
virtual void setXandY(QDomElement& dom, QRectF const &rect);
+
+ QPair<QDomElement, Item::DomElementTypes> generateDom(QDomDocument &document, QPoint const &topLeftPicture);
virtual QPair<QDomElement, Item::DomElementTypes> generateItem(QDomDocument &document, QPoint const &topLeftPicture) = 0;
+ void setVisibilityCondition(VisibilityCondition const &condition);
+ void setVisibilityCondition(QString const &property, QString const &value);
+ VisibilityCondition visibilityCondition();
+
protected:
QList<QPair<ScalingPointState, QColor> > mListScalePoint;
bool mNeedScalingRect;
DomElementTypes mDomElementType;
ScalingPointState mScalingState;
int mZValue;
+ VisibilityCondition mVisibilityCondition;
};
3  qrgui/mainwindow/shapeEdit/scene.h
View
@@ -49,6 +49,8 @@ class Scene : public graphicsUtils::AbstractScene
void addStylus(bool checked);
void addNone(bool checked);
+ QList<Item *> selectedSceneItems();
+
signals:
void noSelectedItems();
void existSelectedItems(QPen const &penItem, QBrush const &brushItem);
@@ -121,7 +123,6 @@ private slots:
void initListSelectedItemsForPaste();
QRectF selectedItemsBoundingRect() const;
- QList<Item *> selectedSceneItems();
QList<TextPicture *> selectedTextPictureItems();
QPointF setCXandCY(QGraphicsSceneMouseEvent *event);
void reshapeLine(QGraphicsSceneMouseEvent *event);
43 qrgui/mainwindow/shapeEdit/shapeEdit.cpp
View
@@ -4,6 +4,7 @@
#include "../../../qrutils/xmlUtils.h"
#include "xmlLoader.h"
#include "../../../qrutils/graphicsUtils/colorlisteditor.h"
+#include "visibilityConditionsDialog.h"
#include <QtGui/QFileDialog>
#include <QtGui/QGraphicsItem>
@@ -25,8 +26,8 @@ ShapeEdit::ShapeEdit(QWidget *parent)
connect(this, SIGNAL(saveSignal()), this, SLOT(saveToXml()));
}
-ShapeEdit::ShapeEdit(const QPersistentModelIndex &index, const int &role)
- : QWidget(NULL), mUi(new Ui::ShapeEdit),mIndex(index), mRole(role)
+ShapeEdit::ShapeEdit(qReal::models::details::LogicalModel *model, QPersistentModelIndex const &index, const int &role)
+ : QWidget(NULL), mUi(new Ui::ShapeEdit), mModel(model), mIndex(index), mRole(role)
{
init();
mUi->saveButton->setEnabled(true);
@@ -83,6 +84,7 @@ void ShapeEdit::init()
connect(mUi->boldCheckBox, SIGNAL(toggled(bool)), mScene, SLOT(changeFontBold(bool)));
connect(mUi->underlineCheckBox, SIGNAL(toggled(bool)), mScene, SLOT(changeFontUnderline(bool)));
+ connect(mUi->visibilityConditionsButton, SIGNAL(clicked()), this, SLOT(visibilityButtonClicked()));
connect(mUi->deleteItemButton, SIGNAL(clicked()), mScene, SLOT(deleteItem()));
connect(mUi->graphicsView, SIGNAL(deleteItem()), mScene, SLOT(deleteItem()));
connect(mUi->clearButton, SIGNAL(clicked()), mScene, SLOT(clearScene()));
@@ -206,7 +208,7 @@ QList<QDomElement> ShapeEdit::generateGraphics()
Item* item = dynamic_cast<Item*>(graphicsItem);
if (item != NULL) {
- QPair<QDomElement, Item::DomElementTypes> genItem = item->generateItem(mDocument, mTopLeftPicture);
+ QPair<QDomElement, Item::DomElementTypes> genItem = item->generateDom(mDocument, mTopLeftPicture);
QDomElement domItem = genItem.first;
Item::DomElementTypes domType = genItem.second;
switch (domType) {
@@ -501,3 +503,38 @@ void ShapeEdit::addStylus(bool checked)
if (checked)
setHighlightOneButton(mUi->stylusButton);
}
+
+void ShapeEdit::visibilityButtonClicked()
+{
+ QList<Item *> selectedItems = mScene->selectedSceneItems();
+ if (selectedItems.isEmpty()) {
+ return;
+ }
+ VisibilityConditionsDialog vcDialog(getEnumValues(), selectedItems);
+ vcDialog.exec();
+}
+
+QMap<QString, QStringList> ShapeEdit::getEnumValues() const
+{
+ QMap<QString, QStringList> result;
+
+ qrRepo::RepoApi *repoApi = dynamic_cast<qrRepo::RepoApi *>(&mModel->mutableApi());
+ qReal::IdList enums = repoApi->elementsByType("MetaEntityEnum");
+
+ foreach (qReal::Id child, repoApi->children(mModel->idByIndex(mIndex))) {
+ QString type = repoApi->stringProperty(child, "attributeType");
+ foreach (qReal::Id e, enums) {
+ if (!repoApi->isLogicalElement(e)) {
+ continue;
+ }
+ if (repoApi->name(e) == type) {
+ QStringList enumValues;
+ foreach (qReal::Id value, repoApi->children(e)) {
+ enumValues << repoApi->stringProperty(value, "valueName");
+ }
+ result.insert(repoApi->name(child), enumValues);
+ }
+ }
+ }
+ return result;
+}
9 qrgui/mainwindow/shapeEdit/shapeEdit.h
View
@@ -8,6 +8,7 @@
#include "scene.h"
#include "item.h"
#include "../../../qrutils/graphicsUtils/abstractItemView.h"
+#include "../../models/details/logicalModel.h"
namespace Ui {
class ShapeEdit;
@@ -17,7 +18,7 @@ class ShapeEdit : public QWidget {
Q_OBJECT
public:
explicit ShapeEdit(QWidget *parent = NULL);
- ShapeEdit(QPersistentModelIndex const &index, int const &role);
+ ShapeEdit(qReal::models::details::LogicalModel *model, QPersistentModelIndex const &index, int const &role);
graphicsUtils::AbstractView* getView();
void load(const QString &text);
~ShapeEdit();
@@ -43,6 +44,8 @@ private slots:
void addLinePort(bool checked);
void addStylus(bool checked);
+ void visibilityButtonClicked();
+
void savePicture();
void saveToXml();
void save();
@@ -62,6 +65,8 @@ private slots:
QDomDocument mDocument;
QPoint mTopLeftPicture;
Ui::ShapeEdit *mUi;
+
+ qReal::models::details::LogicalModel *mModel;
QPersistentModelIndex const mIndex;
int const mRole;
void initButtonGroup();
@@ -88,4 +93,6 @@ private slots:
void generateDom();
void exportToXml(QString const &fileName);
QList<QDomElement> generateGraphics();
+
+ QMap<QString, QStringList> getEnumValues() const;
};
486 qrgui/mainwindow/shapeEdit/shapeEdit.ui
View
@@ -14,104 +14,46 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1">
- <widget class="QPushButton" name="drawCurveButton">
+ <item row="17" column="0" colspan="2">
+ <widget class="QPushButton" name="saveButton">
<property name="enabled">
- <bool>true</bool>
- </property>
- <property name="maximumSize">
- <size>
- <width>65</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Draw curve</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/curve.png</normaloff>:/icons/curve.png</iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>45</width>
- <height>16</height>
- </size>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>false</bool>
- </property>
- <property name="autoDefault">
<bool>false</bool>
</property>
- <property name="default">
- <bool>false</bool>
+ <property name="text">
+ <string>Save</string>
</property>
</widget>
</item>
- <item row="1" column="2" rowspan="17">
- <widget class="graphicsUtils::AbstractView" name="graphicsView">
- <property name="minimumSize">
+ <item row="13" column="0">
+ <widget class="QPushButton" name="deleteItemButton">
+ <property name="maximumSize">
<size>
- <width>150</width>
- <height>2</height>
+ <width>64</width>
+ <height>16777215</height>
</size>
</property>
+ <property name="text">
+ <string>Delete Item</string>
+ </property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QPushButton" name="drawRectButton">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
+ <item row="13" column="1">
+ <widget class="QPushButton" name="clearButton">
<property name="maximumSize">
<size>
- <width>65</width>
+ <width>60</width>
<height>16777215</height>
</size>
</property>
- <property name="toolTip">
- <string>Draw rectangle</string>
- </property>
<property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/rect.png</normaloff>:/icons/rect.png</iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>45</width>
- <height>16</height>
- </size>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>false</bool>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
+ <string>Clear</string>
</property>
- <property name="default">
- <bool>false</bool>
+ </widget>
+ </item>
+ <item row="18" column="0" colspan="2">
+ <widget class="QPushButton" name="openButton">
+ <property name="text">
+ <string>Open</string>
</property>
</widget>
</item>
@@ -238,103 +180,21 @@
</property>
</widget>
</item>
- <item row="13" column="0" colspan="2">
- <widget class="Line" name="line">
- <property name="enabled">
- <bool>false</bool>
- </property>
+ <item row="1" column="2" rowspan="18">
+ <widget class="graphicsUtils::AbstractView" name="graphicsView">
<property name="minimumSize">
<size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="font">
- <font>
- <weight>50</weight>
- <bold>false</bold>
- </font>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QPushButton" name="stylusButton">
- <property name="maximumSize">
- <size>
- <width>65</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Stylus</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/pencil.png</normaloff>:/icons/pencil.png</iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>45</width>
- <height>16</height>
+ <width>150</width>
+ <height>2</height>
</size>
</property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>false</bool>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>false</bool>
- </property>
</widget>
</item>
- <item row="4" column="0">
- <widget class="QPushButton" name="addTextPictureButton">
- <property name="maximumSize">
- <size>
- <width>65</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Add picture text</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/textPicture.png</normaloff>:/icons/textPicture.png</iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>45</width>
- <height>16</height>
- </size>
- </property>
- <property name="checkable">
+ <item row="1" column="1">
+ <widget class="QPushButton" name="drawCurveButton">
+ <property name="enabled">
<bool>true</bool>
</property>
- <property name="autoExclusive">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QPushButton" name="addLinePortButton">
<property name="maximumSize">
<size>
<width>65</width>
@@ -342,14 +202,14 @@
</size>
</property>
<property name="toolTip">
- <string>Add line port</string>
+ <string>Draw curve</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/linePort.png</normaloff>:/icons/linePort.png</iconset>
+ <normaloff>:/icons/curve.png</normaloff>:/icons/curve.png</iconset>
</property>
<property name="iconSize">
<size>
@@ -374,53 +234,6 @@
</property>
</widget>
</item>
- <item row="5" column="1">
- <widget class="QPushButton" name="addPointPortButton">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>25</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>65</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Add point port</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../../qrgui.qrc">
- <normaloff>:/icons/ellipse.png</normaloff>:/icons/ellipse.png</iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>6</width>
- <height>6</height>
- </size>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="autoExclusive">
- <bool>false</bool>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>false</bool>
- </property>
- </widget>
- </item>
<item row="7" column="0" rowspan="2" colspan="2">
<widget class="QToolBox" name="fontToolBox">
<property name="enabled">
@@ -447,7 +260,7 @@
<x>0</x>
<y>0</y>
<width>124</width>
- <height>71</height>
+ <height>72</height>
</rect>
</property>
<attribute name="label">
@@ -667,60 +480,247 @@
</widget>
</widget>
</item>
- <item row="17" column="0" colspan="2">
- <widget class="QPushButton" name="openButton">
+ <item row="15" column="0" colspan="2">
+ <widget class="QPushButton" name="saveAsPictureButton">
<property name="text">
- <string>Open</string>
+ <string>Save as picture</string>
</property>
</widget>
</item>
- <item row="15" column="0" colspan="2">
+ <item row="16" column="0" colspan="2">
<widget class="QPushButton" name="saveToXmlButton">
<property name="text">
<string>Save to Xml</string>
</property>
</widget>
</item>
- <item row="16" column="0" colspan="2">
- <widget class="QPushButton" name="saveButton">
+ <item row="14" column="0" colspan="2">
+ <widget class="Line" name="line">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>50</weight>
+ <bold>false</bold>
+ </font>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QPushButton" name="stylusButton">
+ <property name="maximumSize">
+ <size>
+ <width>65</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Stylus</string>
+ </property>
<property name="text">
- <string>Save</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../qrgui.qrc">
+ <normaloff>:/icons/pencil.png</normaloff>:/icons/pencil.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>45</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>false</bool>
</property>
</widget>
</item>
- <item row="12" column="0">
- <widget class="QPushButton" name="deleteItemButton">
+ <item row="5" column="0">
+ <widget class="QPushButton" name="addLinePortButton">
<property name="maximumSize">
<size>
- <width>64</width>
+ <width>65</width>
<height>16777215</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Add line port</string>
+ </property>
<property name="text">
- <string>Delete Item</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../qrgui.qrc">
+ <normaloff>:/icons/linePort.png</normaloff>:/icons/linePort.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>45</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>false</bool>
</property>
</widget>
</item>
- <item row="12" column="1">
- <widget class="QPushButton" name="clearButton">
+ <item row="5" column="1">
+ <widget class="QPushButton" name="addPointPortButton">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>25</height>
+ </size>
+ </property>
<property name="maximumSize">
<size>
- <width>60</width>
+ <width>65</width>
<height>16777215</height>
</size>
</property>
+ <property name="toolTip">
+ <string>Add point port</string>
+ </property>
<property name="text">
- <string>Clear</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../qrgui.qrc">
+ <normaloff>:/icons/ellipse.png</normaloff>:/icons/ellipse.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>6</width>
+ <height>6</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>false</bool>
</property>
</widget>
</item>
- <item row="14" column="0" colspan="2">
- <widget class="QPushButton" name="saveAsPictureButton">
+ <item row="4" column="0">
+ <widget class="QPushButton" name="addTextPictureButton">
+ <property name="maximumSize">
+ <size>
+ <width>65</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add picture text</string>
+ </property>
<property name="text">
- <string>Save as picture</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../qrgui.qrc">
+ <normaloff>:/icons/textPicture.png</normaloff>:/icons/textPicture.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>45</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="drawRectButton">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>65</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Draw rectangle</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../qrgui.qrc">
+ <normaloff>:/icons/rect.png</normaloff>:/icons/rect.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>45</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="autoExclusive">
+ <bool>false</bool>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>false</bool>
</property>
</widget>
</item>
@@ -758,8 +758,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>124</width>
- <height>90</height>
+ <width>100</width>
+ <height>30</height>
</rect>
</property>
<attribute name="label">
@@ -1063,6 +1063,13 @@
</property>
</widget>
</item>
+ <item row="12" column="0" colspan="2">
+ <widget class="QPushButton" name="visibilityConditionsButton">
+ <property name="text">
+ <string>VisibilityConditions</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<customwidgets>
@@ -1079,6 +1086,7 @@
</customwidgets>
<resources>
<include location="../../qrgui.qrc"/>
+ <include location="../../qrgui.qrc"/>
</resources>
<connections/>
</ui>
61 qrgui/mainwindow/shapeEdit/visibilityConditionsDialog.cpp
View
@@ -0,0 +1,61 @@
+#include <QPushButton>
+
+#include "visibilityConditionsDialog.h"
+#include "ui_visibilityConditionsDialog.h"
+
+VisibilityConditionsDialog::VisibilityConditionsDialog(QMap<QString, QStringList> const &enumValues
+ , QList<Item *> const &items, QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::VisibilityConditionsDialog)
+ , mEnumValues(enumValues), mItems(items)
+{
+ ui->setupUi(this);
+
+ ui->propertyComboBox->addItem(QString());
+ ui->propertyComboBox->addItems(enumValues.keys());
+
+ setIndices();
+
+ connect(ui->propertyComboBox, SIGNAL(activated(QString const &)), this, SLOT(changeValues(QString const &)));
+ connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(okClicked()));
+}
+
+VisibilityConditionsDialog::~VisibilityConditionsDialog()
+{
+ delete ui;
+}
+
+void VisibilityConditionsDialog::changeValues(QString const &enumName)
+{
+ ui->valueComboBox->clear();
+ ui->valueComboBox->addItems(mEnumValues[enumName]);
+}
+
+void VisibilityConditionsDialog::okClicked()
+{
+ foreach (Item *item, mItems) {
+ item->setVisibilityCondition(ui->propertyComboBox->currentText(), ui->valueComboBox->currentText());
+ }
+}
+
+void VisibilityConditionsDialog::setIndices()
+{
+ if (areValuesEqual()) {
+ ui->propertyComboBox->setCurrentIndex(
+ ui->propertyComboBox->findText(mItems.first()->visibilityCondition().property));
+ ui->valueComboBox->addItems(mEnumValues[ui->propertyComboBox->currentText()]);
+ ui->valueComboBox->setCurrentIndex(ui->valueComboBox->findText(mItems.first()->visibilityCondition().value));
+ }
+}
+
+bool VisibilityConditionsDialog::areValuesEqual()
+{
+ Item::VisibilityCondition value = mItems.first()->visibilityCondition();
+ foreach (Item *item, mItems) {
+ if (item->visibilityCondition().property != value.property
+ || item->visibilityCondition().value != value.value) {
+ return false;
+ }
+ }
+ return true;
+}
31 qrgui/mainwindow/shapeEdit/visibilityConditionsDialog.h
View
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <QDialog>
+#include <QMap>
+#include "item.h"
+
+namespace Ui {
+class VisibilityConditionsDialog;
+}
+
+class VisibilityConditionsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit VisibilityConditionsDialog(QMap<QString, QStringList> const &enumValues
+ , QList<Item *> const &items, QWidget *parent = 0);
+ ~VisibilityConditionsDialog();
+
+private slots:
+ void changeValues(QString const &enumName);
+ void okClicked();
+
+private:
+ void setIndices();
+ bool areValuesEqual();
+
+ Ui::VisibilityConditionsDialog *ui;
+ QMap<QString, QStringList> mEnumValues;
+ QList<Item *> mItems;
+};
104 qrgui/mainwindow/shapeEdit/visibilityConditionsDialog.ui
View
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VisibilityConditionsDialog</class>
+ <widget class="QDialog" name="VisibilityConditionsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>381</width>
+ <height>101</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Specify conditions in which choosen element must be shown</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>60</y>
+ <width>341</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="propertyComboBox">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>151</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="valueComboBox">
+ <property name="geometry">
+ <rect>
+ <x>190</x>
+ <y>30</y>
+ <width>181</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="equalLabel">
+ <property name="geometry">
+ <rect>
+ <x>170</x>
+ <y>30</y>
+ <width>16</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>=</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>VisibilityConditionsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>VisibilityConditionsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
2  qrgui/umllib/nodeElement.cpp
View
@@ -45,7 +45,7 @@ NodeElement::NodeElement(ElementImpl* impl)
QList<StatPoint> pointPorts;
QList<StatLine> linePorts;
- mElementImpl->init(mContents, pointPorts, linePorts, factory, titles, mRenderer, mPortRenderer);
+ mElementImpl->init(mContents, pointPorts, linePorts, factory, titles, mRenderer, mPortRenderer, this);
mPortHandler = new PortHandler(this, mGraphicalAssistApi, pointPorts, linePorts);
foreach (ElementTitleInterface *titleIface, titles) {
27 qrgui/umllib/sdfRenderer.cpp
View
@@ -10,7 +10,7 @@
using namespace qReal;
SdfRenderer::SdfRenderer()
- : mStartX(0), mStartY(0), mNeedScale(true)
+ : mStartX(0), mStartY(0), mNeedScale(true), mElementRepo(0)
{
mWorkingDirName = SettingsManager::value("workingDir").toString();
}
@@ -49,6 +49,11 @@ bool SdfRenderer::load(const QString &filename)
return true;
}
+void SdfRenderer::setElementRepo(ElementRepoInterface *elementRepo)
+{
+ mElementRepo = elementRepo;
+}
+
void SdfRenderer::render(QPainter *painter, const QRectF &bounds)
{
current_size_x = static_cast<int>(bounds.width());
@@ -63,6 +68,10 @@ void SdfRenderer::render(QPainter *painter, const QRectF &bounds)
QDomElement elem = node.toElement();
if(!elem.isNull())
{
+ if (!checkShowConditions(elem)) {
+ node = node.nextSibling();
+ continue;
+ }
if (elem.tagName()=="line")
{
line(elem);
@@ -116,6 +125,22 @@ void SdfRenderer::render(QPainter *painter, const QRectF &bounds)
this->painter = 0;
}
+bool SdfRenderer::checkShowConditions(QDomElement const &element) const
+{
+ QDomNodeList showConditions = element.elementsByTagName("showIf");
+ if (showConditions.isEmpty() || !mElementRepo) {
+ return true;
+ }
+ for (int i = 0; i < showConditions.length(); ++i) {
+ QDomElement condition = showConditions.at(i).toElement();
+ QString propertyName = condition.attribute("property");
+ if (mElementRepo->logicalProperty(propertyName) != condition.attribute("value")) {
+ return false;
+ }
+ }
+ return true;
+}
+
void SdfRenderer::line(QDomElement &element)
{
float x1 = x1_def(element);
7 qrgui/umllib/sdfRenderer.h
View
@@ -10,8 +10,10 @@
#include <QTextStream>
#include <QtGui/QIconEngine>
#include <QDebug>
+
#include "../editorPluginInterface/sdfRendererInterface.h"
#include "../../qrkernel/settingsManager.h"
+#include "../editorPluginInterface/elementRepoInterface.h"
class SdfRenderer : public SdfRendererInterface
{
@@ -29,6 +31,8 @@ class SdfRenderer : public SdfRendererInterface
int pictureWidth() { return first_size_x; }
int pictureHeight() { return first_size_y; }
+ void setElementRepo(ElementRepoInterface *elementRepo);
+
private:
QString mWorkingDirName;
QMap<QString, QPixmap> mMapFileImage;
@@ -55,6 +59,9 @@ class SdfRenderer : public SdfRendererInterface
* coords, is useful for rendering icons. default is true
**/
bool mNeedScale;
+ ElementRepoInterface *mElementRepo;
+
+ bool checkShowConditions(QDomElement const &element) const;
void line(QDomElement &element);
void ellipse(QDomElement &element);
2  qrxc/edgeType.cpp
View
@@ -196,7 +196,7 @@ void EdgeType::generateCode(OutFile &out)
out() << "\t\tvoid init(QRectF &, QList<StatPoint> &, QList<StatLine> &,\n"
<< "\t\t\t\t\t\t\t\t\t\t\tElementTitleFactoryInterface &, QList<ElementTitleInterface*> &,\n"
- << "\t\t\t\t\t\t\t\t\t\t\tSdfRendererInterface *, SdfRendererInterface *) {}\n\n"
+ << "\t\t\t\t\t\t\t\t\t\t\tSdfRendererInterface *, SdfRendererInterface *, ElementRepoInterface *) {}\n\n"
<< "\t\tvoid init(ElementTitleFactoryInterface &factory, QList<ElementTitleInterface*> &titles)\n\t\t{\n";
if (!mLabels.isEmpty())
8 qrxc/nodeType.cpp
View
@@ -244,7 +244,7 @@ void NodeType::generateCode(OutFile &out)
<< "\t\tvoid init(QRectF &contents, QList<StatPoint> &pointPorts,\n"
<< "\t\t\t\t\t\t\tQList<StatLine> &linePorts, ElementTitleFactoryInterface &factory,\n"
<< "\t\t\t\t\t\t\tQList<ElementTitleInterface*> &titles, SdfRendererInterface *renderer,\n"
- << "\t\t\t\t\t\t\tSdfRendererInterface *portRenderer)\n\t\t{\n";
+ << "\t\t\t\t\t\t\tSdfRendererInterface *portRenderer, ElementRepoInterface *elementRepo)\n\t\t{\n";
if (!hasPointPorts())
out() << "\t\t\tQ_UNUSED(pointPorts);\n";
@@ -257,7 +257,8 @@ void NodeType::generateCode(OutFile &out)
QFile sdfFile("generated/shapes/" + className + "Class.sdf");
if (sdfFile.exists()) {
out() << "\t\t\tmRenderer = renderer;\n"
- "\t\t\tmRenderer->load(QString(\":/generated/shapes/" << className << "Class.sdf\"));\n";
+ "\t\t\tmRenderer->load(QString(\":/generated/shapes/" << className << "Class.sdf\"));\n"
+ << "\t\t\tmRenderer->setElementRepo(elementRepo);\n";
hasSdf = true;
} else
out() << "\t\t\tQ_UNUSED(portRenderer);\n";
@@ -298,7 +299,8 @@ void NodeType::generateCode(OutFile &out)
out() << (hasPorts ? "\t\t\treturn true;\n" : "\t\t\treturn false;\n")
<< "\t\t}\n\n"
- << "\t\tvoid updateData(ElementRepoInterface *repo) const\n\t\t{\n";
+ << "\t\tvoid updateData(ElementRepoInterface *repo) const\n\t\t{\n"
+ << "\t\t\tmRenderer->setElementRepo(repo);\n";
if (mLabels.isEmpty())
out() << "\t\t\tQ_UNUSED(repo);\n";
Please sign in to comment.
Something went wrong with that request. Please try again.