New diagram properties dialog :

Merge the dialog of default configuration and the dialog of project configuration, into a single configuration dialog.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3317 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-09-20 20:04:02 +00:00
parent e7d33b9b4b
commit 0f40e173ef
5 changed files with 119 additions and 221 deletions

View File

@@ -26,37 +26,53 @@
#include "exportpropertieswidget.h"
#include "ui/reportpropertiewidget.h"
#include "ui/xrefpropertieswidget.h"
#include "qetproject.h"
/**
Constructeur
@param parent QWidget parent
*/
NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
// main tab widget
QTabWidget *tab_widget = new QTabWidget(this);
* @brief NewDiagramPage::NewDiagramPage
* Default constructor
* @param project, If project, edit the propertie of Project
* else edit the properties by default of QElectroTech
* @param parent, parent widget
*/
NewDiagramPage::NewDiagramPage(QETProject *project, QWidget *parent) :
ConfigPage (parent),
m_project (project)
{
//By default we set the global default properties
// dimensions by default for diagram
bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
// default titleblock properties
ipw = new TitleBlockPropertiesWidget(QETDiagramEditor::defaultTitleBlockProperties(), true);
QWidget *diagram_widget = new QWidget();
QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
diagram_layout -> addWidget(bpw);
diagram_layout -> addWidget(ipw);
tab_widget->addTab(diagram_widget, tr("Sch\351ma"));
// default conductor properties
cpw = new ConductorPropertiesWidget(QETDiagramEditor::defaultConductorProperties());
cpw -> setContentsMargins(0, 0, 0, 0);
tab_widget->addTab(cpw, tr("Conducteur"));
// default propertie of report label
rpw = new ReportPropertieWidget(QETDiagramEditor::defaultReportProperties());
tab_widget->addTab(rpw, tr("Report de folio"));
// default properties of xref
xrefpw = new XRefPropertiesWidget(QETDiagramEditor::defaultXRefProperties(), this);
tab_widget->addTab(xrefpw, tr("R\351f\351rence crois\351es"));
//If there is a project, we edit his properties
if (m_project) {
bpw -> setProperties (m_project -> defaultBorderProperties());
cpw -> setProperties (m_project -> defaultConductorProperties());
ipw -> setProperties (m_project -> defaultTitleBlockProperties());
rpw -> setReportProperties (m_project -> defaultReportProperties());
xrefpw -> setProperties (m_project -> defaultXRefProperties());
}
// main tab widget
QTabWidget *tab_widget = new QTabWidget(this);
QWidget *diagram_widget = new QWidget();
QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
diagram_layout -> addWidget(bpw);
diagram_layout -> addWidget(ipw);
tab_widget -> addTab (diagram_widget, tr("Sch\351ma"));
tab_widget -> addTab (cpw, tr("Conducteur"));
tab_widget -> addTab (rpw, tr("Report de folio"));
tab_widget -> addTab (xrefpw, tr("R\351f\351rence crois\351es"));
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1->addWidget(tab_widget);
@@ -64,43 +80,94 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
setLayout(vlayout1);
}
/// Destructeur
/**
* @brief NewDiagramPage::~NewDiagramPage
*/
NewDiagramPage::~NewDiagramPage() {
}
/**
Applique la configuration de cette page
*/
* @brief NewDiagramPage::applyConf
* Apply conf for this page.
* If there is a project, save in the project,
* else save to the default conf of QElectroTech
*/
void NewDiagramPage::applyConf() {
QSettings &settings = QETApp::settings();
if (m_project) { //If project we save to the project
if (m_project -> isReadOnly()) return;
bool modified_project = false;
// dimensions des nouveaux schemas
bpw -> properties().toSettings(settings, "diagrameditor/default");
BorderProperties new_border_prop = bpw -> properties();
if (m_project -> defaultBorderProperties() != new_border_prop) {
m_project -> setDefaultBorderProperties(bpw -> properties());
modified_project = true;
}
// proprietes du cartouche
ipw-> properties().toSettings(settings, "diagrameditor/default");
TitleBlockProperties new_tbt_prop = ipw -> properties();
if (m_project -> defaultTitleBlockProperties() != new_tbt_prop) {
m_project -> setDefaultTitleBlockProperties(ipw -> properties());
modified_project = true;
}
// proprietes par defaut des conducteurs
cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
ConductorProperties new_conductor_prop = cpw -> properties();
if (m_project -> defaultConductorProperties() != new_conductor_prop) {
m_project -> setDefaultConductorProperties(cpw -> properties());
modified_project = true;
}
// default report propertie
rpw->toSettings(settings, "diagrameditor/defaultreport");
QString new_report_prop = rpw -> ReportProperties();
if (m_project -> defaultReportProperties() != new_report_prop) {
m_project -> setDefaultReportProperties(new_report_prop);
modified_project = true;
}
// default xref properties
QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
foreach (QString key, hash_xrp.keys()) {
XRefProperties xrp = hash_xrp[key];
QString str("diagrameditor/defaultxref");
xrp.toSettings(settings, str += key);
QHash<QString, XRefProperties> new_xref_properties = xrefpw -> properties();
if (m_project -> defaultXRefProperties() != new_xref_properties) {
m_project -> setDefaultXRefProperties(new_xref_properties);
modified_project = true;
}
if (modified_project) {
m_project -> setModified(modified_project);
}
} else { //Else we save to the default value
QSettings &settings = QETApp::settings();
// dimensions des nouveaux schemas
bpw -> properties().toSettings(settings, "diagrameditor/default");
// proprietes du cartouche
ipw-> properties().toSettings(settings, "diagrameditor/default");
// proprietes par defaut des conducteurs
cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
// default report propertie
rpw->toSettings(settings, "diagrameditor/defaultreport");
// default xref properties
QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
foreach (QString key, hash_xrp.keys()) {
XRefProperties xrp = hash_xrp[key];
QString str("diagrameditor/defaultxref");
xrp.toSettings(settings, str += key);
}
}
}
/// @return l'icone de cette page
/**
* @brief NewDiagramPage::icon
* @return icon of this page
*/
QIcon NewDiagramPage::icon() const {
return(QET::Icons::NewDiagram);
}
/// @return le titre de cette page
/**
* @brief NewDiagramPage::title
* @return title of this page
*/
QString NewDiagramPage::title() const {
return(tr("Nouveau sch\351ma", "configuration page title"));
}

View File

@@ -25,6 +25,7 @@ class TitleBlockPropertiesWidget;
class ExportPropertiesWidget;
class ReportPropertieWidget;
class XRefPropertiesWidget;
class QETProject;
/**
This configuration page enables users to define the properties of new
@@ -34,7 +35,7 @@ class NewDiagramPage : public ConfigPage {
Q_OBJECT
// constructors, destructor
public:
NewDiagramPage(QWidget * = 0);
NewDiagramPage(QETProject *project = 0, QWidget * = 0);
virtual ~NewDiagramPage();
private:
NewDiagramPage(const NewDiagramPage &);
@@ -47,11 +48,12 @@ class NewDiagramPage : public ConfigPage {
// attributes
private:
BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions
TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties
ConductorPropertiesWidget *cpw; ///< Widget to edit default conductor properties
ReportPropertieWidget *rpw; ///< Widget to edit default report label
XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
QETProject *m_project; ///< Project to edit propertie
BorderPropertiesWidget *bpw; ///< Widget to edit default diagram dimensions
TitleBlockPropertiesWidget *ipw; ///< Widget to edit default title block properties
ConductorPropertiesWidget *cpw; ///< Widget to edit default conductor properties
ReportPropertieWidget *rpw; ///< Widget to edit default report label
XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
};

View File

@@ -207,143 +207,6 @@ void ProjectMainConfigPage::adjustReadOnly() {
//######################################################################################//
/**
Constructor
@param project Project this page is editing.
@param parent Parent QWidget
*/
ProjectNewDiagramConfigPage::ProjectNewDiagramConfigPage(QETProject *project, QWidget *parent) :
ProjectConfigPage(project, parent)
{
init();
}
/**
Destructor
*/
ProjectNewDiagramConfigPage::~ProjectNewDiagramConfigPage() {
}
/**
@return the title for this page
*/
QString ProjectNewDiagramConfigPage::title() const {
return(tr("Nouveau sch\351ma", "project configuration page title"));
}
/**
@return the icon for this page
*/
QIcon ProjectNewDiagramConfigPage::icon() const {
return(QET::Icons::NewDiagram);
}
/**
Apply the configuration after user input
*/
void ProjectNewDiagramConfigPage::applyProjectConf() {
bool modified_project = false;
BorderProperties new_border_prop = border_ -> properties();
if (project_ -> defaultBorderProperties() != new_border_prop) {
project_ -> setDefaultBorderProperties(border_ -> properties());
modified_project = true;
}
TitleBlockProperties new_tbt_prop = titleblock_ -> properties();
if (project_ -> defaultTitleBlockProperties() != new_tbt_prop) {
project_ -> setDefaultTitleBlockProperties(titleblock_ -> properties());
modified_project = true;
}
ConductorProperties new_conductor_prop = conductor_ -> properties();
if (project_ -> defaultConductorProperties() != new_conductor_prop) {
project_ -> setDefaultConductorProperties(conductor_ -> properties());
modified_project = true;
}
QString new_report_prop = report_->ReportProperties();
if (project_->defaultReportProperties() != new_report_prop) {
project_->setDefaultReportProperties(new_report_prop);
modified_project = true;
}
QHash<QString, XRefProperties> new_xref_properties = xref_ -> properties();
if (project_ -> defaultXRefProperties() != new_xref_properties) {
project_ -> setDefaultXRefProperties(new_xref_properties);
modified_project = true;
}
if (modified_project) {
project_ -> setModified(modified_project);
}
}
/**
Initialize widgets displayed by the page.
*/
void ProjectNewDiagramConfigPage::initWidgets() {
informative_label_ = new QLabel(
tr(
"Propri\351t\351s \340 utiliser lors de l'ajout d'un nouveau sch\351ma au projet :",
"explicative label"
)
);
border_ = new BorderPropertiesWidget(BorderProperties());
titleblock_ = new TitleBlockPropertiesWidget(TitleBlockProperties(), true);
conductor_ = new ConductorPropertiesWidget();
conductor_ -> setContentsMargins(0, 0, 0, 0);
report_ = new ReportPropertieWidget("_");
xref_ = new XRefPropertiesWidget();
}
/**
Initialize the layout of this page.
*/
void ProjectNewDiagramConfigPage::initLayout() {
// main tab widget
QTabWidget *tab_widget = new QTabWidget(this);
QWidget *diagram_widget = new QWidget();
QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
diagram_layout -> addWidget(border_);
diagram_layout -> addWidget(titleblock_);
tab_widget -> addTab (diagram_widget, tr("Sch\351ma"));
tab_widget -> addTab (conductor_, tr("Conducteur"));
tab_widget -> addTab (report_, tr("Report de folio"));
tab_widget -> addTab (xref_, tr("R\351f\351rence crois\351es"));
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1->addWidget(tab_widget);
setLayout(vlayout1);
}
/**
Read properties from the edited project then fill widgets with them.
*/
void ProjectNewDiagramConfigPage::readValuesFromProject() {
border_ -> setProperties (project_ -> defaultBorderProperties());
conductor_ -> setProperties (project_ -> defaultConductorProperties());
titleblock_ -> setProperties (project_ -> defaultTitleBlockProperties());
report_ -> setReportProperties (project_ -> defaultReportProperties());
xref_ -> setProperties (project_ -> defaultXRefProperties());
}
/**
editable if the project is editable.
*/
void ProjectNewDiagramConfigPage::adjustReadOnly() {
bool is_read_only = project_ -> isReadOnly();
border_ -> setReadOnly(is_read_only);
titleblock_ -> setReadOnly(is_read_only);
conductor_ -> setReadOnly(is_read_only);
xref_ -> setReadOnly(is_read_only);
}
//######################################################################################//
/**
* @brief ProjectAutoNumConfigPage::ProjectAutoNumConfigPage
* Default constructor

View File

@@ -118,41 +118,6 @@ class ProjectMainConfigPage : public ProjectConfigPage {
DiagramContextWidget *project_variables_;
};
/**
This page enables users to configure the default properties of diagrams
newly added to the edited project.
*/
class ProjectNewDiagramConfigPage : public ProjectConfigPage {
Q_OBJECT
// Constructor, destructor
public:
ProjectNewDiagramConfigPage(QETProject *, QWidget * = 0);
virtual ~ProjectNewDiagramConfigPage();
private:
ProjectNewDiagramConfigPage(const ProjectNewDiagramConfigPage &);
// methods
public:
QString title() const;
QIcon icon() const;
void applyProjectConf();
protected:
void initWidgets();
void initLayout();
void readValuesFromProject();
void adjustReadOnly();
// attributes
private:
QLabel *informative_label_;
BorderPropertiesWidget *border_;
TitleBlockPropertiesWidget *titleblock_;
ConductorPropertiesWidget *conductor_;
ReportPropertieWidget *report_;
XRefPropertiesWidget *xref_;
};
class ProjectAutoNumConfigPage : public ProjectConfigPage {
Q_OBJECT

View File

@@ -19,6 +19,7 @@
#include "configdialog.h"
#include "projectconfigpages.h"
#include <QObject>
#include "configpages.h"
/**
* @brief ProjectPropertiesDialog::ProjectPropertiesDialog
@@ -30,7 +31,7 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *p
m_properties_dialog = new ConfigDialog (parent);
m_properties_dialog -> setWindowTitle(QObject::tr("Propri\351t\351s du projet", "window title"));
m_properties_dialog -> addPage(new ProjectMainConfigPage (project));
m_properties_dialog -> addPage(new ProjectNewDiagramConfigPage (project));
m_properties_dialog -> addPage(new NewDiagramPage (project));
m_properties_dialog -> addPage(new ProjectAutoNumConfigPage (project));
}