branchpropwindow.cpp
changeset 679 d2f72e448522
parent 530 28be7520cb21
child 686 d6cc3365c8b8
     1.1 --- a/branchpropwindow.cpp	Fri Jun 29 09:43:53 2007 +0000
     1.2 +++ b/branchpropwindow.cpp	Mon Mar 03 09:25:40 2008 +0000
     1.3 @@ -27,6 +27,13 @@
     1.4  	ui.framePenColorButton->setPixmap (pix);
     1.5  	ui.frameBrushColorButton->setPixmap (pix);
     1.6  
     1.7 +	// Create Model and View to hold attributes
     1.8 +	attributeModel = new QStandardItemModel (1,3,this);
     1.9 +	attributeModel->setHeaderData(0, Qt::Horizontal, tr("Name","Branchprop window: Attribute name"));
    1.10 +	attributeModel->setHeaderData(1, Qt::Horizontal, tr("Value","Branchprop window: Attribute value"));
    1.11 +	attributeModel->setHeaderData(2, Qt::Horizontal, tr("Type","Branchprop window: Attribute type"));
    1.12 +	ui.attributeTableView->setModel (attributeModel);
    1.13 +	
    1.14  
    1.15  	// Load Settings
    1.16  	resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
    1.17 @@ -112,6 +119,27 @@
    1.18  		else	
    1.19  			ui.incImgHor->setCheckState (Qt::Unchecked);
    1.20  
    1.21 +		// Attributes
    1.22 +		attributeModel->removeRows(0, attributeModel->rowCount(), QModelIndex());
    1.23 +
    1.24 +		// FIXME some samples for testing
    1.25 +		QStringList attrTypes=mapEditor->attributeTable()->getTypes();
    1.26 +		for (int i=0; i<attrTypes.count()-1;i++)
    1.27 +		{
    1.28 +			attributeModel->insertRow (i,QModelIndex ());
    1.29 +			attributeModel->setData(attributeModel->index(i, 0, QModelIndex()), QString ("Name %1").arg(i));
    1.30 +			attributeModel->setData(attributeModel->index(i, 1, QModelIndex()), i);
    1.31 +			attributeModel->setData(attributeModel->index(i, 2, QModelIndex()), attrTypes.at(i));
    1.32 +		}
    1.33 +
    1.34 +
    1.35 +		ui.attributeTableView->resizeColumnsToContents();
    1.36 +
    1.37 +		// Initialize Delegate
    1.38 +		delegate.setAttributeTable (mapEditor->attributeTable());
    1.39 +		ui.attributeTableView->setItemDelegate (&delegate);
    1.40 +
    1.41 +
    1.42  		// Finally activate signals
    1.43  		connectSignals();
    1.44  	} else
    1.45 @@ -137,8 +165,13 @@
    1.46  		switch (i)
    1.47  		{
    1.48  			case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
    1.49 -			case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
    1.50 -			case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
    1.51 +			case 1: 
    1.52 +				mapEditor->setFrameType (FrameObj::Rectangle); 
    1.53 +				break;
    1.54 +			case 2: 
    1.55 +				mapEditor->setFrameType (FrameObj::Ellipse); 
    1.56 +				mapEditor->setFramePadding (5); 
    1.57 +				break;
    1.58  		}
    1.59  		setBranch (branch);
    1.60  	}	
    1.61 @@ -204,6 +237,30 @@
    1.62      return;
    1.63  }
    1.64  
    1.65 +void BranchPropertyWindow::addAttributeClicked()
    1.66 +{
    1.67 +	// Add empty line for adding attributes
    1.68 +	attributeModel->insertRow (attributeModel->rowCount (),QModelIndex ());
    1.69 +	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 0, QModelIndex()),  "Add new");
    1.70 +	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 2, QModelIndex()),  "Undefined");
    1.71 +
    1.72 +	// Select attribute from list
    1.73 +	ui.attributeTableView->edit (attributeModel->index(attributeModel->rowCount()-1,0, QModelIndex() ));
    1.74 +	ui.attributeTableView->resizeColumnsToContents();
    1.75 +
    1.76 +//	QString attname=attributeModel->in
    1.77 +//	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 2, QModelIndex()),  );
    1.78 +
    1.79 +
    1.80 +
    1.81 +	ui.attributeTableView->edit (attributeModel->index(attributeModel->rowCount()-1,1, QModelIndex() ));
    1.82 +
    1.83 +}
    1.84 +
    1.85 +void BranchPropertyWindow::deleteAttributeClicked()
    1.86 +{
    1.87 +	cout << "BPW::delete\n";
    1.88 +}
    1.89  
    1.90  void BranchPropertyWindow::connectSignals()
    1.91  {
    1.92 @@ -237,6 +294,14 @@
    1.93  	connect ( 
    1.94  		ui.incImgHor, SIGNAL (stateChanged( int)), 
    1.95  		this, SLOT (incImgHorChanged (int)));
    1.96 +
    1.97 +	// Attributes	
    1.98 +	connect ( 
    1.99 +		ui.addAttributeButton, SIGNAL (clicked()), 
   1.100 +		this, SLOT (addAttributeClicked()));
   1.101 +	connect ( 
   1.102 +		ui.deleteAttributeButton, SIGNAL (clicked()), 
   1.103 +		this, SLOT (deleteAttributeClicked()));
   1.104  }
   1.105  
   1.106  
   1.107 @@ -255,6 +320,10 @@
   1.108  	// Layout	
   1.109  	disconnect ( ui.incImgVer, 0,0,0);
   1.110  	disconnect ( ui.incImgHor, 0,0,0);
   1.111 +
   1.112 +	// Attributes
   1.113 +	disconnect ( ui.addAttributeButton, 0,0,0);
   1.114 +	disconnect ( ui.deleteAttributeButton, 0,0,0);
   1.115  }
   1.116  
   1.117