QElectroTech  0.8-dev
qettemplateeditor.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TITLEBLOCK_SLASH_QET_TEMPLATE_EDITOR_H
19 #define TITLEBLOCK_SLASH_QET_TEMPLATE_EDITOR_H
20 #include <QtWidgets>
21 #include "qetmainwindow.h"
22 #include "qet.h"
23 #include "templateview.h"
24 #include "templatelocation.h"
29 class QETProject;
30 
37  Q_OBJECT
38 
39  // constructor, destructor
40  public:
41  QETTitleBlockTemplateEditor(QWidget * = nullptr);
43  private:
45 
46  // attributes
47  private:
57  QString filepath_;
61  bool read_only_;
66  bool duplicate_;
80  QUndoStack *undo_stack_;
81  QUndoView *undo_view_;
82  QDockWidget *undo_dock_widget_;
83 
84  // methods
85  public:
87  bool isEditing(const QString &ilepath);
88  void setOpenForDuplication(bool);
89  bool openForDuplication() const;
90 
91  protected:
92  bool canClose();
93  void firstActivation(QEvent *) override;
94  void closeEvent(QCloseEvent *) override;
95 
96  private:
97  void initActions();
98  void initMenus();
99  void initToolbars();
100  void initWidgets();
101  void initLogoManager();
102  QString currentlyEditedTitle() const;
103 
104  public slots:
105  void readSettings();
106  void writeSettings();
107  void selectedCellsChanged(const QList<TitleBlockCell *>&);
109  bool edit(const TitleBlockTemplateLocation &);
110  bool edit(QETProject *, const QString &);
111  bool edit(const QString &);
112  bool editCopyOf(const TitleBlockTemplate *);
113  bool edit(TitleBlockTemplate *);
114  void editLogos();
115  void newTemplate();
116  void open();
117  void openFromFile();
118  bool save();
119  bool saveAs();
120  bool saveAsFile();
121  void setReadOnly(bool);
122  void quit();
125 
126  private slots:
127  TitleBlockTemplateLocation getTitleBlockTemplateLocationFromUser(const QString & = QString(), bool existing_only = true);
130  void pushUndoCommand(QUndoCommand *);
131  void updateEditorTitle();
132  void updateActions();
133  bool saveAs(const TitleBlockTemplateLocation &);
134  bool saveAs(const QString &);
135 };
136 
137 #endif
QETTitleBlockTemplateEditor::cut_
QAction * cut_
Definition: qettemplateeditor.h:52
TitleBlockTemplateLogoManager
Definition: templatelogomanager.h:27
templatelocationsaver.h
QET::Icons::DocumentNew
QIcon DocumentNew
Definition: qeticons.cpp:53
QET::Icons::UserInformations
QIcon UserInformations
Definition: qeticons.cpp:169
QETTitleBlockTemplateEditor::display_menu_
QMenu * display_menu_
Definition: qettemplateeditor.h:49
QETTitleBlockTemplateEditor::~QETTitleBlockTemplateEditor
~QETTitleBlockTemplateEditor() override
Definition: qettemplateeditor.cpp:54
QETApp::customTitleBlockTemplatesDir
static QString customTitleBlockTemplatesDir()
QETApp::customTitleBlockTemplatesDir.
Definition: qetapp.cpp:758
QETTitleBlockTemplateEditor::paste_
QAction * paste_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::editLogos
void editLogos()
Definition: qettemplateeditor.cpp:297
QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor
QETTitleBlockTemplateEditor(QWidget *=nullptr)
Definition: qettemplateeditor.cpp:33
QETTitleBlockTemplateEditor::selectedCellsChanged
void selectedCellsChanged(const QList< TitleBlockCell * > &)
Definition: qettemplateeditor.cpp:620
QET::Icons::ZoomFitBest
QIcon ZoomFitBest
Definition: qeticons.cpp:178
QET::Icons::EditTableCellSplit
QIcon EditTableCellSplit
Definition: qeticons.cpp:74
QET::Icons::EditCopy
QIcon EditCopy
Definition: qeticons.cpp:64
QET::Icons::DocumentOpen
QIcon DocumentOpen
Definition: qeticons.cpp:54
QETApp::realPath
static QString realPath(const QString &)
QETApp::realPath Allows you to know the absolute path of the * .elmt file corresponding to a symbolic...
Definition: qetapp.cpp:842
QETTitleBlockTemplateEditor
Definition: qettemplateeditor.h:36
QETTitleBlockTemplateEditor::edit
bool edit(const TitleBlockTemplateLocation &)
Definition: qettemplateeditor.cpp:187
QETTitleBlockTemplateEditor::filepath_
QString filepath_
Filepath of the currently edited template, if opened from a file.
Definition: qettemplateeditor.h:57
QETMainWindow
Definition: qetmainwindow.h:26
QET::Icons::ZoomIn
QIcon ZoomIn
Definition: qeticons.cpp:179
QETTitleBlockTemplateEditor::updateActions
void updateActions()
Definition: qettemplateeditor.cpp:689
QETTitleBlockTemplateEditor::pushCellUndoCommand
void pushCellUndoCommand(ModifyTitleBlockCellCommand *)
Definition: qettemplateeditor.cpp:634
QETTitleBlockTemplateEditor::pushGridUndoCommand
void pushGridUndoCommand(TitleBlockTemplateCommand *)
Definition: qettemplateeditor.cpp:643
qettemplateeditor.h
qetmainwindow.h
TitleBlockTemplateLocationSaver
Definition: templatelocationsaver.h:30
QETTitleBlockTemplateEditor::canClose
bool canClose()
Definition: qettemplateeditor.cpp:107
QETTitleBlockTemplateEditor::saveAsFile
bool saveAsFile()
Definition: qettemplateeditor.cpp:825
QET::Icons::ZoomOut
QIcon ZoomOut
Definition: qeticons.cpp:181
QETTitleBlockTemplateEditor::getTitleBlockTemplateLocationFromUser
TitleBlockTemplateLocation getTitleBlockTemplateLocationFromUser(const QString &=QString(), bool existing_only=true)
Definition: qettemplateeditor.cpp:878
QETTitleBlockTemplateEditor::openFromFile
void openFromFile()
Definition: qettemplateeditor.cpp:765
QET::Icons::EditUndo
QIcon EditUndo
Definition: qeticons.cpp:82
TitleBlockTemplateLocation::setName
void setName(const QString &)
Definition: templatelocation.cpp:80
TitleBlockTemplateLocation::setParentCollection
void setParentCollection(TitleBlockTemplatesCollection *)
TitleBlockTemplateLocation::setParentCollection.
Definition: templatelocation.cpp:65
QETTitleBlockTemplateEditor::first_activation_
bool first_activation_
Used to track the first activation of the editor main window.
Definition: qettemplateeditor.h:68
TitleBlockTemplateView
Definition: templateview.h:32
QETTitleBlockTemplateEditor::save_
QAction * save_
Definition: qettemplateeditor.h:51
TitleBlockTemplatesProjectCollection::getTemplate
TitleBlockTemplate * getTemplate(const QString &) override
Definition: templatescollection.cpp:191
QETTitleBlockTemplateEditor::template_edition_area_view_
TitleBlockTemplateView * template_edition_area_view_
Definition: qettemplateeditor.h:73
QETTitleBlockTemplateEditor::zoom_fit_
QAction * zoom_fit_
Definition: qettemplateeditor.h:53
QETTitleBlockTemplateEditor::editTemplateInformation
void editTemplateInformation()
Definition: qettemplateeditor.cpp:927
QETTitleBlockTemplateEditor::quit_
QAction * quit_
Definition: qettemplateeditor.h:51
TitleBlockTemplateLocationChooser
Definition: templatelocationchooser.h:28
qetmessagebox.h
QETTitleBlockTemplateEditor::edit_info_
QAction * edit_info_
Definition: qettemplateeditor.h:52
QETMainWindow::event
bool event(QEvent *) override
Definition: qetmainwindow.cpp:233
QETTitleBlockTemplateEditor::currentlyEditedTitle
QString currentlyEditedTitle() const
Definition: qettemplateeditor.cpp:560
QETTitleBlockTemplateEditor::quit
void quit()
Definition: qettemplateeditor.cpp:907
ChangeTemplateInformationsCommand
Definition: templatecommands.h:239
templatecellwidget.h
qetapp.h
QETTitleBlockTemplateEditor::location
TitleBlockTemplateLocation location() const
Definition: qettemplateeditor.cpp:60
QETProject::embeddedTitleBlockTemplatesCollection
TitleBlockTemplatesProjectCollection * embeddedTitleBlockTemplatesCollection()
Definition: qetproject.cpp:243
QETTitleBlockTemplateEditor::initActions
void initActions()
Definition: qettemplateeditor.cpp:333
QETTitleBlockTemplateEditor::undo_view_
QUndoView * undo_view_
Definition: qettemplateeditor.h:81
QET::TitleBlockTemplate
@ TitleBlockTemplate
Definition: qet.h:105
QETTitleBlockTemplateEditor::save_as_file_
QAction * save_as_file_
Definition: qettemplateeditor.h:51
QETTitleBlockTemplateEditor::initMenus
void initMenus()
Definition: qettemplateeditor.cpp:405
TitleBlockTemplate
The TitleBlockTemplate class This class represents an title block template for an electric diagram....
Definition: titleblocktemplate.h:36
templatecommands.h
QETMainWindow::insertMenu
void insertMenu(QMenu *, QMenu *, bool=true)
Definition: qetmainwindow.cpp:172
qeticons.h
qet.h
ModifyTitleBlockCellCommand
Definition: templatecommands.h:33
QETTitleBlockTemplateEditor::duplicateCurrentLocation
void duplicateCurrentLocation()
Definition: qettemplateeditor.cpp:158
QETTitleBlockTemplateEditor::open
void open()
Definition: qettemplateeditor.cpp:751
QET::QetMessageBox::question
QMessageBox::StandardButton question(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
Definition: qetmessagebox.cpp:53
QETTitleBlockTemplateEditor::template_cell_editor_dock_widget_
QDockWidget * template_cell_editor_dock_widget_
Individual cell widget edition.
Definition: qettemplateeditor.h:75
TitleBlockTemplateLocation::isReadOnly
bool isReadOnly() const
Definition: templatelocation.cpp:156
QETTitleBlockTemplateEditor::save
bool save()
Definition: qettemplateeditor.cpp:789
QETTitleBlockTemplateEditor::save_as_
QAction * save_as_
Definition: qettemplateeditor.h:51
TitleBlockTemplateLocation::isValid
bool isValid() const
Definition: templatelocation.cpp:87
TitleBlockTemplateLocation
Definition: templatelocation.h:29
QET::QetMessageBox::information
QMessageBox::StandardButton information(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
Definition: qetmessagebox.cpp:38
QETTitleBlockTemplateEditor::read_only_
bool read_only_
whether the currently edited template is considered read only
Definition: qettemplateeditor.h:61
QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings
void savePreviewWidthToApplicationSettings(int, int)
QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings Save the new preview width to appl...
Definition: qettemplateeditor.cpp:917
QETTitleBlockTemplateEditor::template_edition_area_scene_
QGraphicsScene * template_edition_area_scene_
Template preview.
Definition: qettemplateeditor.h:72
TitleBlockTemplateLocation::toString
QString toString() const
Definition: templatelocation.cpp:108
QETTitleBlockTemplateEditor::add_col_
QAction * add_col_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::merge_cells_
QAction * merge_cells_
Definition: qettemplateeditor.h:52
TitleBlockTemplateCellWidget
The TitleBlockTemplateCellWidget class This class implements an edition widget for cells that compose...
Definition: templatecellwidget.h:32
QETTitleBlockTemplateEditor::edit_logos_
QAction * edit_logos_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::split_cell_
QAction * split_cell_
Definition: qettemplateeditor.h:52
QET::Icons::EditTableCellMerge
QIcon EditTableCellMerge
Definition: qeticons.cpp:73
QETTitleBlockTemplateEditor::editCopyOf
bool editCopyOf(const TitleBlockTemplate *)
Definition: qettemplateeditor.cpp:275
QETTitleBlockTemplateEditor::undo_stack_
QUndoStack * undo_stack_
Undo interface.
Definition: qettemplateeditor.h:80
templateview.h
QET::Icons::QETLogo
QIcon QETLogo
Definition: qeticons.cpp:151
QET::Icons::EditRedo
QIcon EditRedo
Definition: qeticons.cpp:68
QETTitleBlockTemplateEditor::initWidgets
void initWidgets()
Definition: qettemplateeditor.cpp:476
QETTitleBlockTemplateEditor::setOpenForDuplication
void setOpenForDuplication(bool)
QETTitleBlockTemplateEditor::setOpenForDuplication.
Definition: qettemplateeditor.cpp:90
qetproject.h
QETTitleBlockTemplateEditor::undo_dock_widget_
QDockWidget * undo_dock_widget_
Definition: qettemplateeditor.h:82
QET::compareCanonicalFilePaths
bool compareCanonicalFilePaths(const QString &, const QString &)
Definition: qet.cpp:559
QETTitleBlockTemplateEditor::file_menu_
QMenu * file_menu_
menus TODO
Definition: qettemplateeditor.h:49
QETTitleBlockTemplateEditor::zoom_in_
QAction * zoom_in_
Definition: qettemplateeditor.h:53
QETTitleBlockTemplateEditor::template_cell_editor_widget_
TitleBlockTemplateCellWidget * template_cell_editor_widget_
Definition: qettemplateeditor.h:76
QETMainWindow::settings_menu_
QMenu * settings_menu_
Settings menu.
Definition: qetmainwindow.h:65
QETApp::instance
static QETApp * instance()
QETApp::instance.
Definition: qetapp.cpp:153
QETTitleBlockTemplateEditor::saveAs
bool saveAs()
Definition: qettemplateeditor.cpp:811
QETTitleBlockTemplateEditor::edit_menu_
QMenu * edit_menu_
Definition: qettemplateeditor.h:49
QETTitleBlockTemplateEditor::writeSettings
void writeSettings()
QETTitleBlockTemplateEditor::writeSettings Write the settings.
Definition: qettemplateeditor.cpp:609
QET::Icons::ZoomOriginal
QIcon ZoomOriginal
Definition: qeticons.cpp:180
QETProject
Definition: qetproject.h:51
QETTitleBlockTemplateEditor::newTemplate
void newTemplate()
Definition: qettemplateeditor.cpp:324
QETTitleBlockTemplateEditor::location_
TitleBlockTemplateLocation location_
Location of the currently edited template.
Definition: qettemplateeditor.h:55
templatelogomanager.h
QET::Icons::InsertImage
QIcon InsertImage
Definition: qeticons.cpp:116
QETTitleBlockTemplateEditor::redo_
QAction * redo_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::tb_template_
TitleBlockTemplate * tb_template_
Template Object edited.
Definition: qettemplateeditor.h:70
QETTitleBlockTemplateEditor::new_
QAction * new_
actions
Definition: qettemplateeditor.h:51
QETTitleBlockTemplateEditor::initLogoManager
void initLogoManager()
Definition: qettemplateeditor.cpp:545
QETTitleBlockTemplateEditor::duplicate_
bool duplicate_
Definition: qettemplateeditor.h:66
TitleBlockTemplateLocation::parentCollection
TitleBlockTemplatesCollection * parentCollection() const
Definition: templatelocation.cpp:57
QET::Icons::EditTableInsertRowAbove
QIcon EditTableInsertRowAbove
Definition: qeticons.cpp:79
QETTitleBlockTemplateEditor::pushUndoCommand
void pushUndoCommand(QUndoCommand *)
Definition: qettemplateeditor.cpp:651
QETTitleBlockTemplateEditor::opened_from_file_
bool opened_from_file_
Whether to consider the location or the filepath.
Definition: qettemplateeditor.h:59
QETTitleBlockTemplateEditor::openForDuplication
bool openForDuplication() const
Definition: qettemplateeditor.cpp:98
QET::Icons::EditPaste
QIcon EditPaste
Definition: qeticons.cpp:67
QETTitleBlockTemplateEditor::isEditing
bool isEditing(const QString &ilepath)
Definition: qettemplateeditor.cpp:68
QET::Icons::DocumentSave
QIcon DocumentSave
Definition: qeticons.cpp:58
TitleBlockTemplateLocation::getTemplate
TitleBlockTemplate * getTemplate() const
Definition: templatelocation.cpp:147
QETTitleBlockTemplateEditor::logo_manager_
TitleBlockTemplateLogoManager * logo_manager_
Logo manager widget.
Definition: qettemplateeditor.h:78
TitleBlockTemplatesCollection
Definition: templatescollection.h:34
QETTitleBlockTemplateEditor::setReadOnly
void setReadOnly(bool)
Definition: qettemplateeditor.cpp:857
QETTitleBlockTemplateEditor::zoom_reset_
QAction * zoom_reset_
Definition: qettemplateeditor.h:53
QETApp::defaultTitleBlockTemplate
static TitleBlockTemplate * defaultTitleBlockTemplate()
QETApp::defaultTitleBlockTemplate.
Definition: qetapp.cpp:1294
QETTitleBlockTemplateEditor::undo_
QAction * undo_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::updateEditorTitle
void updateEditorTitle()
Definition: qettemplateeditor.cpp:658
QET::Icons::EditTableInsertColumnRight
QIcon EditTableInsertColumnRight
Definition: qeticons.cpp:78
templatelocation.h
QETTitleBlockTemplateEditor::initToolbars
void initToolbars()
Definition: qettemplateeditor.cpp:446
TITLEBLOCKS_FILE_EXTENSION
#define TITLEBLOCKS_FILE_EXTENSION
Definition: templatescollection.h:20
QETTitleBlockTemplateEditor::add_row_
QAction * add_row_
Definition: qettemplateeditor.h:52
QETTitleBlockTemplateEditor::open_from_file_
QAction * open_from_file_
Definition: qettemplateeditor.h:51
QETTitleBlockTemplateEditor::firstActivation
void firstActivation(QEvent *) override
Definition: qettemplateeditor.cpp:134
QETTitleBlockTemplateEditor::readSettings
void readSettings()
QETTitleBlockTemplateEditor::readSettings Read settings.
Definition: qettemplateeditor.cpp:592
TitleBlockTemplateCommand
Definition: templatecommands.h:66
QETTitleBlockTemplateEditor::zoom_out_
QAction * zoom_out_
Definition: qettemplateeditor.h:53
QETTitleBlockTemplateEditor::copy_
QAction * copy_
Definition: qettemplateeditor.h:52
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
QET::Icons::EditCut
QIcon EditCut
Definition: qeticons.cpp:65
QETTitleBlockTemplateEditor::open_
QAction * open_
Definition: qettemplateeditor.h:51
QET::Icons::DocumentSaveAs
QIcon DocumentSaveAs
Definition: qeticons.cpp:60
QET::Icons::Cancel
QIcon Cancel
Definition: qeticons.cpp:34
TitleBlockTemplateLocation::name
QString name() const
Definition: templatelocation.cpp:73
QETTitleBlockTemplateEditor::closeEvent
void closeEvent(QCloseEvent *) override
Definition: qettemplateeditor.cpp:146
QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor
QETTitleBlockTemplateEditor(const QETTitleBlockTemplateEditor &)
QET::Icons::ApplicationExit
QIcon ApplicationExit
Definition: qeticons.cpp:27