# HG changeset patch
# User insilmaril
# Date 1248263303 0
# Node ID 6cbf3c9cbd2181374813cf7f5d79cce48c912306
# Parent  fe839bdfd10c2372caa4ec75dea9e898914a4fb3
Empty branches are always unscrolled after import, relinking to scrolled branch doesn't open branch, starting DBUS implementation

diff -r fe839bdfd10c -r 6cbf3c9cbd21 branchitem.cpp
--- a/branchitem.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/branchitem.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -154,8 +154,11 @@
     return s;
 }
 
-void BranchItem::updateVisibility()	// FIXME-3	Check if this is needed after all...
+void BranchItem::updateVisibility()	
 {
+	// Needed to hide relinked branch, if parent is scrolled
+	if (lmo)
+		lmo->setVisibility(!((BranchItem*)parentItem)->isScrolled());
 }
 
 void BranchItem::setHeadingColor (QColor color)
diff -r fe839bdfd10c -r 6cbf3c9cbd21 main.cpp
--- a/main.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/main.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -1,4 +1,5 @@
 #include <QApplication>
+#include <QtDBus/QDBusConnection>
 
 #include <iostream>
 using namespace std;
@@ -24,6 +25,8 @@
 QString vymCodeName;
 
 Main *mainWindow;				// used in BranchObj::select()								
+QDBusConnection dbusConnection= QDBusConnection::sessionBus();
+
 QString tmpVymDir;				// All temp files go there, created in mainwindow
 QString clipboardDir;			// Clipboard used in all mapEditors
 QString clipboardFile;			// Clipboard used in all mapEditors
@@ -180,8 +183,6 @@
 	m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
 	m.show();
 	m.fileNew();
-
-
 	// Paint Mainwindow first time
 	qApp->processEvents();
 
diff -r fe839bdfd10c -r 6cbf3c9cbd21 mainwindow.cpp
--- a/mainwindow.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/mainwindow.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -1,6 +1,5 @@
 #include "mainwindow.h"
 
-#include <QtDBus/QtDBus>
 #include <QtGui>
 
 #include <iostream>
@@ -38,6 +37,7 @@
 
 extern TextEditor *textEditor;
 extern Main *mainWindow;
+extern QDBusConnection dbusConnection;
 extern QString tmpVymDir;
 extern QString clipboardDir;
 extern QString clipboardFile;
@@ -229,6 +229,14 @@
 
 	updateGeometry();
 
+	//Initialize DBUS
+	new Adaptor (this);
+    dbusConnection = QDBusConnection::sessionBus();
+    dbusConnection.registerObject("/MainWindow", this);
+    dbusConnection.registerService("org.insilmaril.vym");
+
+
+
 }
 
 Main::~Main()
diff -r fe839bdfd10c -r 6cbf3c9cbd21 mainwindow.h
--- a/mainwindow.h	Tue Jul 07 11:21:27 2009 +0000
+++ b/mainwindow.h	Wed Jul 22 11:48:23 2009 +0000
@@ -2,7 +2,10 @@
 #define MAINWINDOW_H
 
 #include <QMainWindow>
+#include <QtDBus>
 
+
+#include "adaptor.h"
 #include "branchpropwindow.h"
 #include "extrainfodialog.h"
 #include "flag.h"
diff -r fe839bdfd10c -r 6cbf3c9cbd21 scripts/update-bookmarks
--- a/scripts/update-bookmarks	Tue Jul 07 11:21:27 2009 +0000
+++ b/scripts/update-bookmarks	Wed Jul 22 11:48:23 2009 +0000
@@ -7,4 +7,3 @@
 # And now the same using QDBUS in KDE 4:
 
 qdbus| grep konqueror- |  xargs -iOBJECT qdbus OBJECT /KBookmarkManager/konqueror org.kde.KIO.KBookmarkManager.notifyCompleteChange
-#qdbus| grep konqueror- |  xargs -iOBJECT qdbus OBJECT /KBookmarkManager/kfilePlaces org.kde.KIO.KBookmarkManager.notifyCompleteChange
diff -r fe839bdfd10c -r 6cbf3c9cbd21 treeitem.cpp
--- a/treeitem.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/treeitem.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -606,7 +606,7 @@
 }
 
 
