Skip to content

Commit 0b4cbe8

Browse files
author
timlinux
committed
Further work on ui cleanups and useability:
- in unique value and graduated symbol dialogs, show symbol previews in classification lists - tidy up for raster props dialog (PeteE I finally capitulated and used a stack widget) - use a label instead of a textbrowser in detailed item widget git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8521 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e366074 commit 0b4cbe8

12 files changed

+1040
-836
lines changed

src/app/qgisapp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ void QgisApp::createMenus()
10181018
void QgisApp::createToolBars()
10191019
{
10201020
QSize myIconSize ( 24,24 );
1021-
//QSize myIconSize ( 32,32 ); //large icons
1021+
// QSize myIconSize ( 32,32 ); //large icons
10221022
// Note: we need to set each object name to ensure that
10231023
// qmainwindow::saveState and qmainwindow::restoreState
10241024
// work properly

src/app/qgsattributetabledisplay.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
5353
void doSearch(const QString& searchString);
5454

5555
virtual void closeEvent(QCloseEvent* ev);
56-
void showHelp();
5756

5857
/** array of feature IDs that match last searched condition */
5958
QgsFeatureIds mSearchIds;
@@ -71,7 +70,7 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
7170
void search();
7271
void advancedSearch();
7372
void searchShowResultsChanged(int item);
74-
void on_btnHelp_clicked();
73+
void showHelp();
7574

7675
public slots:
7776
void changeFeatureAttribute(int row, int column);

src/app/qgsgraduatedsymboldialog.cpp

+91-65
Original file line numberDiff line numberDiff line change
@@ -155,74 +155,74 @@ void QgsGraduatedSymbolDialog::apply()
155155

156156
QgsGraduatedSymbolRenderer* renderer = new QgsGraduatedSymbolRenderer(mVectorLayer->vectorType());
157157
for (int item=0;item<mClassListWidget->count();++item)
158+
{
159+
QString classbreak=mClassListWidget->item(item)->text();
160+
std::map<QString,QgsSymbol*>::iterator it=mEntries.find(classbreak);
161+
if(it==mEntries.end())
162+
{
163+
continue;
164+
}
165+
166+
QString lower_bound=it->second->lowerValue();
167+
QString upper_bound=it->second->upperValue();
168+
QString label=it->second->label();
169+
170+
QgsSymbol* sy = new QgsSymbol(mVectorLayer->vectorType(), lower_bound, upper_bound, label);
171+
172+
sy->setColor(it->second->pen().color());
173+
sy->setLineStyle(it->second->pen().style());
174+
sy->setLineWidth(it->second->pen().widthF());
175+
176+
if (mVectorLayer->vectorType() == QGis::Point)
177+
{
178+
sy->setNamedPointSymbol(it->second->pointSymbolName());
179+
sy->setPointSize(it->second->pointSize());
180+
sy->setScaleClassificationField(it->second->scaleClassificationField());
181+
sy->setRotationClassificationField(it->second->rotationClassificationField());
182+
}
183+
184+
if (mVectorLayer->vectorType() != QGis::Line)
185+
{
186+
sy->setFillColor(it->second->brush().color());
187+
sy->setCustomTexture(it->second->customTexture());//necessary?
188+
sy->setFillStyle(it->second->brush().style());
189+
}
190+
191+
//test, if lower_bound is numeric or not (making a subclass of QString would be the proper solution)
192+
bool lbcontainsletter = false;
193+
for (int j = 0; j < lower_bound.length(); j++)
194+
{
195+
if (lower_bound.ref(j).isLetter())
196+
{
197+
lbcontainsletter = true;
198+
}
199+
}
200+
201+
//test, if upper_bound is numeric or not (making a subclass of QString would be the proper solution)
202+
bool ubcontainsletter = false;
203+
for (int j = 0; j < upper_bound.length(); j++)
204+
{
205+
if (upper_bound.ref(j).isLetter())
206+
{
207+
ubcontainsletter = true;
208+
}
209+
}
210+
if (lbcontainsletter == false && ubcontainsletter == false && lower_bound.length() > 0 && upper_bound.length() > 0) //only add the item if the value bounds do not contain letters and are not null strings
211+
{
212+
renderer->addSymbol(sy);
213+
}
214+
else
158215
{
159-
QString classbreak=mClassListWidget->item(item)->text();
160-
std::map<QString,QgsSymbol*>::iterator it=mEntries.find(classbreak);
161-
if(it==mEntries.end())
162-
{
163-
continue;
164-
}
165-
166-
QString lower_bound=it->second->lowerValue();
167-
QString upper_bound=it->second->upperValue();
168-
QString label=it->second->label();
169-
170-
QgsSymbol* sy = new QgsSymbol(mVectorLayer->vectorType(), lower_bound, upper_bound, label);
171-
172-
sy->setColor(it->second->pen().color());
173-
sy->setLineStyle(it->second->pen().style());
174-
sy->setLineWidth(it->second->pen().widthF());
175-
176-
if (mVectorLayer->vectorType() == QGis::Point)
177-
{
178-
sy->setNamedPointSymbol(it->second->pointSymbolName());
179-
sy->setPointSize(it->second->pointSize());
180-
sy->setScaleClassificationField(it->second->scaleClassificationField());
181-
sy->setRotationClassificationField(it->second->rotationClassificationField());
182-
}
183-
184-
if (mVectorLayer->vectorType() != QGis::Line)
185-
{
186-
sy->setFillColor(it->second->brush().color());
187-
sy->setCustomTexture(it->second->customTexture());//necessary?
188-
sy->setFillStyle(it->second->brush().style());
189-
}
190-
191-
//test, if lower_bound is numeric or not (making a subclass of QString would be the proper solution)
192-
bool lbcontainsletter = false;
193-
for (int j = 0; j < lower_bound.length(); j++)
194-
{
195-
if (lower_bound.ref(j).isLetter())
196-
{
197-
lbcontainsletter = true;
198-
}
199-
}
200-
201-
//test, if upper_bound is numeric or not (making a subclass of QString would be the proper solution)
202-
bool ubcontainsletter = false;
203-
for (int j = 0; j < upper_bound.length(); j++)
204-
{
205-
if (upper_bound.ref(j).isLetter())
206-
{
207-
ubcontainsletter = true;
208-
}
209-
}
210-
if (lbcontainsletter == false && ubcontainsletter == false && lower_bound.length() > 0 && upper_bound.length() > 0) //only add the item if the value bounds do not contain letters and are not null strings
211-
{
212-
renderer->addSymbol(sy);
213-
}
214-
else
215-
{
216-
delete sy;
217-
}
216+
delete sy;
218217
}
218+
}
219219
renderer->updateSymbolAttributes();
220-
220+
221221
std::map<QString,int>::iterator iter=mFieldMap.find(classificationComboBox->currentText());
222222
if(iter!=mFieldMap.end())
223-
{
224-
renderer->setClassificationField(iter->second);
225-
}
223+
{
224+
renderer->setClassificationField(iter->second);
225+
}
226226
mVectorLayer->setRenderer(renderer);
227227
}
228228

