# HG changeset patch
# User insilmaril
# Date 1175333307 0
# Node ID c6a8651e6bbcec7cb8130d14be52761a8ae9a64a
# Parent  717b20c563583b1a51b2e3a871431c20bc4be173
1.8.70 Fixes in property window

diff -r 717b20c56358 -r c6a8651e6bbc branchobj.cpp
--- a/branchobj.cpp	Wed Mar 21 11:51:38 2007 +0000
+++ b/branchobj.cpp	Sat Mar 31 09:28:27 2007 +0000
@@ -572,7 +572,6 @@
 	QPointF ap=getAbsPos();
 	bbox.moveTopLeft (ap);
 	positionContents();
-	setSelBox();
 
 	// set the frame
 	frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
@@ -661,12 +660,20 @@
 	// Sets childpos and parpos depending on orientation
 	if (getOrientation()==OrientLeftOfCenter )
     {
-		childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
-		parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
+		childPos=QPointF (
+			ornamentsBBox.bottomLeft().x(), 
+			bottomlineY);
+		parPos=QPointF (
+			ornamentsBBox.bottomRight().x(),
+			bottomlineY);
     } else
     {
-		childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
-		parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
+		childPos=QPointF (
+			ornamentsBBox.bottomRight().x(), 
+			bottomlineY);
+		parPos=QPointF (
+			ornamentsBBox.bottomLeft().x(),
+			bottomlineY);
     }
 }
 
@@ -1451,7 +1458,7 @@
 
 void BranchObj::select()
 {
-	// set Text in Editor	
+	// update NoteEditor
 	textEditor->setText(note.getNote() );
 	QString fnh=note.getFilenameHint();
 	if (fnh!="")
@@ -1461,7 +1468,9 @@
 	textEditor->setFontHint (note.getFontHint() );
 	isNoteInEditor=true;
 
+	// set selected and visible
     LinkableMapObj::select();
+
 	// Tell parent that I am selected now:
 	BranchObj* po=(BranchObj*)(parObj);
     if (po)	// TODO	    Try to get rid of this cast...
diff -r 717b20c56358 -r c6a8651e6bbc branchpropwindow.cpp
--- a/branchpropwindow.cpp	Wed Mar 21 11:51:38 2007 +0000
+++ b/branchpropwindow.cpp	Sat Mar 31 09:28:27 2007 +0000
@@ -1,5 +1,7 @@
 #include "branchpropwindow.h"
 
+#include <QColorDialog>
+
 #include "frameobj.h"
 
 
@@ -10,39 +12,87 @@
 	branch=NULL;
 	mapEditor=NULL;
 
-	connect ( ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), this, SLOT (frameTypeChanged (int)));
-	connect ( ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), this, SLOT (linkHideUnselectedChanged (int)));
+	ui.tabWidget->setEnabled(false);
+
+	penColor=QColor (Qt::black);
+	brushColor=QColor (Qt::black);
+    QPixmap pix( 16,16);
+    pix.fill (penColor);
+	ui.framePenColorButton->setPixmap (pix);
+	ui.frameBrushColorButton->setPixmap (pix);
+
+	connect ( 
+		ui.framePenColorButton, SIGNAL (clicked()), 
+		this, SLOT (framePenColorClicked()));
+	connect ( 
+		ui.frameBrushColorButton, SIGNAL (clicked()), 
+		this, SLOT (frameBrushColorClicked()));
+	connect ( 
+		ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), 
+		this, SLOT (frameTypeChanged (int)));
+	connect ( 
+		ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), 
+		this, SLOT (linkHideUnselectedChanged (int)));
 }
 
 void BranchPropertyWindow::setBranch (BranchObj *bo)
 {
-	if (!bo) return;
 	branch=bo;
+	if (bo) 
+	{
+		ui.tabWidget->setEnabled (true);
 
-	// Frame
-	switch (branch->getFrameType())
+		// Frame
+		FrameType t=branch->getFrameType();
+		if (t==NoFrame)
+		{
+			ui.frameTypeCombo->setCurrentIndex (0);
+			penColor=Qt::white;
+			brushColor=Qt::white;
+			ui.colorGroupBox->setEnabled (false);
+		} else	
+		{
+			penColor=bo->getFramePenColor();
+			brushColor=bo->getFrameBrushColor();
+			QPixmap pix( 16,16);
+			pix.fill (penColor);
+			ui.frameBrushColorButton->setPixmap (pix);
+			pix.fill (brushColor);
+			ui.frameBrushColorButton->setPixmap (pix);
+			ui.colorGroupBox->setEnabled (true);
+
+			switch (t)
+			{
+				case Rectangle: 
+					ui.frameTypeCombo->setCurrentIndex (1);
+					break;
+				case Ellipse: 
+					ui.frameTypeCombo->setCurrentIndex (2);
+					break;
+				default: 
+					break;
+			}
+		}	
+		
+		// Link
+		if (branch->getHideLinkUnselected())
+			ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
+		else	
+			ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
+	} else
 	{
-		case NoFrame: 
-			ui.frameTypeCombo->setCurrentIndex (0);
-			break;
-		case Rectangle: 
-			ui.frameTypeCombo->setCurrentIndex (1);
-			break;
-		case Ellipse: 
-			ui.frameTypeCombo->setCurrentIndex (2);
-			break;
+		ui.tabWidget->setEnabled (false);
 	}
-	
-	// Link
-	if (branch->getHideLinkUnselected())
-		ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
-	else	
-		ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
 }
 
 void BranchPropertyWindow::setMapEditor (MapEditor *me)
 {
-	if (me) mapEditor=me;
+	mapEditor=me;
+	if (mapEditor) 
+		setBranch (mapEditor->getSelectedBranch() );
+	else
+		ui.tabWidget->setEnabled (false);
+		
 }
 
 void BranchPropertyWindow::frameTypeChanged (int i)
