# HG changeset patch
# User insilmaril
# Date 1241686133 0
# Node ID 7a71a914afdbd6d7e8308cf177ab4ea56a829136
# Parent  d7f79e51b00decfd643122bd27bd6c044a7e2fbd
Started to reanimate flags

diff -r d7f79e51b00d -r 7a71a914afdb branchobj.cpp
--- a/branchobj.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/branchobj.cpp	Thu May 07 08:48:53 2009 +0000
@@ -436,6 +436,7 @@
 	// if (isNoteInEditor) getNoteFromTextEditor();		//FIXME-2 moved to TreeItem
 	
     QString s,a;
+	/*
 	QString scrolledAttr;
 	if ( ((BranchItem*)treeItem)->isScrolled() ) 
 		scrolledAttr=attribut ("scrolled","yes");
@@ -512,6 +513,7 @@
     decIndent();
     s+=endElement   ("branch");
     return s;
+*/	
 }
 
 void BranchObj::addXLink (XLinkObj *xlo)
diff -r d7f79e51b00d -r 7a71a914afdb flagrowobj.cpp
--- a/flagrowobj.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/flagrowobj.cpp	Thu May 07 08:48:53 2009 +0000
@@ -1,8 +1,12 @@
+#include <QToolBar>
+
+#include <iostream>
+using namespace std;
+
 #include "flagrowobj.h"
+
 #include "geometry.h"
 
-#include <QToolBar>
-
 /////////////////////////////////////////////////////////////////
 // FlagRowObj
 /////////////////////////////////////////////////////////////////
@@ -128,7 +132,7 @@
 	return false;
 }
 
-void FlagRowObj::toggle (const QString &foname, bool exclusive)
+void FlagRowObj::toggle (const QString &foname)
 {
 	FlagObj *fo=findFlag (foname);
 	if (fo)
@@ -146,11 +150,12 @@
 		{
 			fo=addFlag (fo);
 			fo->activate();
-			if (exclusive) 
+			/*FIXME-0 move to VM if (exclusive) 
 			{
 				deactivateGroup (fo);
 				updateToolbar();
 			}
+			*/
 		} else
 			qWarning ("FlagRowObj ("+name+")::toggle ("+foname+")  failed - could not find it in parentRow");
 	}	
@@ -160,6 +165,7 @@
 
 void FlagRowObj::activate (const QString &foname)
 {
+	cout << "FRO::activate  "<<foname.toStdString()<<endl;
 	// Note: "activate" is also called during loading of a map
 	// Here we do not check for exclusive flags!
 	FlagObj *fo=findFlag (foname);
@@ -223,7 +229,7 @@
 	}
 }
 
