mirror of https://github.com/KLayout/klayout.git
Merge pull request #390 from KLayout/issue-382
Implemented #382: text editor view for user props
This commit is contained in:
commit
9fffd03ad3
|
|
@ -102,5 +102,6 @@ plugins.depends += lib rdb db
|
|||
unit_tests.depends += plugins $$MAIN_DEPENDS
|
||||
|
||||
RESOURCES += \
|
||||
plugins/tools/import/lay_plugin/layResources.qrc
|
||||
plugins/tools/import/lay_plugin/layResources.qrc \
|
||||
laybasic/laybasic/layResources.qrc
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ SOURCES = \
|
|||
layClipDialog.cc \
|
||||
layCrashMessage.cc \
|
||||
layFillDialog.cc \
|
||||
layGenericSyntaxHighlighter.cc \
|
||||
layGSIHelpProvider.cc \
|
||||
layHelpDialog.cc \
|
||||
layHelpProvider.cc \
|
||||
|
|
|
|||
|
|
@ -113,7 +113,14 @@ MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::str
|
|||
if (! scheme.empty ()) {
|
||||
|
||||
QResource res (tl::to_qstring (":/syntax/" + scheme + ".xml"));
|
||||
QByteArray data = qUncompress (QByteArray ((const char *) res.data (), int (res.size ())));
|
||||
|
||||
QByteArray data;
|
||||
if (res.isCompressed ()) {
|
||||
data = qUncompress ((const unsigned char *)res.data (), (int)res.size ());
|
||||
} else {
|
||||
data = QByteArray ((const char *)res.data (), (int)res.size ());
|
||||
}
|
||||
|
||||
QBuffer input (&data);
|
||||
input.open (QIODevice::ReadOnly);
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (parent, input, attributes);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SelectStippleForm</class>
|
||||
<widget class="QDialog" name="SelectStippleForm" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="SelectStippleForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
|
|
@ -12,86 +10,102 @@
|
|||
<height>374</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Select Stipple Pattern</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="stipple_items" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<widget class="QListWidget" name="stipple_items">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="acceptDrops" >
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0" >
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragEnabled" >
|
||||
<property name="dragEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors" >
|
||||
<property name="alternatingRowColors">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="movement" >
|
||||
<property name="movement">
|
||||
<enum>QListView::Static</enum>
|
||||
</property>
|
||||
<property name="viewMode" >
|
||||
<property name="viewMode">
|
||||
<enum>QListView::ListMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line" >
|
||||
<property name="orientation" >
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame5" >
|
||||
<property name="frameShape" >
|
||||
<widget class="QFrame" name="frame5">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>81</width>
|
||||
<height>31</height>
|
||||
|
|
@ -100,21 +114,21 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ok_button" >
|
||||
<property name="text" >
|
||||
<widget class="QPushButton" name="ok_button">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancel_button" >
|
||||
<property name="text" >
|
||||
<widget class="QPushButton" name="cancel_button">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
@ -124,11 +138,8 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11" />
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources>
|
||||
<include location="layResources.qrc" />
|
||||
</resources>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>ok_button</sender>
|
||||
|
|
@ -136,11 +147,11 @@
|
|||
<receiver>SelectStippleForm</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>182</x>
|
||||
<y>334</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>163</x>
|
||||
<y>178</y>
|
||||
</hint>
|
||||
|
|
@ -152,11 +163,11 @@
|
|||
<receiver>SelectStippleForm</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>275</x>
|
||||
<y>334</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>163</x>
|
||||
<y>178</y>
|
||||
</hint>
|
||||
|
|
|
|||
|
|
@ -1,179 +1,198 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserPropertiesForm</class>
|
||||
<widget class="QDialog" name="UserPropertiesForm" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="UserPropertiesForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>305</height>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>User Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>0</number>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>332</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="title_lbl" >
|
||||
<property name="text" >
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="title_lbl">
|
||||
<property name="text">
|
||||
<string>User properties</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QTreeWidget" name="prop_list" >
|
||||
<property name="rootIsDecorated" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QFrame" name="edit_frame" >
|
||||
<property name="frameShape" >
|
||||
<item row="3" column="1">
|
||||
<widget class="QFrame" name="edit_frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>114</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item rowspan="4" row="0" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>6</width>
|
||||
<height>201</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QPushButton" name="edit_pb" >
|
||||
<property name="text" >
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2" >
|
||||
<widget class="QPushButton" name="add_pb" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="layResources.qrc" >:/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QPushButton" name="remove_pb" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="layResources.qrc" >:/del.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTabWidget" name="mode_tab">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>332</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Table</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1" rowspan="4">
|
||||
<spacer name="spacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>6</width>
|
||||
<height>201</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="add_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../lay/lay/layResources.qrc">
|
||||
<normaloff>:/add.png</normaloff>:/add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="remove_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../lay/lay/layResources.qrc">
|
||||
<normaloff>:/del.png</normaloff>:/del.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="edit_pb">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>211</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="4">
|
||||
<widget class="QTreeWidget" name="prop_list">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allColumnsShowFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Text Editor</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="text_edit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="help_label">
|
||||
<property name="text">
|
||||
<string><html>Use the Variant Notation for key and value (<a href="int:/about/variant_notation.xml">See here for details</a>)</html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11" />
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<tabstops>
|
||||
<tabstop>prop_list</tabstop>
|
||||
<tabstop>add_pb</tabstop>
|
||||
<tabstop>remove_pb</tabstop>
|
||||
<tabstop>edit_pb</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="layResources.qrc" />
|
||||
<include location="../../lay/lay/layResources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
@ -182,11 +201,11 @@
|
|||
<receiver>UserPropertiesForm</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>211</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>211</x>
|
||||
<y>152</y>
|
||||
</hint>
|
||||
|
|
@ -198,11 +217,11 @@
|
|||
<receiver>UserPropertiesForm</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>211</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>211</x>
|
||||
<y>152</y>
|
||||
</hint>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "layLayoutView.h"
|
||||
#include "layCellTreeModel.h"
|
||||
#include "layQtTools.h"
|
||||
#include "layGenericSyntaxHighlighter.h"
|
||||
|
||||
#include "ui_LayerSourceDialog.h"
|
||||
#include "ui_NewLayoutPropertiesDialog.h"
|
||||
|
|
@ -55,6 +56,9 @@
|
|||
#include "ui_UserPropertiesForm.h"
|
||||
#include "ui_UserPropertiesEditForm.h"
|
||||
|
||||
#include <QResource>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
|
|
@ -1012,17 +1016,38 @@ FlattenInstOptionsDialog::exec_dialog (int &levels, bool &prune)
|
|||
// UserPropertiesForm implementation
|
||||
|
||||
UserPropertiesForm::UserPropertiesForm (QWidget *parent)
|
||||
: QDialog (parent), m_editable (false)
|
||||
: QDialog (parent), m_editable (false), mp_prep (0)
|
||||
{
|
||||
setObjectName (QString::fromUtf8 ("user_properties_form"));
|
||||
|
||||
mp_ui = new Ui::UserPropertiesForm ();
|
||||
mp_ui->setupUi (this);
|
||||
|
||||
mp_ui->text_edit->setFont (QFont ("Monospace"));
|
||||
mp_ui->text_edit->setAcceptRichText (false);
|
||||
|
||||
connect (mp_ui->add_pb, SIGNAL (clicked ()), this, SLOT (add ()));
|
||||
connect (mp_ui->remove_pb, SIGNAL (clicked ()), this, SLOT (remove ()));
|
||||
connect (mp_ui->edit_pb, SIGNAL (clicked ()), this, SLOT (edit ()));
|
||||
connect (mp_ui->prop_list, SIGNAL (itemDoubleClicked (QTreeWidgetItem *, int)), this, SLOT (dbl_clicked (QTreeWidgetItem *, int)));
|
||||
connect (mp_ui->mode_tab, SIGNAL (currentChanged (int)), this, SLOT (tab_changed (int)));
|
||||
|
||||
activate_help_links (mp_ui->help_label);
|
||||
|
||||
QResource res (tl::to_qstring (":/syntax/ur_text.xml"));
|
||||
QByteArray data ((const char *) res.data (), int (res.size ()));
|
||||
if (res.isCompressed ()) {
|
||||
data = qUncompress (data);
|
||||
}
|
||||
|
||||
QBuffer input (&data);
|
||||
input.open (QIODevice::ReadOnly);
|
||||
mp_hl_basic_attributes.reset (new GenericSyntaxHighlighterAttributes ());
|
||||
mp_hl_attributes.reset (new GenericSyntaxHighlighterAttributes (mp_hl_basic_attributes.get ()));
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (mp_ui->text_edit, input, mp_hl_attributes.get ());
|
||||
input.close ();
|
||||
|
||||
hl->setDocument (mp_ui->text_edit->document ());
|
||||
}
|
||||
|
||||
UserPropertiesForm::~UserPropertiesForm ()
|
||||
|
|
@ -1031,35 +1056,12 @@ UserPropertiesForm::~UserPropertiesForm ()
|
|||
mp_ui = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
UserPropertiesForm::show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id)
|
||||
db::PropertiesRepository::properties_set
|
||||
UserPropertiesForm::get_properties (int tab)
|
||||
{
|
||||
bool ret = false;
|
||||
db::PropertiesRepository::properties_set props;
|
||||
|
||||
BEGIN_PROTECTED
|
||||
|
||||
const lay::CellView &cv = view->cellview (cv_index);
|
||||
db::PropertiesRepository &prep = cv->layout ().properties_repository ();
|
||||
|
||||
m_editable = cv->layout ().is_editable ();
|
||||
if (m_editable) {
|
||||
mp_ui->edit_frame->show ();
|
||||
} else {
|
||||
mp_ui->edit_frame->hide ();
|
||||
}
|
||||
|
||||
mp_ui->prop_list->clear ();
|
||||
|
||||
const db::PropertiesRepository::properties_set &props = prep.properties (prop_id);
|
||||
for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) {
|
||||
QTreeWidgetItem *entry = new QTreeWidgetItem (mp_ui->prop_list);
|
||||
entry->setText (0, tl::to_qstring (prep.prop_name (p->first).to_parsable_string ()));
|
||||
entry->setText (1, tl::to_qstring (p->second.to_parsable_string ()));
|
||||
}
|
||||
|
||||
if (exec ()) {
|
||||
|
||||
db::PropertiesRepository::properties_set props;
|
||||
if (tab == 0) {
|
||||
|
||||
QTreeWidgetItemIterator it (mp_ui->prop_list);
|
||||
while (*it) {
|
||||
|
|
@ -1076,13 +1078,92 @@ BEGIN_PROTECTED
|
|||
kex.read (k);
|
||||
kex.expect_end ();
|
||||
|
||||
props.insert (std::make_pair (prep.prop_name_id (k), v));
|
||||
props.insert (std::make_pair (mp_prep->prop_name_id (k), v));
|
||||
|
||||
++it;
|
||||
|
||||
}
|
||||
|
||||
prop_id = prep.properties_id (props);
|
||||
} else {
|
||||
|
||||
std::string text = tl::to_string (mp_ui->text_edit->toPlainText ());
|
||||
std::vector<std::string> lines = tl::split (text, "\n");
|
||||
|
||||
for (std::vector<std::string>::const_iterator l = lines.begin (); l != lines.end (); ++l) {
|
||||
|
||||
tl::Extractor ex (l->c_str ());
|
||||
if (ex.at_end ()) {
|
||||
// empty line
|
||||
} else {
|
||||
|
||||
tl::Variant v, k;
|
||||
ex.read (k);
|
||||
ex.test (":");
|
||||
ex.read (v);
|
||||
ex.expect_end ();
|
||||
|
||||
props.insert (std::make_pair (mp_prep->prop_name_id (k), v));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
void
|
||||
UserPropertiesForm::set_properties (const db::PropertiesRepository::properties_set &props)
|
||||
{
|
||||
mp_ui->prop_list->clear ();
|
||||
|
||||
for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) {
|
||||
QTreeWidgetItem *entry = new QTreeWidgetItem (mp_ui->prop_list);
|
||||
entry->setText (0, tl::to_qstring (mp_prep->prop_name (p->first).to_parsable_string ()));
|
||||
entry->setText (1, tl::to_qstring (p->second.to_parsable_string ()));
|
||||
}
|
||||
|
||||
std::string text;
|
||||
for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) {
|
||||
text += mp_prep->prop_name (p->first).to_parsable_string ();
|
||||
text += ": ";
|
||||
text += p->second.to_parsable_string ();
|
||||
text += "\n";
|
||||
}
|
||||
|
||||
mp_ui->text_edit->setPlainText (tl::to_qstring (text));
|
||||
}
|
||||
|
||||
bool
|
||||
UserPropertiesForm::show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
BEGIN_PROTECTED
|
||||
|
||||
const lay::CellView &cv = view->cellview (cv_index);
|
||||
mp_prep = &cv->layout ().properties_repository ();
|
||||
|
||||
m_editable = cv->layout ().is_editable ();
|
||||
if (m_editable) {
|
||||
mp_ui->edit_frame->show ();
|
||||
} else {
|
||||
mp_ui->edit_frame->hide ();
|
||||
}
|
||||
|
||||
mp_ui->text_edit->setReadOnly (! m_editable);
|
||||
mp_ui->prop_list->clear ();
|
||||
|
||||
const db::PropertiesRepository::properties_set &props = mp_prep->properties (prop_id);
|
||||
set_properties (props);
|
||||
|
||||
if (exec ()) {
|
||||
|
||||
if (m_editable) {
|
||||
db::PropertiesRepository::properties_set props = get_properties (mp_ui->mode_tab->currentIndex ());
|
||||
prop_id = mp_prep->properties_id (props);
|
||||
}
|
||||
|
||||
ret = true;
|
||||
|
||||
|
|
@ -1090,6 +1171,8 @@ BEGIN_PROTECTED
|
|||
ret = false;
|
||||
}
|
||||
|
||||
mp_prep = 0;
|
||||
|
||||
END_PROTECTED
|
||||
|
||||
return ret;
|
||||
|
|
@ -1144,6 +1227,50 @@ UserPropertiesForm::dbl_clicked (QTreeWidgetItem *, int)
|
|||
edit ();
|
||||
}
|
||||
|
||||
void
|
||||
UserPropertiesForm::tab_changed (int tab_index)
|
||||
{
|
||||
if (! m_editable) {
|
||||
return;
|
||||
}
|
||||
|
||||
BEGIN_PROTECTED
|
||||
|
||||
int prev_tab = tab_index == 0 ? 1 : 0;
|
||||
|
||||
try {
|
||||
|
||||
// sync content
|
||||
set_properties (get_properties (prev_tab));
|
||||
|
||||
} catch (...) {
|
||||
|
||||
mp_ui->mode_tab->blockSignals (true);
|
||||
mp_ui->mode_tab->setCurrentIndex (prev_tab);
|
||||
mp_ui->mode_tab->blockSignals (false);
|
||||
|
||||
throw;
|
||||
|
||||
}
|
||||
|
||||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
UserPropertiesForm::accept ()
|
||||
{
|
||||
BEGIN_PROTECTED
|
||||
|
||||
// Test for errors
|
||||
if (m_editable) {
|
||||
get_properties (mp_ui->mode_tab->currentIndex ());
|
||||
}
|
||||
|
||||
QDialog::accept ();
|
||||
|
||||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
UserPropertiesForm::edit ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@
|
|||
#include "dbPoint.h"
|
||||
#include "dbVector.h"
|
||||
#include "dbTypes.h"
|
||||
#include "dbPropertiesRepository.h"
|
||||
#include "laybasicCommon.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
|
||||
class QTreeWidgetItem;
|
||||
|
||||
|
|
@ -39,6 +41,11 @@ namespace db
|
|||
struct LayerProperties;
|
||||
}
|
||||
|
||||
namespace lay
|
||||
{
|
||||
class GenericSyntaxHighlighterAttributes;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class LayerSourceDialog;
|
||||
|
|
@ -412,11 +419,17 @@ public slots:
|
|||
void remove ();
|
||||
void edit ();
|
||||
void dbl_clicked (QTreeWidgetItem *, int);
|
||||
void tab_changed (int);
|
||||
|
||||
private:
|
||||
bool m_editable;
|
||||
db::PropertiesRepository::properties_set get_properties (int tab);
|
||||
void set_properties (const db::PropertiesRepository::properties_set &props);
|
||||
void accept ();
|
||||
|
||||
bool m_editable;
|
||||
db::PropertiesRepository *mp_prep;
|
||||
Ui::UserPropertiesForm *mp_ui;
|
||||
std::auto_ptr<lay::GenericSyntaxHighlighterAttributes> mp_hl_attributes, mp_hl_basic_attributes;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -432,7 +445,6 @@ public:
|
|||
bool show (QString &key, QString &value);
|
||||
virtual void accept ();
|
||||
|
||||
private:
|
||||
Ui::UserPropertiesEditForm *mp_ui;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#define HDR_layGenericSyntaxHighlighter
|
||||
|
||||
#include "tlString.h"
|
||||
#include "laybasicCommon.h"
|
||||
|
||||
#include <QSyntaxHighlighter>
|
||||
#include <QString>
|
||||
|
|
@ -40,7 +41,7 @@ namespace lay
|
|||
/**
|
||||
* @brief Specifies one element in the text block's user data
|
||||
*/
|
||||
struct SyntaxHighlighterElement
|
||||
struct LAYBASIC_PUBLIC SyntaxHighlighterElement
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -61,7 +62,7 @@ public:
|
|||
*
|
||||
* The user data will contain useful data for bracket detection and other things
|
||||
*/
|
||||
class SyntaxHighlighterUserData
|
||||
class LAYBASIC_PUBLIC SyntaxHighlighterUserData
|
||||
: public QTextBlockUserData
|
||||
{
|
||||
public:
|
||||
|
|
@ -92,7 +93,7 @@ public:
|
|||
* Rule implementations must implement this base class in order to plug into the
|
||||
* generic syntax highlighter framework.
|
||||
*/
|
||||
class GenericSyntaxHighlighterRuleBase
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -131,7 +132,7 @@ public:
|
|||
/**
|
||||
* @brief A specialization of GenericSyntaxHighlighterRuleBase which looks for a choice of strings
|
||||
*/
|
||||
class GenericSyntaxHighlighterRuleStringList
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleStringList
|
||||
: public GenericSyntaxHighlighterRuleBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -152,7 +153,7 @@ private:
|
|||
*
|
||||
* This object will forward the match request to the actual implementation.
|
||||
*/
|
||||
class GenericSyntaxHighlighterRule
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterRule
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -319,7 +320,7 @@ private:
|
|||
* Special context ID's are 0 (#stay), -n (#pop n times).
|
||||
* A context is associated with an attribute, which is given by an integer ID.
|
||||
*/
|
||||
class GenericSyntaxHighlighterContext
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterContext
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
|
|
@ -478,7 +479,7 @@ private:
|
|||
/**
|
||||
* @brief A collection of (named) contexts
|
||||
*/
|
||||
class GenericSyntaxHighlighterContexts
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterContexts
|
||||
{
|
||||
public:
|
||||
GenericSyntaxHighlighterContexts ();
|
||||
|
|
@ -579,7 +580,7 @@ enum def_style {
|
|||
/**
|
||||
* @brief A collection of attributes
|
||||
*/
|
||||
class GenericSyntaxHighlighterAttributes
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterAttributes
|
||||
{
|
||||
public:
|
||||
typedef std::map<QString, int>::const_iterator const_iterator;
|
||||
|
|
@ -672,7 +673,7 @@ private:
|
|||
/**
|
||||
* @brief The parser's state
|
||||
*/
|
||||
class GenericSyntaxHighlighterState
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighterState
|
||||
{
|
||||
public:
|
||||
GenericSyntaxHighlighterState (const GenericSyntaxHighlighterContexts *contexts);
|
||||
|
|
@ -710,7 +711,7 @@ private:
|
|||
/**
|
||||
* @brief A generic syntax highlighter using "Kate"'s syntax highlight scripts
|
||||
*/
|
||||
class GenericSyntaxHighlighter
|
||||
class LAYBASIC_PUBLIC GenericSyntaxHighlighter
|
||||
: public QSyntaxHighlighter
|
||||
{
|
||||
public:
|
||||
|
|
@ -177,7 +177,8 @@ SOURCES = \
|
|||
layNetlistCrossReferenceModel.cc \
|
||||
layNetlistBrowserTreeModel.cc \
|
||||
layLibrariesView.cc \
|
||||
layBookmarksView.cc
|
||||
layBookmarksView.cc \
|
||||
layGenericSyntaxHighlighter.cc
|
||||
|
||||
HEADERS = \
|
||||
gtf.h \
|
||||
|
|
@ -275,7 +276,8 @@ HEADERS = \
|
|||
layNetlistCrossReferenceModel.h \
|
||||
layNetlistBrowserTreeModel.h \
|
||||
layLibrariesView.h \
|
||||
layBookmarksView.h
|
||||
layBookmarksView.h \
|
||||
layGenericSyntaxHighlighter.h
|
||||
|
||||
INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC
|
||||
DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC
|
||||
|
|
|
|||
|
|
@ -44,5 +44,6 @@
|
|||
<file>images/icon_device_bjt_32.png</file>
|
||||
<file>images/icon_device_bjt_24.png</file>
|
||||
<file>images/icon_device_bjt_16.png</file>
|
||||
<file>syntax/ur_text.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE language SYSTEM "language.dtd">
|
||||
|
||||
<language name="UserPropertiesTextFormat">
|
||||
|
||||
<highlighting>
|
||||
|
||||
<contexts>
|
||||
|
||||
<context name="Normal" attribute="Normal Text">
|
||||
|
||||
<DetectChar attribute="String" char=""" context="Quoted Key String"/>
|
||||
<DetectChar attribute="Raw String" char="'" context="Apostrophed Key String"/>
|
||||
|
||||
<RegExpr attribute="Float" String="##\s*\-?[0-9]([0-9]|_[0-9])*(\.[0-9]([0-9]|_[0-9])*)?([eE]\-?[1-9]([0-9]|_[0-9])*(\.[0-9]*)?)?" context="After Key"/>
|
||||
<RegExpr attribute="Dec" String="#\s*\-?[1-9]([0-9]|_[0-9])*" context="After Key"/>
|
||||
<RegExpr attribute="Symbol" String="[_A-Za-z0-9]+\b" context="After Key"/>
|
||||
|
||||
<RegExpr attribute="Error" String="[^\s]" context="Error"/>
|
||||
|
||||
</context>
|
||||
|
||||
<context name="After Key" attribute="Normal Text" fallthrough="true" fallthroughContext="Value" lineEndContext="Error">
|
||||
<DetectChar attribute="Normal" char=":" context="Value"/>
|
||||
<RegExpr attribute="Normal" String="\s+" context="#stay"/>
|
||||
</context>
|
||||
|
||||
<context name="Value" attribute="Normal Text" fallthrough="true" fallthroughContext="Error" lineEndContext="Error">
|
||||
|
||||
<DetectChar attribute="String" char=""" context="Quoted Value String"/>
|
||||
<DetectChar attribute="Raw String" char="'" context="Apostrophed Value String"/>
|
||||
|
||||
<RegExpr attribute="Float" String="##\s*\-?[0-9]([0-9]|_[0-9])*(\.[0-9]([0-9]|_[0-9])*)?([eE]\-?[1-9]([0-9]|_[0-9])*(\.[0-9]*)?)?" context="After Value"/>
|
||||
<RegExpr attribute="Dec" String="#\s*\-?[1-9]([0-9]|_[0-9])*" context="After Value"/>
|
||||
<RegExpr attribute="Symbol" String="[_A-Za-z0-9]+\b" context="After Value"/>
|
||||
|
||||
<RegExpr attribute="Normal" String="\s+" context="Value"/>
|
||||
|
||||
</context>
|
||||
|
||||
<context name="After Value" attribute="Normal Text" fallthrough="true" fallthroughContext="Error" lineEndContext="Normal">
|
||||
<RegExpr attribute="Normal" String="\s+" context="#stay"/>
|
||||
</context>
|
||||
|
||||
<context name="Error" attribute="Error" lineEndContext="Normal">
|
||||
</context>
|
||||
|
||||
<context name="Quoted Key String" attribute="String" lineEndContext="Error">
|
||||
<StringDetect attribute="String" String="\\" context="#stay"/>
|
||||
<RegExpr attribute="String" String="\\\"" context="#stay"/>
|
||||
<DetectChar char=""" attribute="String" context="After Key"/>
|
||||
</context>
|
||||
|
||||
<context name="Apostrophed Key String" attribute="Raw String" lineEndContext="Error">
|
||||
<StringDetect attribute="String" String="\\" context="#stay"/>
|
||||
<RegExpr attribute="String" String="\\\'" context="#stay"/>
|
||||
<DetectChar char="'" attribute="Raw String" context="After Key"/>
|
||||
</context>
|
||||
|
||||
<context name="Quoted Value String" attribute="String" lineEndContext="Error">
|
||||
<StringDetect attribute="String" String="\\" context="#stay"/>
|
||||
<RegExpr attribute="String" String="\\\"" context="#stay"/>
|
||||
<DetectChar char=""" attribute="String" context="After Value"/>
|
||||
</context>
|
||||
|
||||
<context name="Apostrophed Value String" attribute="Raw String" lineEndContext="Error">
|
||||
<StringDetect attribute="String" String="\\" context="#stay"/>
|
||||
<RegExpr attribute="String" String="\\\'" context="#stay"/>
|
||||
<DetectChar char="'" attribute="Raw String" context="After Value"/>
|
||||
</context>
|
||||
|
||||
</contexts>
|
||||
|
||||
<itemDatas>
|
||||
<itemData name="Normal Text" defStyleNum="dsNormal"/>
|
||||
|
||||
<itemData name="Dec" defStyleNum="dsDecVal"/>
|
||||
<itemData name="Float" defStyleNum="dsFloat"/>
|
||||
<itemData name="Symbol" defStyleNum="dsString" color="#D40000"/>
|
||||
<itemData name="String" defStyleNum="dsString"/>
|
||||
<itemData name="Raw String" defStyleNum="dsString" color="#DD4A4A" selColor="#DD4A4A"/>
|
||||
|
||||
<!-- use these to mark errors and alerts things -->
|
||||
<itemData name="Error" defStyleNum="dsAlert"/>
|
||||
|
||||
</itemDatas>
|
||||
|
||||
</highlighting>
|
||||
</language>
|
||||
Loading…
Reference in New Issue