@@ -50,12 +100,38 @@
 	if (mapEditor)
 		switch (i)
 		{
-			case 0: mapEditor->setFrame (NoFrame); break;
-			case 1: mapEditor->setFrame (Rectangle); break;
-			case 2: mapEditor->setFrame (Ellipse); break;
+			case 0: mapEditor->setFrameType (NoFrame); break;
+			case 1: mapEditor->setFrameType (Rectangle); break;
+			case 2: mapEditor->setFrameType (Ellipse); break;
 		}
 }
 
+void BranchPropertyWindow::framePenColorClicked()
+{
+	if (mapEditor) 
+	{	
+		QColor col = QColorDialog::getColor( penColor, this );
+		if ( col.isValid() ) 
+		{
+			penColor=col;
+			mapEditor->setFramePenColor (penColor);
+		}	
+	}
+}
+
+void BranchPropertyWindow::frameBrushColorClicked()
+{
+	if (mapEditor) 
+	{
+		QColor col = QColorDialog::getColor( brushColor, this );
+		if ( col.isValid() ) 
+		{
+			brushColor=col;
+			mapEditor->setFrameBrushColor (brushColor);
+		}	
+	}	
+}
+
 void BranchPropertyWindow::linkHideUnselectedChanged (int i)
 {
 	if (!branch) return;
diff -r 717b20c56358 -r c6a8651e6bbc branchpropwindow.h
--- a/branchpropwindow.h	Wed Mar 21 11:51:38 2007 +0000
+++ b/branchpropwindow.h	Sat Mar 31 09:28:27 2007 +0000
@@ -16,6 +16,8 @@
 
 private slots:
 	void frameTypeChanged (int);
+	void framePenColorClicked ();
+	void frameBrushColorClicked ();
 	void linkHideUnselectedChanged (int);
 
 private:
@@ -23,6 +25,9 @@
 
 	BranchObj *branch;
 	MapEditor *mapEditor;
+
+	QColor penColor;	// FIXME replace this with Palette
+	QColor brushColor;
 };
 
 #endif // 
diff -r 717b20c56358 -r c6a8651e6bbc branchpropwindow.ui
--- a/branchpropwindow.ui	Wed Mar 21 11:51:38 2007 +0000
+++ b/branchpropwindow.ui	Sat Mar 31 09:28:27 2007 +0000
@@ -5,12 +5,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>343</width>
-    <height>208</height>
+    <width>395</width>
+    <height>282</height>
    </rect>
   </property>
   <property name="windowTitle" >
-   <string>Form</string>
+   <string>Branch Property Editor</string>
   </property>
   <layout class="QVBoxLayout" >
    <property name="margin" >