-void FlagRowObj::deactivateGroup (FlagObj *keepfo)
+void FlagRowObj::deactivateGroup (FlagObj *keepfo)	//FIXME-0 move to VM
 {
 	// deactivate all flags in keepof, but keep keepfo [sic!]
 	if (keepfo)
diff -r d7f79e51b00d -r 7a71a914afdb flagrowobj.h
--- a/flagrowobj.h	Wed May 06 11:08:38 2009 +0000
+++ b/flagrowobj.h	Thu May 07 08:48:53 2009 +0000
@@ -3,7 +3,7 @@
 
 #include <QMainWindow>
 
-#include "mapobj.h"
+//#include "mapobj.h"
 #include "flagobj.h"
 
 /*! \brief A collection of flags (FlagObj). 
@@ -12,7 +12,7 @@
    A toolbar can be created from the flags in this row.
  */
 
-class FlagRowObj:public MapObj {
+class FlagRowObj:public MapObj {	// FIXME-0 move pixmaps to mainwindow or model in the end...
 public:
     FlagRowObj ();
     FlagRowObj (QGraphicsScene *);
@@ -28,19 +28,19 @@
     virtual void calcBBoxSize();
 	virtual QString getFlagName (const QPointF &p);	// Find flag by position
 	bool isActive(const QString&);
-	void toggle (const QString&,bool);
+	void toggle (const QString &name);
 	void activate(const QString&);
 	void deactivate(const QString&);
 	void deactivateAll();
-	void deactivateGroup(FlagObj *);
-	void setToolBar (QToolBar *);
+	void deactivateGroup(FlagObj *);	//FIXME-0
+	void setToolBar (QToolBar *);		//FIXME-0
 	void setEnabled (bool);
 	void setShowFlags (bool);
 	void resetUsedCounter();
 	QString saveToDir (const QString &,const QString &,bool);
 	void setName (const QString&);			// prefix for exporting flags to dir
-	void makeToolbar (QMainWindow*, const QString &);	// Create Toolbar buttons
-	void updateToolbar();					// Update Toolbar buttons	
+	void makeToolbar (QMainWindow*, const QString &);	// Create Toolbar buttons FIXME-0
+	void updateToolbar();					// Update Toolbar buttons	FIXME-0
 private:	
 	FlagRowObj* parentRow;					// look for flags in this row
 	FlagObj* findFlag (const QString&);
diff -r d7f79e51b00d -r 7a71a914afdb mainwindow.cpp
--- a/mainwindow.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/mainwindow.cpp	Thu May 07 08:48:53 2009 +0000
@@ -3815,8 +3815,8 @@
 
 void Main::standardFlagChanged()
 {
-	if (currentMapEditor())
-		currentMapEditor()->toggleStandardFlag(sender()->name());
+	if (currentModel())
+		currentModel()->toggleStandardFlag(sender()->name());
 }
 
 void Main::testFunction1()
diff -r d7f79e51b00d -r 7a71a914afdb mapcenterobj.cpp
--- a/mapcenterobj.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/mapcenterobj.cpp	Thu May 07 08:48:53 2009 +0000
@@ -112,6 +112,7 @@
 {
     QString s,a;
 
+/*
 	// save area, if not scrolled
 	QString areaAttr=
 		attribut("x1",QString().setNum(absPos.x()-offset.x())) +
@@ -120,14 +121,14 @@
 		attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
 	
 	// Providing an ID for a branch makes export to XHTML easier
-	/* FIXME-3
+	// FIXME-3
 	QString idAttr;
 	if (treeItem->xlinkCount()>0)
 		idAttr=attribut ("id",mapEditor->getModel()->getSelectString(this)); //TODO directly access model
 
 	else
 		idAttr="";
-	*/	
+	
 
 	QString linkAttr=getLinkAttr();
 
@@ -173,6 +174,7 @@
 
     decIndent();
     s+=endElement   ("mapcenter");
+	*/
     return s;
 }
 
diff -r d7f79e51b00d -r 7a71a914afdb mapeditor.cpp
--- a/mapeditor.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/mapeditor.cpp	Thu May 07 08:48:53 2009 +0000
@@ -250,35 +250,6 @@
 	setRenderHint(QPainter::SmoothPixmapTransform,b);
 }
 
-void MapEditor::toggleStandardFlag(QString f)
-{
-	BranchItem *bi=model->getSelectedBranchItem();
-	if (bi) 
-	{
-		QString u,r;
-		/* FIXME-2 isSetStandardFlag needs to be ported
-		if (bi->isSetStandardFlag(f))
-		{
-			r="unsetFlag";
-			u="setFlag";
-		}	
-		else
-		{
-			u="unsetFlag";
-			r="setFlag";
-		}	
-		*/
-		model->saveState(
-			bi,
-			QString("%1 (\"%2\")").arg(u).arg(f), 
-			bi,
-			QString("%1 (\"%2\")").arg(r).arg(f),
-			QString("Toggling standard flag \"%1\" of %2").arg(f).arg(model->getObjectName(bi)));
-		// FIXME-2 bi->toggleStandardFlag (f,mainWindow->useFlagGroups());
-		model->updateSelection();	// geometry has changed
-	}
-}
-
 TreeItem* MapEditor::findMapItem (QPointF p,TreeItem *exclude)
 {
 	// Start with mapcenter, no images allowed at rootItem
diff -r d7f79e51b00d -r 7a71a914afdb mapeditor.h
--- a/mapeditor.h	Wed May 06 11:08:38 2009 +0000
+++ b/mapeditor.h	Thu May 07 08:48:53 2009 +0000
@@ -26,7 +26,6 @@
 	void setAntiAlias (bool);	//!< Set or unset antialiasing
 	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
 public:
-	void toggleStandardFlag(QString);	//FIXME-2 still needed?
 	TreeItem *findMapItem (QPointF p,TreeItem *exclude);	//! find item in map at position p. Ignore item exclude 
 
 	AttributeTable* attributeTable();
diff -r d7f79e51b00d -r 7a71a914afdb ornamentedobj.cpp
--- a/ornamentedobj.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/ornamentedobj.cpp	Thu May 07 08:48:53 2009 +0000
@@ -189,13 +189,13 @@
 	ox=leftPad + d;
 	oy=topPad + d;
 	
-	//FIXME-2 systemFlags-> move (ox +x , oy + y );
+	systemFlags-> move (ox +x , oy + y );
 
 	// vertical align heading to bottom
     heading->move (ox + x + systemFlags->getBBox().width(),
 				   oy + y + ornamentsBBox.height() - heading->getHeight() 
 					);
-	//FIXME-2 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
+	standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
 
 	ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
 	clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
@@ -318,36 +318,36 @@
 	forceReposition();
 }
 
-void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
+void OrnamentedObj::toggleStandardFlag(const QString &name)
 {
-	standardFlags->toggle(f,exclusive);
+	standardFlags->toggle(name);
 	calcBBoxSize();
 	positionBBox();
 	move (absPos.x(), absPos.y() );
 	forceReposition();
 }
 
-void OrnamentedObj::activateStandardFlag(QString f)
+void OrnamentedObj::activateStandardFlag(const QString &name)
 {
-	standardFlags->activate(f);
+	standardFlags->activate(name);
 	calcBBoxSize();
 	positionBBox();
 	move (absPos.x(), absPos.y() );
 	forceReposition();
 }
 
-void OrnamentedObj::deactivateStandardFlag(QString f)
+void OrnamentedObj::deactivateStandardFlag(const QString &name)
 {
-	standardFlags->deactivate(f);
+	standardFlags->deactivate(name);
 	calcBBoxSize();
 	positionBBox();
 	move (absPos.x(), absPos.y() );
 	forceReposition();
 }
 
-bool OrnamentedObj::isSetStandardFlag (QString f)
+bool OrnamentedObj::isSetStandardFlag (const QString &name)
 {
-	return standardFlags->isActive(f);
+	return standardFlags->isActive(name);
 }
 
 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
@@ -355,9 +355,9 @@
 	return systemFlags->getFlagName(p);	
 }
 
-bool OrnamentedObj::isActiveFlag (const QString & fname)
+bool OrnamentedObj::isActiveFlag (const QString &name)
 {
-	if (standardFlags->isActive (fname) ) return true;
+	if (standardFlags->isActive (name) ) return true;
 	return false;
 }
 
diff -r d7f79e51b00d -r 7a71a914afdb ornamentedobj.h
--- a/ornamentedobj.h	Wed May 06 11:08:38 2009 +0000
+++ b/ornamentedobj.h	Thu May 07 08:48:53 2009 +0000
@@ -63,10 +63,10 @@
 	virtual QList <Attribute> getAttributes ();
 
 	virtual void clearStandardFlags();
-	virtual void toggleStandardFlag(QString, bool exclusive=false);
-	virtual void activateStandardFlag(QString);
-	virtual void deactivateStandardFlag(QString);
-	virtual bool isSetStandardFlag(QString);
+	virtual void toggleStandardFlag(const QString &name);
+	virtual void activateStandardFlag(const QString &name);
+	virtual void deactivateStandardFlag(const QString &name);
+	virtual bool isSetStandardFlag(const QString &name);
 	virtual QString getSystemFlagName (const QPointF &p);
 	virtual bool isActiveFlag(const QString&);	// check if flag is set
 	virtual void updateSystemFlags();
diff -r d7f79e51b00d -r 7a71a914afdb treeitem.cpp
--- a/treeitem.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/treeitem.cpp	Thu May 07 08:48:53 2009 +0000
@@ -218,6 +218,35 @@
 		default: return -1;
 	}
 }
