Skip to content
Permalink
Browse files

Double clicking an attribute item adds it to assigned items

  • Loading branch information
m-kuhn committed Sep 6, 2012
1 parent ba0bed0 commit 6cd3d7776286d95af899056fc4332e1200d52836
Showing with 25 additions and 15 deletions.
  1. +22 −13 src/app/qgsdiagramproperties.cpp
  2. +3 −2 src/app/qgsdiagramproperties.h
@@ -343,6 +343,23 @@ void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int inde
mScaleDependencyLabel->hide();
}
}
void QgsDiagramProperties::addAttribute( QTreeWidgetItem * item )
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );

newItem->setText( 0, item->text( 0 ) );
newItem->setData( 0, Qt::UserRole, item->data( 0, Qt::UserRole ) );
newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

//set initial color for diagram category
int red = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int green = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int blue = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
QColor randomColor( red, green, blue );
newItem->setBackground( 1, QBrush( randomColor ) );
mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
}


void QgsDiagramProperties::on_mTransparencySlider_valueChanged( int value )
{
@@ -353,22 +370,14 @@ void QgsDiagramProperties::on_mAddCategoryPushButton_clicked()
{
foreach ( QTreeWidgetItem *attributeItem, mAttributesTreeWidget->selectedItems() )
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );

newItem->setText( 0, attributeItem->text( 0 ) );
newItem->setData( 0, Qt::UserRole, attributeItem->data( 0, Qt::UserRole ) );
newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );

//set initial color for diagram category
int red = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int green = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
int blue = 1 + ( int )( 255.0 * rand() / ( RAND_MAX + 1.0 ) );
QColor randomColor( red, green, blue );
newItem->setBackground( 1, QBrush( randomColor ) );
mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
addAttribute( attributeItem );
}
}

void QgsDiagramProperties::on_mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem * item, int column )
{
addAttribute( item );
}

void QgsDiagramProperties::on_mRemoveCategoryPushButton_clicked()
{
@@ -29,14 +29,15 @@ class QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPropertiesBas

public:
QgsDiagramProperties( QgsVectorLayer* layer, QWidget* parent );

//void handleAttributeDoubleClicked( QTreeWidgetItem * item, int column );
/**Adds an attribute from the list of available attributes to the assigned attributes with a random color.*/
void addAttribute( QTreeWidgetItem * item );

public slots:
void apply();
void on_mDiagramTypeComboBox_currentIndexChanged( int index );
void on_mTransparencySlider_valueChanged( int value );
void on_mAddCategoryPushButton_clicked();
void on_mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem * item, int column );
void on_mBackgroundColorButton_clicked();
void on_mFindMaximumValueButton_clicked();
void on_mDiagramPenColorButton_clicked();

0 comments on commit 6cd3d77

Please sign in to comment.
You can’t perform that action at this time.