# HG changeset patch
# User insilmaril
# Date 1269970239 0
# Node ID bec08247247190b7b7f7caef2d36542f14426417
# Parent  46553c106c522923db17d107c2070f52b1be686b
Much improved results in FindResultsWidget

diff -r 46553c106c52 -r bec082472471 findresultitem.cpp
--- a/findresultitem.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultitem.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -9,7 +9,9 @@
     parentItem = parent;
     itemData = data;
 	orgID=-1;
+	orgIndex=-1;
 	orgModel=NULL;
+	itemData.append(QVariant("empty"));
 }
 
 FindResultItem::~FindResultItem()
@@ -53,7 +55,6 @@
     return 0;
 }
 
-
 bool FindResultItem::insertChildren(int position, int count, int columns)
 {
     if (position < 0 || position > childItems.size())
@@ -127,11 +128,21 @@
 	orgID=ti->getID();
 }
 
-uint FindResultItem::getOrgID()
+int FindResultItem::getOriginalID()
 {
 	return orgID;
 }
 
+void FindResultItem::setOriginalIndex(int i)
+{
+	orgIndex=i;
+}
+
+int FindResultItem::getOriginalIndex()
+{
+	return orgIndex;
+}
+
 VymModel* FindResultItem::getOrgModel()
 {
 	return orgModel;
diff -r 46553c106c52 -r bec082472471 findresultitem.h
--- a/findresultitem.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultitem.h	Tue Mar 30 17:30:39 2010 +0000
@@ -27,7 +27,9 @@
     int childNumber() const;
     bool setData(int column, const QVariant &value);
 	void setOriginal (TreeItem *ti);
-	uint getOrgID();
+	int getOriginalID();
+	void setOriginalIndex(int i);
+	int getOriginalIndex ();
 	VymModel* getOrgModel();
 
 private:
@@ -35,7 +37,8 @@
     QVector<QVariant> itemData;
     FindResultItem *parentItem;
 
-	uint orgID;
+	int orgID;
+	int orgIndex;
 	VymModel *orgModel;
 };
 
diff -r 46553c106c52 -r bec082472471 findresultmodel.cpp
--- a/findresultmodel.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultmodel.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -180,7 +180,7 @@
     return result;
 }
 