+void TreeItem::setType(const Type t)
+{
+	type=t;
+	itemData[1]=getTypeName();
+}
+
+TreeItem::Type TreeItem::getType()
+{
+	return type;
+}
+
+bool TreeItem::isBranchLikeType() const
+{
+	if (type==Branch ||type==MapCenter) return true;
+	return false;
+}
+
+QString TreeItem::getTypeName()
+{
+	switch (type)
+	{
+		case Undefined: return QString ("Undefined");
+		case MapCenter: return QString ("MapCenter");
+		case Branch: return QString ("Branch");
+		case Image: return QString ("Image");
+		default: return QString ("TreeItem::getTypeName no typename defined?!");
+	}
+}
+
 
 QVariant TreeItem::data(int column) const
 {
@@ -290,33 +319,35 @@
     return note.getNoteOpenDoc();
 }
 
-void TreeItem::setType(const Type t)
+void TreeItem::activateStandardFlag (const QString &name)
 {
-	type=t;
-	itemData[1]=getTypeName();
+	cout << "TI::activateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
+	cout << "   lmo="<<lmo<< "  "<<isBranchLikeType()<<endl;
+	standardFlags.activate (name);
+	if (lmo &&isBranchLikeType() ) 
+		((BranchObj*)lmo)->activateStandardFlag (name);
 }
 
