Much improved results in FindResultsWidget
authorinsilmaril
Tue Mar 30 17:30:39 2010 +0000 (2010-03-30)
changeset 842bec082472471
parent 841 46553c106c52
child 843 2d36a7bb0867
Much improved results in FindResultsWidget
findresultitem.cpp
findresultitem.h
findresultmodel.cpp
findresultmodel.h
findresultwidget.cpp
findresultwidget.h
main.cpp
mainwindow.cpp
mainwindow.h
mapeditor.cpp
noteobj.cpp
noteobj.h
shortcuts.cpp
shortcuts.h
texteditor.cpp
texteditor.h
version.h
vym.changelog
vymmodel.cpp
vymmodel.h
vymview.cpp
vymview.h
     1.1 --- a/findresultitem.cpp	Mon Mar 22 15:37:23 2010 +0000
     1.2 +++ b/findresultitem.cpp	Tue Mar 30 17:30:39 2010 +0000
     1.3 @@ -9,7 +9,9 @@
     1.4      parentItem = parent;
     1.5      itemData = data;
     1.6  	orgID=-1;
     1.7 +	orgIndex=-1;
     1.8  	orgModel=NULL;
     1.9 +	itemData.append(QVariant("empty"));
    1.10  }
    1.11  
    1.12  FindResultItem::~FindResultItem()
    1.13 @@ -53,7 +55,6 @@
    1.14      return 0;
    1.15  }
    1.16  
    1.17 -
    1.18  bool FindResultItem::insertChildren(int position, int count, int columns)
    1.19  {
    1.20      if (position < 0 || position > childItems.size())
    1.21 @@ -127,11 +128,21 @@
    1.22  	orgID=ti->getID();
    1.23  }
    1.24  
    1.25 -uint FindResultItem::getOrgID()
    1.26 +int FindResultItem::getOriginalID()
    1.27  {
    1.28  	return orgID;
    1.29  }
    1.30  
    1.31 +void FindResultItem::setOriginalIndex(int i)
    1.32 +{
    1.33 +	orgIndex=i;
    1.34 +}
    1.35 +
    1.36 +int FindResultItem::getOriginalIndex()
    1.37 +{
    1.38 +	return orgIndex;
    1.39 +}
    1.40 +
    1.41  VymModel* FindResultItem::getOrgModel()
    1.42  {
    1.43  	return orgModel;
     2.1 --- a/findresultitem.h	Mon Mar 22 15:37:23 2010 +0000
     2.2 +++ b/findresultitem.h	Tue Mar 30 17:30:39 2010 +0000
     2.3 @@ -27,7 +27,9 @@
     2.4      int childNumber() const;
     2.5      bool setData(int column, const QVariant &value);
     2.6  	void setOriginal (TreeItem *ti);
     2.7 -	uint getOrgID();
     2.8 +	int getOriginalID();
     2.9 +	void setOriginalIndex(int i);
    2.10 +	int getOriginalIndex ();
    2.11  	VymModel* getOrgModel();
    2.12  
    2.13  private:
    2.14 @@ -35,7 +37,8 @@
    2.15      QVector<QVariant> itemData;
    2.16      FindResultItem *parentItem;
    2.17  
    2.18 -	uint orgID;
    2.19 +	int orgID;
    2.20 +	int orgIndex;
    2.21  	VymModel *orgModel;
    2.22  };
    2.23  
     3.1 --- a/findresultmodel.cpp	Mon Mar 22 15:37:23 2010 +0000
     3.2 +++ b/findresultmodel.cpp	Tue Mar 30 17:30:39 2010 +0000
     3.3 @@ -180,7 +180,7 @@
     3.4      return result;
     3.5  }
     3.6  
     3.7 -FindResultItem *FindResultModel::getItem(const QModelIndex &index) const
     3.8 +FindResultItem* FindResultModel::getItem(const QModelIndex &index) const
     3.9  {
    3.10      if (index.isValid()) {
    3.11          FindResultItem *item = static_cast<FindResultItem*>(index.internalPointer());
    3.12 @@ -189,58 +189,80 @@
    3.13      return rootItem;
    3.14  }
    3.15  
    3.16 -FindResultItem *FindResultModel::findTreeItem(TreeItem *ti)
    3.17 +FindResultItem *FindResultModel::findTreeItem(TreeItem *)
    3.18  {
    3.19 +	return NULL;	// FIXME-3 not used so far
    3.20  }
    3.21  
    3.22 -void FindResultModel::addItem (TreeItem *ti)
    3.23 +FindResultItem*  FindResultModel::addItem (TreeItem *ti)
    3.24  {
    3.25 +	FindResultItem *ni=NULL;
    3.26  	if (ti)
    3.27  	{
    3.28 -		QModelIndex ix (index (rootItem));
    3.29 +		QModelIndex parix (index (rootItem));
    3.30  		
    3.31 -		if (!insertRow(ix.row()+1, ix.parent()))
    3.32 -			return;
    3.33 +		emit (layoutAboutToBeChanged() );
    3.34  
    3.35 -		for (int column = 0; column < columnCount(ix.parent()); ++column) 
    3.36 +		int n=rowCount (parix);
    3.37 +		beginInsertRows (parix,n,n);
    3.38 +		if (rootItem->insertChildren (n,1,0) )
    3.39  		{
    3.40 -			QModelIndex child = index(ix.row()+1, column, ix.parent());
    3.41 -			setData(child, QVariant(ti->getHeading()), Qt::EditRole);
    3.42 -			getItem(child)->setOriginal (ti);
    3.43 +			QModelIndex ix=index(n,0,QModelIndex());
    3.44 +			setData (ix,QVariant(ti->getHeading()),Qt::EditRole);
    3.45 +			ni=getItem(ix);
    3.46 +			ni->setOriginal (ti);
    3.47  		}
    3.48 +		endInsertRows ();
    3.49 +
    3.50 +		emit (layoutChanged() );
    3.51  	}
    3.52 +	return ni;
    3.53  }
    3.54  
    3.55 -void FindResultModel::addItem (const QString &s)
    3.56 +FindResultItem*  FindResultModel::addSubItem (FindResultItem *parent,const QString &s, TreeItem *pi, int i)
    3.57  {
    3.58 -	if (!s.isEmpty())
    3.59 +	FindResultItem *ni=NULL;
    3.60 +	if (pi && parent)
    3.61  	{
    3.62 -		QModelIndex ix ( index (rootItem));
    3.63 +		QModelIndex parix ( index (parent));
    3.64  		
    3.65 -		if (!insertRow(ix.row()+1, ix.parent()))
    3.66 -			return;
    3.67 +		emit (layoutAboutToBeChanged() );
    3.68  
    3.69 -		for (int column = 0; column < columnCount(ix.parent()); ++column) {
    3.70 -			QModelIndex child = index(ix.row()+1, column, ix.parent());
    3.71 -			setData(child, QVariant(s), Qt::EditRole);
    3.72 +		int n=rowCount (parix);
    3.73 +		beginInsertRows (parix,n,n);
    3.74 +
    3.75 +		QModelIndex ix;
    3.76 +		if (parent->insertChildren (n,1,0))
    3.77 +		{
    3.78 +			ix=index(n,0,parix);
    3.79 +			setData (ix,QVariant(s),Qt::EditRole);
    3.80 +			ni=getItem(ix);
    3.81 +			ni->setOriginal (pi);
    3.82 +			ni->setOriginalIndex (i);
    3.83  		}
    3.84 +		endInsertRows ();
    3.85 +		emit (layoutChanged() );
    3.86  	}
    3.87 +	return ni;
    3.88  }
    3.89  
    3.90 -void FindResultModel::addSubItem (TreeItem *parent,const QString &s, TreeItem *ti, int i)
    3.91 +void FindResultModel::setSearchString( const QString &s)
    3.92  {
    3.93 -	if (ti)
    3.94 -	{
    3.95 -		QModelIndex ix ( index (rootItem));
    3.96 -		
    3.97 -		if (!insertRow(ix.row()+1, ix.parent()))
    3.98 -			return;
    3.99 -
   3.100 -		for (int column = 0; column < columnCount(ix.parent()); ++column) {
   3.101 -			QModelIndex child = index(ix.row()+1, column, ix.parent());
   3.102 -			setData(child, QVariant("Note: "+ti->getHeading()), Qt::EditRole);
   3.103 -			getItem(child)->setOriginal (ti);
   3.104 -		}
   3.105 -	}
   3.106 +	searchString=s;
   3.107  }
   3.108  
   3.109 +QString FindResultModel::getSearchString()
   3.110 +{
   3.111 +	return searchString;
   3.112 +}
   3.113 +
   3.114 +void FindResultModel::setSearchFlags( QTextDocument::FindFlags f)
   3.115 +{
   3.116 +	searchFlags=f;
   3.117 +}
   3.118 +
   3.119 +QTextDocument::FindFlags FindResultModel::getSearchFlags()
   3.120 +{
   3.121 +	return searchFlags;
   3.122 +}
   3.123 +
     4.1 --- a/findresultmodel.h	Mon Mar 22 15:37:23 2010 +0000
     4.2 +++ b/findresultmodel.h	Tue Mar 30 17:30:39 2010 +0000
     4.3 @@ -3,6 +3,7 @@
     4.4  
     4.5  #include <QAbstractItemModel>
     4.6  #include <QModelIndex>
     4.7 +#include <QTextDocument>
     4.8  #include <QVariant>
     4.9  
    4.10  class FindResultItem;
    4.11 @@ -44,16 +45,23 @@
    4.12      bool removeRows(int position, int rows,
    4.13                      const QModelIndex &parent = QModelIndex());
    4.14  
    4.15 -    FindResultItem *getItem(const QModelIndex &index) const;
    4.16 -	FindResultItem *findTreeItem (TreeItem *ti);
    4.17 +    FindResultItem* getItem(const QModelIndex &index) const;
    4.18 +	FindResultItem* findTreeItem (TreeItem *ti);
    4.19  
    4.20 -	void addItem (TreeItem *ti);
    4.21 -	void addItem (const QString &s);
    4.22 -	void addSubItem (TreeItem *parent,const QString &s, TreeItem *ti, int i);
    4.23 +	FindResultItem* addItem (TreeItem *ti);
    4.24 +	FindResultItem* addSubItem (FindResultItem *parent,const QString &s, TreeItem *pi, int i);
    4.25 +
    4.26 +	void setSearchString( const QString &s);
    4.27 +	QString getSearchString();
    4.28 +	void setSearchFlags( QTextDocument::FindFlags f);
    4.29 +	QTextDocument::FindFlags getSearchFlags();
    4.30  
    4.31  private:
    4.32  
    4.33      FindResultItem *rootItem;
    4.34 +
    4.35 +	QString searchString;
    4.36 +	QTextDocument::FindFlags searchFlags;
    4.37  };
    4.38  
    4.39  #endif
     5.1 --- a/findresultwidget.cpp	Mon Mar 22 15:37:23 2010 +0000
     5.2 +++ b/findresultwidget.cpp	Tue Mar 30 17:30:39 2010 +0000
     5.3 @@ -39,6 +39,8 @@
     5.4  	// Selection
     5.5  	connect (view->selectionModel(),SIGNAL (selectionChanged (QItemSelection,QItemSelection)),
     5.6  		this, SLOT (updateSelection (QItemSelection,QItemSelection)));
     5.7 +
     5.8 +	connect (resultsModel, SIGNAL(layoutChanged() ), view, SLOT (expandAll() ));	
     5.9  }
    5.10  
    5.11  void FindResultWidget::addItem (TreeItem *ti)
    5.12 @@ -87,14 +89,6 @@
    5.13  	return resultsModel;
    5.14  }
    5.15  
    5.16 -void FindResultWidget::addResult (const QString &category, TreeItem *ti)
    5.17 -{
    5.18 -	if (!category.isEmpty())
    5.19 -		addItem (category);
    5.20 -	else	
    5.21 -		addItem (model->getSelectedItem());
    5.22 -}
    5.23 -
    5.24  void FindResultWidget::popup()
    5.25  {
    5.26  	show();
    5.27 @@ -112,11 +106,15 @@
    5.28  	foreach (ix,newsel.indexes() )
    5.29  	{
    5.30  		FindResultItem *fri= static_cast<FindResultItem*>(ix.internalPointer());
    5.31 -		if (fri->getOrgModel() && fri->getOrgID()>0)
    5.32 +		if (fri->getOrgModel() && fri->getOriginalID()>0)
    5.33  		{
    5.34 -			TreeItem *ti=fri->getOrgModel()->findID(fri->getOrgID() );
    5.35 +			TreeItem *ti=fri->getOrgModel()->findID(fri->getOriginalID() );
    5.36  			if (ti)
    5.37 +			{
    5.38  				fri->getOrgModel()->select (ti);
    5.39 +				int i=fri->getOriginalIndex();
    5.40 +				if (i>=0) emit (noteSelected (resultsModel->getSearchString(),i));
    5.41 +			}	
    5.42  		}
    5.43  	}
    5.44  }
     6.1 --- a/findresultwidget.h	Mon Mar 22 15:37:23 2010 +0000
     6.2 +++ b/findresultwidget.h	Tue Mar 30 17:30:39 2010 +0000
     6.3 @@ -20,7 +20,6 @@
     6.4  	FindResultModel* getResultModel();
     6.5  	void addItem (TreeItem *ti);
     6.6  	void addItem (const QString &s);
     6.7 -	void addResult (const QString &category, TreeItem *ti);
     6.8  
     6.9  public slots:	
    6.10  	void popup();
    6.11 @@ -29,6 +28,7 @@
    6.12  
    6.13  signals:
    6.14  	void hideFindResultWidget();
    6.15 +	void noteSelected (QString , int );
    6.16  
    6.17  private:
    6.18  	VymModel *model;
     7.1 --- a/main.cpp	Mon Mar 22 15:37:23 2010 +0000
     7.2 +++ b/main.cpp	Tue Mar 30 17:30:39 2010 +0000
     7.3 @@ -72,13 +72,15 @@
     7.4  
     7.5  	// Reading and initializing options commandline options
     7.6  	options.add ("debug", Option::Switch, "d", "debug");
     7.7 -	options.add ("version", Option::Switch, "v","version");
     7.8 +	options.add ("help", Option::Switch, "h", "help");
     7.9  	options.add ("local", Option::Switch, "l", "local");
    7.10  	options.add ("name", Option::String, "n", "name");
    7.11 -	options.add ("help", Option::Switch, "h", "help");
    7.12  	options.add ("quit", Option::Switch, "q", "quit");
    7.13  	options.add ("run", Option::String, "r", "run");
    7.14 +	options.add ("shortcuts", Option::Switch, "s", "shortcuts");
    7.15 +	options.add ("shortcutsLaTeX", Option::Switch, "sl", "shortcutsLaTeX");
    7.16  	options.add ("test", Option::String, "t", "test");
    7.17 +	options.add ("version", Option::Switch, "v","version");
    7.18  	options.setHelpText (
    7.19  		"VYM - View Your Mind\n"
    7.20  		"--------------------\n\n"
     8.1 --- a/mainwindow.cpp	Mon Mar 22 15:37:23 2010 +0000
     8.2 +++ b/mainwindow.cpp	Tue Mar 30 17:30:39 2010 +0000
     8.3 @@ -23,6 +23,7 @@
     8.4  #include "settings.h"
     8.5  #include "shortcuts.h"
     8.6  #include "texteditor.h"
     8.7 +#include "treeeditor.h"
     8.8  #include "warningdialog.h"
     8.9  #include "xlinkitem.h"
    8.10  
    8.11 @@ -138,6 +139,8 @@
    8.12  	dw->setObjectName ("FindResultWidget");
    8.13  	dw->hide();	
    8.14  	addDockWidget (Qt::RightDockWidgetArea,dw);
    8.15 +	connect (findResultWidget, SIGNAL (noteSelected (QString, int)),this, SLOT (selectInNoteEditor (QString, int)));
    8.16 +
    8.17  
    8.18  	// Satellite windows //////////////////////////////////////////
    8.19  	// history window
    8.20 @@ -234,7 +237,8 @@
    8.21  	setupSettingsActions();
    8.22  	setupContextMenus();
    8.23  	setupMacros();
    8.24 -	if (debug) switchboard.print();
    8.25 +	if (options.isOn("shortcuts")) switchboard.print();
    8.26 +	if (options.isOn("shortcutsLaTeX")) switchboard.printLaTeX();
    8.27  
    8.28  	if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
    8.29  	setupHelpActions();
    8.30 @@ -628,9 +632,12 @@
    8.31  
    8.32  	// Shortcut to add attribute
    8.33  	a= new QAction(tr( "Add attribute" ), this);
    8.34 -	a->setShortcut ( Qt::Key_Q);	
    8.35 -	a->setShortcutContext (Qt::WindowShortcut);
    8.36 -	switchboard.addConnection(a,tr("Edit","Shortcut group"));
    8.37 +	if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
    8.38 +	{
    8.39 +		a->setShortcut ( Qt::Key_Q);	
    8.40 +		a->setShortcutContext (Qt::WindowShortcut);
    8.41 +		switchboard.addConnection(a,tr("Edit","Shortcut group"));
    8.42 +	}
    8.43  	addAction (a);
    8.44  	connect( a, SIGNAL( triggered() ), this, SLOT( editAddAttribute() ) );
    8.45  	actionAddAttribute= a;
    8.46 @@ -719,7 +726,7 @@
    8.47  
    8.48  	a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up","Edit menu" ), this);
    8.49  	a->setStatusTip ( tr( "Move branch up" ) );
    8.50 -	a->setShortcut (Qt::Key_PageUp );				// Move branch up
    8.51 +	a->setShortcut (Qt::Key_PageUp );				// Move branch up	//FIXME-2 If already on top, GraphicsView scrolls up, probably because this action is disabled?!
    8.52  	a->setEnabled (false);
    8.53  	switchboard.addConnection(a,tr("Edit","Shortcut group"));
    8.54  	tb->addAction (a);
    8.55 @@ -1224,7 +1231,8 @@
    8.56  	connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleNoteEditor() ) );
    8.57  	actionViewToggleNoteEditor=a;
    8.58  
    8.59 -	a = new QAction(QPixmap(), tr( "Show tree editor","View action" ),this);
    8.60 +	// Original icon is "category" from KDE
    8.61 +	a = new QAction(QPixmap(iconPath+"treeeditor.png"), tr( "Show tree editor","View action" ),this);
    8.62  	a->setStatusTip ( tr( "Show tree editor" ));
    8.63  	a->setShortcut ( Qt::CTRL + Qt::Key_T );	// Toggle Tree Editor // FIXME-3 originally: color subtree
    8.64  	switchboard.addConnection(a,tr("View shortcuts","Shortcut group"));
    8.65 @@ -2730,13 +2738,12 @@
    8.66  void Main::editFindNext(QString s)  
    8.67  {
    8.68  	Qt::CaseSensitivity cs=Qt::CaseInsensitive;
    8.69 -	QTextCursor cursor;
    8.70  	VymModel *m=currentModel();
    8.71  	if (m) 
    8.72  	{
    8.73  		m->findAll (findResultWidget->getResultModel(),s,cs);
    8.74  
    8.75 -		BranchItem *bi=m->findText(s, cs,cursor);
    8.76 +		BranchItem *bi=m->findText(s, cs);
    8.77  		if (bi)
    8.78  		{
    8.79  			findWidget->setStatus (FindWidget::Success);
    8.80 @@ -3636,6 +3643,13 @@
    8.81  	textEditor->setNote (ti->getNoteObj() );
    8.82  }
    8.83  
    8.84 +void Main::selectInNoteEditor(QString s,int i)
    8.85 +{
    8.86 +	// TreeItem is already selected at this time, therefor
    8.87 +	// the note is already in the editor
    8.88 +	textEditor->findText (s,0,i);
    8.89 +}
    8.90 +
    8.91  void Main::changeSelection (VymModel *model, const QItemSelection &newsel, const QItemSelection &oldsel)
    8.92  {
    8.93  	branchPropertyWindow->setModel (model ); //FIXME-3 this used to be called from BranchObj::select(). Maybe use signal now...
    8.94 @@ -3681,6 +3695,10 @@
    8.95  	actionViewToggleNoteEditor->setChecked (textEditor->isVisible());
    8.96  	actionViewToggleHistoryWindow->setChecked (historyWindow->isVisible());
    8.97  	actionViewTogglePropertyWindow->setChecked (branchPropertyWindow->isVisible());
    8.98 +	if ( tabWidget->currentPage())
    8.99 +		actionViewToggleTreeEditor->setChecked (
   8.100 +			vymViews.at(tabWidget->currentIndex())->getTreeEditor()->isVisible()
   8.101 +		);
   8.102  
   8.103  	VymModel  *m =currentModel();
   8.104  	if (m) 
     9.1 --- a/mainwindow.h	Mon Mar 22 15:37:23 2010 +0000
     9.2 +++ b/mainwindow.h	Tue Mar 30 17:30:39 2010 +0000
     9.3 @@ -227,6 +227,7 @@
     9.4  	void windowToggleSmoothPixmap();
     9.5  	void updateNoteFlag();
     9.6  	void updateNoteEditor (QModelIndex index);
     9.7 +	void selectInNoteEditor (QString s, int i);
     9.8  	void changeSelection (VymModel *model,const QItemSelection &newSel, const QItemSelection &delSel);
     9.9  
    9.10  	void updateActions();
    10.1 --- a/mapeditor.cpp	Mon Mar 22 15:37:23 2010 +0000
    10.2 +++ b/mapeditor.cpp	Tue Mar 30 17:30:39 2010 +0000
    10.3 @@ -985,8 +985,10 @@
    10.4  
    10.5  void MapEditor::keyPressEvent(QKeyEvent* e)
    10.6  {
    10.7 -	//qDebug()<<"ME::keyPressed";
    10.8 -	//return;
    10.9 +	if (e->key()==Qt::Key_PageUp || e->key()==Qt::Key_PageDown)
   10.10 +		// Ignore PageUP/Down to avoid scrolling with keys
   10.11 +		return;
   10.12 +
   10.13  	if (e->modifiers() & Qt::ControlModifier)
   10.14  	{
   10.15  		switch (mainWindow->getModMode())
    11.1 --- a/noteobj.cpp	Mon Mar 22 15:37:23 2010 +0000
    11.2 +++ b/noteobj.cpp	Tue Mar 30 17:30:39 2010 +0000
    11.3 @@ -1,9 +1,7 @@
    11.4 -#include <qfile.h>
    11.5 -#include <qtextstream.h>
    11.6 -#include <qmessagebox.h>
    11.7 -#include <qregexp.h>
    11.8 +#include "noteobj.h"
    11.9  
   11.10 -#include "noteobj.h"
   11.11 +#include <QRegExp>
   11.12 +#include <QDebug>
   11.13  
   11.14  /////////////////////////////////////////////////////////////////
   11.15  // NoteObj
   11.16 @@ -51,12 +49,12 @@
   11.17  
   11.18  QString NoteObj::getNoteASCII()
   11.19  {
   11.20 -	return getNoteASCII (QString(""),80);
   11.21 +	return getNoteASCII ("",80);
   11.22  }
   11.23  
   11.24 -QString NoteObj::getNoteASCII(const QString &indent, const int &width)
   11.25 +QString NoteObj::getNoteASCII(QString indent, const int &width)
   11.26  {
   11.27 -	// FIXME-3 make use of width
   11.28 +	if (note.isEmpty()) return note;
   11.29  	QString r=note;
   11.30  
   11.31  	// Remove all <style...> ...</style>
   11.32 @@ -95,7 +93,7 @@
   11.33  	r.replace (rx,indent);
   11.34  	r=indent + r;	// Don't forget first line
   11.35  
   11.36 -/* FIXME-5	wrap text at width
   11.37 +/* FIXME-3	wrap text at width
   11.38  	if (fonthint !="fixed")
   11.39  	{
   11.40  	}
    12.1 --- a/noteobj.h	Mon Mar 22 15:37:23 2010 +0000
    12.2 +++ b/noteobj.h	Tue Mar 30 17:30:39 2010 +0000
    12.3 @@ -21,7 +21,7 @@
    12.4  	void setNote (const QString&);
    12.5  	QString getNote() const;
    12.6  	QString getNoteASCII();
    12.7 -	QString getNoteASCII(const QString &indent, const int &width=0);
    12.8 +	QString getNoteASCII(QString igdent, const int &width=0);
    12.9  	QString getNoteOpenDoc();
   12.10  	void setFontHint (const QString&);
   12.11  	QString getFontHint () const;
    13.1 --- a/shortcuts.cpp	Mon Mar 22 15:37:23 2010 +0000
    13.2 +++ b/shortcuts.cpp	Tue Mar 30 17:30:39 2010 +0000
    13.3 @@ -41,3 +41,19 @@
    13.4  		cout <<endl;
    13.5  	}
    13.6  }
    13.7 +
    13.8 +void Switchboard::printLaTeX ()
    13.9 +{
   13.10 +	QString g;
   13.11 +	foreach (g,actions.uniqueKeys())
   13.12 +	{
   13.13 +		cout <<"Group: "<<g.toStdString()<<endl;
   13.14 +		QList <QAction*> values=actions.values(g);
   13.15 +		for (int i=0;i<values.size();++i)
   13.16 +			if (!values.at(i)->shortcut().toString().isEmpty())
   13.17 +				cout<<QString ("  %1& %2\\\\ ") 
   13.18 +					.arg(values.at(i)->text().left(30),30)
   13.19 +					.arg(values.at(i)->shortcut().toString()).toStdString()<<endl;
   13.20 +		cout <<endl;
   13.21 +	}
   13.22 +}
    14.1 --- a/shortcuts.h	Mon Mar 22 15:37:23 2010 +0000
    14.2 +++ b/shortcuts.h	Tue Mar 30 17:30:39 2010 +0000
    14.3 @@ -23,6 +23,7 @@
    14.4      Switchboard ();
    14.5  	void addConnection(QAction *a,const QString &s);
    14.6  	void print();
    14.7 +	void printLaTeX();
    14.8  protected:  
    14.9  	QMultiMap <QString,QAction*> actions;
   14.10  };
    15.1 --- a/texteditor.cpp	Mon Mar 22 15:37:23 2010 +0000
    15.2 +++ b/texteditor.cpp	Tue Mar 30 17:30:39 2010 +0000
    15.3 @@ -232,18 +232,40 @@
    15.4  	setFontHint (note.getFontHint() );
    15.5  }
    15.6  
    15.7 -bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, QTextCursor &cursor)
    15.8 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
    15.9  {
   15.10  	if (e->find (t,flags))
   15.11 +		return true;
   15.12 +	else	
   15.13 +		return false;
   15.14 +}
   15.15 +
   15.16 +bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags, int i)
   15.17 +{
   15.18 +	// Position at beginning
   15.19 +	QTextCursor c=e->textCursor();
   15.20 +	c.setPosition (0,QTextCursor::MoveAnchor);
   15.21 +	e->setTextCursor (c);
   15.22 +
   15.23 +	// Search for t
   15.24 +	int j=0;
   15.25 +	while (j<=i)
   15.26  	{
   15.27 -		cursor=e->textCursor();
   15.28 -		return true;
   15.29 -	}	
   15.30 -	else	
   15.31 -	{
   15.32 -		cursor=QTextCursor();
   15.33 -		return false;
   15.34 +		if (!e->find (t,flags)) return false;
   15.35 +		j++;
   15.36  	}
   15.37 +	return true;
   15.38 +
   15.39 +}
   15.40 +
   15.41 +void TextEditor::setTextCursor (const QTextCursor &cursor)
   15.42 +{
   15.43 +	e->setTextCursor (cursor);
   15.44 +}
   15.45 +
   15.46 +QTextCursor TextEditor::getTextCursor()
   15.47 +{
   15.48 +	return e->textCursor();
   15.49  }
   15.50  
   15.51  void TextEditor::setupFileActions()
   15.52 @@ -808,6 +830,11 @@
   15.53  
   15.54  void TextEditor::textAlign( QAction *a )
   15.55  {
   15.56 +	qDebug()<<"TE::textAlign";
   15.57 +	QTextCursor c=e->textCursor();
   15.58 +	c.setPosition (3,QTextCursor::MoveAnchor);
   15.59 +	e->setTextCursor (c);
   15.60 +
   15.61      if ( a == actionAlignLeft )
   15.62  		e->setAlignment( Qt::AlignLeft );
   15.63      else if ( a == actionAlignCenter )
    16.1 --- a/texteditor.h	Mon Mar 22 15:37:23 2010 +0000
    16.2 +++ b/texteditor.h	Tue Mar 30 17:30:39 2010 +0000
    16.3 @@ -28,7 +28,10 @@
    16.4  	NoteObj getNoteObj();
    16.5  	void setNote(const NoteObj &note);
    16.6  
    16.7 -	bool findText(const QString &, const QTextDocument::FindFlags &,QTextCursor &cursor); 
    16.8 +	bool findText(const QString &, const QTextDocument::FindFlags &); 
    16.9 +	bool findText(const QString &, const QTextDocument::FindFlags &,int i); 
   16.10 +	void setTextCursor (const QTextCursor & cursor );
   16.11 +	QTextCursor getTextCursor();
   16.12  
   16.13  protected:
   16.14  	void setupFileActions();
    17.1 --- a/version.h	Mon Mar 22 15:37:23 2010 +0000
    17.2 +++ b/version.h	Tue Mar 30 17:30:39 2010 +0000
    17.3 @@ -7,7 +7,7 @@
    17.4  #define __VYM_VERSION "1.13.1"
    17.5  //#define __VYM_CODENAME "Codename: RC-1"
    17.6  #define __VYM_CODENAME "Codename: development version, not for production!"
    17.7 -#define __VYM_BUILD_DATE "2010-03-18"
    17.8 +#define __VYM_BUILD_DATE "2010-03-30"
    17.9  
   17.10  
   17.11  bool checkVersion(const QString &);
    18.1 --- a/vym.changelog	Mon Mar 22 15:37:23 2010 +0000
    18.2 +++ b/vym.changelog	Tue Mar 30 17:30:39 2010 +0000
    18.3 @@ -1,9 +1,22 @@
    18.4 +-------------------------------------------------------------------
    18.5 +Tue Mar 30 19:29:43 CEST 2010 - vym@insilmaril.de
    18.6 +
    18.7 +- Bugfix: Much improved overview of search results, now also for notes
    18.8 +
    18.9 +-------------------------------------------------------------------
   18.10 +Tue Mar 23 22:36:19 CET 2010 - vym@insilmaril.de
   18.11 +
   18.12 +- Feature: Added commandline options to list keyboard shortcuts
   18.13 +- Bugfix: (Regression) Scrolling with PageUp/Down disabled, moving
   18.14 +          branches instead
   18.15 +- Bugfix: update scene after load, required user interaction before
   18.16  -------------------------------------------------------------------
   18.17  Mon Mar 22 08:37:42 CET 2010 - vym@insilmaril.de
   18.18  
   18.19  - Bugfix: Segfault when undoing deleting of MapCenter
   18.20  - Bugfix: Workaround for Qt bug, where cursor of embedded QLineEdits
   18.21            in 2nd tab was not shown
   18.22 +- Bugfix: Icon of TreeEditor now shows correct state
   18.23  
   18.24  -------------------------------------------------------------------
   18.25  Thu Mar 18 12:45:45 CET 2010 - vym@insilmaril.de
    19.1 --- a/vymmodel.cpp	Mon Mar 22 15:37:23 2010 +0000
    19.2 +++ b/vymmodel.cpp	Tue Mar 30 17:30:39 2010 +0000
    19.3 @@ -503,6 +503,9 @@
    19.4  	updateActions();
    19.5  
    19.6  	if (mapEditor) mapEditor->setZoomFactorTarget (zoomFactor);
    19.7 +
    19.8 +	//Update view (scene()->update() is not enough)
    19.9 +	qApp->processEvents();	// Update view (scene()->update() is not enough)
   19.10  	return err;
   19.11  }
   19.12  
   19.13 @@ -1650,22 +1653,41 @@
   19.14  void  VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs)   
   19.15  {
   19.16  	rmodel->clear();
   19.17 +	rmodel->setSearchString (s);
   19.18 +	rmodel->setSearchFlags (0);	//FIXME-2 translate cs to QTextDocument::FindFlag
   19.19  	BranchItem *cur=NULL;
   19.20  	BranchItem *prev=NULL;
   19.21  	nextBranch(cur,prev);
   19.22 +
   19.23 +	FindResultItem *lastParent=NULL;
   19.24  	while (cur) 
   19.25  	{
   19.26 +		lastParent=NULL;
   19.27  		if (cur->getHeading().contains (s,cs))
   19.28 +			lastParent=rmodel->addItem (cur);
   19.29 +		QString n=cur->getNoteASCII();
   19.30 +		int i=0;
   19.31 +		int j=0;
   19.32 +		while ( i>=0)
   19.33  		{
   19.34 -			rmodel->addItem (cur);
   19.35 -		}	
   19.36 -		int i=0;
   19.37 -		while (i>=0)
   19.38 -		{
   19.39 -			i=cur->getNote().indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
   19.40 +			i=n.indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
   19.41  			if (i>=0) 
   19.42  			{
   19.43 -				rmodel->addSubItem (cur,"Note",cur,i);
   19.44 +				// If not there yet, add "parent" item
   19.45 +				if (!lastParent)
   19.46 +				{
   19.47 +					lastParent=rmodel->addItem (cur);
   19.48 +					if (!lastParent)
   19.49 +						qWarning()<<"VymModel::findAll still no lastParent?!";
   19.50 +					/*
   19.51 +					else
   19.52 +						lastParent->setSelectable (false);
   19.53 +					*/	
   19.54 +				}	
   19.55 +
   19.56 +				// save index of occurence
   19.57 +				rmodel->addSubItem (lastParent,QString(tr("Note","FindAll in VymModel")+" "+s),cur,j);
   19.58 +				j++;
   19.59  				i++;
   19.60  			}
   19.61  		} 
   19.62 @@ -1673,7 +1695,7 @@
   19.63  	}
   19.64  }
   19.65  
   19.66 -BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs,QTextCursor &cursor)   
   19.67 +BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs)
   19.68  {
   19.69  	if (!s.isEmpty() && s!=findString)
   19.70  	{
   19.71 @@ -1703,7 +1725,7 @@
   19.72  			if (findCurrent->getNote().contains(findString,cs))
   19.73  			{
   19.74  				select (findCurrent);
   19.75 -				if (textEditor->findText(findString,flags,cursor)) 
   19.76 +				if (textEditor->findText(findString,flags)) 
   19.77  				{
   19.78  					searching=false;
   19.79  					foundNote=true;
   19.80 @@ -5064,6 +5086,20 @@
   19.81  	return false;
   19.82  }
   19.83  
   19.84 +bool VymModel::select (TreeItem *ti, int i)
   19.85 +{
   19.86 +	if (!ti || i<0) return false;
   19.87 +	if (select (index(ti)))
   19.88 +	{
   19.89 +		qDebug ()<<"VM::select with index: "<<i<<" Trying to find text in note ";
   19.90 +		QTextCursor c=textEditor->getTextCursor();
   19.91 +		c.setPosition (i-1,QTextCursor::MoveAnchor);
   19.92 +		textEditor->setTextCursor (c);
   19.93 +	} else	
   19.94 +		qDebug ()<<"VM::select with index: "<<i<<" Giving up to find text in note ";
   19.95 +	return true;	
   19.96 +}
   19.97 +
   19.98  bool VymModel::select (const QModelIndex &index)
   19.99  {
  19.100  	if (index.isValid() )
    20.1 --- a/vymmodel.h	Mon Mar 22 15:37:23 2010 +0000
    20.2 +++ b/vymmodel.h	Tue Mar 30 17:30:39 2010 +0000
    20.3 @@ -27,7 +27,6 @@
    20.4  	Q_OBJECT
    20.5  	Q_CLASSINFO("D-Bus Interface", "org.insilmaril.vym.VymModel-h")
    20.6  
    20.7 -
    20.8  ////////////////////////////////////////////
    20.9  // General housekeeping
   20.10  ////////////////////////////////////////////
   20.11 @@ -275,7 +274,7 @@
   20.12  public:
   20.13  	void findDuplicateURLs();				// find duplicate URLs, testing only so far
   20.14      void findAll (FindResultModel*, QString s, Qt::CaseSensitivity cs);	// Search all objects at once, also notes
   20.15 -    BranchItem* findText(QString s,Qt::CaseSensitivity cs,QTextCursor &cursor);	// Find object, also in note
   20.16 +    BranchItem* findText(QString s,Qt::CaseSensitivity cs);	// Find object, also in note
   20.17      void findReset();						// Reset Search
   20.18  private:	
   20.19  	QString findString;
   20.20 @@ -606,6 +605,7 @@
   20.21  	bool select (const QString &);			//! Select by string
   20.22  	bool select (LinkableMapObj *lmo);		//! Select by pointer to LMO
   20.23  	bool select (TreeItem *ti );			//! Select by pointer to TreeItem
   20.24 +	bool select (TreeItem *ti,int i );		//! Select by pointer to TreeItem and index in note
   20.25  	bool select (const QModelIndex &index);	//! Select by ModelIndex
   20.26  	void unselect();
   20.27  	bool reselect();
    21.1 --- a/vymview.cpp	Mon Mar 22 15:37:23 2010 +0000
    21.2 +++ b/vymview.cpp	Tue Mar 30 17:30:39 2010 +0000
    21.3 @@ -117,6 +117,11 @@
    21.4  	return mapEditor;
    21.5  }
    21.6  
    21.7 +TreeEditor* VymView::getTreeEditor()
    21.8 +{
    21.9 +	return treeEditor;
   21.10 +}
   21.11 +
   21.12  void VymView::initFocus()
   21.13  {
   21.14  	mapEditor->setFocus();
    22.1 --- a/vymview.h	Mon Mar 22 15:37:23 2010 +0000
    22.2 +++ b/vymview.h	Tue Mar 30 17:30:39 2010 +0000
    22.3 @@ -18,6 +18,7 @@
    22.4  	~VymView();
    22.5  	VymModel* getModel();
    22.6  	MapEditor* getMapEditor();
    22.7 +	TreeEditor* getTreeEditor();
    22.8  	void initFocus();
    22.9  
   22.10  public slots: