[qet] [1877] Refactored the ConfigDialog class to make it more generic. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1877
Author: xavier
Date: 2012-06-29 07:21:32 +0200 (Fri, 29 Jun 2012)
Log Message:
-----------
Refactored the ConfigDialog class to make it more generic.
Modified Paths:
--------------
trunk/sources/configdialog.cpp
trunk/sources/configdialog.h
trunk/sources/qetapp.cpp
Modified: trunk/sources/configdialog.cpp
===================================================================
--- trunk/sources/configdialog.cpp 2012-06-29 05:21:30 UTC (rev 1876)
+++ trunk/sources/configdialog.cpp 2012-06-29 05:21:32 UTC (rev 1877)
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configdialog.h"
+#include "configpages.h"
#include "qetapp.h"
/**
@@ -23,9 +24,6 @@
@param parent QWidget parent
*/
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
-
- setWindowTitle(tr("Configurer QElectroTech", "window title"));
-
// liste des pages
pages_list = new QListWidget();
pages_list -> setViewMode(QListView::IconMode);
@@ -37,11 +35,6 @@
// pages
pages_widget = new QStackedWidget();
- addPage(new GeneralConfigurationPage());
- addPage(new NewDiagramPage());
- addPage(new ExportConfigPage());
- addPage(new PrintConfigPage());
- buildPagesList();
// boutons
buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
@@ -80,15 +73,22 @@
void ConfigDialog::buildPagesList() {
pages_list -> clear();
foreach(ConfigPage *page, pages) {
- QListWidgetItem *new_button = new QListWidgetItem(pages_list);
- new_button -> setIcon(page -> icon());
- new_button -> setText(page -> title());
- new_button -> setTextAlignment(Qt::AlignHCenter);
- new_button -> setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ addPageToList(page);
}
}
/**
+ Add the \a page ConfigPage to this configuration dialog.
+*/
+void ConfigDialog::addPageToList(ConfigPage *page) {
+ QListWidgetItem *new_button = new QListWidgetItem(pages_list);
+ new_button -> setIcon(page -> icon());
+ new_button -> setText(page -> title());
+ new_button -> setTextAlignment(Qt::AlignHCenter);
+ new_button -> setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+}
+
+/**
Applique la configuration de toutes les pages
*/
void ConfigDialog::applyConf() {
@@ -105,4 +105,5 @@
if (!page || pages.contains(page)) return;
pages << page;
pages_widget -> addWidget(page);
+ addPageToList(page);
}
Modified: trunk/sources/configdialog.h
===================================================================
--- trunk/sources/configdialog.h 2012-06-29 05:21:30 UTC (rev 1876)
+++ trunk/sources/configdialog.h 2012-06-29 05:21:32 UTC (rev 1877)
@@ -18,7 +18,7 @@
#ifndef CONFIG_DIALOG_H
#define CONFIG_DIALOG_H
#include <QDialog>
-#include "configpages.h"
+class ConfigPage;
class QListWidget;
class QListWidgetItem;
class QStackedWidget;
@@ -45,6 +45,7 @@
private:
void buildPagesList();
+ void addPageToList(ConfigPage *);
// attributs
private:
Modified: trunk/sources/qetapp.cpp
===================================================================
--- trunk/sources/qetapp.cpp 2012-06-29 05:21:30 UTC (rev 1876)
+++ trunk/sources/qetapp.cpp 2012-06-29 05:21:32 UTC (rev 1877)
@@ -18,6 +18,7 @@
#include "qetapp.h"
#include "aboutqet.h"
#include "configdialog.h"
+#include "configpages.h"
#include "qetdiagrameditor.h"
#include "qetelementeditor.h"
#include "elementscollectionitem.h"
@@ -1144,7 +1145,13 @@
// cree le dialogue
ConfigDialog cd;
+ cd.setWindowTitle(tr("Configurer QElectroTech", "window title"));
+ cd.addPage(new GeneralConfigurationPage());
+ cd.addPage(new NewDiagramPage());
+ cd.addPage(new ExportConfigPage());
+ cd.addPage(new PrintConfigPage());
+
// associe le dialogue a un eventuel widget parent
if (parent_widget) {
#ifdef Q_WS_MAC