Resolved issue #774. New feature. Matching Parentheses.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-11-14 13:46:28 +02:00
parent c347d97e12
commit 5f0d4ea586
36 changed files with 712 additions and 135 deletions

View File

@ -31,6 +31,7 @@
- [#771] Improve tool Point at intersection of arc and line.
- [#772] New tool Duplicate detail.
- [#726] Improve Move tool. Add optional rotate option.
- [#774] New feature. Matching Parentheses.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -227,7 +227,7 @@
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="enabled">
<bool>false</bool>
</property>
@ -340,7 +340,7 @@
</widget>
</item>
<item row="10" column="1">
<widget class="QPlainTextEdit" name="plainTextEditDescription">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="enabled">
<bool>false</bool>
</property>
@ -803,7 +803,7 @@
</widget>
</item>
<item row="9" column="1">
<widget class="QPlainTextEdit" name="plainTextEditNotes">
<widget class="VPlainTextEdit" name="plainTextEditNotes">
<property name="enabled">
<bool>false</bool>
</property>
@ -827,7 +827,7 @@
<x>0</x>
<y>0</y>
<width>835</width>
<height>25</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -1184,6 +1184,13 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="share/resources/tapeicon.qrc"/>
</resources>

View File

@ -247,7 +247,7 @@
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="enabled">
<bool>false</bool>
</property>
@ -354,7 +354,7 @@
</widget>
</item>
<item row="7" column="1">
<widget class="QPlainTextEdit" name="plainTextEditDescription">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="enabled">
<bool>false</bool>
</property>
@ -432,9 +432,16 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
<include location="../../../libs/vmisc/share/resources/theme.qrc"/>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>960</width>
<height>497</height>
<height>517</height>
</rect>
</property>
<property name="minimumSize">
@ -39,7 +39,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabIncrements">
<attribute name="title">
@ -175,12 +175,6 @@
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>236</height>
</size>
</property>
<property name="toolTip">
<string>Details</string>
</property>
@ -331,7 +325,7 @@
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="enabled">
<bool>false</bool>
</property>
@ -360,12 +354,6 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
@ -432,7 +420,7 @@
</widget>
</item>
<item row="7" column="1">
<widget class="QPlainTextEdit" name="plainTextEditDescription">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="enabled">
<bool>false</bool>
</property>
@ -442,6 +430,12 @@
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item row="10" column="1">
@ -609,12 +603,6 @@
<verstretch>4</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>236</height>
</size>
</property>
<property name="toolTip">
<string>Details</string>
</property>
@ -765,7 +753,7 @@
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue_2">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaPC">
<widget class="VPlainTextEdit" name="plainTextEditFormulaPC">
<property name="enabled">
<bool>false</bool>
</property>
@ -794,12 +782,6 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
@ -866,7 +848,7 @@
</widget>
</item>
<item row="7" column="1">
<widget class="QPlainTextEdit" name="plainTextEditDescriptionPC">
<widget class="VPlainTextEdit" name="plainTextEditDescriptionPC">
<property name="enabled">
<bool>false</bool>
</property>
@ -876,6 +858,12 @@
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item row="10" column="1">
@ -1148,6 +1136,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tableWidgetIncrement</tabstop>
<tabstop>toolButtonAdd</tabstop>
@ -1156,8 +1151,8 @@
<tabstop>tableWidgetSplines</tabstop>
</tabstops>
<resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
<include location="../../../libs/vmisc/share/resources/theme.qrc"/>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>655</width>
<height>532</height>
<height>547</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -107,7 +107,7 @@
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditDescription">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="documentTitle">
<string/>
</property>
@ -174,7 +174,7 @@
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEditTechNotes"/>
<widget class="VPlainTextEdit" name="plainTextEditTechNotes"/>
</item>
</layout>
</item>
@ -1381,6 +1381,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
<customwidget>
<class>VLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -149,7 +149,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -428,6 +428,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>

View File

@ -149,7 +149,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -195,8 +195,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -345,6 +344,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -323,7 +323,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF1">
<widget class="VPlainTextEdit" name="plainTextEditF1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -503,7 +503,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF2">
<widget class="VPlainTextEdit" name="plainTextEditF2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -666,6 +666,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="plainTextEditRadius">
<widget class="VPlainTextEdit" name="plainTextEditRadius">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -320,7 +320,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF1">
<widget class="VPlainTextEdit" name="plainTextEditF1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -500,7 +500,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength">
<widget class="VPlainTextEdit" name="plainTextEditLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -655,6 +655,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -334,6 +333,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -325,6 +324,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -260,6 +259,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -260,6 +259,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -260,6 +259,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -150,7 +150,7 @@
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditRadius1">
<widget class="VPlainTextEdit" name="plainTextEditRadius1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -336,7 +336,7 @@
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditRadius2">
<widget class="VPlainTextEdit" name="plainTextEditRadius2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -522,7 +522,7 @@
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditF1">
<widget class="VPlainTextEdit" name="plainTextEditF1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -708,7 +708,7 @@
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditF2">
<widget class="VPlainTextEdit" name="plainTextEditF2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -894,7 +894,7 @@
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditRotationAngle">
<widget class="VPlainTextEdit" name="plainTextEditRotationAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1038,6 +1038,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -164,7 +164,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -210,8 +210,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -360,7 +359,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle">
<widget class="VPlainTextEdit" name="plainTextEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -406,8 +405,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -531,6 +529,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -352,6 +351,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle">
<widget class="VPlainTextEdit" name="plainTextEditAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -320,7 +320,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength">
<widget class="VPlainTextEdit" name="plainTextEditLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -500,7 +500,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPlainTextEdit" name="plainTextEditRotationAngle">
<widget class="VPlainTextEdit" name="plainTextEditRotationAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -590,6 +590,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -525,6 +524,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditRadius">
<widget class="VPlainTextEdit" name="plainTextEditRadius">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -183,8 +183,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -309,6 +308,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -343,6 +342,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditCircle1Radius">
<widget class="VPlainTextEdit" name="plainTextEditCircle1Radius">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -320,7 +320,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditCircle2Radius">
<widget class="VPlainTextEdit" name="plainTextEditCircle2Radius">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -488,6 +488,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -140,7 +140,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -234,6 +234,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -143,7 +143,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormula">
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -186,8 +186,7 @@
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<property name="iconSize">
<size>
@ -382,6 +381,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLength</tabstop>

View File

@ -182,7 +182,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength1F">
<widget class="VPlainTextEdit" name="plainTextEditLength1F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -362,7 +362,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle1F">
<widget class="VPlainTextEdit" name="plainTextEditAngle1F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -580,7 +580,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength2F">
<widget class="VPlainTextEdit" name="plainTextEditLength2F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -760,7 +760,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle2F">
<widget class="VPlainTextEdit" name="plainTextEditAngle2F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -929,6 +929,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>comboBoxP1</tabstop>
<tabstop>comboBoxP4</tabstop>

View File

@ -169,7 +169,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength1F">
<widget class="VPlainTextEdit" name="plainTextEditLength1F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -349,7 +349,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle1F">
<widget class="VPlainTextEdit" name="plainTextEditAngle1F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -542,7 +542,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength2F">
<widget class="VPlainTextEdit" name="plainTextEditLength2F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -722,7 +722,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="plainTextEditAngle2F">
<widget class="VPlainTextEdit" name="plainTextEditAngle2F">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -891,6 +891,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>490</height>
<height>511</height>
</rect>
</property>
<property name="windowTitle">
@ -260,7 +260,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidth">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -496,7 +496,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -695,7 +695,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1016,6 +1016,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../vmisc/share/resources/icon.qrc"/>
</resources>
@ -1054,7 +1061,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroupMarkType"/>
<buttongroup name="buttonGroupAngleType"/>
<buttongroup name="buttonGroupMarkType"/>
</buttongroups>
</ui>

View File

@ -88,7 +88,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
@ -105,7 +105,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
<pixmap resource="../../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
@ -139,7 +139,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidth">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -271,7 +271,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
@ -288,7 +288,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
<pixmap resource="../../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
@ -322,7 +322,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula_2">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaHeight">
<widget class="VPlainTextEdit" name="plainTextEditFormulaHeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -454,7 +454,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
@ -471,7 +471,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
<pixmap resource="../../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
@ -505,7 +505,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_formula_3">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaAngle">
<widget class="VPlainTextEdit" name="plainTextEditFormulaAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -615,8 +615,15 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
<include location="../../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>

View File

@ -173,7 +173,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="lineEditRotFormula">
<widget class="VPlainTextEdit" name="lineEditRotFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -362,7 +362,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPlainTextEdit" name="lineEditLenFormula">
<widget class="VPlainTextEdit" name="lineEditLenFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -526,6 +526,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -400,7 +400,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QPlainTextEdit" name="lineEditDLWidthFormula">
<widget class="VPlainTextEdit" name="lineEditDLWidthFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -602,7 +602,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QPlainTextEdit" name="lineEditDLHeightFormula">
<widget class="VPlainTextEdit" name="lineEditDLHeightFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -888,7 +888,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QPlainTextEdit" name="lineEditDLAngleFormula">
<widget class="VPlainTextEdit" name="lineEditDLAngleFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1106,7 +1106,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<widget class="QPlainTextEdit" name="lineEditPLWidthFormula">
<widget class="VPlainTextEdit" name="lineEditPLWidthFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1308,7 +1308,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<widget class="QPlainTextEdit" name="lineEditPLHeightFormula">
<widget class="VPlainTextEdit" name="lineEditPLHeightFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1594,7 +1594,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_28">
<item>
<widget class="QPlainTextEdit" name="lineEditPLAngleFormula">
<widget class="VPlainTextEdit" name="lineEditPLAngleFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -1683,6 +1683,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
<customwidget>
<class>VLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -283,7 +283,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidth">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -522,7 +522,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -712,7 +712,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<widget class="VPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -929,6 +929,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../../vmisc/share/resources/icon.qrc"/>
</resources>

View File

@ -0,0 +1,90 @@
/************************************************************************
**
** @file vhighlighter.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 14 11, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vhighlighter.h"
//---------------------------------------------------------------------------------------------------------------------
VTextBlockData::VTextBlockData()
: m_parentheses()
{
// Nothing to do
}
//---------------------------------------------------------------------------------------------------------------------
QVector<ParenthesisInfo *> VTextBlockData::Parentheses()
{
return m_parentheses;
}
//---------------------------------------------------------------------------------------------------------------------
void VTextBlockData::insert(ParenthesisInfo *info)
{
int i = 0;
while (i < m_parentheses.size() && info->position > m_parentheses.at(i)->position)
{
++i;
}
m_parentheses.insert(i, info);
}
//---------------------------------------------------------------------------------------------------------------------
VHighlighter::VHighlighter(QTextDocument *document)
: QSyntaxHighlighter(document)
{
}
//---------------------------------------------------------------------------------------------------------------------
void VHighlighter::highlightBlock(const QString &text)
{
QScopedPointer<VTextBlockData> data(new VTextBlockData);
int leftPos = text.indexOf('(');
while (leftPos != -1)
{
QScopedPointer<ParenthesisInfo> info(new ParenthesisInfo);
info->character = '(';
info->position = leftPos;
data->insert(info.take());
leftPos = text.indexOf('(', leftPos + 1);
}
int rightPos = text.indexOf(')');
while (rightPos != -1)
{
QScopedPointer<ParenthesisInfo> info(new ParenthesisInfo);
info->character = ')';
info->position = rightPos;
data->insert(info.take());
rightPos = text.indexOf(')', rightPos +1);
}
setCurrentBlockUserData(data.take());
}

View File

@ -0,0 +1,64 @@
/************************************************************************
**
** @file vhighlighter.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 14 11, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VHIGHLIGHTER_H
#define VHIGHLIGHTER_H
#include <QSyntaxHighlighter>
#include <QVector>
class QString;
class QTextDocument;
struct ParenthesisInfo
{
char character;
int position;
};
class VTextBlockData : public QTextBlockUserData
{
public:
VTextBlockData();
QVector<ParenthesisInfo *> Parentheses();
void insert(ParenthesisInfo *info);
private:
QVector<ParenthesisInfo *> m_parentheses;
};
class VHighlighter : public QSyntaxHighlighter
{
public:
VHighlighter(QTextDocument *document);
protected:
virtual void highlightBlock(const QString &text);
};
#endif // VHIGHLIGHTER_H

View File

@ -0,0 +1,184 @@
/************************************************************************
**
** @file vplaintextedit.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 14 11, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vplaintextedit.h"
//---------------------------------------------------------------------------------------------------------------------
VPlainTextEdit::VPlainTextEdit(QWidget * parent)
: QPlainTextEdit(parent),
m_highlighter(document())
{
connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses);
}
//---------------------------------------------------------------------------------------------------------------------
VPlainTextEdit::VPlainTextEdit(const QString & text, QWidget * parent)
: QPlainTextEdit(text, parent),
m_highlighter(document())
{
connect(this, &QPlainTextEdit::cursorPositionChanged, this, &VPlainTextEdit::MatchParentheses);
}
//---------------------------------------------------------------------------------------------------------------------
VPlainTextEdit::~VPlainTextEdit()
{
document()->blockSignals(true); // prevent crash
}
//---------------------------------------------------------------------------------------------------------------------
void VPlainTextEdit::MatchParentheses()
{
QList<QTextEdit::ExtraSelection> selections;
setExtraSelections(selections);
VTextBlockData *data = static_cast<VTextBlockData *>(textCursor().block().userData());
if (data)
{
QVector<ParenthesisInfo *> infos = data->Parentheses();
int pos = textCursor().block().position();
for (int i = 0; i < infos.size(); ++i)
{
ParenthesisInfo *info = infos.at(i);
int curPos = textCursor().position() - textCursor().block().position();
if ((info->position == curPos - 1 || info->position == curPos) && info->character == '(')
{
CreateParenthesisSelection(pos + info->position, MatchLeftParenthesis(textCursor().block(), i + 1, 0));
return;
}
else if ((info->position == curPos - 1 || info->position == curPos) && info->character == ')')
{
CreateParenthesisSelection(pos + info->position, MatchRightParenthesis(textCursor().block(), i - 1, 0));
return;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VPlainTextEdit::MatchLeftParenthesis(QTextBlock currentBlock, int i, int numLeftParentheses)
{
VTextBlockData *data = static_cast<VTextBlockData *>(currentBlock.userData());
QVector<ParenthesisInfo *> infos = data->Parentheses();
int docPos = currentBlock.position();
for (; i < infos.size(); ++i)
{
ParenthesisInfo *info = infos.at(i);
if (info->character == '(')
{
++numLeftParentheses;
continue;
}
if (info->character == ')' && numLeftParentheses == 0)
{
CreateParenthesisSelection(docPos + info->position);
return true;
}
else
{
--numLeftParentheses;
}
}
currentBlock = currentBlock.next();
if (currentBlock.isValid())
{
return MatchLeftParenthesis(currentBlock, 0, numLeftParentheses);
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPlainTextEdit::MatchRightParenthesis(QTextBlock currentBlock, int i, int numRightParentheses)
{
VTextBlockData *data = static_cast<VTextBlockData *>(currentBlock.userData());
QVector<ParenthesisInfo *> parentheses = data->Parentheses();
int docPos = currentBlock.position();
for (; i > -1 && parentheses.size() > 0; --i)
{
ParenthesisInfo *info = parentheses.at(i);
if (info->character == ')')
{
++numRightParentheses;
continue;
}
if (info->character == '(' && numRightParentheses == 0)
{
CreateParenthesisSelection(docPos + info->position);
return true;
}
else
{
--numRightParentheses;
}
}
currentBlock = currentBlock.previous();
if (currentBlock.isValid())
{
return MatchRightParenthesis(currentBlock, 0, numRightParentheses);
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VPlainTextEdit::CreateParenthesisSelection(int pos, bool match)
{
QList<QTextEdit::ExtraSelection> selections = extraSelections();
QTextEdit::ExtraSelection selection;
QTextCharFormat format = selection.format;
if (match)
{
format.setBackground(Qt::lightGray);
format.setForeground(Qt::yellow);
}
else
{
format.setForeground(Qt::red);
}
selection.format = format;
QTextCursor cursor = textCursor();
cursor.setPosition(pos);
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
selection.cursor = cursor;
selections.append(selection);
setExtraSelections(selections);
}

View File

@ -0,0 +1,53 @@
/************************************************************************
**
** @file vplaintextedit.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 14 11, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPLAINTEXTEDIT_H
#define VPLAINTEXTEDIT_H
#include <QPlainTextEdit>
#include "vhighlighter.h"
class VPlainTextEdit : public QPlainTextEdit
{
Q_OBJECT
public:
VPlainTextEdit(QWidget * parent = nullptr);
VPlainTextEdit(const QString & text, QWidget * parent = nullptr);
virtual ~VPlainTextEdit();
private slots:
void MatchParentheses();
private:
VHighlighter m_highlighter;
bool MatchLeftParenthesis(QTextBlock currentBlock, int i, int numLeftParentheses);
bool MatchRightParenthesis(QTextBlock currentBlock, int i, int numRightParentheses);
void CreateParenthesisSelection(int pos, bool match = true);
};
#endif // VPLAINTEXTEDIT_H

View File

@ -22,7 +22,9 @@ SOURCES += \
$$PWD/global.cpp \
$$PWD/vscenepoint.cpp \
$$PWD/scalesceneitems.cpp \
$$PWD/vlineedit.cpp
$$PWD/vlineedit.cpp \
$$PWD/vplaintextedit.cpp \
$$PWD/vhighlighter.cpp
*msvc*:SOURCES += $$PWD/stable.cpp
@ -48,4 +50,6 @@ HEADERS += \
$$PWD/global.h \
$$PWD/vscenepoint.h \
$$PWD/scalesceneitems.h \
$$PWD/vlineedit.h
$$PWD/vlineedit.h \
$$PWD/vplaintextedit.h \
$$PWD/vhighlighter.h