@@ -339,7 +339,9 @@ void QgsGraduatedSymbolDialog::adjustClassification()
339339
(*symbol_it)->setLowerValue(QString::number(lower,'f',3));
340340
(*symbol_it)->setUpperValue(QString::number(upper,'f',3));
341341
listBoxText=QString::number(lower,'f',3)+" - " +QString::number(upper,'f',3);
342-
mClassListWidget->addItem(listBoxText);
342+
QListWidgetItem * mypItem = new QListWidgetItem(listBoxText);
343+
updateEntryIcon(*symbol_it,mypItem);
344+
mClassListWidget->addItem(mypItem);
343345

344346
mEntries.insert(std::make_pair(listBoxText,*symbol_it));
345347
++symbol_it;
@@ -372,6 +374,7 @@ void QgsGraduatedSymbolDialog::changeCurrentValue()
372374
{
373375
sydialog.set((*it).second);
374376
sydialog.setLabel((*it).second->label());
377+
updateEntryIcon((*it).second,item);
375378
}
376379
}
377380
sydialog.blockSignals(false);
@@ -388,6 +391,7 @@ void QgsGraduatedSymbolDialog::applySymbologyChanges()
388391
{
389392
sydialog.apply((*it).second);
390393
it->second->setLabel((*it).second->label());
394+
updateEntryIcon((*it).second,item);
391395
}
392396
}
393397
}
@@ -419,7 +423,8 @@ void QgsGraduatedSymbolDialog::modifyClass(QListWidgetItem* item)
419423
QString newclass=dialog.lowerValue()+"-"+dialog.upperValue();
420424
mEntries.insert(std::make_pair(newclass,symbol));
421425
item->setText(newclass);
422-
}
426+
updateEntryIcon(symbol,item);
427+
}
423428
}
424429
}
425430

@@ -532,3 +537,24 @@ QColor QgsGraduatedSymbolDialog::getColorFromRamp(QString ramp, int step, int to
532537
}
533538
return color;
534539
}
540+
541+
void QgsGraduatedSymbolDialog::updateEntryIcon(QgsSymbol * thepSymbol,
542+
QListWidgetItem * thepItem)
543+
{
544+
QGis::VectorType myType = mVectorLayer->vectorType();
545+
switch (myType)
546+
{
547+
case QGis::Point:
548+
thepItem->setIcon(QIcon(QPixmap::fromImage(thepSymbol->getPointSymbolAsImage())));
549+
break;
550+
case QGis::Line:
551+
thepItem->setIcon(QIcon(QPixmap::fromImage(thepSymbol->getLineSymbolAsImage())));
552+
break;
553+
case QGis::Polygon:
554+
thepItem->setIcon(QIcon(QPixmap::fromImage(thepSymbol->getPolygonSymbolAsImage())));
555+
break;
556+
default: //unknown
557+
//do nothing
558+
;
559+
}
560+
}

src/app/qgsgraduatedsymboldialog.h

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class QgsGraduatedSymbolDialog: public QDialog, private Ui::QgsGraduatedSymbolDi
7575
void deleteCurrentClass();
7676

7777
private:
78+
/** Update the list widget item icon with a preview for the symbol.
79+
* @param QgsSymbol * - symbol holding the style info.
80+
* @param QListWidgetItem * - item to get its icon updated.
81+
*/
82+
void updateEntryIcon(QgsSymbol * thepSymbol,QListWidgetItem * thepItem);
7883
/**Default constructor is privat to not use is*/
7984
QgsGraduatedSymbolDialog();
8085
};

src/app/qgspluginmanager.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef QGSPLUGINMANAGER_H
2020
#define QGSPLUGINMANAGER_H
2121
#include <vector>
22-
#include <QTableView>
2322
#include <QStandardItemModel>
2423
#include <QSortFilterProxyModel>
2524
#include <QStandardItem>

0 commit comments

Comments
 (0)