| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| /*************************************************************************** | ||
| qgsfieldsproperties.h | ||
| --------------------- | ||
| begin : September 2012 | ||
| copyright : (C) 2012 by Matthias Kuhn | ||
| email : matthias dot kuhn at gmx dot ch | ||
| *************************************************************************** | ||
| * * | ||
| * This program 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 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSFIELDSPROPERTIES_H | ||
| #define QGSFIELDSPROPERTIES_H | ||
|
|
||
| #include <QWidget> | ||
| #include <QPushButton> | ||
| #include <QTreeWidget> | ||
| #include <QTableWidget> | ||
|
|
||
| #include "qgsvectorlayer.h" | ||
| #include "ui_qgsfieldspropertiesbase.h" | ||
|
|
||
| class QgsAttributesList : public QTableWidget | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsAttributesList( QWidget* parent = 0 ) | ||
| : QTableWidget( parent ) | ||
| {} | ||
|
|
||
| protected: | ||
| // virtual void dragMoveEvent( QDragMoveEvent *event ); | ||
| //QMimeData *mimeData( const QList<QTableWidgetItem *> items ) const; | ||
| //Qt::DropActions supportedDropActions() const; | ||
| }; | ||
|
|
||
| class QgsAttributesTree : public QTreeWidget | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsAttributesTree( QWidget* parent = 0 ) | ||
| : QTreeWidget( parent ) | ||
| {} | ||
| QTreeWidgetItem* addContainer( QTreeWidgetItem* parent , QString title ); | ||
| QTreeWidgetItem* addItem( QTreeWidgetItem* parent , QString fieldName ); | ||
|
|
||
| protected: | ||
| virtual void dragMoveEvent( QDragMoveEvent *event ); | ||
| virtual void dropEvent( QDropEvent *event ); | ||
| virtual bool dropMimeData( QTreeWidgetItem * parent, int index, const QMimeData * data, Qt::DropAction action ); | ||
| /* Qt::DropActions supportedDropActions() const;*/ | ||
| }; | ||
|
|
||
|
|
||
| class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent = 0 ); | ||
|
|
||
| /**Adds an attribute to the table (but does not commit it yet) | ||
| @param field the field to add | ||
| @return false in case of a name conflict, true in case of success */ | ||
| bool addAttribute( const QgsField &field ); | ||
|
|
||
| /**Deletes an attribute (but does not commit it) | ||
| @param name attribute name | ||
| @return false in case of a non-existing attribute.*/ | ||
| bool deleteAttribute( int attr ); | ||
|
|
||
| /**Creates the a proper item to save from the tree | ||
| * @param item The tree widget item to process | ||
| * @return A widget definition. Containing another container or the final field | ||
| */ | ||
| QgsAttributeEditorElement* createAttributeEditorWidget( QTreeWidgetItem* item, QObject *parent ); | ||
|
|
||
| void init(); | ||
| void apply(); | ||
|
|
||
| void updateButtons(); | ||
| void loadRows(); | ||
| void setRow( int row, int idx, const QgsField &field ); | ||
|
|
||
| void loadAttributeEditorTree(); | ||
| QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement* const widgetDef, QTreeWidgetItem* parent ); | ||
|
|
||
| signals: | ||
| void toggleEditing( QgsMapLayer * ); | ||
|
|
||
| public slots: | ||
| void on_mAddAttributeButton_clicked(); | ||
| void on_mDeleteAttributeButton_clicked(); | ||
| void on_mCalculateFieldButton_clicked(); | ||
| void on_attributeSelectionChanged(); | ||
| void on_mAttributesList_cellChanged( int row, int column ); | ||
| void on_pbnSelectEditForm_clicked(); | ||
| void on_mEditorLayoutComboBox_currentIndexChanged ( int index ); | ||
| void addAttribute(); | ||
| void deleteAttribute(); | ||
|
|
||
| void attributeAdded( int idx ); | ||
| void attributeDeleted( int idx ); | ||
| void attributeTypeDialog(); | ||
|
|
||
| void on_mAddTabOrGroupButton_clicked(); | ||
| void on_mAddItemButton_clicked(); | ||
| void on_mRemoveTabGroupItemButton_clicked(); | ||
| void on_mMoveDownItem_clicked(); | ||
| void on_mMoveUpItem_clicked(); | ||
|
|
||
|
|
||
|
|
||
| protected: | ||
| QgsVectorLayer* mLayer; | ||
| QgsAttributesTree* mAttributesTree; | ||
| QgsAttributesList* mAttributesList; | ||
|
|
||
| /** toggle editing of layer */ | ||
| void toggleEditing(); | ||
|
|
||
| /** editing of layer was toggled */ | ||
| void editingToggled(); | ||
|
|
||
| QMap<int, QgsVectorLayer::ValueRelationData> mValueRelationData; | ||
| QMap<int, QMap<QString, QVariant> > mValueMaps; | ||
| QMap<int, QgsVectorLayer::RangeData> mRanges; | ||
| QMap<int, QPair<QString, QString> > mCheckedStates; | ||
| QMap<int, QgsVectorLayer::EditType> mEditTypeMap; | ||
| QMap<int, QPushButton*> mButtonMap; | ||
|
|
||
| enum attrColumns | ||
| { | ||
| attrIdCol = 0, | ||
| attrNameCol, | ||
| attrTypeCol, | ||
| attrLengthCol, | ||
| attrPrecCol, | ||
| attrCommentCol, | ||
| attrEditTypeCol, | ||
| attrAliasCol, | ||
| attrWMSCol, | ||
| attrWFSCol, | ||
| attrColCount, | ||
| }; | ||
|
|
||
| static QMap< QgsVectorLayer::EditType, QString > editTypeMap; | ||
| static void setupEditTypes(); | ||
| static QString editTypeButtonText( QgsVectorLayer::EditType type ); | ||
| static QgsVectorLayer::EditType editTypeFromButtonText( QString text ); | ||
|
|
||
| }; | ||
|
|
||
| #endif // QGSFIELDSPROPERTIES_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>QgsAddTabOrGroupBase</class> | ||
| <widget class="QDialog" name="QgsAddTabOrGroupBase"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>447</width> | ||
| <height>164</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Dialog</string> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout_2"> | ||
| <item row="3" column="1"> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="0" colspan="2"> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Create category</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="mName"/> | ||
| </item> | ||
| <item row="0" column="3"> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>as</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0" colspan="2"> | ||
| <widget class="QRadioButton" name="mTabButton"> | ||
| <property name="text"> | ||
| <string>a tab</string> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <attribute name="buttonGroup"> | ||
| <string notr="true">buttonGroup</string> | ||
| </attribute> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="0" colspan="2"> | ||
| <widget class="QRadioButton" name="mGroupButton"> | ||
| <property name="text"> | ||
| <string>a group in container</string> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>false</bool> | ||
| </property> | ||
| <attribute name="buttonGroup"> | ||
| <string notr="true">buttonGroup</string> | ||
| </attribute> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="2" colspan="2"> | ||
| <widget class="QComboBox" name="mTabList"> | ||
| <property name="enabled"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item row="1" column="0" rowspan="3" colspan="2"> | ||
| <spacer name="verticalSpacer"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>20</width> | ||
| <height>40</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>QgsAddTabOrGroupBase</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>QgsAddTabOrGroupBase</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> | ||
| <buttongroups> | ||
| <buttongroup name="buttonGroup"/> | ||
| </buttongroups> | ||
| </ui> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,330 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>QgsFieldsPropertiesBase</class> | ||
| <widget class="QWidget" name="QgsFieldsPropertiesBase"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>782</width> | ||
| <height>663</height> | ||
| </rect> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout_6"> | ||
| <item row="0" column="3"> | ||
| <widget class="QToolButton" name="mCalculateFieldButton"> | ||
| <property name="toolTip"> | ||
| <string>Field calculator</string> | ||
| </property> | ||
| <property name="whatsThis"> | ||
| <string>Click to toggle table editing</string> | ||
| </property> | ||
| <property name="text"> | ||
| <string/> | ||
| </property> | ||
| <property name="checkable"> | ||
| <bool>false</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="4"> | ||
| <spacer> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>100</width> | ||
| <height>19</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| <item row="0" column="2"> | ||
| <widget class="QToolButton" name="mToggleEditingButton"> | ||
| <property name="toolTip"> | ||
| <string>Toggle editing mode</string> | ||
| </property> | ||
| <property name="whatsThis"> | ||
| <string>Click to toggle table editing</string> | ||
| </property> | ||
| <property name="text"> | ||
| <string/> | ||
| </property> | ||
| <property name="checkable"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="0"> | ||
| <widget class="QToolButton" name="mAddAttributeButton"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="toolTip"> | ||
| <string>New column</string> | ||
| </property> | ||
| <property name="text"> | ||
| <string/> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset> | ||
| <normaloff>.designer/xpm/new_attribute.png</normaloff>.designer/xpm/new_attribute.png</iconset> | ||
| </property> | ||
| <property name="shortcut"> | ||
| <string>Ctrl+N</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1"> | ||
| <widget class="QToolButton" name="mDeleteAttributeButton"> | ||
| <property name="toolTip"> | ||
| <string>Delete column</string> | ||
| </property> | ||
| <property name="text"> | ||
| <string/> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset> | ||
| <normaloff>.designer/xpm/delete_attribute.png</normaloff>.designer/xpm/delete_attribute.png</iconset> | ||
| </property> | ||
| <property name="shortcut"> | ||
| <string>Ctrl+X</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0" colspan="7"> | ||
| <layout class="QHBoxLayout" name="horizontalLayout_15"> | ||
| <item> | ||
| <widget class="QWidget" name="mAttributesListFrame" native="true"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QWidget" name="widget" native="true"> | ||
| <layout class="QGridLayout" name="gridLayout_18"> | ||
| <property name="margin"> | ||
| <number>0</number> | ||
| </property> | ||
| <item row="1" column="0" colspan="3"> | ||
| <widget class="QStackedWidget" name="mAttributeEditorOptionsWidget"> | ||
| <property name="currentIndex"> | ||
| <number>0</number> | ||
| </property> | ||
| <widget class="QWidget" name="page"> | ||
| <layout class="QGridLayout" name="gridLayout_2"> | ||
| <item row="0" column="1"> | ||
| <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
| <item> | ||
| <widget class="QLineEdit" name="leEditForm"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="pbnSelectEditForm"> | ||
| <property name="text"> | ||
| <string>...</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="label_3"> | ||
| <property name="text"> | ||
| <string>Init function</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="1"> | ||
| <widget class="QLineEdit" name="leEditFormInit"/> | ||
| </item> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Edit UI</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="0" colspan="2"> | ||
| <spacer name="verticalSpacer"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>20</width> | ||
| <height>40</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <widget class="QWidget" name="page_2"> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="1" column="1"> | ||
| <widget class="QWidget" name="mAttributesTreeButtonFrame" native="true"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="maximumSize"> | ||
| <size> | ||
| <width>30</width> | ||
| <height>16777215</height> | ||
| </size> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <property name="spacing"> | ||
| <number>6</number> | ||
| </property> | ||
| <property name="margin"> | ||
| <number>0</number> | ||
| </property> | ||
| <item> | ||
| <spacer name="verticalSpacer_4"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>20</width> | ||
| <height>186</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="mAddTabOrGroupButton"> | ||
| <property name="text"> | ||
| <string>+</string> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset resource="../../images/images.qrc"> | ||
| <normaloff>:/images/themes/default/mActionSignPlus.png</normaloff>:/images/themes/default/mActionSignPlus.png</iconset> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="mRemoveTabGroupItemButton"> | ||
| <property name="text"> | ||
| <string>-</string> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset resource="../../images/images.qrc"> | ||
| <normaloff>:/images/themes/default/mActionSignMinus.png</normaloff>:/images/themes/default/mActionSignMinus.png</iconset> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="mAddItemButton"> | ||
| <property name="text"> | ||
| <string>></string> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset resource="../../images/images.qrc"> | ||
| <normaloff>:/images/themes/default/mActionArrowRight.png</normaloff>:/images/themes/default/mActionArrowRight.png</iconset> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="mMoveUpItem"> | ||
| <property name="text"> | ||
| <string>^</string> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset resource="../../images/images.qrc"> | ||
| <normaloff>:/images/themes/default/mActionArrowUp.png</normaloff>:/images/themes/default/mActionArrowUp.png</iconset> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="mMoveDownItem"> | ||
| <property name="text"> | ||
| <string>v</string> | ||
| </property> | ||
| <property name="icon"> | ||
| <iconset resource="../../images/images.qrc"> | ||
| <normaloff>:/images/themes/default/mActionArrowDown.png</normaloff>:/images/themes/default/mActionArrowDown.png</iconset> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <spacer name="verticalSpacer_3"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>5</width> | ||
| <height>176</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="2"> | ||
| <widget class="QWidget" name="mAttributesTreeFrame" native="true"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="autoFillBackground"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item row="0" column="6"> | ||
| <widget class="QComboBox" name="mEditorLayoutComboBox"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Autogenerate</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Drag and drop designer</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Provide ui-file</string> | ||
| </property> | ||
| </item> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="5"> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Attribute editor layout:</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <resources> | ||
| <include location="../../images/images.qrc"/> | ||
| </resources> | ||
| <connections/> | ||
| </ui> |