Fixed regression in Undo
authorinsilmaril
Fri Nov 27 13:31:21 2009 +0000 (2009-11-27)
changeset 811c79486b7cb4b
parent 810 a9295db4dcbf
child 812 62d4137bfb90
Fixed regression in Undo
findwidget.cpp
findwidget.h
tex/vym.changelog
vymmodel.cpp
vymmodel.h
vymview.cpp
vymview.h
     1.1 --- a/findwidget.cpp	Thu Nov 26 14:55:23 2009 +0000
     1.2 +++ b/findwidget.cpp	Fri Nov 27 13:31:21 2009 +0000
     1.3 @@ -6,6 +6,7 @@
     1.4  
     1.5  
     1.6  extern QString vymName;
     1.7 +extern QString iconPath;
     1.8  
     1.9  FindWidget::FindWidget(QWidget *)
    1.10  {
    1.11 @@ -14,7 +15,8 @@
    1.12      
    1.13  	// Create Buttons
    1.14  	cancelbutton = new QPushButton;
    1.15 -	cancelbutton->setText(tr("Cancel"));
    1.16 +	//cancelbutton->setText(tr("Cancel"));
    1.17 +	cancelbutton->setIcon (QIcon (iconPath+"fileclose.png"));
    1.18  	cancelbutton->setShortcut (Qt::Key_Escape);
    1.19  	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    1.20  	
    1.21 @@ -25,6 +27,9 @@
    1.22      findcombo = new QComboBox;
    1.23  	findcombo->setMinimumWidth(250);
    1.24  	findcombo->setEditable(true);
    1.25 +
    1.26 +	QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    1.27 +    findcombo->setSizePolicy(sizePolicy);
    1.28  	connect ( findcombo, SIGNAL( highlighted(int) ), 
    1.29  		this, SLOT( nextPressed() ) );
    1.30  	connect ( findcombo, SIGNAL( textChanged(const QString &) ), 
    1.31 @@ -45,7 +50,7 @@
    1.32  	mainLayout->addLayout (row2Layout);
    1.33  
    1.34  	setLayout (mainLayout);
    1.35 -	setStatus (Undefined);
    1.36 +	status=Undefined;
    1.37  }
    1.38  
    1.39  void FindWidget::popup()
    1.40 @@ -53,6 +58,7 @@
    1.41  	show();
    1.42  	findcombo->lineEdit()->selectAll();
    1.43  	findcombo->setFocus();
    1.44 +	setStatus (Undefined);
    1.45  }
    1.46  
    1.47  void FindWidget::cancelPressed()
    1.48 @@ -67,17 +73,20 @@
    1.49  
    1.50  void FindWidget::findTextChanged(const QString&)
    1.51  {
    1.52 -	emit (somethingChanged() );
    1.53 +	setStatus (Undefined);
    1.54  }
    1.55  
    1.56  void FindWidget::setStatus (Status st)
    1.57  {
    1.58 +	if (st==status) return;
    1.59 +
    1.60 +	status=st;
    1.61  	QPalette p=palette();
    1.62  	QColor c;
    1.63  	switch (st)
    1.64  	{
    1.65 -		case Success: c=QColor (100,255,100); break;
    1.66 -		case Failed:  c=QColor (255,100,100); break;
    1.67 +		case Success: c=QColor (120,255,120); break;
    1.68 +		case Failed:  c=QColor (255,120,120); break;
    1.69  		default:  c=QColor (255,255,255); 
    1.70  	}
    1.71      p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
     2.1 --- a/findwidget.h	Thu Nov 26 14:55:23 2009 +0000
     2.2 +++ b/findwidget.h	Fri Nov 27 13:31:21 2009 +0000
     2.3 @@ -24,6 +24,9 @@
     2.4  	void findTextChanged(const QString&);
     2.5  	void setStatus (Status st);
     2.6  
     2.7 +private:
     2.8 +	Status status;
     2.9 +
    2.10  signals:
    2.11  	void nextButton(QString);
    2.12  	void somethingChanged();
     3.1 --- a/tex/vym.changelog	Thu Nov 26 14:55:23 2009 +0000
     3.2 +++ b/tex/vym.changelog	Fri Nov 27 13:31:21 2009 +0000
     3.3 @@ -1,3 +1,9 @@
     3.4 +-------------------------------------------------------------------
     3.5 +Thu Nov 26 22:32:34 CET 2009 - vym@insilmaril.de
     3.6 +
     3.7 +- Bugfix: Regression in Undo
     3.8 +- Bugfix: Find didn't find stuff in previous part of tree
     3.9 +
    3.10  -------------------------------------------------------------------
    3.11  Tue Nov 24 22:34:42 CET 2009 - vym@insilmaril.de
    3.12  
     4.1 --- a/vymmodel.cpp	Thu Nov 26 14:55:23 2009 +0000
     4.2 +++ b/vymmodel.cpp	Fri Nov 27 13:31:21 2009 +0000
     4.3 @@ -120,9 +120,7 @@
     4.4  	selectionBlocked=false;
     4.5  
     4.6  	// find routine
     4.7 -	findCurrent=NULL;				
     4.8 -	findPrevious=NULL;				
     4.9 -	EOFind=false;
    4.10 +	findReset();
    4.11  
    4.12  	// animations	// FIXME-3 switch to new animation system 
    4.13  	animationUse=settings.readBoolEntry("/animation/use",false);	// FIXME-3 add options to control _what_ is animated
    4.14 @@ -1139,6 +1137,7 @@
    4.15  		return;
    4.16  	}
    4.17  
    4.18 +
    4.19  	if (debug)
    4.20  	{
    4.21  		cout << "VymModel::undo() begin\n";
    4.22 @@ -1156,7 +1155,7 @@
    4.23  
    4.24  	bool noErr;
    4.25  	QString errMsg;
    4.26 -	parseAtom (redoCommand,noErr,errMsg);
    4.27 +	parseAtom (undoCommand,noErr,errMsg);
    4.28  
    4.29  	undosAvail--;
    4.30  	curStep--; 
    4.31 @@ -1568,6 +1567,12 @@
    4.32  
    4.33  BranchItem* VymModel::findText (QString s, bool cs)   
    4.34  {
    4.35 +	if (!s.isEmpty() && s!=findString)
    4.36 +	{
    4.37 +		findReset();
    4.38 +		findString=s;
    4.39 +	}
    4.40 +
    4.41  	QTextDocument::FindFlags flags=0;
    4.42  	if (cs) flags=QTextDocument::FindCaseSensitively;
    4.43  
    4.44 @@ -1587,7 +1592,7 @@
    4.45  		if (findCurrent)
    4.46  		{
    4.47  			// Searching in Note
    4.48 -			if (findCurrent->getNote().contains(s,cs))
    4.49 +			if (findCurrent->getNote().contains(findString,cs))
    4.50  			{
    4.51  				select (findCurrent);
    4.52  				/*
    4.53 @@ -1597,14 +1602,14 @@
    4.54  					emitShowSelection();
    4.55  				}
    4.56  				*/
    4.57 -				if (textEditor->findText(s,flags)) 
    4.58 +				if (textEditor->findText(findString,flags)) 
    4.59  				{
    4.60  					searching=false;
    4.61  					foundNote=true;
    4.62  				}	
    4.63  			}
    4.64  			// Searching in Heading
    4.65 -			if (searching && findCurrent->getHeading().contains (s,cs) ) 
    4.66 +			if (searching && findCurrent->getHeading().contains (findString,cs) ) 
    4.67  			{
    4.68  				select(findCurrent);
    4.69  				searching=false;
    4.70 @@ -1625,6 +1630,7 @@
    4.71  
    4.72  void VymModel::findReset()
    4.73  {	// Necessary if text to find changes during a find process
    4.74 +	findString.clear();
    4.75  	findCurrent=NULL;
    4.76  	findPrevious=NULL;
    4.77  	EOFind=false;
     5.1 --- a/vymmodel.h	Thu Nov 26 14:55:23 2009 +0000
     5.2 +++ b/vymmodel.h	Fri Nov 27 13:31:21 2009 +0000
     5.3 @@ -266,6 +266,8 @@
     5.4      BranchItem* findText(QString,bool);		// Find object
     5.5      void findReset();						// Reset Search
     5.6  	void emitShowFindWidget();				// Tell views to show FindWidget
     5.7 +private:	
     5.8 +	QString findString;
     5.9  signals:
    5.10  	void showFindWidget();				
    5.11  
     6.1 --- a/vymview.cpp	Thu Nov 26 14:55:23 2009 +0000
     6.2 +++ b/vymview.cpp	Fri Nov 27 13:31:21 2009 +0000
     6.3 @@ -115,7 +115,6 @@
     6.4  		findWidget, SIGNAL (nextButton (QString) ),
     6.5  		this, SLOT (findNext(QString) ) );
     6.6  		
     6.7 -
     6.8  	mapEditor->setAntiAlias (mainWindow->isAliased());
     6.9  	mapEditor->setSmoothPixmap(mainWindow->hasSmoothPixmapTransform());
    6.10  
    6.11 @@ -303,3 +302,10 @@
    6.12  		findWidget->setStatus (FindWidget::Failed);
    6.13  
    6.14  }
    6.15 +
    6.16 +void VymView::findReset()
    6.17 +{
    6.18 +	model->findReset();
    6.19 +	if (mapEditor) mapEditor->setFocus();
    6.20 +}
    6.21 +
     7.1 --- a/vymview.h	Thu Nov 26 14:55:23 2009 +0000
     7.2 +++ b/vymview.h	Fri Nov 27 13:31:21 2009 +0000
     7.3 @@ -30,6 +30,7 @@
     7.4  	void showSelection ();
     7.5  	void showFindWidget();
     7.6  	void findNext (QString s);
     7.7 +	void findReset();
     7.8  
     7.9  private:
    7.10  	VymModel *model;