-void TreeItem::setHideTmp (HideTmpMode mode)
+void TreeItem::setHideTmp (HideTmpMode mode)  //FIXME-2
 {
 	if (isBranchLikeType() )
 		((BranchItem*)this)->updateVisibility();
diff -r fe839bdfd10c -r 6cbf3c9cbd21 vym.pro
--- a/vym.pro	Tue Jul 07 11:21:27 2009 +0000
+++ b/vym.pro	Wed Jul 22 11:48:23 2009 +0000
@@ -3,13 +3,12 @@
 
 CONFIG	+= qt warn_on release debug
 CONFIG += x86 ppc
-
+CONFIG += qdbus
 
 include (/data/qtanimationframework-2.3-opensource/src/gui-animation.pri)
 include (/data/qtanimationframework-2.3-opensource/src/corelib-animation.pri)
 include (/data/qtanimationframework-2.3-opensource/src/qtanimationframework.pri)
 
-
 TRANSLATIONS += lang/vym_de.ts
 TRANSLATIONS += lang/vym_en.ts
 TRANSLATIONS += lang/vym_es.ts
@@ -33,6 +32,7 @@
 
 HEADERS	+= \
 	aboutdialog.h \
+	adaptor.h \
 	animpoint.h \
 	attribute.h \
 #	attributedelegate.h\
@@ -93,6 +93,7 @@
 
 SOURCES	+= \
 	aboutdialog.cpp \
+	adaptor.cpp \
 	animpoint.cpp \
 	attribute.cpp \
 #	attributedelegate.cpp \
diff -r fe839bdfd10c -r 6cbf3c9cbd21 vymmodel.cpp
--- a/vymmodel.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/vymmodel.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -22,6 +22,8 @@
 
 extern bool debug;
 extern Main *mainWindow;
+extern QDBusConnection dbusConnection;
+
 extern Settings settings;
 extern QString tmpVymDir;
 
@@ -148,6 +150,12 @@
 	// Create MapCenter
 	//  addMapCenter();  FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene
 
+	//Initialize DBUS
+	//new CarAdaptor(car);
+    //connection.registerObject("/Car", car);
+    dbusConnection.registerService("org.insilmaril.vym");
+
+
 }
 
 void VymModel::makeTmpDirectories()
@@ -2169,7 +2177,13 @@
 
 		emit (layoutChanged() );
 		reposition();	// both for moveUp/Down and relinking
-		select (branch);
+		if (dst->isScrolled() )
+		{
+			select (dst);	
+			branch->updateVisibility();
+		}
+		else	
+			select (branch);
 		return true;
 	}
 	return false;
@@ -2316,6 +2330,7 @@
 		beginRemoveRows (ix,0,n);
 		removeRows (0,n+1,ix);
 		endRemoveRows();
+		if (selbi->isScrolled()) selbi->unScroll();
 		emit (layoutChanged() );
 		reposition();
 	}	
diff -r fe839bdfd10c -r 6cbf3c9cbd21 vymmodel.h
--- a/vymmodel.h	Tue Jul 07 11:21:27 2009 +0000
+++ b/vymmodel.h	Wed Jul 22 11:48:23 2009 +0000
@@ -3,6 +3,7 @@
 
 #include <QGraphicsScene>
 #include <QtNetwork>
+#include <QtDBus/QDBusConnection>
 
 #include "file.h"
 #include "imageitem.h"
diff -r fe839bdfd10c -r 6cbf3c9cbd21 xml-vym.cpp
--- a/xml-vym.cpp	Tue Jul 07 11:21:27 2009 +0000
+++ b/xml-vym.cpp	Wed Jul 22 11:48:23 2009 +0000
@@ -145,7 +145,7 @@
 		{
 			// Treat the found mapcenter as a branch 
 			// in an existing map
-			BranchItem *bi=model->getSelectedBranchItem();
+			BranchItem *bi=model->getSelectedBranchItem();	//FIXME-3 selection is no longer used here...
 			if (bi)
 			{
 				lastBranch=bi;
@@ -191,7 +191,7 @@
 	{
 		// This is used in vymparts, which have no mapcenter!
 		isVymPart=true;
-		TreeItem *ti=model->getSelectedItem();
+		TreeItem *ti=model->getSelectedItem();	//FIXME-3 selection is no longer used here...
 		if (!ti)
 		{
 			// If a vym part is _loaded_ (not imported), 
@@ -269,8 +269,9 @@
 	/* Testing
 	cout << "endElement </" <<qPrintable(eName)
 		<<">  state=" <<state 
-		<<"  laststate=" <<laststate
-		<<"  stateStack="<<stateStack.last() 
+	//	<<"  laststate=" <<laststate
+	//	<<"  stateStack="<<stateStack.last() 
+		<<"  selString="<<model->getSelectString().toStdString()
 		<<endl;
 	*/
     switch ( state ) 
@@ -279,14 +280,17 @@
 			mainWindow->removeProgressBar();
 			break;
         case StateMapCenter: 
-			model->selectParent();	// FIXME-3 really needed to "select"? Maybe optimize...
 			model->emitDataHasChanged (lastBranch);
 			lastBranch=(BranchItem*)(lastBranch->parent());
 			lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
             break;
         case StateBranch: 
-			model->selectParent();// FIXME-3 really needed to "select"? Maybe optimize...
+			// Empty branches may not be scrolled 
+			// (happens if bookmarks are imported)
+			if (lastBranch->isScrolled() && lastBranch->branchCount()==0) 
+				lastBranch->unScroll();
 			model->emitDataHasChanged (lastBranch);
+
 			lastBranch=(BranchItem*)(lastBranch->parent());
 			lastBranch->setLastSelectedBranch (0);	// Reset last selected to first child branch
             break;