mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-03 11:00:53 +01:00
When editing a diagram, it is now possible to edit and/or duplicate a title block template from the title block properties dialog.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1479 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -34,6 +34,8 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
opened_from_file_(false),
|
||||
read_only_(false),
|
||||
duplicate_(false),
|
||||
first_activation_(true),
|
||||
tb_template_(0),
|
||||
logo_manager_(0)
|
||||
{
|
||||
@@ -59,6 +61,22 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::location() const {
|
||||
return(location_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param true for this editor to prompt the user for a new template name as
|
||||
soon as the window appears in order to duplicate the edited one.
|
||||
*/
|
||||
void QETTitleBlockTemplateEditor::setOpenForDuplication(bool duplicate) {
|
||||
duplicate_ = duplicate;
|
||||
}
|
||||
|
||||
/**
|
||||
@return true if this editor will prompt the user for a new template name as
|
||||
soon as the window appears in order to duplicate the edited one.
|
||||
*/
|
||||
bool QETTitleBlockTemplateEditor::openForDuplication() const {
|
||||
return(duplicate_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true if the currently edited template can be closed. A template can be
|
||||
closed if it has not been modified. If the template has been modified, this
|
||||
@@ -88,6 +106,20 @@ bool QETTitleBlockTemplateEditor::canClose() {
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@param event Object describing the received event.
|
||||
*/
|
||||
bool QETTitleBlockTemplateEditor::event(QEvent *event) {
|
||||
if (first_activation_ && event -> type() == QEvent::WindowActivate) {
|
||||
if (duplicate_ && !opened_from_file_ && location_.isValid()) {
|
||||
// this editor is supposed to duplicate its current location
|
||||
QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
|
||||
}
|
||||
first_activation_ = false;
|
||||
}
|
||||
return(QMainWindow::event(event));
|
||||
}
|
||||
|
||||
/**
|
||||
Handle the closing of the main window
|
||||
@param qce The QCloseEvent event
|
||||
@@ -99,6 +131,29 @@ void QETTitleBlockTemplateEditor::closeEvent(QCloseEvent *qce) {
|
||||
} else qce -> ignore();
|
||||
}
|
||||
|
||||
/**
|
||||
Ask the user for a new template name in order to duplicate the currently
|
||||
edited template.
|
||||
*/
|
||||
void QETTitleBlockTemplateEditor::duplicateCurrentLocation() {
|
||||
// this method does not work for templates edited from the filesystem
|
||||
if (opened_from_file_) return;
|
||||
|
||||
bool accepted = false;
|
||||
QString new_template_name = QInputDialog::getText(
|
||||
this,
|
||||
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"),
|
||||
QLineEdit::Normal,
|
||||
QString("%1_copy").arg(location_.name()),
|
||||
&accepted
|
||||
);
|
||||
if (accepted) {
|
||||
TitleBlockTemplateLocation new_template_location(new_template_name, location_.parentCollection());
|
||||
saveAs(new_template_location);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param location Location of the tile block template to be edited.
|
||||
*/
|
||||
@@ -665,13 +720,14 @@ bool QETTitleBlockTemplateEditor::saveAsFile() {
|
||||
currently edited template, false to allow full edition.
|
||||
*/
|
||||
void QETTitleBlockTemplateEditor::setReadOnly(bool read_only) {
|
||||
if (read_only == read_only_) return;
|
||||
read_only_ = read_only;
|
||||
if (logo_manager_) {
|
||||
logo_manager_ -> setReadOnly(read_only_);
|
||||
if (read_only != read_only_) {
|
||||
read_only_ = read_only;
|
||||
if (logo_manager_) {
|
||||
logo_manager_ -> setReadOnly(read_only_);
|
||||
}
|
||||
template_cell_editor_widget_ -> setReadOnly(read_only_);
|
||||
template_edition_area_view_ -> setReadOnly(read_only_);
|
||||
}
|
||||
template_cell_editor_widget_ -> setReadOnly(read_only_);
|
||||
template_edition_area_view_ -> setReadOnly(read_only_);
|
||||
updateActions();
|
||||
updateEditorTitle();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,13 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
|
||||
bool opened_from_file_;
|
||||
/// whether the currently edited template is considered read only
|
||||
bool read_only_;
|
||||
/**
|
||||
Whether to ask the user a new template name when the window appears in order
|
||||
to rename the edited template.
|
||||
*/
|
||||
bool duplicate_;
|
||||
/// Used to track the first activation of the editor main window.
|
||||
bool first_activation_;
|
||||
/// Template Object edited
|
||||
TitleBlockTemplate *tb_template_;
|
||||
/// Template preview
|
||||
@@ -78,9 +85,12 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
|
||||
// methods
|
||||
public:
|
||||
TitleBlockTemplateLocation location() const;
|
||||
void setOpenForDuplication(bool);
|
||||
bool openForDuplication() const;
|
||||
|
||||
protected:
|
||||
bool canClose();
|
||||
bool event(QEvent *);
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
@@ -92,6 +102,7 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
|
||||
|
||||
public slots:
|
||||
void selectedCellsChanged(QList<TitleBlockCell *>);
|
||||
void duplicateCurrentLocation();
|
||||
bool edit(const TitleBlockTemplateLocation &);
|
||||
bool edit(QETProject *, const QString &);
|
||||
bool edit(const QString &);
|
||||
|
||||
Reference in New Issue
Block a user