-TreeItem::Type TreeItem::getType()
+void TreeItem::deactivateStandardFlag (const QString &name)
 {
-	return type;
+	cout << "TI::deactivateStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
+	standardFlags.deactivate (name);
+	if (lmo &&isBranchLikeType() ) 
+		((BranchObj*)lmo)->deactivateStandardFlag (name);
 }
 
-bool TreeItem::isBranchLikeType() const
+void TreeItem::toggleStandardFlag(const QString &name)
 {
-	if (type==Branch ||type==MapCenter) return true;
-	return false;
+	cout << "TI::toggleStandardFlag "<<name.toStdString()<<" for item "<<getHeadingStd()<<endl;
+	if (standardFlags.isActive (name))
+		deactivateStandardFlag (name);
+	else	
+		activateStandardFlag (name);
 }
 
-QString TreeItem::getTypeName()
+bool TreeItem::isActiveStandardFlag (const QString &name)
 {
-	switch (type)
-	{
-		case Undefined: return QString ("Undefined");
-		case MapCenter: return QString ("MapCenter");
-		case Branch: return QString ("Branch");
-		case Image: return QString ("Image");
-		default: return QString ("TreeItem::getTypeName no typename defined?!");
-	}
+	return standardFlags.isActive (name);
 }
 
 void TreeItem::setID (const QString &s)
diff -r d7f79e51b00d -r 7a71a914afdb treeitem.h
--- a/treeitem.h	Wed May 06 11:08:38 2009 +0000
+++ b/treeitem.h	Thu May 07 08:48:53 2009 +0000
@@ -5,6 +5,7 @@
 #include <QList>
 #include <QVariant>
 
+#include "flagrow.h"
 #include "mapitem.h"
 #include "noteobj.h"
 #include "xmlobj.h"
@@ -53,7 +54,15 @@
 	virtual int num();					//! Return number of item by type
 	virtual int num (TreeItem *item);	//! Return number of item by type
 
-	// Accessing data
+protected:
+	Type type;
+public:	
+	virtual void setType (const Type t);
+	virtual Type getType ();
+	virtual bool isBranchLikeType() const;
+	virtual QString getTypeName ();
+
+// Accessing data
     virtual QVariant data(int column) const;
 
 protected:
@@ -77,12 +86,14 @@
     virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
 
 protected:
-	Type type;
+	FlagRow standardFlags;
 public:	
-	virtual void setType (const Type t);
-	virtual Type getType ();
-	virtual bool isBranchLikeType() const;
-	virtual QString getTypeName ();
+	virtual void activateStandardFlag(const QString &flag);
+	virtual void deactivateStandardFlag(const QString &flag);
+	virtual void toggleStandardFlag(const QString &flag);
+	virtual bool isActiveStandardFlag (const QString &flag);
+
+
 
 protected:
 	QString objID;					//! id set during load/save currently used for xLinks
