Skip to content

Commit

Permalink
Replaced Q3ListBox in the unique value dialog with QListWidget
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6523 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 4, 2007
1 parent 9b335ac commit 3e654a9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 55 deletions.
34 changes: 22 additions & 12 deletions src/app/qgsuniquevaluedialog.cpp
Expand Up @@ -74,13 +74,13 @@ QgsUniqueValueDialog::QgsUniqueValueDialog(QgsVectorLayer* vl): QDialog(), mVect
sym->setNamedPointSymbol(symbol->pointSymbolName());
sym->setPointSize(symbol->pointSize());
mValues.insert(std::make_pair(symbolvalue,sym));
mClassBreakBox->insertItem(symbolvalue);
mClassBreakBox->addItem(symbolvalue);
}
}

QObject::connect(mClassifyButton, SIGNAL(clicked()), this, SLOT(changeClassificationAttribute()));
QObject::connect(mDeletePushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentClass()));
QObject::connect(mClassBreakBox, SIGNAL(selectionChanged()), this, SLOT(changeCurrentValue()));
QObject::connect(mClassBreakBox, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(changeCurrentValue()));
QObject::connect(&sydialog, SIGNAL(settingsChanged()), this, SLOT(applySymbologyChanges()));
mSymbolWidgetStack->addWidget(&sydialog);
mSymbolWidgetStack->raiseWidget(&sydialog);
Expand Down Expand Up @@ -168,7 +168,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
int green = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
int blue = 1 + (int) (255.0 * rand() / (RAND_MAX + 1.0));
thecolor.setRgb(red, green, blue);
mClassBreakBox->insertItem(it->first);
mClassBreakBox->addItem(it->first);
QgsSymbol* sym=it->second;
QPen pen;
QBrush brush;
Expand Down Expand Up @@ -196,7 +196,7 @@ void QgsUniqueValueDialog::changeClassificationAttribute()
void QgsUniqueValueDialog::changeCurrentValue()
{
sydialog.blockSignals(true);//block signal to prevent sydialog from changing the current QgsRenderItem
Q3ListBoxItem* item=mClassBreakBox->selectedItem();
QListWidgetItem* item=mClassBreakBox->currentItem();
if(item)
{
QString value=item->text();
Expand All @@ -216,28 +216,38 @@ void QgsUniqueValueDialog::changeCurrentValue()

void QgsUniqueValueDialog::deleteCurrentClass()
{
QString classValue = mClassBreakBox->currentText();
int currentIndex = mClassBreakBox->currentItem();
QListWidgetItem* currentItem = mClassBreakBox->currentItem();
if(!currentItem)
{
return;
}

QString classValue = currentItem->text();
int currentIndex = mClassBreakBox->currentRow();
mValues.erase(classValue);
mClassBreakBox->removeItem(currentIndex);
delete (mClassBreakBox->takeItem(currentIndex));
qWarning("numRows: ");
qWarning(QString::number(mClassBreakBox->numRows()));
qWarning(QString::number(mClassBreakBox->count()));
//
if(mClassBreakBox->numRows() < (currentIndex + 1))
if(mClassBreakBox->count() < (currentIndex + 1))
{
qWarning("selecting numRows - 1");
mClassBreakBox->setSelected(mClassBreakBox->numRows() - 1, true);
mClassBreakBox->setCurrentRow(mClassBreakBox->count() - 1);
}
else
{
qWarning("selecting currentIndex");
mClassBreakBox->setSelected(currentIndex, true);
mClassBreakBox->setCurrentRow(currentIndex);
}
}

void QgsUniqueValueDialog::applySymbologyChanges()
{
Q3ListBoxItem* item=mClassBreakBox->selectedItem();
QListWidgetItem* item=mClassBreakBox->currentItem();
if(!item)
{
return;
}
QString value=item->text();
std::map<QString,QgsSymbol*>::iterator it=mValues.find(value);
if(it!=mValues.end())
Expand Down
81 changes: 38 additions & 43 deletions src/ui/qgsuniquevaluedialogbase.ui
Expand Up @@ -19,27 +19,38 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="mClassVarLabel" >
<item row="1" column="2" colspan="4" >
<widget class="QListWidget" name="mClassBreakBox" />
</item>
<item row="1" column="0" colspan="2" >
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
<widget class="QWidget" name="WStackPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>246</height>
</rect>
</property>
</widget>
</widget>
</item>
<item row="0" column="3" >
<widget class="QPushButton" name="mClassifyButton" >
<property name="text" >
<string>Classify</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="mClassificationComboBox" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text" >
<string>Classification Field:</string>
</property>
<property name="buddy" >
<cstring>mClassificationComboBox</cstring>
</property>
</widget>
</item>
<item row="0" column="4" >
<widget class="QPushButton" name="mDeletePushButton" >
<property name="text" >
<string>Delete class</string>
</property>
</widget>
</item>
<item row="0" column="5" >
Expand All @@ -58,50 +69,34 @@
</property>
</spacer>
</item>
<item row="1" column="2" colspan="4" >
<widget class="Q3ListBox" name="mClassBreakBox" />
<item row="0" column="4" >
<widget class="QPushButton" name="mDeletePushButton" >
<property name="text" >
<string>Delete class</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="mClassificationComboBox" >
<item row="0" column="0" >
<widget class="QLabel" name="mClassVarLabel" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QPushButton" name="mClassifyButton" >
<property name="text" >
<string>Classify</string>
<string>Classification Field:</string>
</property>
<property name="buddy" >
<cstring>mClassificationComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Q3WidgetStack" name="mSymbolWidgetStack" >
<widget class="QWidget" name="WStackPage" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>190</width>
<height>246</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Q3ListBox</class>
<extends>Q3Frame</extends>
<header>q3listbox.h</header>
</customwidget>
<customwidget>
<class>Q3WidgetStack</class>
<extends>Q3WidgetStack</extends>
Expand Down

0 comments on commit 3e654a9

Please sign in to comment.