From 28034d2b86648e0cc5e3a307e841febf0afc1c98 Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 7 Nov 2006 08:57:11 +0000 Subject: [PATCH] Cancel did not reset uiprefs dialog to stored state --- src/qtgui/uiprefs_w.cpp | 53 +++++++++++++++++++++++++---------------- src/qtgui/uiprefs_w.h | 7 ++++-- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index 04fa91dc..a00b5bbc 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.7 2006-09-22 10:46:26 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.8 2006-11-07 08:57:11 dockes Exp $ (C) 2005 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -48,6 +48,27 @@ static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.7 2006-09-22 10:46:26 dockes Ex #include "uiprefs_w.h" void UIPrefsDialog::init() +{ + + connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog())); + connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog())); + connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont())); + connect(extraDbLE,SIGNAL(textChanged(const QString&)), this, + SLOT(extraDbTextChanged(const QString&))); + connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked())); + connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked())); + connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked())); + connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked())); + connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked())); + connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked())); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(buildAbsCB, SIGNAL(toggled(bool)), + replAbsCB, SLOT(setEnabled(bool))); +} + +// Update dialog state from stored prefs +void UIPrefsDialog::setFromPrefs() { // Entries per result page spinbox pageLenSB->setValue(prefs.respagesize); @@ -72,7 +93,9 @@ void UIPrefsDialog::init() s.setNum(reslistFontSize)); } helpBrowserLE->setText(prefs.htmlBrowser); + // Stemming language combobox + stemLangCMB->clear(); stemLangCMB->insertItem(tr("(no stemming)")); list langs; string reason; @@ -81,7 +104,6 @@ void UIPrefsDialog::init() exit(1); } langs = rcldb->getStemLangs(); - int i = 0, cur = -1; for (list::const_iterator it = langs.begin(); it != langs.end(); it++) { @@ -100,9 +122,7 @@ void UIPrefsDialog::init() autoPhraseCB->setChecked(prefs.ssearchAutoPhrase); buildAbsCB->setChecked(prefs.queryBuildAbstract); - if (!prefs.queryBuildAbstract) { - replAbsCB->setEnabled(false); - } + replAbsCB->setEnabled(prefs.queryBuildAbstract); replAbsCB->setChecked(prefs.queryReplaceAbstract); // Initialize the extra indexes listboxes @@ -111,30 +131,16 @@ void UIPrefsDialog::init() it != prefs.allExtraDbs.end(); it++) { ql.append(QString::fromLocal8Bit(it->c_str())); } + allDbsLB->clear(); allDbsLB->insertStringList(ql); ql.clear(); for (list::iterator it = prefs.activeExtraDbs.begin(); it != prefs.activeExtraDbs.end(); it++) { ql.append(QString::fromLocal8Bit(it->c_str())); } + actDbsLB->clear(); actDbsLB->insertStringList(ql); ql.clear(); - - connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog())); - connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog())); - connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont())); - connect(extraDbLE,SIGNAL(textChanged(const QString&)), this, - SLOT(extraDbTextChanged(const QString&))); - connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked())); - connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked())); - connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked())); - connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked())); - connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked())); - connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked())); - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(buildAbsCB, SIGNAL(toggled(bool)), - replAbsCB, SLOT(setEnabled(bool))); } void UIPrefsDialog::accept() @@ -184,6 +190,11 @@ void UIPrefsDialog::accept() emit uiprefsDone(); QDialog::accept(); } +void UIPrefsDialog::reject() +{ + setFromPrefs(); + QDialog::reject(); +} void UIPrefsDialog::showFontDialog() { diff --git a/src/qtgui/uiprefs_w.h b/src/qtgui/uiprefs_w.h index 28b714b5..0e4ebc8f 100644 --- a/src/qtgui/uiprefs_w.h +++ b/src/qtgui/uiprefs_w.h @@ -1,4 +1,4 @@ -/* @(#$Id: uiprefs_w.h,v 1.1 2006-09-04 15:13:02 dockes Exp $ (C) 2006 J.F.Dockes */ +/* @(#$Id: uiprefs_w.h,v 1.2 2006-11-07 08:57:11 dockes Exp $ (C) 2006 J.F.Dockes */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ */ #ifndef _UIPREFS_W_H_INCLUDED_ #define _UIPREFS_W_H_INCLUDED_ -/* @(#$Id: uiprefs_w.h,v 1.1 2006-09-04 15:13:02 dockes Exp $ (C) 2005 J.F.Dockes */ +/* @(#$Id: uiprefs_w.h,v 1.2 2006-11-07 08:57:11 dockes Exp $ (C) 2005 J.F.Dockes */ #include #include @@ -53,6 +53,9 @@ signals: protected slots: virtual void accept(); + virtual void reject(); + private: + void setFromPrefs(); };