diff -r d7f79e51b00d -r 7a71a914afdb vym.pro
--- a/vym.pro	Wed May 06 11:08:38 2009 +0000
+++ b/vym.pro	Thu May 07 08:48:53 2009 +0000
@@ -44,6 +44,7 @@
 	findwindow.h \
 	flagobj.h \
 	flagrowobj.h \
+	flagrow.h \
 	floatimageobj.h \
 	floatobj.h \
 	frameobj.h \
@@ -102,6 +103,7 @@
 	file.cpp \
 	findwindow.cpp \
 	flagobj.cpp \
+	flagrow.cpp \
 	flagrowobj.cpp \
 	floatimageobj.cpp \
 	floatobj.cpp \
diff -r d7f79e51b00d -r 7a71a914afdb vymmodel.cpp
--- a/vymmodel.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/vymmodel.cpp	Thu May 07 08:48:53 2009 +0000
@@ -2140,7 +2140,6 @@
 			parbi=selbi;
 			parix=index(parbi);
 			n=parbi->childCount();
-			cout <<"n="<<n<<endl;
 			beginInsertRows (parix,n,n+1);	
 			parbi->appendChild (newbi);	
 			endInsertRows ();
@@ -2474,6 +2473,34 @@
 	emit (expandAll() );
 }
 
+void VymModel::toggleStandardFlag (const QString &name)
+{
+	cout << "VM::toggleStandardFlag "<<name.toStdString()<<endl;
+	BranchItem *bi=getSelectedBranchItem();
+	if (bi) 
+	{
+		QString u,r;
+		if (bi->isActiveStandardFlag(name))
+		{
+			r="unsetFlag";
+			u="setFlag";
+		}	
+		else
+		{
+			u="unsetFlag";
+			r="setFlag";
+		}	
+		saveState(
+			bi,
+			QString("%1 (\"%2\")").arg(u).arg(name), 
+			bi,
+			QString("%1 (\"%2\")").arg(r).arg(name),
+			QString("Toggling standard flag \"%1\" of %2").arg(name).arg(getObjectName(bi)));
+		bi->toggleStandardFlag (name); //FIXME-0,mainWindow->useFlagGroups());
+		//FIXME-0 model->updateSelection();	// geometry has changed
+	}
+}
+
 void VymModel::addFloatImage (const QPixmap &img) //FIXME-2
 {
 /*
@@ -4858,7 +4885,6 @@
 				// left of center
 				if (type == TreeItem::Branch )
 				{
-					cout << "VM::selLeft\n";
 					selectLastSelectedBranch();
 					return;
 				}
@@ -4899,7 +4925,6 @@
 				if (type == TreeItem::Branch ||
 					type == TreeItem::Image)
 				{
-					cout << "VM::selRight\n";
 					QModelIndex ix=index(selbi->parent());
 					selModel->select (ix,QItemSelectionModel::ClearAndSelect  );
 				}
diff -r d7f79e51b00d -r 7a71a914afdb vymmodel.h
--- a/vymmodel.h	Wed May 06 11:08:38 2009 +0000
+++ b/vymmodel.h	Thu May 07 08:48:53 2009 +0000
@@ -328,12 +328,12 @@
 public:	
     void toggleScroll();
     void unscrollChildren();
-
 	void emitExpandAll();
 signals:	
 	void expandAll();
 
 public:	
+	void toggleStandardFlag (const QString &name);
     void addFloatImage(const QPixmap &img);
 
     void colorBranch(QColor);
diff -r d7f79e51b00d -r 7a71a914afdb xml-vym.cpp
--- a/xml-vym.cpp	Wed May 06 11:08:38 2009 +0000
+++ b/xml-vym.cpp	Thu May 07 08:48:53 2009 +0000
@@ -326,7 +326,7 @@
 			break;
         case StateBranch: break;
         case StateStandardFlag: 
-            //FIXME-2 lastBranchItem->activateStandardFlag(ch_simplified); 
+            lastBranchItem->activateStandardFlag(ch_simplified); 
             break;
         case StateFloatImage: break;
         case StateHtmlNote: break;