2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2014-01-29 18:37:45 +00:00
|
|
|
Copyright 2006-2014 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
|
|
|
#define CUSTOM_ELEMENT_EDITOR_H
|
|
|
|
#include <QtGui>
|
2012-02-13 22:13:19 +00:00
|
|
|
#include "qetmainwindow.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "qet.h"
|
2007-08-25 03:43:05 +00:00
|
|
|
#include "elementscene.h"
|
2007-06-30 17:41:07 +00:00
|
|
|
#include "orientationset.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
#include "elementslocation.h"
|
2010-02-18 00:42:41 +00:00
|
|
|
class ElementItemEditor;
|
2007-08-25 03:43:05 +00:00
|
|
|
class ElementView;
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This class represents an element editor, allowing users to draw, change and
|
|
|
|
configure a particular electrical element.
|
2007-10-21 16:10:21 +00:00
|
|
|
*/
|
2012-02-13 22:13:19 +00:00
|
|
|
class QETElementEditor : public QETMainWindow {
|
2007-06-30 17:41:07 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// constructor, destructor
|
2007-06-30 17:41:07 +00:00
|
|
|
public:
|
2007-08-25 03:43:05 +00:00
|
|
|
QETElementEditor(QWidget * = 0);
|
|
|
|
virtual ~QETElementEditor();
|
2007-06-30 17:41:07 +00:00
|
|
|
private:
|
2007-08-25 03:43:05 +00:00
|
|
|
QETElementEditor(const QETElementEditor &);
|
2007-06-30 17:41:07 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// attributes
|
2007-06-30 17:41:07 +00:00
|
|
|
private:
|
2012-11-09 21:09:24 +00:00
|
|
|
/// whether the editor is "read-only"
|
2007-06-30 17:41:07 +00:00
|
|
|
bool read_only;
|
|
|
|
/// menus
|
2012-02-13 22:13:19 +00:00
|
|
|
QMenu *file_menu, *edit_menu, *paste_from_menu, *display_menu, *tools_menu;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// view widget for the editing scene
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementView *ce_view;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// editing scene
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementScene *ce_scene;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// container for widgets dedicated to primitive edition
|
2007-06-30 17:41:07 +00:00
|
|
|
QDockWidget *tools_dock;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Stack of widgets for tools_dock
|
2009-04-03 19:30:25 +00:00
|
|
|
QStackedWidget *tools_dock_stack_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// label displayed when several primitives are selected
|
2009-04-03 19:30:25 +00:00
|
|
|
QLabel *default_informations;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Hash associating primitive names with their matching edition widget
|
2010-02-18 00:42:41 +00:00
|
|
|
QHash<QString, ElementItemEditor *> editors_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// ScrollArea for the tools_dock DockWidget
|
2009-04-03 19:30:25 +00:00
|
|
|
QScrollArea *tools_dock_scroll_area_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// container for the undo list
|
2007-08-23 15:33:55 +00:00
|
|
|
QDockWidget *undo_dock;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Container for the list of existing primitives
|
2007-11-07 20:23:24 +00:00
|
|
|
QDockWidget *parts_dock;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// List of primitives
|
2007-11-07 20:23:24 +00:00
|
|
|
QListWidget *parts_list;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// actions for the "file" menu
|
2009-04-03 19:30:25 +00:00
|
|
|
QAction *new_element, *open, *open_file, *save, *save_as, *save_as_file, *reload, *quit;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// actions for the "edit" menu
|
2007-06-30 17:41:07 +00:00
|
|
|
QAction *selectall, *deselectall, *inv_select;
|
2009-11-22 16:12:22 +00:00
|
|
|
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
|
2007-08-25 04:33:32 +00:00
|
|
|
QAction *undo, *redo;
|
2014-06-03 20:21:19 +00:00
|
|
|
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
|
2007-10-07 18:52:01 +00:00
|
|
|
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// actions for the "display" menu
|
2009-06-19 19:31:48 +00:00
|
|
|
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// toolbars
|
2008-01-07 19:40:08 +00:00
|
|
|
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// toolbars actions
|
2007-06-30 17:41:07 +00:00
|
|
|
QActionGroup *parts;
|
2013-02-11 21:45:51 +00:00
|
|
|
QAction *move, *add_line, *add_rectangle, *add_ellipse, *add_polygon, *add_text;
|
2007-06-30 17:41:07 +00:00
|
|
|
QAction *add_arc, *add_terminal, *add_textfield;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// minimum window title
|
2007-06-30 17:41:07 +00:00
|
|
|
QString min_title;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// filename of the currently edited element
|
2009-04-03 19:30:25 +00:00
|
|
|
QString filename_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// location of the currently edited element
|
2009-04-03 19:30:25 +00:00
|
|
|
ElementsLocation location_;
|
2012-11-09 21:09:24 +00:00
|
|
|
/// whether the currently edited element comes from a file or a location
|
2009-04-03 19:30:25 +00:00
|
|
|
bool opened_from_file;
|
2007-06-30 17:41:07 +00:00
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
// methods
|
2007-06-30 17:41:07 +00:00
|
|
|
public:
|
|
|
|
void setNames(const NamesList &);
|
|
|
|
OrientationSet orientations() const;
|
2009-04-03 19:30:25 +00:00
|
|
|
void setLocation(const ElementsLocation &);
|
|
|
|
ElementsLocation location() const;
|
2007-06-30 17:41:07 +00:00
|
|
|
void setFileName(const QString &);
|
|
|
|
QString fileName() const;
|
|
|
|
void setReadOnly(bool);
|
|
|
|
bool isReadOnly() const;
|
|
|
|
void fromFile(const QString &);
|
2009-04-03 19:30:25 +00:00
|
|
|
void fromLocation(const ElementsLocation &);
|
2007-06-30 17:41:07 +00:00
|
|
|
bool toFile(const QString &);
|
2009-04-03 19:30:25 +00:00
|
|
|
bool toLocation(const ElementsLocation &);
|
2010-03-28 16:27:48 +00:00
|
|
|
bool isEditing(const ElementsLocation &);
|
|
|
|
bool isEditing(const QString &);
|
2007-08-25 03:43:05 +00:00
|
|
|
ElementScene *elementScene() const;
|
2007-11-12 15:21:14 +00:00
|
|
|
void readSettings();
|
|
|
|
void writeSettings();
|
2009-04-03 19:30:25 +00:00
|
|
|
static QPointF pasteOffset();
|
2009-11-22 16:12:22 +00:00
|
|
|
static QString getOpenElementFileName(QWidget * = 0, const QString & = QString());
|
2013-09-17 20:14:30 +00:00
|
|
|
void contextMenu(QContextMenuEvent *event);
|
|
|
|
|
2007-06-30 17:41:07 +00:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
2012-03-16 18:01:32 +00:00
|
|
|
virtual void firstActivation(QEvent *);
|
2013-09-14 13:11:32 +00:00
|
|
|
|
2007-06-30 17:41:07 +00:00
|
|
|
private:
|
|
|
|
void setupActions();
|
|
|
|
void setupMenus();
|
|
|
|
void setupInterface();
|
2007-09-21 18:07:05 +00:00
|
|
|
bool canClose();
|
2009-04-04 18:29:53 +00:00
|
|
|
QWidget *clearToolsDock();
|
2009-11-22 16:12:22 +00:00
|
|
|
void copyAndPasteXml(const QDomDocument &);
|
2007-06-30 17:41:07 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void slot_new();
|
|
|
|
void slot_open();
|
2009-04-03 19:30:25 +00:00
|
|
|
void slot_openFile();
|
2008-07-30 11:51:27 +00:00
|
|
|
void openRecentFile(const QString &);
|
|
|
|
void openElement(const QString &);
|
2007-12-09 12:00:11 +00:00
|
|
|
void slot_reload();
|
2007-06-30 17:41:07 +00:00
|
|
|
bool slot_save();
|
|
|
|
bool slot_saveAs();
|
2009-04-03 19:30:25 +00:00
|
|
|
bool slot_saveAsFile();
|
2007-06-30 17:41:07 +00:00
|
|
|
void slot_setRubberBandToView();
|
|
|
|
void slot_setNoDragToView();
|
|
|
|
void slot_setNormalMode();
|
|
|
|
void slot_updateInformations();
|
|
|
|
void slot_updateMenus();
|
2007-08-25 15:46:09 +00:00
|
|
|
void slot_updateTitle();
|
2007-11-07 20:23:24 +00:00
|
|
|
void slot_createPartsList();
|
|
|
|
void slot_updatePartsList();
|
|
|
|
void slot_updateSelectionFromPartsList();
|
2007-06-30 17:41:07 +00:00
|
|
|
void xmlPreview();
|
2009-06-01 02:05:20 +00:00
|
|
|
bool checkElement();
|
2009-11-22 16:12:22 +00:00
|
|
|
void pasteFromFile();
|
|
|
|
void pasteFromElement();
|
2010-02-18 00:42:41 +00:00
|
|
|
void updateCurrentPartEditor();
|
2007-06-30 17:41:07 +00:00
|
|
|
};
|
|
|
|
|
2007-12-09 10:07:33 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@param nameslist the new list of names for the currently edited element
|
2007-12-09 10:07:33 +00:00
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
inline void QETElementEditor::setNames(const NamesList &nameslist) {
|
2007-06-30 17:41:07 +00:00
|
|
|
ce_scene -> setNames(nameslist);
|
|
|
|
}
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the location of the currently edited element
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
inline ElementsLocation QETElementEditor::location() const {
|
|
|
|
return(location_);
|
|
|
|
}
|
|
|
|
|
2007-12-09 10:07:33 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the filename of the currently edited element
|
2007-12-09 10:07:33 +00:00
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
inline QString QETElementEditor::fileName() const {
|
2009-04-03 19:30:25 +00:00
|
|
|
return(filename_);
|
2007-06-30 17:41:07 +00:00
|
|
|
}
|
|
|
|
|
2007-12-09 10:07:33 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
@return the editing scene
|
2007-12-09 10:07:33 +00:00
|
|
|
*/
|
2007-08-25 03:43:05 +00:00
|
|
|
inline ElementScene *QETElementEditor::elementScene() const {
|
|
|
|
return(ce_scene);
|
|
|
|
}
|
|
|
|
|
2007-06-30 17:41:07 +00:00
|
|
|
#endif
|