@@ -28,31 +28,133 @@
       <attribute name="title" >
        <string>Frame</string>
       </attribute>
-      <widget class="QComboBox" name="frameTypeCombo" >
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>10</y>
-         <width>301</width>
-         <height>22</height>
-        </rect>
+      <layout class="QVBoxLayout" >
+       <property name="margin" >
+        <number>9</number>
+       </property>
+       <property name="spacing" >
+        <number>6</number>
        </property>
        <item>
-        <property name="text" >
-         <string>No Frame</string>
-        </property>
+        <layout class="QVBoxLayout" >
+         <property name="margin" >
+          <number>0</number>
+         </property>
+         <property name="spacing" >
+          <number>6</number>
+         </property>
+         <item>
+          <widget class="QComboBox" name="frameTypeCombo" >
+           <item>
+            <property name="text" >
+             <string>No Frame</string>
+            </property>
+           </item>
+           <item>
+            <property name="text" >
+             <string>Rectangle</string>
+            </property>
+           </item>
+           <item>
+            <property name="text" >
+             <string>Ellipse</string>
+            </property>
+           </item>
+          </widget>
+         </item>
+         <item>
+          <widget class="QGroupBox" name="colorGroupBox" >
+           <property name="sizePolicy" >
+            <sizepolicy>
+             <hsizetype>7</hsizetype>
+             <vsizetype>5</vsizetype>
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="title" >
+            <string>Colors</string>
+           </property>
+           <layout class="QGridLayout" >
+            <property name="margin" >
+             <number>7</number>
+            </property>
+            <property name="spacing" >
+             <number>6</number>
+            </property>
+            <item row="0" column="0" >
+             <widget class="QPushButton" name="framePenColorButton" >
+              <property name="maximumSize" >
+               <size>
+                <width>20</width>
+                <height>16777215</height>
+               </size>
+              </property>
+              <property name="text" >
+               <string/>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="1" >
+             <widget class="QLabel" name="penColorLabelDesc" >
+              <property name="sizePolicy" >
+               <sizepolicy>
+                <hsizetype>7</hsizetype>
+                <vsizetype>5</vsizetype>
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="text" >
+               <string>Borderline color</string>
+              </property>
+              <property name="buddy" >
+               <cstring>framePenColorButton</cstring>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="0" >
+             <widget class="QPushButton" name="frameBrushColorButton" >
+              <property name="maximumSize" >
+               <size>
+                <width>20</width>
+                <height>16777215</height>
+               </size>
+              </property>
+              <property name="text" >
+               <string/>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="1" >
+             <widget class="QLabel" name="brushColorLabelDesc" >
+              <property name="text" >
+               <string>Background color</string>
+              </property>
+              <property name="buddy" >
+               <cstring>frameBrushColorButton</cstring>
+              </property>
+             </widget>
+            </item>
+            <item row="0" column="2" >
+             <spacer>
+              <property name="orientation" >
+               <enum>Qt::Horizontal</enum>
+              </property>
+              <property name="sizeHint" >
+               <size>
+                <width>40</width>
+                <height>20</height>
+               </size>
+              </property>
+             </spacer>
+            </item>
+           </layout>
+          </widget>
+         </item>
+        </layout>
        </item>
-       <item>
-        <property name="text" >
-         <string>Rectangle</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>Ellipse</string>
-        </property>
-       </item>
-      </widget>
+      </layout>
      </widget>
      <widget class="QWidget" name="tab_2" >
       <attribute name="title" >
@@ -75,6 +177,19 @@
     </widget>
    </item>
    <item>
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>71</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
@@ -89,8 +204,8 @@
        </property>
        <property name="sizeHint" >
         <size>
-         <width>251</width>
-         <height>20</height>
+         <width>41</width>
+         <height>31</height>
         </size>
        </property>
       </spacer>
diff -r 717b20c56358 -r c6a8651e6bbc exports.cpp
--- a/exports.cpp	Wed Mar 21 11:51:38 2007 +0000
+++ b/exports.cpp	Sat Mar 31 09:28:27 2007 +0000
@@ -131,6 +131,7 @@
 	bo=mapCenter->first();
 	while (bo) 
 	{
+		cout << "export bo="<<bo->getHeading().ascii()<<endl;
 		// Make indentstring
 		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
 
@@ -142,6 +143,8 @@
 		} else 	if (bo->getDepth()==1)
 			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
 		else	if (bo->getDepth()==2)
