More fixes to new findwidget
authorinsilmaril
Thu, 26 Nov 2009 14:55:23 +0000
changeset 810a9295db4dcbf
parent 809 0a1abd218f36
child 811 c79486b7cb4b
More fixes to new findwidget
findwidget.cpp
findwidget.h
mapeditor.cpp
version.h
vymview.cpp
     1.1 --- a/findwidget.cpp	Wed Nov 25 15:28:05 2009 +0000
     1.2 +++ b/findwidget.cpp	Thu Nov 26 14:55:23 2009 +0000
     1.3 @@ -7,7 +7,7 @@
     1.4  
     1.5  extern QString vymName;
     1.6  
     1.7 -FindWidget::FindWidget(QWidget* parent)
     1.8 +FindWidget::FindWidget(QWidget *)
     1.9  {
    1.10      QVBoxLayout* mainLayout = new QVBoxLayout;
    1.11      QHBoxLayout *row2Layout = new QHBoxLayout;
    1.12 @@ -18,6 +18,9 @@
    1.13  	cancelbutton->setShortcut (Qt::Key_Escape);
    1.14  	connect ( cancelbutton, SIGNAL( clicked() ), this, SLOT( cancelPressed() ) );
    1.15  	
    1.16 +	QLabel *label=new QLabel;
    1.17 +	label->setText (tr("Find:","FindWidget"));
    1.18 +	
    1.19  	// Create LineEdit (here QComboBox)
    1.20      findcombo = new QComboBox;
    1.21  	findcombo->setMinimumWidth(250);
    1.22 @@ -29,17 +32,20 @@
    1.23  
    1.24  	nextbutton = new QPushButton;
    1.25  	nextbutton->setText (tr("Next","Find widget"));
    1.26 -	//nextbutton->setDefault (true);
    1.27 -	//nextbutton->setShortcut (Qt::Key_Return);
    1.28 +	nextbutton->setDefault (true);
    1.29 +	nextbutton->setShortcut (Qt::Key_Return);
    1.30 +	//nextbutton->setShortcutContext (Qt::WidgetShortcut);
    1.31  	connect ( nextbutton, SIGNAL( clicked() ), this, SLOT( nextPressed() ) );
    1.32  
    1.33  	row2Layout->addWidget (cancelbutton);
    1.34 +	row2Layout->addWidget (label);
    1.35  	row2Layout->addWidget(findcombo);
    1.36  	row2Layout->addWidget(nextbutton);
    1.37  
    1.38  	mainLayout->addLayout (row2Layout);
    1.39  
    1.40  	setLayout (mainLayout);
    1.41 +	setStatus (Undefined);
    1.42  }
    1.43  
    1.44  void FindWidget::popup()
    1.45 @@ -64,3 +70,18 @@
    1.46  	emit (somethingChanged() );
    1.47  }
    1.48  
    1.49 +void FindWidget::setStatus (Status st)
    1.50 +{
    1.51 +	QPalette p=palette();
    1.52 +	QColor c;
    1.53 +	switch (st)
    1.54 +	{
    1.55 +		case Success: c=QColor (100,255,100); break;
    1.56 +		case Failed:  c=QColor (255,100,100); break;
    1.57 +		default:  c=QColor (255,255,255); 
    1.58 +	}
    1.59 +    p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
    1.60 +    p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);
    1.61 +    findcombo->setPalette(p);
    1.62 +}
    1.63 +
     2.1 --- a/findwidget.h	Wed Nov 25 15:28:05 2009 +0000
     2.2 +++ b/findwidget.h	Thu Nov 26 14:55:23 2009 +0000
     2.3 @@ -13,13 +13,16 @@
     2.4  	Q_OBJECT
     2.5  
     2.6  public:
     2.7 -	FindWidget (QWidget* parent=0);
     2.8 +	enum Status {Undefined,Success,Failed};
     2.9 +
    2.10 +	FindWidget (QWidget *parent=NULL);
    2.11  
    2.12  public slots:	
    2.13  	void popup();
    2.14  	void cancelPressed();
    2.15  	void nextPressed();
    2.16  	void findTextChanged(const QString&);
    2.17 +	void setStatus (Status st);
    2.18  
    2.19  signals:
    2.20  	void nextButton(QString);
     3.1 --- a/mapeditor.cpp	Wed Nov 25 15:28:05 2009 +0000
     3.2 +++ b/mapeditor.cpp	Thu Nov 26 14:55:23 2009 +0000
     3.3 @@ -125,6 +125,7 @@
     3.4  
     3.5  	a = new QAction( tr( "Edit heading","MapEditor" ), this);
     3.6  	a->setShortcut ( Qt::Key_Return );					//Edit heading
     3.7 +	a->setShortcutContext (Qt::WidgetShortcut);
     3.8  	addAction (a);
     3.9      connect( a, SIGNAL( triggered() ), this, SLOT( editHeading() ) );
    3.10  	a = new QAction( tr( "Edit heading","MapEditor" ), this);
     4.1 --- a/version.h	Wed Nov 25 15:28:05 2009 +0000
     4.2 +++ b/version.h	Thu Nov 26 14:55:23 2009 +0000
     4.3 @@ -7,7 +7,7 @@
     4.4  #define __VYM_VERSION "1.13.0"
     4.5  //#define __VYM_CODENAME "Codename: RC-1"
     4.6  #define __VYM_CODENAME "Codename: development version, not for production!"
     4.7 -#define __VYM_BUILD_DATE "2009-11-25"
     4.8 +#define __VYM_BUILD_DATE "2009-11-26"
     4.9  
    4.10  
    4.11  bool checkVersion(const QString &);
     5.1 --- a/vymview.cpp	Wed Nov 25 15:28:05 2009 +0000
     5.2 +++ b/vymview.cpp	Thu Nov 26 14:55:23 2009 +0000
     5.3 @@ -18,6 +18,7 @@
     5.4  
     5.5  	// Create findWidget
     5.6  	findWidget=new FindWidget (this);
     5.7 +	findWidget->hide();
     5.8  
     5.9  	// Create TreeView
    5.10  	treeEditor=new TreeEditor (model);
    5.11 @@ -172,7 +173,7 @@
    5.12  	}
    5.13  }
    5.14  
    5.15 -void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &oldsel)
    5.16 +void VymView::changeProxySelection (const QItemSelection &newsel, const QItemSelection &)
    5.17  {
    5.18  	// Notify mainwindow to update satellites, but map selection to 
    5.19  	// original model first
    5.20 @@ -289,7 +290,7 @@
    5.21  
    5.22  void VymView::showFindWidget()
    5.23  {
    5.24 -	findWidget->show();
    5.25 +	findWidget->popup();
    5.26  }
    5.27  
    5.28  void VymView::findNext (QString s)
    5.29 @@ -297,14 +298,8 @@
    5.30  	bool cs=false;
    5.31  	BranchItem *bi=model->findText(s, cs);
    5.32  	if (bi)
    5.33 -	{	
    5.34 -		//statusBar()->message( "Found: " + bi->getHeading(), statusbarTime );
    5.35 -		cout << "VV::Found!\n";
    5.36 -	} else
    5.37 -	{
    5.38 -		cout << "VV::Nothing found!\n";
    5.39 -		//QMessageBox::information( findWindow, tr( "VYM -Information:" ),
    5.40 -		//					   tr("No matches found for \"%1\"").arg(s));
    5.41 -	}	
    5.42 +		findWidget->setStatus (FindWidget::Success);
    5.43 +	else
    5.44 +		findWidget->setStatus (FindWidget::Failed);
    5.45  
    5.46  }