Skip to content

Commit

Permalink
Hello from Wroclaw QGIS Hackfest November 2010! Tidy up for vector sy…
Browse files Browse the repository at this point in the history
…mbology dialog

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14556 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 12, 2010
1 parent 31d828f commit c6eced8
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 59 deletions.
12 changes: 9 additions & 3 deletions src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsSt
}

connect( btnSymbolProperties, SIGNAL( clicked() ), this, SLOT( changeSymbolProperties() ) );
connect( lblPreview, SIGNAL( clicked() ), this, SLOT( changeSymbolProperties() ) );
connect( btnStyleManager, SIGNAL( clicked() ), SLOT( openStyleManager() ) );

QStandardItemModel* model = new QStandardItemModel( viewSymbols );
viewSymbols->setModel( model );
connect( viewSymbols, SIGNAL( clicked( const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );

lblSymbolName->setText("");
populateSymbolView();
updateSymbolPreview();
updateSymbolInfo();
Expand Down Expand Up @@ -81,7 +82,9 @@ void QgsSymbolV2SelectorDialog::populateSymbolView()

QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
if ( !model )
{
return;
}
model->clear();

QStringList names = mStyle->symbolNames();
Expand All @@ -94,6 +97,8 @@ void QgsSymbolV2SelectorDialog::populateSymbolView()
continue;
}
QStandardItem* item = new QStandardItem( names[i] );
item->setData( names[i], Qt::UserRole ); //so we can show a label when it is clicked
item->setText(""); //set the text to nothing and show in label when clicked rather
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
// create preview icon
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize );
Expand All @@ -106,7 +111,8 @@ void QgsSymbolV2SelectorDialog::populateSymbolView()

void QgsSymbolV2SelectorDialog::setSymbolFromStyle( const QModelIndex & index )
{
QString symbolName = index.data().toString();
QString symbolName = index.data( Qt::UserRole ).toString();
lblSymbolName->setText( symbolName );
// get new instance of symbol from style
QgsSymbolV2* s = mStyle->symbol( symbolName );
// remove all symbol layers from original symbol
Expand Down Expand Up @@ -264,7 +270,7 @@ void QgsSymbolV2SelectorDialog::on_mTransparencySlider_valueChanged( int value )
void QgsSymbolV2SelectorDialog::displayTransparency( double alpha )
{
double transparencyPercent = ( 1 - alpha ) * 100;
mTransparencyLabel->setText( tr( "Transparency: %1%" ).arg(( int ) transparencyPercent ) );
mTransparencyLabel->setText( tr( "Transparency %1%" ).arg(( int ) transparencyPercent ) );
}

QMenu* QgsSymbolV2SelectorDialog::advancedMenu()
Expand Down
164 changes: 108 additions & 56 deletions src/ui/qgssymbolv2selectordialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,49 @@
<property name="windowTitle">
<string>Symbol selector</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="lblPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="lblPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnSymbolProperties">
<property name="text">
<string>Change...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="mSymbolUnitLabel">
Expand Down Expand Up @@ -115,16 +126,19 @@
</item>
</layout>
</item>
<item>
<item row="0" column="2" colspan="2">
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="pageMarker">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
Expand Down Expand Up @@ -168,21 +182,31 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>178</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageLine">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="spinWidth">
<property name="decimals">
<number>2</number>
Expand All @@ -195,6 +219,32 @@
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>37</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>37</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageFill">
Expand All @@ -206,18 +256,7 @@
</widget>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnSymbolProperties">
<property name="text">
<string>Properties</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -230,35 +269,35 @@
</property>
</spacer>
</item>
<item>
<item row="1" column="1" colspan="2">
<widget class="QPushButton" name="btnAdvanced">
<property name="text">
<string>Advanced</string>
</property>
</widget>
</item>
<item>
<item row="1" column="3">
<widget class="QPushButton" name="btnAddToStyle">
<property name="text">
<string>Add to style</string>
<string>Save as style</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Symbols from style</string>
<string>Saved styles</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -308,11 +347,24 @@
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="3" column="0">
<widget class="QLabel" name="lblSymbolName">
<property name="text">
<string>Symbol Name</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down

0 comments on commit c6eced8

Please sign in to comment.