+			ts << (actIndent + " * " + bo->getHeading()+ "\n");
+		else	if (bo->getDepth()==3)
 			ts << (actIndent + " o " + bo->getHeading()+ "\n");
 		else	
 			ts << (actIndent + " - " + bo->getHeading()+ "\n");
diff -r 717b20c56358 -r c6a8651e6bbc selection.cpp
--- a/selection.cpp	Wed Mar 21 11:51:38 2007 +0000
+++ b/selection.cpp	Sat Mar 31 09:28:27 2007 +0000
@@ -1,17 +1,26 @@
 #include "selection.h"
 
+#include "mainwindow.h"
+#include "mapeditor.h"
+
+
+
+extern Main *mainWindow;
 
 Selection::Selection()
 {
+	color= QColor(255,255,0);
 }
 
 Selection::~Selection()
 {
 }
 
-void Selection::setMapCenter(MapCenterObj *mco)
+void Selection::setMapEditor (MapEditor *me)
 {
-	mapCenter=mco;
+	mapEditor=me;
+	mapCenter=me->getMapCenter();
+	scene=mapCenter->getScene();
 }
 
 void Selection::copy(const Selection &other)
@@ -27,11 +36,44 @@
 	lastSelectList.clear();
 }
 
+void Selection::update()
+{
+	QRectF bbox;
+	int w=0;
+	for (int i=0; i< selectList.count(); ++i) 
+	{
+		bbox=selectList.at(i)->getBBox();
+		selboxList.at(i)->setRect (
+			bbox.x()-w,bbox.y()-w, 
+			bbox.width()+2*w, bbox.height()+2*w);
+		selboxList.at(i)->setPen (color);	
+		selboxList.at(i)->setBrush (color);	
+	}	
+}
+
+void Selection::setColor (QColor col)
+{
+	color=col;
+	update();
+}
+
+QColor Selection::getColor ()
+{
+	return color;
+}
+
 bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
 {
 	if (!selectList.isEmpty()) unselect();
 	selectList.append (lmo);
+	QGraphicsRectItem *sb = scene->addRect(
+		QRectF(0,0,0,0), 
+		QPen(color),
+		color);
+	sb->setZValue(Z_SELBOX);
+	selboxList.append (sb);
 	lmo->select();
+	mainWindow->updateSatellites (mapEditor);	// update branchPropWindow...
 	return true;
 }
 
@@ -69,6 +111,9 @@
 			selectList.at(i)->unselect();
 		lastSelectList=selectList;
 		selectList.clear();
+		while (!selboxList.isEmpty() )
+			delete selboxList.takeFirst();
+
 	}	
 }
 
diff -r 717b20c56358 -r c6a8651e6bbc selection.h
--- a/selection.h	Wed Mar 21 11:51:38 2007 +0000
+++ b/selection.h	Sat Mar 31 09:28:27 2007 +0000
@@ -1,8 +1,18 @@
 #ifndef SELECTION_H
 #define SELECTION_H
 
-#include "linkablemapobj.h"
-#include "mapcenterobj.h"
+#include <QString>
+#include <QList>
+#include <QGraphicsScene>
+
+
+class MapEditor;
+class BranchObj;
+class FloatImageObj;
+class MapCenterObj;
+class LinkableMapObj;
+
+
 
 enum SelectionType {Undefined,Branch,MapCenter,FloatImage};
 
@@ -13,8 +23,10 @@
 	~Selection();
 	void copy(const Selection&);
 	void clear();
-	void setMapCenter (MapCenterObj *);
-	
+	void setMapEditor (MapEditor *);
+	void update();
+	void setColor (QColor c);
+	QColor getColor ();
 	bool select (LinkableMapObj*);
 	bool select (const QString &);
 	bool reselect ();
@@ -33,7 +45,12 @@
 	void init();
 	QList <LinkableMapObj*> selectList;
 	QList <LinkableMapObj*> lastSelectList;
+	QList <QGraphicsRectItem*> selboxList;
+	MapEditor *mapEditor;
 	MapCenterObj *mapCenter;
+	QGraphicsScene *scene;
+
+	QColor color;
 };
 #endif