# HG changeset patch
# User insilmaril
# Date 1204128546 0
# Node ID 459110777aaf30d04f870f484d15e3e86c37385a
# Parent  367d875453ed5f57aa575c5976056e702350a8d5
autosave fix

diff -r 367d875453ed -r 459110777aaf branchpropwindow.cpp
--- a/branchpropwindow.cpp	Wed Feb 27 16:09:06 2008 +0000
+++ b/branchpropwindow.cpp	Wed Feb 27 16:09:06 2008 +0000
@@ -27,6 +27,13 @@
 	ui.framePenColorButton->setPixmap (pix);
 	ui.frameBrushColorButton->setPixmap (pix);
 
+	// Create Model and View to hold attributes
+	attributeModel = new QStandardItemModel (1,3,this);
+	attributeModel->setHeaderData(0, Qt::Horizontal, tr("Name","Branchprop window: Attribute name"));
+	attributeModel->setHeaderData(1, Qt::Horizontal, tr("Value","Branchprop window: Attribute value"));
+	attributeModel->setHeaderData(2, Qt::Horizontal, tr("Type","Branchprop window: Attribute type"));
+	ui.attributeTableView->setModel (attributeModel);
+	
 
 	// Load Settings
 	resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
@@ -112,6 +119,27 @@
 		else	
 			ui.incImgHor->setCheckState (Qt::Unchecked);
 
+		// Attributes
+		attributeModel->removeRows(0, attributeModel->rowCount(), QModelIndex());
+
+		// FIXME some samples for testing
+		QStringList attrTypes=mapEditor->attributeTable()->getTypes();
+		for (int i=0; i<attrTypes.count()-1;i++)
+		{
+			attributeModel->insertRow (i,QModelIndex ());
+			attributeModel->setData(attributeModel->index(i, 0, QModelIndex()), QString ("Name %1").arg(i));
+			attributeModel->setData(attributeModel->index(i, 1, QModelIndex()), i);
+			attributeModel->setData(attributeModel->index(i, 2, QModelIndex()), attrTypes.at(i));
+		}
+
+
+		ui.attributeTableView->resizeColumnsToContents();
+
+		// Initialize Delegate
+		delegate.setAttributeTable (mapEditor->attributeTable());
+		ui.attributeTableView->setItemDelegate (&delegate);
+
+
 		// Finally activate signals
 		connectSignals();
 	} else
@@ -137,8 +165,13 @@
 		switch (i)
 		{
 			case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
-			case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
-			case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
+			case 1: 
+				mapEditor->setFrameType (FrameObj::Rectangle); 
+				break;
+			case 2: 
+				mapEditor->setFrameType (FrameObj::Ellipse); 
+				mapEditor->setFramePadding (5); 
+				break;
 		}
 		setBranch (branch);
 	}	
@@ -204,6 +237,30 @@
     return;
 }
 
+void BranchPropertyWindow::addAttributeClicked()
+{
+	// Add empty line for adding attributes
+	attributeModel->insertRow (attributeModel->rowCount (),QModelIndex ());
+	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 0, QModelIndex()),  "Add new");
+	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 2, QModelIndex()),  "Undefined");
+
+	// Select attribute from list
+	ui.attributeTableView->edit (attributeModel->index(attributeModel->rowCount()-1,0, QModelIndex() ));
+	ui.attributeTableView->resizeColumnsToContents();
+
+//	QString attname=attributeModel->in
+//	attributeModel->setData(attributeModel->index(attributeModel->rowCount()-1, 2, QModelIndex()),  );
+
+
+
+	ui.attributeTableView->edit (attributeModel->index(attributeModel->rowCount()-1,1, QModelIndex() ));
+
+}
+
+void BranchPropertyWindow::deleteAttributeClicked()
+{
+	cout << "BPW::delete\n";
+}
 
 void BranchPropertyWindow::connectSignals()
 {
@@ -237,6 +294,14 @@
 	connect ( 
 		ui.incImgHor, SIGNAL (stateChanged( int)), 
 		this, SLOT (incImgHorChanged (int)));
+
+	// Attributes	
+	connect ( 
+		ui.addAttributeButton, SIGNAL (clicked()), 
+		this, SLOT (addAttributeClicked()));
+	connect ( 
+		ui.deleteAttributeButton, SIGNAL (clicked()), 
+		this, SLOT (deleteAttributeClicked()));
 }
 
 
@@ -255,6 +320,10 @@
 	// Layout	
 	disconnect ( ui.incImgVer, 0,0,0);
 	disconnect ( ui.incImgHor, 0,0,0);
+
+	// Attributes
+	disconnect ( ui.addAttributeButton, 0,0,0);
+	disconnect ( ui.deleteAttributeButton, 0,0,0);
 }