Introduce loadNote and saveNote commands
authorinsilmaril
Tue, 09 Mar 2010 08:29:09 +0000
changeset 83125a950c2eb98
parent 830 b5537d245165
child 832 6a6018ba4cc7
Introduce loadNote and saveNote commands
file.cpp
file.h
findresultmodel.cpp
highlighter.cpp
tex/vym.changelog
version.h
vymmodel.cpp
vymmodel.h
     1.1 --- a/file.cpp	Tue Mar 09 08:28:49 2010 +0000
     1.2 +++ b/file.cpp	Tue Mar 09 08:29:09 2010 +0000
     1.3 @@ -1,9 +1,9 @@
     1.4 +#include <QDebug>
     1.5  #include <QDir>
     1.6  #include <QMessageBox>
     1.7  #include <QPixmap>
     1.8  #include <QLabel>
     1.9  #include <QTextStream>
    1.10 -#include <iostream>
    1.11  
    1.12  #include "file.h"
    1.13  #include "process.h"
     2.1 --- a/file.h	Tue Mar 09 08:28:49 2010 +0000
     2.2 +++ b/file.h	Tue Mar 09 08:29:09 2010 +0000
     2.3 @@ -24,8 +24,8 @@
     2.4  void makeSubDirs (const QString &);
     2.5  ErrorCode zipDir (const QDir &,const QString&);
     2.6  ErrorCode unzipDir (const QDir &,const QString&);
     2.7 -bool loadStringFromDisk (const QString &, QString &);
     2.8 -bool saveStringToDisk (const QString &, const QString &s);
     2.9 +bool loadStringFromDisk (const QString &fn, QString &s);
    2.10 +bool saveStringToDisk (const QString &fn, const QString &s);
    2.11  
    2.12  /////////////////////////////////////////////////////////////////////////////
    2.13  #include <QLabel>
     3.1 --- a/findresultmodel.cpp	Tue Mar 09 08:28:49 2010 +0000
     3.2 +++ b/findresultmodel.cpp	Tue Mar 09 08:29:09 2010 +0000
     3.3 @@ -9,9 +9,7 @@
     3.4  {
     3.5      QVector<QVariant> rootData;
     3.6  	rootData << "Heading";
     3.7 -
     3.8      rootItem = new FindResultItem(rootData);
     3.9 -    //setupModelData(data.split(QString("\n")), rootItem);
    3.10  }
    3.11  
    3.12  FindResultModel::~FindResultModel()
    3.13 @@ -22,10 +20,7 @@
    3.14  void FindResultModel::clear()
    3.15  {
    3.16  	if (rootItem->childCount()>0)
    3.17 -	{
    3.18 -		//QModelIndex ix=createIndex(0,0,rootItem);
    3.19  		removeRows (0,rowCount (QModelIndex ()));
    3.20 -	}
    3.21  }
    3.22  
    3.23  int FindResultModel::columnCount(const QModelIndex & /* parent */) const
     4.1 --- a/highlighter.cpp	Tue Mar 09 08:28:49 2010 +0000
     4.2 +++ b/highlighter.cpp	Tue Mar 09 08:29:09 2010 +0000
     4.3 @@ -56,6 +56,7 @@
     4.4  					<< "\\bimportDir\\b"
     4.5  					<< "\\blinkTo\\b" 
     4.6  					<< "\\bloadImage\\b"
     4.7 +					<< "\\bloadNote\\b"
     4.8  					<< "\\bmoveBranchUp\\b" 
     4.9  					<< "\\bmoveBranchDown\\b"
    4.10  					<< "\\bmove\\b" 
    4.11 @@ -64,6 +65,7 @@
    4.12  					<< "\\bpaste\\b" 
    4.13  					<< "\\bqa\\b" 
    4.14  					<< "\\bsaveImage\\b" 
    4.15 +					<< "\\bsaveNote\\b" 
    4.16  					<< "\\bscroll\\b" 
    4.17  					<< "\\bselect\\b" 
    4.18  					<< "\\bselectLastBranch\\b" 
     5.1 --- a/tex/vym.changelog	Tue Mar 09 08:28:49 2010 +0000
     5.2 +++ b/tex/vym.changelog	Tue Mar 09 08:29:09 2010 +0000
     5.3 @@ -1,3 +1,11 @@
     5.4 +-------------------------------------------------------------------
     5.5 +Mon Mar  8 07:45:34 CET 2010 - vym@insilmaril.de
     5.6 +
     5.7 +- Feature: New widget to display all results of Find action.
     5.8 +           Also opened with CTRL-F once FindWidget is open
     5.9 +- Feature: loadNote and saveNote commands to allow changing of note 
    5.10 +           from external
    5.11 +
    5.12  -------------------------------------------------------------------
    5.13  Fri Feb 19 08:05:02 CET 2010 - vym@insilmaril.de
    5.14  
     6.1 --- a/version.h	Tue Mar 09 08:28:49 2010 +0000
     6.2 +++ b/version.h	Tue Mar 09 08:29:09 2010 +0000
     6.3 @@ -7,7 +7,7 @@
     6.4  #define __VYM_VERSION "1.13.0"
     6.5  //#define __VYM_CODENAME "Codename: RC-1"
     6.6  #define __VYM_CODENAME "Codename: development version, not for production!"
     6.7 -#define __VYM_BUILD_DATE "2010-03-08"
     6.8 +#define __VYM_BUILD_DATE "2010-03-09"
     6.9  
    6.10  
    6.11  bool checkVersion(const QString &);
     7.1 --- a/vymmodel.cpp	Tue Mar 09 08:28:49 2010 +0000
     7.2 +++ b/vymmodel.cpp	Tue Mar 09 08:29:09 2010 +0000
     7.3 @@ -1553,7 +1553,6 @@
     7.4  	TreeItem *selti=getSelectedItem();
     7.5  	if (selti) 
     7.6  	{
     7.7 -		emitNoteHasChanged(selti);
     7.8  		saveState(
     7.9  			selti,
    7.10  			"setNote (\""+selti->getNote()+"\")", 
    7.11 @@ -1561,7 +1560,8 @@
    7.12  			"setNote (\""+s+"\")", 
    7.13  			QString("Set note of %1 ").arg(getObjectName(selti)) );
    7.14  	}
    7.15 -		selti->setNote(s);
    7.16 +	selti->setNote(s);
    7.17 +	emitNoteHasChanged(selti);
    7.18  }
    7.19  
    7.20  QString VymModel::getNote()
    7.21 @@ -1573,6 +1573,39 @@
    7.22  		return QString();
    7.23  }
    7.24  
    7.25 +void VymModel::loadNote (const QString &fn)
    7.26 +{
    7.27 +	BranchItem *selbi=getSelectedBranch();
    7.28 +	if (selbi)
    7.29 +	{
    7.30 +		QString n;
    7.31 +		if (!loadStringFromDisk (fn,n))
    7.32 +			qWarning ()<<"VymModel::loadNote Couldn't load "<<fn;
    7.33 +		else
    7.34 +			setNote (n);
    7.35 +	} else
    7.36 +		qWarning ("VymModel::loadNote no branch selected");
    7.37 +}
    7.38 +
    7.39 +void VymModel::saveNote (const QString &fn)
    7.40 +{
    7.41 +	BranchItem *selbi=getSelectedBranch();
    7.42 +	if (selbi)
    7.43 +	{
    7.44 +		QString n=selbi->getNote();
    7.45 +		if (n.isEmpty())
    7.46 +			qWarning ()<<"VymModel::saveNote  note is empty, won't save to "<<fn;
    7.47 +		else
    7.48 +		{
    7.49 +			if (!saveStringToDisk (fn,n))
    7.50 +				qWarning ()<<"VymModel::saveNote Couldn't save "<<fn;
    7.51 +			else
    7.52 +				selbi->setNote (n);
    7.53 +		}	
    7.54 +	} else
    7.55 +		qWarning ("VymModel::saveNote no branch selected");
    7.56 +}
    7.57 +
    7.58  void VymModel::findDuplicateURLs()	// FIXME-3 needs GUI
    7.59  {
    7.60  	// Generate map containing _all_ URLs and branches
    7.61 @@ -1612,6 +1645,7 @@
    7.62  void  VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs)   
    7.63  {
    7.64  	rmodel->clear();
    7.65 +	int i=0;
    7.66  	BranchItem *cur=NULL;
    7.67  	BranchItem *prev=NULL;
    7.68  	nextBranch(cur,prev);
    7.69 @@ -1621,7 +1655,14 @@
    7.70  		{
    7.71  			rmodel->addItem (cur);
    7.72  		}	
    7.73 -		//if (cur->getNote().contains (s,cs))	//FIXME-2 does not detect multiple occurences
    7.74 +		//if (cur->getNote().contains (s,cs))	//FIXME-2 does not detect multiple occurences yet
    7.75 +		while (i>=0)
    7.76 +		{
    7.77 +			i=cur->getNote().indexOf (s,i,cs);
    7.78 +			if (i>=0) i++;
    7.79 +			qDebug()<<"i="<<i;
    7.80 +
    7.81 +		} 
    7.82  		nextBranch(cur,prev);
    7.83  	}
    7.84  }
    7.85 @@ -3526,6 +3567,20 @@
    7.86  			if (ok) loadFloatImageInt (selbi,s);
    7.87  		}	
    7.88  	/////////////////////////////////////////////////////////////////////
    7.89 +	} else if (com=="loadNote")
    7.90 +	{
    7.91 +		if (!selti)
    7.92 +		{
    7.93 +			parser.setError (Aborted,"Nothing selected");
    7.94 +		} else if (! selbi )
    7.95 +		{				  
    7.96 +			parser.setError (Aborted,"Type of selection is not a branch");
    7.97 +		} else if (parser.checkParCount(1))
    7.98 +		{
    7.99 +			s=parser.parString(ok,0);
   7.100 +			if (ok) loadNote (s);
   7.101 +		}	
   7.102 +	/////////////////////////////////////////////////////////////////////
   7.103  	} else if (com=="moveUp")
   7.104  	{
   7.105  		if (!selti )
   7.106 @@ -3691,6 +3746,20 @@
   7.107  			}
   7.108  		}	
   7.109  	/////////////////////////////////////////////////////////////////////
   7.110 +	} else if (com=="saveNote")
   7.111 +	{
   7.112 +		if (!selti)
   7.113 +		{
   7.114 +			parser.setError (Aborted,"Nothing selected");
   7.115 +		} else if (! selbi )
   7.116 +		{				  
   7.117 +			parser.setError (Aborted,"Type of selection is not a branch");
   7.118 +		} else if (parser.checkParCount(1))
   7.119 +		{
   7.120 +			s=parser.parString(ok,0);
   7.121 +			if (ok) saveNote (s);
   7.122 +		}	
   7.123 +	/////////////////////////////////////////////////////////////////////
   7.124  	} else if (com=="scroll")
   7.125  	{
   7.126  		if (!selti)
     8.1 --- a/vymmodel.h	Tue Mar 09 08:28:49 2010 +0000
     8.2 +++ b/vymmodel.h	Tue Mar 09 08:29:09 2010 +0000
     8.3 @@ -264,6 +264,8 @@
     8.4  	QString getHeading ();					//!< Get heading of item
     8.5  	void setNote(const QString &s);			//!< Set note text
     8.6  	QString getNote();						//!< Get note text
     8.7 +	void loadNote (const QString &fn);		//!< Load note from file
     8.8 +	void saveNote (const QString &fn);		//!< Save note to file
     8.9  
    8.10  private:
    8.11  	BranchItem* findCurrent;				// next object in find process