-FindResultItem *FindResultModel::getItem(const QModelIndex &index) const
+FindResultItem* FindResultModel::getItem(const QModelIndex &index) const
 {
     if (index.isValid()) {
         FindResultItem *item = static_cast<FindResultItem*>(index.internalPointer());
@@ -189,58 +189,80 @@
     return rootItem;
 }
 
-FindResultItem *FindResultModel::findTreeItem(TreeItem *ti)
+FindResultItem *FindResultModel::findTreeItem(TreeItem *)
 {
+	return NULL;	// FIXME-3 not used so far
 }
 
-void FindResultModel::addItem (TreeItem *ti)
+FindResultItem*  FindResultModel::addItem (TreeItem *ti)
 {
+	FindResultItem *ni=NULL;
 	if (ti)
 	{
-		QModelIndex ix (index (rootItem));
+		QModelIndex parix (index (rootItem));
 		
-		if (!insertRow(ix.row()+1, ix.parent()))
-			return;
+		emit (layoutAboutToBeChanged() );
 
-		for (int column = 0; column < columnCount(ix.parent()); ++column) 
+		int n=rowCount (parix);
+		beginInsertRows (parix,n,n);
+		if (rootItem->insertChildren (n,1,0) )
 		{
-			QModelIndex child = index(ix.row()+1, column, ix.parent());
-			setData(child, QVariant(ti->getHeading()), Qt::EditRole);
-			getItem(child)->setOriginal (ti);
+			QModelIndex ix=index(n,0,QModelIndex());
+			setData (ix,QVariant(ti->getHeading()),Qt::EditRole);
+			ni=getItem(ix);
+			ni->setOriginal (ti);
 		}
+		endInsertRows ();
+
+		emit (layoutChanged() );
 	}
+	return ni;
 }
 
-void FindResultModel::addItem (const QString &s)
+FindResultItem*  FindResultModel::addSubItem (FindResultItem *parent,const QString &s, TreeItem *pi, int i)
 {
-	if (!s.isEmpty())
+	FindResultItem *ni=NULL;
+	if (pi && parent)
 	{
-		QModelIndex ix ( index (rootItem));
+		QModelIndex parix ( index (parent));
 		
-		if (!insertRow(ix.row()+1, ix.parent()))
-			return;
+		emit (layoutAboutToBeChanged() );
 
-		for (int column = 0; column < columnCount(ix.parent()); ++column) {
-			QModelIndex child = index(ix.row()+1, column, ix.parent());
-			setData(child, QVariant(s), Qt::EditRole);
+		int n=rowCount (parix);
+		beginInsertRows (parix,n,n);
+
+		QModelIndex ix;
+		if (parent->insertChildren (n,1,0))
+		{
+			ix=index(n,0,parix);
+			setData (ix,QVariant(s),Qt::EditRole);
+			ni=getItem(ix);
+			ni->setOriginal (pi);
+			ni->setOriginalIndex (i);
 		}
+		endInsertRows ();
+		emit (layoutChanged() );
 	}
+	return ni;
 }
 
-void FindResultModel::addSubItem (TreeItem *parent,const QString &s, TreeItem *ti, int i)
+void FindResultModel::setSearchString( const QString &s)
 {
-	if (ti)
-	{
-		QModelIndex ix ( index (rootItem));
-		
-		if (!insertRow(ix.row()+1, ix.parent()))
-			return;
-
-		for (int column = 0; column < columnCount(ix.parent()); ++column) {
-			QModelIndex child = index(ix.row()+1, column, ix.parent());
-			setData(child, QVariant("Note: "+ti->getHeading()), Qt::EditRole);
-			getItem(child)->setOriginal (ti);
-		}
-	}
+	searchString=s;
 }
 
+QString FindResultModel::getSearchString()
+{
+	return searchString;
+}
+
+void FindResultModel::setSearchFlags( QTextDocument::FindFlags f)
+{
+	searchFlags=f;
+}
+
+QTextDocument::FindFlags FindResultModel::getSearchFlags()
+{
+	return searchFlags;
+}
+
diff -r 46553c106c52 -r bec082472471 findresultmodel.h
--- a/findresultmodel.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultmodel.h	Tue Mar 30 17:30:39 2010 +0000
@@ -3,6 +3,7 @@
 
 #include <QAbstractItemModel>
 #include <QModelIndex>
+#include <QTextDocument>
 #include <QVariant>
 
 class FindResultItem;
@@ -44,16 +45,23 @@
     bool removeRows(int position, int rows,
                     const QModelIndex &parent = QModelIndex());
 
-    FindResultItem *getItem(const QModelIndex &index) const;
-	FindResultItem *findTreeItem (TreeItem *ti);
+    FindResultItem* getItem(const QModelIndex &index) const;
+	FindResultItem* findTreeItem (TreeItem *ti);
 
-	void addItem (TreeItem *ti);
-	void addItem (const QString &s);
-	void addSubItem (TreeItem *parent,const QString &s, TreeItem *ti, int i);
+	FindResultItem* addItem (TreeItem *ti);
+	FindResultItem* addSubItem (FindResultItem *parent,const QString &s, TreeItem *pi, int i);
+
+	void setSearchString( const QString &s);
+	QString getSearchString();
+	void setSearchFlags( QTextDocument::FindFlags f);
+	QTextDocument::FindFlags getSearchFlags();
 
 private:
 
     FindResultItem *rootItem;
+
+	QString searchString;
+	QTextDocument::FindFlags searchFlags;
 };
 
 #endif
diff -r 46553c106c52 -r bec082472471 findresultwidget.cpp
--- a/findresultwidget.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultwidget.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -39,6 +39,8 @@
 	// Selection
 	connect (view->selectionModel(),SIGNAL (selectionChanged (QItemSelection,QItemSelection)),
 		this, SLOT (updateSelection (QItemSelection,QItemSelection)));
+
+	connect (resultsModel, SIGNAL(layoutChanged() ), view, SLOT (expandAll() ));	
 }
 
 void FindResultWidget::addItem (TreeItem *ti)
@@ -87,14 +89,6 @@
 	return resultsModel;
 }
 
-void FindResultWidget::addResult (const QString &category, TreeItem *ti)
-{
-	if (!category.isEmpty())
-		addItem (category);
-	else	
-		addItem (model->getSelectedItem());
-}
-
 void FindResultWidget::popup()
 {
 	show();
@@ -112,11 +106,15 @@
 	foreach (ix,newsel.indexes() )
 	{
 		FindResultItem *fri= static_cast<FindResultItem*>(ix.internalPointer());
-		if (fri->getOrgModel() && fri->getOrgID()>0)
+		if (fri->getOrgModel() && fri->getOriginalID()>0)
 		{
-			TreeItem *ti=fri->getOrgModel()->findID(fri->getOrgID() );
+			TreeItem *ti=fri->getOrgModel()->findID(fri->getOriginalID() );
 			if (ti)
+			{
 				fri->getOrgModel()->select (ti);
+				int i=fri->getOriginalIndex();
+				if (i>=0) emit (noteSelected (resultsModel->getSearchString(),i));
+			}	
 		}
 	}
 }
diff -r 46553c106c52 -r bec082472471 findresultwidget.h
--- a/findresultwidget.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/findresultwidget.h	Tue Mar 30 17:30:39 2010 +0000
@@ -20,7 +20,6 @@
 	FindResultModel* getResultModel();
 	void addItem (TreeItem *ti);
 	void addItem (const QString &s);
-	void addResult (const QString &category, TreeItem *ti);
 
 public slots:	
 	void popup();
@@ -29,6 +28,7 @@
 
 signals:
 	void hideFindResultWidget();
+	void noteSelected (QString , int );
 
 private:
 	VymModel *model;
diff -r 46553c106c52 -r bec082472471 main.cpp
--- a/main.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/main.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -72,13 +72,15 @@
 
 	// Reading and initializing options commandline options
 	options.add ("debug", Option::Switch, "d", "debug");
-	options.add ("version", Option::Switch, "v","version");
+	options.add ("help", Option::Switch, "h", "help");
 	options.add ("local", Option::Switch, "l", "local");
 	options.add ("name", Option::String, "n", "name");
-	options.add ("help", Option::Switch, "h", "help");
 	options.add ("quit", Option::Switch, "q", "quit");
 	options.add ("run", Option::String, "r", "run");
+	options.add ("shortcuts", Option::Switch, "s", "shortcuts");
+	options.add ("shortcutsLaTeX", Option::Switch, "sl", "shortcutsLaTeX");
 	options.add ("test", Option::String, "t", "test");
