mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Title block properties dialog: the templates list is now dynamically updated.
Also, it is now possible to edit and/or duplicate the default template. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1480 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -469,7 +469,7 @@ void DiagramView::editDiagramProperties() {
|
|||||||
|
|
||||||
TitleBlockPropertiesWidget *titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
|
TitleBlockPropertiesWidget *titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, &popup);
|
||||||
if (QETProject *parent_project = scene -> project()) {
|
if (QETProject *parent_project = scene -> project()) {
|
||||||
titleblock_infos -> setTitleBlockTemplatesList(parent_project -> embeddedTitleBlockTemplates());
|
titleblock_infos -> setTitleBlockTemplatesCollection(parent_project -> embeddedTitleBlockTemplatesCollection());
|
||||||
titleblock_infos -> setTitleBlockTemplatesVisible(true);
|
titleblock_infos -> setTitleBlockTemplatesVisible(true);
|
||||||
// we have to parse again the TitleBlockProperties object, since the
|
// we have to parse again the TitleBlockProperties object, since the
|
||||||
// first parsing did not know of our templates
|
// first parsing did not know of our templates
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ bool QETTitleBlockTemplateEditor::canClose() {
|
|||||||
*/
|
*/
|
||||||
bool QETTitleBlockTemplateEditor::event(QEvent *event) {
|
bool QETTitleBlockTemplateEditor::event(QEvent *event) {
|
||||||
if (first_activation_ && event -> type() == QEvent::WindowActivate) {
|
if (first_activation_ && event -> type() == QEvent::WindowActivate) {
|
||||||
if (duplicate_ && !opened_from_file_ && location_.isValid()) {
|
if (duplicate_ && !opened_from_file_ && location_.parentCollection()) {
|
||||||
// this editor is supposed to duplicate its current location
|
// this editor is supposed to duplicate its current location
|
||||||
QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
|
QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
|
||||||
}
|
}
|
||||||
@@ -139,13 +139,20 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation() {
|
|||||||
// this method does not work for templates edited from the filesystem
|
// this method does not work for templates edited from the filesystem
|
||||||
if (opened_from_file_) return;
|
if (opened_from_file_) return;
|
||||||
|
|
||||||
|
QString proposed_name;
|
||||||
|
if (location_.name().isEmpty()) {
|
||||||
|
proposed_name = tr("nouveau_modele", "template name suggestion when duplicating the default one");
|
||||||
|
} else {
|
||||||
|
proposed_name = QString("%1_copy").arg(location_.name());
|
||||||
|
}
|
||||||
|
|
||||||
bool accepted = false;
|
bool accepted = false;
|
||||||
QString new_template_name = QInputDialog::getText(
|
QString new_template_name = QInputDialog::getText(
|
||||||
this,
|
this,
|
||||||
tr("Dupliquer un mod\350le de cartouche", "input dialog title"),
|
tr("Dupliquer un mod\350le de cartouche", "input dialog title"),
|
||||||
tr("Pour dupliquer ce mod\350le, entrez le nom voulu pour sa copie", "input dialog text"),
|
tr("Pour dupliquer ce mod\350le, entrez le nom voulu pour sa copie", "input dialog text"),
|
||||||
QLineEdit::Normal,
|
QLineEdit::Normal,
|
||||||
QString("%1_copy").arg(location_.name()),
|
proposed_name,
|
||||||
&accepted
|
&accepted
|
||||||
);
|
);
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "titleblockpropertieswidget.h"
|
#include "titleblockpropertieswidget.h"
|
||||||
#include "qeticons.h"
|
#include "qeticons.h"
|
||||||
|
#include "templatescollection.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -26,7 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) :
|
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
display_current_date(false)
|
display_current_date(false),
|
||||||
|
tbt_collection_(0)
|
||||||
{
|
{
|
||||||
initWidgets(titleblock);
|
initWidgets(titleblock);
|
||||||
initLayouts();
|
initLayouts();
|
||||||
@@ -167,6 +169,21 @@ void TitleBlockPropertiesWidget::setTitleBlockTemplatesList(const QList<QString>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param tbt_collection Collection from which title block templates should be read.
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *tbt_collection) {
|
||||||
|
if (!tbt_collection) return;
|
||||||
|
if (tbt_collection_ && tbt_collection != tbt_collection_) {
|
||||||
|
// forget any connection with the previous collection
|
||||||
|
disconnect(tbt_collection_, 0, this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
tbt_collection_ = tbt_collection;
|
||||||
|
updateTemplateList();
|
||||||
|
connect(tbt_collection_, SIGNAL(changed(TitleBlockTemplatesCollection*, QString)), this, SLOT(updateTemplateList()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param visible true to display the title block templates list, false to
|
@param visible true to display the title block templates list, false to
|
||||||
hide it.
|
hide it.
|
||||||
@@ -188,6 +205,17 @@ QString TitleBlockPropertiesWidget::currentTitleBlockTemplateName() const {
|
|||||||
return(QString());
|
return(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the currently selected title block template.
|
||||||
|
@param template_name Template to be selected
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::setCurrentTitleBlockTemplateName(const QString &template_name) {
|
||||||
|
int matching_index = titleblock_template_name -> findData(template_name);
|
||||||
|
if (matching_index != -1) {
|
||||||
|
titleblock_template_name -> setCurrentIndex(matching_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a row in the additional fields table if needed.
|
Adds a row in the additional fields table if needed.
|
||||||
*/
|
*/
|
||||||
@@ -200,13 +228,22 @@ void TitleBlockPropertiesWidget::checkTableRows() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update the title block templates list.
|
||||||
|
*/
|
||||||
|
void TitleBlockPropertiesWidget::updateTemplateList() {
|
||||||
|
if (!tbt_collection_) return;
|
||||||
|
|
||||||
|
QString current_template_name = currentTitleBlockTemplateName();
|
||||||
|
setTitleBlockTemplatesList(tbt_collection_ -> templates());
|
||||||
|
setCurrentTitleBlockTemplateName(current_template_name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Edit the currently selected title block template
|
Edit the currently selected title block template
|
||||||
*/
|
*/
|
||||||
void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
|
void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
|
||||||
QString current_template_name = currentTitleBlockTemplateName();
|
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), false));
|
||||||
if (current_template_name.isEmpty()) return;
|
|
||||||
emit(editTitleBlockTemplate(current_template_name, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,9 +251,7 @@ void TitleBlockPropertiesWidget::editCurrentTitleBlockTemplate() {
|
|||||||
for a name), then edit it.
|
for a name), then edit it.
|
||||||
*/
|
*/
|
||||||
void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() {
|
void TitleBlockPropertiesWidget::duplicateCurrentTitleBlockTemplate() {
|
||||||
QString current_template_name = currentTitleBlockTemplateName();
|
emit(editTitleBlockTemplate(currentTitleBlockTemplateName(), true));
|
||||||
if (current_template_name.isEmpty()) return;
|
|
||||||
emit(editTitleBlockTemplate(current_template_name, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define TITLEBLOCK_PROPERTIES_WIDGET_H
|
#define TITLEBLOCK_PROPERTIES_WIDGET_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "titleblockproperties.h"
|
#include "titleblockproperties.h"
|
||||||
|
class TitleBlockTemplatesCollection;
|
||||||
/**
|
/**
|
||||||
Ce widget permet d'editer un objet TitleBlockProperties, c'est-a-dire les
|
Ce widget permet d'editer un objet TitleBlockProperties, c'est-a-dire les
|
||||||
valeurs affichees par le cartouche d'un schema.
|
valeurs affichees par le cartouche d'un schema.
|
||||||
@@ -40,12 +41,15 @@ class TitleBlockPropertiesWidget : public QWidget {
|
|||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void setReadOnly(bool);
|
void setReadOnly(bool);
|
||||||
void setTitleBlockTemplatesList(const QList<QString> &);
|
void setTitleBlockTemplatesList(const QList<QString> &);
|
||||||
|
void setTitleBlockTemplatesCollection(TitleBlockTemplatesCollection *);
|
||||||
void setTitleBlockTemplatesVisible(bool);
|
void setTitleBlockTemplatesVisible(bool);
|
||||||
QString currentTitleBlockTemplateName() const;
|
QString currentTitleBlockTemplateName() const;
|
||||||
|
void setCurrentTitleBlockTemplateName(const QString &);
|
||||||
|
|
||||||
// slots:
|
// slots:
|
||||||
private slots:
|
private slots:
|
||||||
void checkTableRows();
|
void checkTableRows();
|
||||||
|
void updateTemplateList();
|
||||||
void editCurrentTitleBlockTemplate();
|
void editCurrentTitleBlockTemplate();
|
||||||
void duplicateCurrentTitleBlockTemplate();
|
void duplicateCurrentTitleBlockTemplate();
|
||||||
|
|
||||||
@@ -80,5 +84,6 @@ class TitleBlockPropertiesWidget : public QWidget {
|
|||||||
QLabel *additional_fields_label;
|
QLabel *additional_fields_label;
|
||||||
QTableWidget *additional_fields_table;
|
QTableWidget *additional_fields_table;
|
||||||
QTabBar *tabbar;
|
QTabBar *tabbar;
|
||||||
|
TitleBlockTemplatesCollection *tbt_collection_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user