+	options.add ("version", Option::Switch, "v","version");
 	options.setHelpText (
 		"VYM - View Your Mind\n"
 		"--------------------\n\n"
diff -r 46553c106c52 -r bec082472471 mainwindow.cpp
--- a/mainwindow.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/mainwindow.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -23,6 +23,7 @@
 #include "settings.h"
 #include "shortcuts.h"
 #include "texteditor.h"
+#include "treeeditor.h"
 #include "warningdialog.h"
 #include "xlinkitem.h"
 
@@ -138,6 +139,8 @@
 	dw->setObjectName ("FindResultWidget");
 	dw->hide();	
 	addDockWidget (Qt::RightDockWidgetArea,dw);
+	connect (findResultWidget, SIGNAL (noteSelected (QString, int)),this, SLOT (selectInNoteEditor (QString, int)));
+
 
 	// Satellite windows //////////////////////////////////////////
 	// history window
@@ -234,7 +237,8 @@
 	setupSettingsActions();
 	setupContextMenus();
 	setupMacros();
-	if (debug) switchboard.print();
+	if (options.isOn("shortcuts")) switchboard.print();
+	if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
 
 	if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
 	setupHelpActions();
@@ -628,9 +632,12 @@
 
 	// Shortcut to add attribute
 	a= new QAction(tr( "Add attribute" ), this);
-	a->setShortcut ( Qt::Key_Q);	
-	a->setShortcutContext (Qt::WindowShortcut);
-	switchboard.addConnection(a,tr("Edit","Shortcut group"));
+	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
+	{
+		a->setShortcut ( Qt::Key_Q);	
+		a->setShortcutContext (Qt::WindowShortcut);
+		switchboard.addConnection(a,tr("Edit","Shortcut group"));
+	}
 	addAction (a);
 	connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
 	actionAddAttribute= a;
@@ -719,7 +726,7 @@
 
 	a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
 	a->setStatusTip ( tr( "Move branch up" ) );
-	a->setShortcut (Qt::Key_PageUp );				// Move branch up
+	a->setShortcut (Qt::Key_PageUp );				// Move branch up	//FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
 	a->setEnabled (false);
 	switchboard.addConnection(a,tr("Edit","Shortcut group"));
 	tb->addAction (a);
@@ -1224,7 +1231,8 @@
 	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
 	actionViewToggleNoteEditor=a;
 
-	a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
+	// Original icon is "category" from KDE
+	a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
 	a->setStatusTip ( tr( "Show tree editor" ));
 	a->setShortcut ( Qt::CTRL + Qt::Key_T );	// Toggle Tree Editor // FIXME-3 originally: color subtree
 	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
@@ -2730,13 +2738,12 @@
 void Main::editFindNext(QString s)  
 {
 	Qt::CaseSensitivity cs=Qt::CaseInsensitive;
-	QTextCursor cursor;
 	VymModel *m=currentModel();
 	if (m) 
 	{
 		m->findAll (findResultWidget->getResultModel(),s,cs);
 
-		BranchItem *bi=m->findText(s, cs,cursor);
+		BranchItem *bi=m->findText(s, cs);
 		if (bi)
 		{
 			findWidget->setStatus (FindWidget::Success);
@@ -3636,6 +3643,13 @@
 	textEditor->setNote (ti->getNoteObj() );
 }
 
+void Main::selectInNoteEditor(QString s,int i)
+{
+	// TreeItem is already selected at this time, therefor
+	// the note is already in the editor
+	textEditor->findText (s,0,i);
+}
+
 void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
 {
 	branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
@@ -3681,6 +3695,10 @@
 	actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
 	actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
 	actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
+	if ( tabWidget->currentPage())
+		actionViewToggleTreeEditor->setChecked (
+			vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
+		);
 
 	VymModel  *m =currentModel();
 	if (m) 
diff -r 46553c106c52 -r bec082472471 mainwindow.h
--- a/mainwindow.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/mainwindow.h	Tue Mar 30 17:30:39 2010 +0000
@@ -227,6 +227,7 @@
 	void windowToggleSmoothPixmap();
 	void updateNoteFlag();
 	void updateNoteEditor (QModelIndex index);
+	void selectInNoteEditor (QString s, int i);
 	void changeSelection (VymModel *model,const QItemSelection &newSel, const QItemSelection &delSel);
 
 	void updateActions();
diff -r 46553c106c52 -r bec082472471 mapeditor.cpp
--- a/mapeditor.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/mapeditor.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -985,8 +985,10 @@
 
 void MapEditor::keyPressEvent(QKeyEvent* e)
 {
-	//qDebug()<<"ME::keyPressed";
-	//return;
+	if (e->key()==Qt::Key_PageUp || e->key()==Qt::Key_PageDown)
+		// Ignore PageUP/Down to avoid scrolling with keys
+		return;
+
 	if (e->modifiers() & Qt::ControlModifier)
 	{
 		switch (mainWindow->getModMode())
diff -r 46553c106c52 -r bec082472471 noteobj.cpp
--- a/noteobj.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/noteobj.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -1,9 +1,7 @@
-#include <qfile.h>
-#include <qtextstream.h>
-#include <qmessagebox.h>
-#include <qregexp.h>
+#include "noteobj.h"
 
-#include "noteobj.h"
+#include <QRegExp>
+#include <QDebug>
 
 /////////////////////////////////////////////////////////////////
 // NoteObj
@@ -51,12 +49,12 @@
 
 QString NoteObj::getNoteASCII()
 {
-	return getNoteASCII (QString(""),80);
+	return getNoteASCII ("",80);
 }
 
-QString NoteObj::getNoteASCII(const QString &indent, const int &width)
+QString NoteObj::getNoteASCII(QString indent, const int &width)
 {
-	// FIXME-3 make use of width
+	if (note.isEmpty()) return note;
 	QString r=note;
 
 	// Remove all <style...> ...</style>
@@ -95,7 +93,7 @@
 	r.replace (rx,indent);
 	r=indent + r;	// Don't forget first line
 
-/* FIXME-5	wrap text at width
+/* FIXME-3	wrap text at width
 	if (fonthint !="fixed")
 	{
 	}
diff -r 46553c106c52 -r bec082472471 noteobj.h
--- a/noteobj.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/noteobj.h	Tue Mar 30 17:30:39 2010 +0000
@@ -21,7 +21,7 @@
 	void setNote (const QString&);
 	QString getNote() const;
 	QString getNoteASCII();
-	QString getNoteASCII(const QString &indent, const int &width=0);
+	QString getNoteASCII(QString igdent, const int &width=0);
 	QString getNoteOpenDoc();
 	void setFontHint (const QString&);
 	QString getFontHint () const;
diff -r 46553c106c52 -r bec082472471 shortcuts.cpp
--- a/shortcuts.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/shortcuts.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -41,3 +41,19 @@
 		cout <<endl;
 	}
 }
+
+void Switchboard::printLaTeX ()
+{
+	QString g;
+	foreach (g,actions.uniqueKeys())
+	{
+		cout <<"Group: "<<g.toStdString()<<endl;
+		QList <QAction*> values=actions.values(g);
+		for (int i=0;i<values.size();++i)
+			if (!values.at(i)->shortcut().toString().isEmpty())
+				cout<<QString ("  %1& %2\\\\ ") 
+					.arg(values.at(i)->text().left(30),30)
+					.arg(values.at(i)->shortcut().toString()).toStdString()<<endl;
+		cout <<endl;
+	}
+}
diff -r 46553c106c52 -r bec082472471 shortcuts.h
--- a/shortcuts.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/shortcuts.h	Tue Mar 30 17:30:39 2010 +0000
@@ -23,6 +23,7 @@
     Switchboard ();
 	void addConnection(QAction *a,const QString &s);
 	void print();
+	void printLaTeX();
 protected:  
 	QMultiMap <QString,QAction*> actions;
 };
diff -r 46553c106c52 -r bec082472471 texteditor.cpp
--- a/texteditor.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/texteditor.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -232,18 +232,40 @@
 	setFontHint (note.getFontHint() );
 }
 
-bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, QTextCursor &cursor)
+bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
 {
 	if (e->find (t,flags))
+		return true;
+	else	
+		return false;
+}
+
+bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, int i)
+{
+	// Position at beginning
+	QTextCursor c=e->textCursor();
+	c.setPosition (0,QTextCursor::MoveAnchor);
+	e->setTextCursor (c);
+
+	// Search for t
+	int j=0;
+	while (j<=i)
 	{
-		cursor=e->textCursor();
-		return true;
-	}	
-	else	
-	{
-		cursor=QTextCursor();
-		return false;
+		if (!e->find (t,flags)) return false;
+		j++;
 	}
+	return true;
+
+}
+
+void TextEditor::setTextCursor (const QTextCursor &cursor)
+{
+	e->setTextCursor (cursor);
+}
+
+QTextCursor TextEditor::getTextCursor()
+{
+	return e->textCursor();
 }
 
 void TextEditor::setupFileActions()
@@ -808,6 +830,11 @@
 
 void TextEditor::textAlign( QAction *a )
 {
+	qDebug()<<"TE::textAlign";
+	QTextCursor c=e->textCursor();
+	c.setPosition (3,QTextCursor::MoveAnchor);
+	e->setTextCursor (c);
+
     if ( a == actionAlignLeft )
 		e->setAlignment( Qt::AlignLeft );
     else if ( a == actionAlignCenter )
diff -r 46553c106c52 -r bec082472471 texteditor.h
--- a/texteditor.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/texteditor.h	Tue Mar 30 17:30:39 2010 +0000
@@ -28,7 +28,10 @@
 	NoteObj getNoteObj();
 	void setNote(const NoteObj &note);
 
-	bool findText(const QString &, const QTextDocument::FindFlags &,QTextCursor &cursor); 
+	bool findText(const QString &, const QTextDocument::FindFlags &); 
+	bool findText(const QString &, const QTextDocument::FindFlags &,int i); 
+	void setTextCursor (const QTextCursor & cursor );
+	QTextCursor getTextCursor();
 
 protected:
 	void setupFileActions();
diff -r 46553c106c52 -r bec082472471 version.h
--- a/version.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/version.h	Tue Mar 30 17:30:39 2010 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.1"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version, not for production!"
-#define __VYM_BUILD_DATE "2010-03-18"
+#define __VYM_BUILD_DATE "2010-03-30"
 
 
 bool checkVersion(const QString &);
diff -r 46553c106c52 -r bec082472471 vym.changelog
--- a/vym.changelog	Mon Mar 22 15:37:23 2010 +0000
+++ b/vym.changelog	Tue Mar 30 17:30:39 2010 +0000
@@ -1,9 +1,22 @@
+-------------------------------------------------------------------
+Tue Mar 30 19:29:43 CEST 2010 - vym@insilmaril.de
+
+- Bugfix: Much improved overview of search results, now also for notes
+
+-------------------------------------------------------------------
+Tue Mar 23 22:36:19 CET 2010 - vym@insilmaril.de
+
+- Feature: Added commandline options to list keyboard shortcuts
+- Bugfix: (Regression) Scrolling with PageUp/Down disabled, moving
+          branches instead
+- Bugfix: update scene after load, required user interaction before
 -------------------------------------------------------------------
 Mon Mar 22 08:37:42 CET 2010 - vym@insilmaril.de
 
 - Bugfix: Segfault when undoing deleting of MapCenter
 - Bugfix: Workaround for Qt bug, where cursor of embedded QLineEdits
           in 2nd tab was not shown
+- Bugfix: Icon of TreeEditor now shows correct state
 
 -------------------------------------------------------------------
 Thu Mar 18 12:45:45 CET 2010 - vym@insilmaril.de
diff -r 46553c106c52 -r bec082472471 vymmodel.cpp
--- a/vymmodel.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/vymmodel.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -503,6 +503,9 @@
 	updateActions();
 
 	if (mapEditor) mapEditor->setZoomFactorTarget (zoomFactor);
+
+	//Update view (scene()->update() is not enough)
+	qApp->processEvents();	// Update view (scene()->update() is not enough)
 	return err;
 }
 
@@ -1650,22 +1653,41 @@
 void  VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs)   
 {
 	rmodel->clear();
+	rmodel->setSearchString (s);
+	rmodel->setSearchFlags (0);	//FIXME-2 translate cs to QTextDocument::FindFlag
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	nextBranch(cur,prev);
+
+	FindResultItem *lastParent=NULL;
 	while (cur) 
 	{
+		lastParent=NULL;
 		if (cur->getHeading().contains (s,cs))
+			lastParent=rmodel->addItem (cur);
+		QString n=cur->getNoteASCII();
+		int i=0;
+		int j=0;
+		while ( i>=0)
 		{
-			rmodel->addItem (cur);
-		}	
-		int i=0;
-		while (i>=0)
-		{
-			i=cur->getNote().indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
+			i=n.indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
 			if (i>=0) 
 			{
-				rmodel->addSubItem (cur,"Note",cur,i);
+				// If not there yet, add "parent" item
+				if (!lastParent)
+				{
+					lastParent=rmodel->addItem (cur);
+					if (!lastParent)
+						qWarning()<<"VymModel::findAll still no lastParent?!";
+					/*
+					else
+						lastParent->setSelectable (false);
+					*/	
+				}	
+
+				// save index of occurence
+				rmodel->addSubItem (lastParent,QString(tr("Note","FindAll in VymModel")+" "+s),cur,j);
+				j++;
 				i++;
 			}
 		} 
@@ -1673,7 +1695,7 @@
 	}
 }
 
-BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs,QTextCursor &cursor)   
+BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs)
 {
 	if (!s.isEmpty() && s!=findString)
 	{
@@ -1703,7 +1725,7 @@
 			if (findCurrent->getNote().contains(findString,cs))
 			{
 				select (findCurrent);
-				if (textEditor->findText(findString,flags,cursor)) 
+				if (textEditor->findText(findString,flags)) 
 				{
 					searching=false;
 					foundNote=true;
@@ -5064,6 +5086,20 @@
 	return false;
 }
 
+bool VymModel::select (TreeItem *ti, int i)
+{
+	if (!ti || i<0) return false;
+	if (select (index(ti)))
+	{
+		qDebug ()<<"VM::select with index: "<<i<<" Trying to find text in note ";
+		QTextCursor c=textEditor->getTextCursor();
+		c.setPosition (i-1,QTextCursor::MoveAnchor);
+		textEditor->setTextCursor (c);
+	} else	
+		qDebug ()<<"VM::select with index: "<<i<<" Giving up to find text in note ";
+	return true;	
+}
+
 bool VymModel::select (const QModelIndex &index)
 {
 	if (index.isValid() )
diff -r 46553c106c52 -r bec082472471 vymmodel.h
--- a/vymmodel.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/vymmodel.h	Tue Mar 30 17:30:39 2010 +0000
@@ -27,7 +27,6 @@
 	Q_OBJECT
 	Q_CLASSINFO("D-Bus Interface", "org.insilmaril.vym.VymModel-h")
 
-
 ////////////////////////////////////////////
 // General housekeeping
 ////////////////////////////////////////////
@@ -275,7 +274,7 @@
 public:
 	void findDuplicateURLs();				// find duplicate URLs, testing only so far
     void findAll (FindResultModel*, QString s, Qt::CaseSensitivity cs);	// Search all objects at once, also notes
-    BranchItem* findText(QString s,Qt::CaseSensitivity cs,QTextCursor &cursor);	// Find object, also in note
+    BranchItem* findText(QString s,Qt::CaseSensitivity cs);	// Find object, also in note
     void findReset();						// Reset Search
 private:	
 	QString findString;
@@ -606,6 +605,7 @@
 	bool select (const QString &);			//! Select by string
 	bool select (LinkableMapObj *lmo);		//! Select by pointer to LMO
 	bool select (TreeItem *ti );			//! Select by pointer to TreeItem
+	bool select (TreeItem *ti,int i );		//! Select by pointer to TreeItem and index in note
 	bool select (const QModelIndex &index);	//! Select by ModelIndex
 	void unselect();
 	bool reselect();
diff -r 46553c106c52 -r bec082472471 vymview.cpp
--- a/vymview.cpp	Mon Mar 22 15:37:23 2010 +0000
+++ b/vymview.cpp	Tue Mar 30 17:30:39 2010 +0000
@@ -117,6 +117,11 @@
 	return mapEditor;
 }
 
+TreeEditor* VymView::getTreeEditor()
+{
+	return treeEditor;
+}
+
 void VymView::initFocus()
 {
 	mapEditor->setFocus();
diff -r 46553c106c52 -r bec082472471 vymview.h
--- a/vymview.h	Mon Mar 22 15:37:23 2010 +0000
+++ b/vymview.h	Tue Mar 30 17:30:39 2010 +0000
@@ -18,6 +18,7 @@
 	~VymView();
 	VymModel* getModel();
 	MapEditor* getMapEditor();
+	TreeEditor* getTreeEditor();
 	void initFocus();
 
 public slots: