Compare commits

..

41 Commits

Author SHA1 Message Date
joshua 2b5887f994 Fix crash 2022-08-03 14:47:10 +02:00
joshua ea978c5e24 Fix a funny bug
When we create a summary table and uncheck the option "adjust the size
of the table to the folio" an infinity of new diagram are added to the
project.
2022-04-01 20:42:00 +02:00
joshua 5925c227ab Fix bug 244
I was thinking that the commit 5a51f6bace
fix the bug 244, but not they only fix this bug :
https://qelectrotech.org/forum/viewtopic.php?pid=16022#p16022

This commit really fix the bug 244
2022-04-01 20:06:00 +02:00
joshua 0f95edc5e6 Fix crash
See bug N°244
https://qelectrotech.org/bugtracker/view.php?id=244
2022-03-31 19:09:42 +02:00
joshua 67637acaab Fix segfault.
Fix bug 249.
https://qelectrotech.org/bugtracker/view.php?id=249
2021-12-28 15:30:19 +01:00
Laurent Trinques 242c53e3be Add Russian translation, thanks "А.Разживин" 2021-12-18 12:59:56 +01:00
joshua 6775930e81 Bug fix : in some condition element are not loaded when open a project
If an element are overwrite by a modified element and the terminals of
the modified element are moved, the old element is not loaded because
some terminal are not found.
This commit remove the checking of not found terminal because it's
useless now.
2021-09-07 22:33:05 +02:00
joshua 54b53b4086 Minor fix : slave Xref item is not updated when variable %F is used 2021-06-28 21:34:40 +02:00
joshua e765cf037c Minor fix : master XRef is not updated when variable %F is used 2021-06-28 21:33:33 +02:00
joshua 39cff98649 Remove table useless qetgraphicstableitem when model is reseted
When the model of a qetgraphicstableitem is reseted (for exemple when
the sql query is modified) we check if there is useless tables (table
with 0 row displayed) and remove it.
2021-06-24 19:57:03 +02:00
joshua 13041720df Fix crash
When a qetgraphicstable is deleted, the next and previous table is not
aware about the deletion and keep a dangled pointer of the deleted table
who cause a segfault.
2021-06-24 19:56:37 +02:00
joshua d7a49b9e74 Fix xrefproperties bug
Change only slave Xrefproperties is not applied due to overload operator
== who don't compare the formula string of slave.
2021-05-15 18:59:31 +02:00
joshua ecf783332a Improve element collection loading time
According to Qt creator flame graph, call QSettings take lot of time.
When loading the element collection, each items of the collection get
the current language by calling the function QString
QETApp::langFromSetting().
This function instantiate a QSettings object each time and take a lot of
time.
Now the QSettings is instantiate only at the first call, and the value
is stored in memory, then all other call of the function don't
instantiate a QSettings, but just return the value in memory.
2021-04-25 10:49:13 +02:00
joshua fbb97cb686 Element query widget : make code more readable 2021-04-25 10:48:42 +02:00
joshua 4aaa8eebe4 Element nomenclature sql query minor fix
Filter "is empty" don't work for any case :
We must to filter for NULL and empty string then replace the sql
sentence "value IS NULL" by "(value IS NULL OR value = '')"
2021-04-25 10:48:11 +02:00
joshua 4b6e0ad8e5 Element nomenclature SQL query : minor fix
the filter "is not empty" in nomenclature don't work for every case.
Replace SQL sentence "IS NULL" by "!= ''" because an empty string is not
a NULL value string, but a NULL value string is like an empty string
2021-04-25 10:47:43 +02:00
joshua 86c8a2d45b Fix unwanted moving part in element editor.
Fix an unwanted behavior when the properties dock widget is displayed :

1 there is no selection
2 the dock widget width is set to minimum
3 select a part, the dock widget gain new widgets used to edit the
current selected part and the width of the dock grow so the width of the
QGraphicsView is reduced and cause a mouse move event.
When this case occur the part is moved but they should not.
2021-04-07 13:05:27 +02:00
joshua 43e3c9a998 Improve gui layout for low resolution screen 2021-04-07 13:05:10 +02:00
joshua 349765a90c Use QStringLiteral and QLatin1String. 2021-04-07 13:00:43 +02:00
joshua a4ca872158 Use QStringLiteral and QLatin1String.
According to the Qt documentation
(https://doc.qt.io/qt-5/qstring.html#QStringLiteral)
(https://woboq.com/blog/qstringliteral.html), use QStringLiteral and
QLatin1String is better on some conditions (faster).
This commit change the code related to the loading of a project (in
qetproject class), let see if loading time is improved.
2021-04-07 13:00:21 +02:00
joshua 6602c65679 Make MachineInfo a singleton class
Because on windows MachineInfo take a little time to init, we make it to
a singleton.
MachineInfo is build the first time in main.cpp.
Now all other places where we use MachineInfo (aboutqetdialog and
configdialog) gui don't hang anymore in waiting to MachineInfo finish to
build.
2021-03-26 18:43:30 +01:00
joshua fc870e7afc Rename class Machine_info to MachinInfo
Rename to follow the code style of QElectroTech
2021-03-26 18:43:12 +01:00
Joshua Claveau 04226a5dee little fix 2021-03-26 18:42:53 +01:00
Joshua Claveau 164536c3ef Project properties dialog launch a little more faster (especially on windows)
Instead of build machine_info class which take time, only to get the max
width and height of screens, call  of methods
Machine_info::i_max_screen_width() and
Machine_info::i_max_screen_height() are now static and compute only
this.
The project properties dialog is now faster because don't wait the end
build of machine_info.
2021-03-26 18:42:29 +01:00
Joshua Claveau 0915d946c5 Qet start a little more faster (especially on windows)
Machine_Info class take time on windows even in powerful computer.
Run the machine_info in main.cpp in parallel into another thread.
2021-03-26 18:42:08 +01:00
Laurent Trinques 959f088306 Update displayed version 2021-03-19 16:04:58 +01:00
Gleb Popov ea2638acad Add installation phase to CMake build system 2021-03-19 15:59:35 +01:00
Simon De Backer 89aa2fbf63 Fix cmake user properties class
for commit 44db25e76b
2021-03-19 15:56:42 +01:00
Gleb Popov 86f8b85a78 Fix CMake build when git revision can't be determined 2021-03-19 15:56:03 +01:00
Gleb Popov 491efe7b1d Add CMake option to allow using system pugixml library 2021-03-19 15:55:10 +01:00
Gleb Popov 86552e481a Add CMake option to allow using system KF5 libraries 2021-03-19 15:54:31 +01:00
Simon De Backer b58482a0d5 Fix Cmake
did not compile
2021-03-19 15:52:32 +01:00
Laurent Trinques 875eaac766 Update SingleApplication to upstream master 2021-03-02 19:07:02 +01:00
Laurent Trinques fa9f6b9c03 Upgrade pugixml XML parser to 1.11 release
https://pugixml.org/docs/manual.html#v1.11
2021-03-02 19:06:50 +01:00
joshua a6e55e1918 Fix wrong element type 2021-02-24 20:51:33 +01:00
joshua 3f586b0b8e Fix wrong element type 2021-02-24 20:51:03 +01:00
Laurent Trinques 8ccfb93e89 DiagramView::mouseMoveEvent remove "DEV" in toolTip message mouse
postion
2021-02-24 19:44:12 +01:00
Lars Biskupek 54e2af4fb2 Tab-stop definitions inserted where appropriate
Tab stop definitions inserted in some dialogs, so that the order of tab-stops-moves corresponds as closely as possible to the fields' position in the window.
2021-02-24 19:43:37 +01:00
Lars Biskupek 3e95b51af6 Modifications to SaveFile-Dialog for "Save As PDF"
Fixed a typo that prevented existing PDF files from being displayed in SaveFileDialog for PDFs.

The way the file name for the PDF is generated has changed. If the project has already been saved, the PDF has the same file name (with .pdf of course); If not, the file name is generated from the project title (= same behavior as Save as - dialog for a .qet project file).
2021-02-24 19:43:04 +01:00
joshua fb58ecacfc Fix typo
Fixed a typo that resulted in existing PDF files not being displayed in
the dialog box "Save As PDF".
Thanks Bisku
2021-02-24 19:42:26 +01:00
Pawel Śmiech 8053303ce5 Polish translation updated
Signed-off-by: Pawel Śmiech <pawel@localhost.localdomain>
2021-02-24 19:41:27 +01:00
114 changed files with 21557 additions and 25168 deletions
+25
View File
@@ -131,3 +131,28 @@ target_include_directories(
${QET_DIR}/sources/factory/ui
${QET_DIR}/sources/print
)
install(TARGETS ${PROJECT_NAME})
install(DIRECTORY ico/breeze-icons/16x16 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/22x22 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/32x32 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/48x48 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/64x64 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/128x128 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY ico/breeze-icons/256x256 DESTINATION ${QET_ICONS_PATH})
install(DIRECTORY elements DESTINATION share/qelectrotech)
install(DIRECTORY examples DESTINATION share/qelectrotech)
install(DIRECTORY titleblocks DESTINATION share/qelectrotech)
install(FILES LICENSE ELEMENTS.LICENSE CREDIT README ChangeLog DESTINATION share/doc/qelectrotech)
install(FILES misc/qelectrotech.desktop DESTINATION share/applications)
install(FILES misc/x-qet-element.xml
misc/x-qet-project.xml
misc/x-qet-titleblock.xml
DESTINATION share/mime/application)
install(FILES misc/x-qet-element.desktop
misc/x-qet-project.desktop
misc/x-qet-titleblock.desktop
DESTINATION share/mimelnk/application)
install(FILES misc/qelectrotech.xml DESTINATION share/mime/packages)
install(FILES misc/qelectrotech.appdata.xml DESTINATION ${QET_APPDATA_PATH})
install(FILES ${QM_FILES} DESTINATION ${QET_LANG_PATH})
@@ -1,7 +1,7 @@
{
"id": "org.qelectrotech.QElectroTech",
"runtime": "org.kde.Platform",
"runtime-version": "5.15",
"runtime-version": "5.14",
"sdk": "org.kde.Sdk",
"command": "qelectrotech",
"rename-desktop-file": "qelectrotech.desktop",
+2 -2
View File
@@ -19,9 +19,9 @@ message(" - fetch_kdeaddons")
if(DEFINED BUILD_WITH_KF5)
Include(FetchContent)
set(BUILD_KF5_YES "YES")
option(BUILD_KF5 "Build KF5 libraries, use system ones otherwise" YES)
if(DEFINED BUILD_KF5_YES)
if(BUILD_KF5)
if(NOT DEFINED KF5_GIT_TAG)
#https://qelectrotech.org/forum/viewtopic.php?pid=13924#p13924
+12 -5
View File
@@ -18,9 +18,16 @@ message(" - fetch_pugixml")
Include(FetchContent)
FetchContent_Declare(
pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG v1.11.4)
option(BUILD_PUGIXML "Build pugixml library, use system one otherwise" YES)
FetchContent_MakeAvailable(pugixml)
if(BUILD_PUGIXML)
FetchContent_Declare(
pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG v1.11.4)
FetchContent_MakeAvailable(pugixml)
else()
find_package(pugixml REQUIRED)
endif()
+3 -3
View File
@@ -28,9 +28,6 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# This strips terminating newline in the variable
string(REGEX REPLACE "\n$" "" GIT_COMMIT_SHA "${GIT_COMMIT_SHA}")
# This adds to definitions => .cpp
add_definitions(-DGIT_COMMIT_SHA="${GIT_COMMIT_SHA}")
if(NOT GIT_COMMIT_RESULT EQUAL "0")
message(
FATAL_ERROR
@@ -39,3 +36,6 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
", please check")
endif()
endif()
# This adds to definitions => .cpp
add_definitions(-DGIT_COMMIT_SHA="${GIT_COMMIT_SHA}")
+2
View File
@@ -383,6 +383,8 @@ set(QET_SRC_FILES
${QET_DIR}/sources/properties/terminaldata.h
${QET_DIR}/sources/properties/xrefproperties.cpp
${QET_DIR}/sources/properties/xrefproperties.h
${QET_DIR}/sources/properties/userproperties.cpp
${QET_DIR}/sources/properties/userproperties.h
${QET_DIR}/sources/PropertiesEditor/propertieseditordialog.h
${QET_DIR}/sources/PropertiesEditor/propertieseditordockwidget.cpp
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 KiB

After

Width:  |  Height:  |  Size: 112 KiB

+583 -712
View File
File diff suppressed because it is too large Load Diff
+591 -720
View File
File diff suppressed because it is too large Load Diff
+583 -712
View File
File diff suppressed because it is too large Load Diff
+592 -723
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+595 -723
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+874 -1006
View File
File diff suppressed because it is too large Load Diff
+590 -719
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+590 -721
View File
File diff suppressed because it is too large Load Diff
+585 -714
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+579 -708
View File
File diff suppressed because it is too large Load Diff
+582 -711
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+587 -718
View File
File diff suppressed because it is too large Load Diff
+594 -723
View File
File diff suppressed because it is too large Load Diff
+583 -712
View File
File diff suppressed because it is too large Load Diff
+579 -708
View File
File diff suppressed because it is too large Load Diff
+583 -712
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+591 -722
View File
File diff suppressed because it is too large Load Diff
+591 -720
View File
File diff suppressed because it is too large Load Diff
+588 -720
View File
File diff suppressed because it is too large Load Diff
+585 -714
View File
File diff suppressed because it is too large Load Diff
+583 -712
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+2136 -2149
View File
File diff suppressed because it is too large Load Diff
+579 -708
View File
File diff suppressed because it is too large Load Diff
+579 -708
View File
File diff suppressed because it is too large Load Diff
+579 -708
View File
File diff suppressed because it is too large Load Diff
+583 -712
View File
File diff suppressed because it is too large Load Diff
+579 -708
View File
File diff suppressed because it is too large Load Diff
@@ -17,7 +17,7 @@
*/
#include "elementscollectionwidget.h"
#include "../editor/ui/qetelementeditor.h"
#include "../editor/qetelementeditor.h"
#include "../elementscategoryeditor.h"
#include "../newelementwizard.h"
#include "../qetapp.h"
@@ -38,9 +38,6 @@
#include <QUrl>
#include <QVBoxLayout>
#include <QtGlobal>
#include <QProgressBar>
#include <QStatusBar>
#include <QLineEdit>
/**
@brief ElementsCollectionWidget::ElementsCollectionWidget
+1
View File
@@ -331,6 +331,7 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
// through setFolioData(),
// which in turn calls updateDiagramContextForTitleBlock().
emit(needTitleBlockTemplate(ip.template_name));
emit informationChanged();
}
/**
+6
View File
@@ -245,6 +245,12 @@ class BorderTitleBlock : public QObject
since it does not know of its parent project.
*/
void needTitleBlockTemplate(const QString &);
/**
* @brief infoChanged
* Signal emitted when the informations changed.
*/
void informationChanged();
// attributes
private:
+8
View File
@@ -368,6 +368,14 @@ void ConductorProperties::fromXml(QDomElement &e)
"vertical-alignment",
"AlignRight"
).toStdString().data()));
//Keep retrocompatible with version older than 0,4
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
//@TODO remove this code for qet 0.6 or later
#if TODO_LIST
#pragma message("@TODO remove this code for qet 0.6 or later")
#endif
if (e.attribute("type") == "simple") m_show_text = false;
}
/**
+3 -4
View File
@@ -27,7 +27,6 @@
@param parent QWidget parent
*/
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
Machine_info *mymachineinfo= new Machine_info(this);
//ScrollArea for low screens
QScrollArea *scroll = new QScrollArea(this);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
@@ -36,7 +35,7 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
// liste des pages
pages_list = new QListWidget();
pages_list -> setViewMode(QListView::IconMode);
if(mymachineinfo->i_max_screen_height()<1000){
if(MachineInfo::instance()->i_max_screen_height()<1000){
pages_list -> setIconSize(QSize(64, 64));
} else {
pages_list -> setIconSize(QSize(128, 128));
@@ -80,8 +79,8 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
connect(pages_list, SIGNAL(currentRowChanged(int)),
pages_widget, SLOT(setCurrentIndex(int)));
setMaximumSize(mymachineinfo->i_max_screen_width(),
mymachineinfo->i_max_screen_height());
setMaximumSize(MachineInfo::instance()->i_max_screen_width(),
MachineInfo::instance()->i_max_screen_height());
resize(1400,1000);
#ifdef Q_OS_MACOS
+46 -49
View File
@@ -157,40 +157,41 @@ void ElementQueryWidget::setQuery(const QString &query)
//Element type filter
if (where.contains("element_sub_type") || where.contains("element_type"))
{
int c=0;
ui->m_simple_cb->setChecked (where.contains("Simple") ? true : false);
if (ui->m_simple_cb->isChecked()) {
++c;
where.remove("element_type = 'Simple' ");
}
ui->m_terminal_cb->setChecked (where.contains("Terminale") ? true : false);
if (ui->m_terminal_cb->isChecked()) {
++c;
where.remove("element_type = 'Terminale'");
}
ui->m_coil_cb->setChecked (where.contains("coil") ? true : false);
if (ui->m_coil_cb->isChecked()) {
++c;
where.remove("element_sub_type = 'coil' ");
}
ui->m_button_cb->setChecked (where.contains("commutator") ? true : false);
if (ui->m_button_cb->isChecked()) {
++c;
where.remove("element_sub_type = 'commutator' ");
}
ui->m_protection_cb->setChecked(where.contains("protection") ? true : false);
if (ui->m_protection_cb) {
++c;
where.remove("element_sub_type = 'protection'");
}
QRegularExpression rx("^(\\( .+?\\))");
auto rxm = rx.match(where);
if (rxm.hasMatch())
{
auto str_type = rxm.captured(1);
where.remove(str_type);
if (c == 5) {
ui->m_all_cb->setCheckState(Qt::Checked);
} else if (c > 0) {
ui->m_all_cb->setCheckState(Qt::PartiallyChecked);
}
int c=0;
ui->m_simple_cb->setChecked (str_type.contains("Simple") ? true : false);
if (ui->m_simple_cb->isChecked()) {
++c;
}
ui->m_terminal_cb->setChecked (str_type.contains("Terminale") ? true : false);
if (ui->m_terminal_cb->isChecked()) {
++c;
}
ui->m_coil_cb->setChecked (str_type.contains("coil") ? true : false);
if (ui->m_coil_cb->isChecked()) {
++c;
}
ui->m_button_cb->setChecked (str_type.contains("commutator") ? true : false);
if (ui->m_button_cb->isChecked()) {
++c;
}
ui->m_protection_cb->setChecked(str_type.contains("protection") ? true : false);
if (ui->m_protection_cb) {
++c;
}
where.remove("OR");
if (c == 5) {
ui->m_all_cb->setCheckState(Qt::Checked);
} else if (c > 0) {
ui->m_all_cb->setCheckState(Qt::PartiallyChecked);
}
}
}
else // There is not "element_sub_type" or "element_type" that mean every element are selected
{
@@ -206,20 +207,16 @@ void ElementQueryWidget::setQuery(const QString &query)
strl.append(item->data(Qt::UserRole).toString());
}
QString beginning_rx;
beginning_rx.append(QString("^(").append(strl.join("|")));
beginning_rx.append(")");
QRegularExpression rx_is_not_null(beginning_rx + " IS NOT NULL$");
QRegularExpression rx_is_null (beginning_rx + " IS NULL$");
QRegularExpression rx_like (beginning_rx + QString(" LIKE'%(.+)%'$"));
QRegularExpression rx_not_like (beginning_rx + QString(" NOT LIKE'%(.+)%'$"));
QRegularExpression rx_equal (beginning_rx + QString("='(.+)'$"));
QRegularExpression rx_not_equal (beginning_rx + QString("!='(.+)'$"));
QString join_str = strl.join("|");
QRegularExpression rx_is_not_null(QStringLiteral("^(%1) != ''$").arg(join_str));
QRegularExpression rx_is_null (QStringLiteral("^\\((%1) IS NULL OR (%1) = ''\\)").arg(join_str));
QRegularExpression rx_like (QStringLiteral("^(%1) LIKE'%(.+)%'$").arg(join_str));
QRegularExpression rx_not_like (QStringLiteral("^(%1) NOT LIKE'%(.+)%'$").arg(join_str));
QRegularExpression rx_equal (QStringLiteral("^(%1)='(.+)'$").arg(join_str));
QRegularExpression rx_not_equal (QStringLiteral("^(%1)!='(.+)'$").arg(join_str));
QStringList split_where;
//Remove the white space at begin and end of each string
for (auto str : where.split("AND "))
{
@@ -310,22 +307,22 @@ QString ElementQueryWidget::queryStr() const
case 0: //No filter
break;
case 1: //Not empty
filter_ += QString(" AND ") += key += " IS NOT NULL";
filter_ += QStringLiteral(" AND ") += key += " != ''";
break;
case 2: //empty
filter_ += QString(" AND ") += key += " IS NULL";
filter_ += QStringLiteral(" AND (%1 IS NULL OR %1 = '')").arg(key);
break;
case 3: // contain
filter_ += QString(" AND ") += key += QString(" LIKE'%") += f.second += "%'";
filter_ += QStringLiteral(" AND ") += key += QStringLiteral(" LIKE'%") += f.second += "%'";
break;
case 4: // not contain
filter_ += QString(" AND ") += key += QString(" NOT LIKE'%") += f.second += "%'";
filter_ += QStringLiteral(" AND ") += key += QStringLiteral(" NOT LIKE'%") += f.second += "%'";
break;
case 5: // is equal
filter_ += QString(" AND ") += key += QString("='") += f.second += "'";
filter_ += QStringLiteral(" AND ") += key += QStringLiteral("='") += f.second += "'";
break;
case 6: // is not equal
filter_ += QString(" AND ") += key += QString("!='") += f.second += "'";
filter_ += QStringLiteral(" AND ") += key += QStringLiteral("!='") += f.second += "'";
break;
}
}
+187 -170
View File
@@ -92,6 +92,9 @@ Diagram::Diagram(QETProject *project) :
pen.setColor(Qt::black);
conductor_setter_ -> setPen(pen);
connect(&border_and_titleblock,
&BorderTitleBlock::informationChanged,
this, &Diagram::diagramInformationChanged);
connect(&border_and_titleblock,
&BorderTitleBlock::needTitleBlockTemplate,
this, &Diagram::setTitleBlockTemplate);
@@ -134,15 +137,20 @@ Diagram::~Diagram()
delete m_event_interface;
// list removable items
QList<QGraphicsItem *> deletable_items;
for(QGraphicsItem *qgi : items())
QVector<QGraphicsItem *> deletable_items;
for(const auto &qgi : items())
{
if (qgi -> parentItem()) continue;
if (qgraphicsitem_cast<Conductor *>(qgi)) continue;
deletable_items << qgi;
if (qgi->parentItem())
continue;
if (qgraphicsitem_cast<Conductor *>(qgi))
continue;
deletable_items.append(qgi);
}
for (const auto &item : qAsConst(deletable_items))
{
removeItem(item);
delete item;
}
qDeleteAll (deletable_items);
}
/**
@@ -189,12 +197,12 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
// If user allow zoom out beyond of folio,
// we draw grid outside of border.
QSettings settings;
int xGrid = settings.value("diagrameditor/Xgrid",
Diagram::xGrid).toInt();
int yGrid = settings.value("diagrameditor/Ygrid",
Diagram::yGrid).toInt();
int xGrid = settings.value(QStringLiteral("diagrameditor/Xgrid"),
Diagram::xGrid).toInt();
int yGrid = settings.value(QStringLiteral("diagrameditor/Ygrid"),
Diagram::yGrid).toInt();
QRectF rect = settings.value(
"diagrameditor/zoom-out-beyond-of-folio",
QStringLiteral("diagrameditor/zoom-out-beyond-of-folio"),
false).toBool() ? r
: border_and_titleblock
.insideBorderRect()
@@ -324,15 +332,6 @@ void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
*/
void Diagram::keyPressEvent(QKeyEvent *event)
{
QSettings settings;
int xKeyGrid = settings.value("diagrameditor/key_Xgrid",
Diagram::xKeyGrid).toInt();
int yKeyGrid = settings.value("diagrameditor/key_Ygrid",
Diagram::yKeyGrid).toInt();
int xKeyGridFine = settings.value("diagrameditor/key_fine_Xgrid",
Diagram::xKeyGridFine).toInt();
int yKeyGridFine = settings.value("diagrameditor/key_fine_Ygrid",
Diagram::yKeyGridFine).toInt();
event->setAccepted(false);
if (m_event_interface) {
@@ -361,6 +360,11 @@ void Diagram::keyPressEvent(QKeyEvent *event)
//Move item with the keyboard arrow
if(event->modifiers() == Qt::NoModifier)
{
QSettings settings;
int xKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Xgrid"),
Diagram::xKeyGrid).toInt();
int yKeyGrid = settings.value(QStringLiteral("diagrameditor/key_Ygrid"),
Diagram::yKeyGrid).toInt();
switch(event->key())
{
case Qt::Key_Left:
@@ -399,6 +403,11 @@ void Diagram::keyPressEvent(QKeyEvent *event)
}
else if(event->modifiers() == Qt::AltModifier)
{
QSettings settings;
int xKeyGridFine = settings.value(QStringLiteral("diagrameditor/key_fine_Xgrid"),
Diagram::xKeyGridFine).toInt();
int yKeyGridFine = settings.value(QStringLiteral("diagrameditor/key_fine_Ygrid"),
Diagram::yKeyGridFine).toInt();
switch(event->key())
{
case Qt::Key_Left:
@@ -732,7 +741,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
// XML tree root
// racine de l'arbre XML
auto dom_root = document.createElement("diagram");
auto dom_root = document.createElement(QStringLiteral("diagram"));
// schema properties
// proprietes du schema
@@ -742,24 +751,24 @@ QDomDocument Diagram::toXml(bool whole_content) {
// Default conductor properties
QDomElement default_conductor =
document.createElement("defaultconductor");
document.createElement(QStringLiteral("defaultconductor"));
defaultConductorProperties.toXml(default_conductor);
dom_root.appendChild(default_conductor);
// Conductor autonum
if (!m_conductors_autonum_name.isEmpty()) {
dom_root.setAttribute("conductorAutonum",
dom_root.setAttribute(QStringLiteral("conductorAutonum"),
m_conductors_autonum_name);
}
//Default New Element
dom_root.setAttribute("freezeNewElement",
m_freeze_new_elements ? "true" : "false");
dom_root.setAttribute(QStringLiteral("freezeNewElement"),
m_freeze_new_elements ? QStringLiteral("true") : QStringLiteral("false"));
//Default New Conductor
dom_root.setAttribute("freezeNewConductor",
dom_root.setAttribute(QStringLiteral("freezeNewConductor"),
m_freeze_new_conductors_
? "true" : "false");
? QStringLiteral("true") : QStringLiteral("false"));
//Element Folio Sequential Variables
if (!m_elmt_unitfolio_max.isEmpty()
@@ -767,37 +776,37 @@ QDomDocument Diagram::toXml(bool whole_content) {
|| !m_elmt_hundredfolio_max.isEmpty()) {
QDomElement elmtfoliosequential =
document.createElement(
"elementautonumfoliosequentials");
QStringLiteral("elementautonumfoliosequentials"));
if (!m_elmt_unitfolio_max.isEmpty()) {
QDomElement elmtfolioseq =
document.createElement(
"elementunitfolioseq");
QStringLiteral("elementunitfolioseq"));
folioSequentialsToXml(&m_elmt_unitfolio_max,
&elmtfolioseq,
"sequf_",
"unitfolioseq",
QStringLiteral("sequf_"),
QStringLiteral("unitfolioseq"),
&document);
elmtfoliosequential.appendChild(elmtfolioseq);
}
if (!m_elmt_tenfolio_max.isEmpty()) {
QDomElement elmtfolioseq =
document.createElement(
"elementtenfolioseq");
QStringLiteral("elementtenfolioseq"));
folioSequentialsToXml(&m_elmt_tenfolio_max,
&elmtfolioseq,
"seqtf_",
"tenfolioseq",
QStringLiteral("seqtf_"),
QStringLiteral("tenfolioseq"),
&document);
elmtfoliosequential.appendChild(elmtfolioseq);
}
if (!m_elmt_hundredfolio_max.isEmpty()) {
QDomElement elmtfolioseq =
document.createElement(
"elementhundredfolioseq");
QStringLiteral("elementhundredfolioseq"));
folioSequentialsToXml(&m_elmt_hundredfolio_max,
&elmtfolioseq,
"seqhf_",
"hundredfolioseq",
QStringLiteral("seqhf_"),
QStringLiteral("hundredfolioseq"),
&document);
elmtfoliosequential.appendChild(elmtfolioseq);
}
@@ -809,38 +818,38 @@ QDomDocument Diagram::toXml(bool whole_content) {
!m_cnd_hundredfolio_max.isEmpty()) {
QDomElement cndfoliosequential =
document.createElement(
"conductorautonumfoliosequentials");
QStringLiteral("conductorautonumfoliosequentials"));
QHash<QString, QStringList>::iterator i;
if (!m_cnd_unitfolio_max.isEmpty()) {
QDomElement cndfolioseq =
document.createElement(
"conductorunitfolioseq");
QStringLiteral("conductorunitfolioseq"));
folioSequentialsToXml(&m_cnd_unitfolio_max,
&cndfolioseq,
"sequf_",
"unitfolioseq",
QStringLiteral("sequf_"),
QStringLiteral("unitfolioseq"),
&document);
cndfoliosequential.appendChild(cndfolioseq);
}
if (!m_cnd_tenfolio_max.isEmpty()) {
QDomElement cndfolioseq =
document.createElement(
"conductortenfolioseq");
QStringLiteral("conductortenfolioseq"));
folioSequentialsToXml(&m_cnd_tenfolio_max,
&cndfolioseq,
"seqtf_",
"tenfolioseq",
QStringLiteral("seqtf_"),
QStringLiteral("tenfolioseq"),
&document);
cndfoliosequential.appendChild(cndfolioseq);
}
if (!m_cnd_hundredfolio_max.isEmpty()) {
QDomElement cndfolioseq =
document.createElement(
"conductorhundredfolioseq");
QStringLiteral("conductorhundredfolioseq"));
folioSequentialsToXml(&m_cnd_hundredfolio_max,
&cndfolioseq,
"seqhf_",
"hundredfolioseq",
QStringLiteral("seqhf_"),
QStringLiteral("hundredfolioseq"),
&document);
cndfoliosequential.appendChild(cndfolioseq);
}
@@ -851,7 +860,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
//this method with whole_content to false,
//is often use to copy and paste the current selection
//so we add the id of the project where copy occur.
dom_root.setAttribute("projectId", QETApp::projectId(m_project));
dom_root.setAttribute(QStringLiteral("projectId"), QETApp::projectId(m_project));
}
document.appendChild(dom_root);
@@ -921,7 +930,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
QHash<Terminal *, int> table_adr_id;
if (!list_elements.isEmpty()) {
auto dom_elements = document.createElement("elements");
auto dom_elements = document.createElement(QStringLiteral("elements"));
for (auto elmt : list_elements) {
dom_elements.appendChild(elmt->toXml(document,
table_adr_id));
@@ -930,7 +939,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
}
if (!list_conductors.isEmpty()) {
auto dom_conductors = document.createElement("conductors");
auto dom_conductors = document.createElement(QStringLiteral("conductors"));
for (auto cond : list_conductors) {
dom_conductors.appendChild(cond->toXml(document,
table_adr_id));
@@ -939,7 +948,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
}
if (!list_texts.isEmpty()) {
auto dom_texts = document.createElement("inputs");
auto dom_texts = document.createElement(QStringLiteral("inputs"));
for (auto dti : list_texts) {
dom_texts.appendChild(dti->toXml(document));
}
@@ -947,7 +956,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
}
if (!list_images.isEmpty()) {
auto dom_images = document.createElement("images");
auto dom_images = document.createElement(QStringLiteral("images"));
for (auto dii : list_images) {
dom_images.appendChild(dii->toXml(document));
}
@@ -955,7 +964,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
}
if (!list_shapes.isEmpty()) {
auto dom_shapes = document.createElement("shapes");
auto dom_shapes = document.createElement(QStringLiteral("shapes"));
for (auto dii : list_shapes) {
dom_shapes.appendChild(dii -> toXml(document));
}
@@ -963,7 +972,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
}
if (table_vector.size()) {
auto tables = document.createElement("tables");
auto tables = document.createElement(QStringLiteral("tables"));
for (auto table : table_vector) {
tables.appendChild(table->toXml(document));
}
@@ -987,11 +996,15 @@ void Diagram::folioSequentialsToXml(QHash<QString,
QDomElement *domElement,
const QString& seq_type,
const QString& type,
QDomDocument *doc) {
QDomDocument *doc)
{
QHash<QString, QStringList>::iterator i;
for (i = hash->begin(); i != hash->end(); i++) {
for (i = hash->begin(); i != hash->end(); i++)
{
QDomElement folioseq = doc->createElement(type);
folioseq.setAttribute("title", i.key());
folioseq.setAttribute(QStringLiteral("title"), i.key());
for (int j = 0; j < i.value().size(); j++) {
folioseq.setAttribute(seq_type + QString::number(j+1),
i.value().at(j));
@@ -1096,14 +1109,15 @@ bool Diagram::initFromXml(QDomElement &document,
@return
*/
Terminal* findTerminal(int conductor_index,
QDomElement& f,
QHash<int,
Terminal *>& table_adr_id,
QList<Element *>& added_elements) {
QDomElement& f,
QHash<int,Terminal *>& table_adr_id,
QList<Element *>& added_elements)
{
assert(conductor_index == 1 || conductor_index == 2);
QString element_index = "element" + QString::number(conductor_index);
QString terminal_index = "terminal" + QString::number(conductor_index);
auto str_index = QString::number(conductor_index);
QString element_index = QStringLiteral("element") + str_index;
QString terminal_index = QStringLiteral("terminal") + str_index;
if (f.hasAttribute(element_index)) {
QUuid element_uuid = QUuid(f.attribute(element_index));
@@ -1185,10 +1199,13 @@ Terminal* findTerminal(int conductor_index,
bool Diagram::fromXml(QDomElement &document,
QPointF position,
bool consider_informations,
DiagramContent *content_ptr) {
DiagramContent *content_ptr)
{
const QDomElement& root = document;
// The first element must be a diagram
if (root.tagName() != "diagram") return(false);
// The first element must be a diagram
if (root.tagName() != QLatin1String("diagram")) {
return(false);
}
// Read attributes of this diagram
if (consider_informations)
@@ -1197,56 +1214,57 @@ bool Diagram::fromXml(QDomElement &document,
border_and_titleblock.titleBlockFromXml(root);
border_and_titleblock.borderFromXml(root);
// Find the element "defaultconductor".
// If found, load default conductor properties.
// Find the element "defaultconductor".
// If found, load default conductor properties.
QDomElement default_conductor_elmt =
root.firstChildElement("defaultconductor");
root.firstChildElement(QStringLiteral("defaultconductor"));
if (!default_conductor_elmt.isNull()) {
defaultConductorProperties.fromXml(default_conductor_elmt);
}
// Load the autonum
m_conductors_autonum_name = root.attribute("conductorAutonum");
// Load the autonum
m_conductors_autonum_name = root.attribute(QStringLiteral("conductorAutonum"));
// Load Freeze New Element
m_freeze_new_elements = root.attribute("freezeNewElement").toInt();
// Load Freeze New Element
m_freeze_new_elements = root.attribute(QStringLiteral("freezeNewElement")).toInt();
// Load Freeze New Conductor
m_freeze_new_conductors_ = root.attribute("freezeNewConductor").toInt();
// Load Freeze New Conductor
m_freeze_new_conductors_ = root.attribute(QStringLiteral("freezeNewConductor")).toInt();
//Load Element Folio Sequential
//Load Element Folio Sequential
folioSequentialsFromXml(root,
&m_elmt_unitfolio_max,
"elementunitfolioseq",
"sequf_",
"unitfolioseq",
"elementautonumfoliosequentials");
QStringLiteral("elementunitfolioseq"),
QStringLiteral("sequf_"),
QStringLiteral("unitfolioseq"),
QStringLiteral("elementautonumfoliosequentials"));
folioSequentialsFromXml(root, &m_elmt_tenfolio_max,
"elementtenfolioseq",
"seqtf_",
"tenfolioseq",
"elementautonumfoliosequentials");
QStringLiteral("elementtenfolioseq"),
QStringLiteral("seqtf_"),
QStringLiteral("tenfolioseq"),
QStringLiteral("elementautonumfoliosequentials"));
folioSequentialsFromXml(root, &m_elmt_hundredfolio_max,
"elementhundredfolioseq",
"seqhf_",
"hundredfolioseq",
"elementautonumfoliosequentials");
QStringLiteral("elementhundredfolioseq"),
QStringLiteral("seqhf_"),
QStringLiteral("hundredfolioseq"),
QStringLiteral("elementautonumfoliosequentials"));
//Load Conductor Folio Sequential
//Load Conductor Folio Sequential
folioSequentialsFromXml(root, &m_cnd_unitfolio_max,
"conductorunitfolioseq",
"sequf_",
"unitfolioseq",
"conductorautonumfoliosequentials");
QStringLiteral("conductorunitfolioseq"),
QStringLiteral("sequf_"),
QStringLiteral("unitfolioseq"),
QStringLiteral("conductorautonumfoliosequentials"));
folioSequentialsFromXml(root, &m_cnd_tenfolio_max,
"conductortenfolioseq",
"seqtf_","tenfolioseq",
"conductorautonumfoliosequentials");
QStringLiteral("conductortenfolioseq"),
QStringLiteral("seqtf_"),
QStringLiteral("tenfolioseq"),
QStringLiteral("conductorautonumfoliosequentials"));
folioSequentialsFromXml(root, &m_cnd_hundredfolio_max,
"conductorhundredfolioseq",
"seqhf_",
"hundredfolioseq",
"conductorautonumfoliosequentials");
QStringLiteral("conductorhundredfolioseq"),
QStringLiteral("seqhf_"),
QStringLiteral("hundredfolioseq"),
QStringLiteral("conductorautonumfoliosequentials"));
}
// if child haven't got a child, loading is finish (diagram is empty)
@@ -1255,10 +1273,10 @@ bool Diagram::fromXml(QDomElement &document,
}
//If paste from another project
if (root.hasAttribute("projectId")) {
QETProject *other_project = QETApp::project(
root.attribute("projectId",
"-1").toInt());
if (root.hasAttribute(QStringLiteral("projectId")))
{
QETProject *other_project = QETApp::project(root.attribute(QStringLiteral("projectId"),
QStringLiteral("-1")).toInt());
/* We try to paste from another project,
* then befor paste elements,
@@ -1266,17 +1284,18 @@ bool Diagram::fromXml(QDomElement &document,
* (owned by other project)
* in the embedded collection of this project
*/
if (other_project && other_project != m_project) {
if (other_project && other_project != m_project)
{
ElementCollectionHandler ech;
foreach (QDomElement element_xml,
for (auto element_xml :
QET::findInDomElement(root,
"elements",
"element")) {
QStringLiteral("elements"),
QStringLiteral("element"))) {
if (!Element::valideXml(element_xml)) continue;
QString type_id = element_xml.attribute("type");
QString type_id = element_xml.attribute(QStringLiteral("type"));
if (type_id.startsWith("embed://")) {
if (type_id.startsWith(QStringLiteral("embed://"))) {
ElementsLocation location(
type_id,
other_project);
@@ -1289,15 +1308,15 @@ bool Diagram::fromXml(QDomElement &document,
//Load all elements from the XML
QList<Element *> added_elements;
QHash<int, Terminal *> table_adr_id;
foreach (QDomElement element_xml,
QET::findInDomElement(root, "elements", "element"))
for (auto element_xml :
QET::findInDomElement(root, QStringLiteral("elements"), QStringLiteral("element")))
{
if (!Element::valideXml(element_xml)) continue;
// cree un element dont le type correspond a l'id type
QString type_id = element_xml.attribute("type");
QString type_id = element_xml.attribute(QStringLiteral("type"));
ElementsLocation element_location;
if (type_id.startsWith("embed://")) {
if (type_id.startsWith(QStringLiteral("embed://"))) {
element_location = ElementsLocation(type_id, m_project);
}
else {
@@ -1326,8 +1345,7 @@ bool Diagram::fromXml(QDomElement &document,
{
removeItem(nvel_elmt);
delete nvel_elmt;
qDebug() << "Diagram::fromXml() : Le chargement des "
"parametres d'un element a echoue";
qDebug() << QStringLiteral("Diagram::fromXml() : Le chargement des parametres d'un element a echoue");
} else {
added_elements << nvel_elmt;
}
@@ -1335,9 +1353,9 @@ bool Diagram::fromXml(QDomElement &document,
// Load text
QList<IndependentTextItem *> added_texts;
foreach (QDomElement text_xml, QET::findInDomElement(root,
"inputs",
"input")) {
for (auto text_xml : QET::findInDomElement(root,
QStringLiteral("inputs"),
QStringLiteral("input"))) {
IndependentTextItem *iti = new IndependentTextItem();
iti -> fromXml(text_xml);
addItem(iti);
@@ -1346,9 +1364,9 @@ bool Diagram::fromXml(QDomElement &document,
// Load image
QList<DiagramImageItem *> added_images;
foreach (QDomElement image_xml, QET::findInDomElement(root,
"images",
"image")) {
for (auto image_xml : QET::findInDomElement(root,
QStringLiteral("images"),
QStringLiteral("image"))) {
DiagramImageItem *dii = new DiagramImageItem ();
dii -> fromXml(image_xml);
addItem(dii);
@@ -1357,9 +1375,9 @@ bool Diagram::fromXml(QDomElement &document,
// Load shape
QList<QetShapeItem *> added_shapes;
foreach (QDomElement shape_xml, QET::findInDomElement(root,
"shapes",
"shape")) {
for (auto shape_xml : QET::findInDomElement(root,
QStringLiteral("shapes"),
QStringLiteral("shape"))) {
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
dii -> fromXml(shape_xml);
addItem(dii);
@@ -1368,9 +1386,9 @@ bool Diagram::fromXml(QDomElement &document,
// Load conductor
QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root,
"conductors",
"conductor"))
for (auto f : QET::findInDomElement(root,
QStringLiteral("conductors"),
QStringLiteral("conductor")))
{
if (!Conductor::valideXml(f)) continue;
@@ -1395,10 +1413,9 @@ bool Diagram::fromXml(QDomElement &document,
//Load tables
QVector<QetGraphicsTableItem *> added_tables;
for (auto dom_table
: QETXML::subChild(root,
"tables",
QetGraphicsTableItem::xmlTagName()))
for (const auto &dom_table : QETXML::subChild(root,
QStringLiteral("tables"),
QetGraphicsTableItem::xmlTagName()))
{
auto table = new QetGraphicsTableItem();
addItem(table);
@@ -1410,12 +1427,12 @@ bool Diagram::fromXml(QDomElement &document,
if (position != QPointF())
{
QVector <QGraphicsItem *> added_items;
for (auto element : added_elements ) added_items << element;
for (auto cond : added_conductors) added_items << cond;
for (auto shape : added_shapes ) added_items << shape;
for (auto text : added_texts ) added_items << text;
for (auto image : added_images ) added_items << image;
for (auto table : added_tables ) added_items << table;
for (auto element : qAsConst(added_elements )) added_items << element;
for (auto cond : qAsConst(added_conductors )) added_items << cond;
for (auto shape : qAsConst(added_shapes )) added_items << shape;
for (auto text : qAsConst(added_texts )) added_items << text;
for (auto image : qAsConst(added_images )) added_items << image;
for (auto table : qAsConst(added_tables )) added_items << table;
//Get the top left corner of the rectangle that contain all added items
QRectF items_rect;
@@ -1487,7 +1504,7 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root,
= folioSeqAutoNum.firstChildElement(type);
!folioseq.isNull();
folioseq = folioseq.nextSiblingElement(type)) {
QString title = folioseq.attribute("title");
QString title = folioseq.attribute(QStringLiteral("title"));
QStringList list;
int i = 1;
while (folioseq.hasAttribute(seq
@@ -1871,10 +1888,10 @@ void Diagram::loadElmtFolioSeq()
|| !m_elmt_unitfolio_max.contains(title)) {
//Insert Initial Value
if (project()->elementAutoNumCurrentFormula().contains(
"%sequf_")) {
QStringLiteral("%sequf_"))) {
insertFolioSeqHash(&m_elmt_unitfolio_max,
title,
"unitfolio",
QStringLiteral("unitfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1882,10 +1899,10 @@ void Diagram::loadElmtFolioSeq()
else if (m_elmt_unitfolio_max.contains(title)) {
//Load Folio Current Value
if (project()->elementAutoNumCurrentFormula().contains(
"%sequf_")) {
QStringLiteral("%sequf_"))) {
loadFolioSeqHash(&m_elmt_unitfolio_max,
title,
"unitfolio",
QStringLiteral("unitfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1896,10 +1913,10 @@ void Diagram::loadElmtFolioSeq()
|| !m_elmt_tenfolio_max.contains(title)) {
//Insert Initial Value
if (project()->elementAutoNumCurrentFormula().contains(
"%seqtf_")) {
QStringLiteral("%seqtf_"))) {
insertFolioSeqHash(&m_elmt_tenfolio_max,
title,
"tenfolio",
QStringLiteral("tenfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1907,10 +1924,10 @@ void Diagram::loadElmtFolioSeq()
else if (m_elmt_tenfolio_max.contains(title)) {
//Load Folio Current Value
if (project()->elementAutoNumCurrentFormula().contains(
"%seqtf_")) {
QStringLiteral("%seqtf_"))) {
loadFolioSeqHash(&m_elmt_tenfolio_max,
title,
"tenfolio",
QStringLiteral("tenfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1921,10 +1938,10 @@ void Diagram::loadElmtFolioSeq()
|| !m_elmt_hundredfolio_max.contains(title)) {
//Insert Initial Value
if (project()->elementAutoNumCurrentFormula().contains(
"%seqhf_")) {
QStringLiteral("%seqhf_"))) {
insertFolioSeqHash(&m_elmt_hundredfolio_max,
title,
"hundredfolio",
QStringLiteral("hundredfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1932,10 +1949,10 @@ void Diagram::loadElmtFolioSeq()
else if (m_elmt_hundredfolio_max.contains(title)) {
//Load Folio Current Value
if (project()->elementAutoNumCurrentFormula().contains(
"%seqhf_")) {
QStringLiteral("%seqhf_"))) {
loadFolioSeqHash(&m_elmt_hundredfolio_max,
title,
"hundredfolio",
QStringLiteral("hundredfolio"),
&nc);
project()->addElementAutoNum(title,nc);
}
@@ -1958,20 +1975,20 @@ void Diagram::loadCndFolioSeq()
if (m_cnd_unitfolio_max.isEmpty()
|| !m_cnd_unitfolio_max.contains(title)) {
//Insert Initial Value
if (formula.contains("%sequf_")) {
if (formula.contains(QStringLiteral("%sequf_"))) {
insertFolioSeqHash(&m_cnd_unitfolio_max,
title,
"unitfolio",
QStringLiteral("unitfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
}
else if (m_cnd_unitfolio_max.contains(title)) {
//Load Folio Current Value
if (formula.contains("%sequf_")) {
if (formula.contains(QStringLiteral("%sequf_"))) {
loadFolioSeqHash(&m_cnd_unitfolio_max,
title,
"unitfolio",
QStringLiteral("unitfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -1981,20 +1998,20 @@ void Diagram::loadCndFolioSeq()
if (m_cnd_tenfolio_max.isEmpty()
|| !m_cnd_tenfolio_max.contains(title)) {
//Insert Initial Value
if (formula.contains("%seqtf_")) {
if (formula.contains(QStringLiteral("%seqtf_"))) {
insertFolioSeqHash(&m_cnd_tenfolio_max,
title,
"tenfolio",
QStringLiteral("tenfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
}
else if (m_cnd_tenfolio_max.contains(title)) {
//Load Folio Current Value
if (formula.contains("%seqtf_")) {
if (formula.contains(QStringLiteral("%seqtf_"))) {
loadFolioSeqHash(&m_cnd_tenfolio_max,
title,
"tenfolio",
QStringLiteral("tenfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -2004,20 +2021,20 @@ void Diagram::loadCndFolioSeq()
if (m_cnd_hundredfolio_max.isEmpty()
|| !m_cnd_hundredfolio_max.contains(title)) {
//Insert Initial Value
if (formula.contains("%seqhf_")) {
if (formula.contains(QStringLiteral("%seqhf_"))) {
insertFolioSeqHash(&m_cnd_hundredfolio_max,
title,
"hundredfolio",
QStringLiteral("hundredfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
}
else if (m_cnd_hundredfolio_max.contains(title)) {
//Load Folio Current Value
if (formula.contains("%seqhf_")) {
if (formula.contains(QStringLiteral("%seqhf_"))) {
loadFolioSeqHash(&m_cnd_hundredfolio_max,
title,
"hundredfolio",
QStringLiteral("hundredfolio"),
&nc);
project()->addConductorAutoNum(title,nc);
}
@@ -2257,10 +2274,10 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
QPointF Diagram::snapToGrid(const QPointF &p)
{
QSettings settings;
int xGrid = settings.value("diagrameditor/Xgrid",
Diagram::xGrid).toInt();
int yGrid = settings.value("diagrameditor/Ygrid",
Diagram::yGrid).toInt();
int xGrid = settings.value(QStringLiteral("diagrameditor/Xgrid"),
Diagram::xGrid).toInt();
int yGrid = settings.value(QStringLiteral("diagrameditor/Ygrid"),
Diagram::yGrid).toInt();
//Return a point rounded to the nearest pixel
if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier))
@@ -2330,8 +2347,8 @@ QSet<Conductor *> Diagram::selectedConductors() const
bool Diagram::clipboardMayContainDiagram()
{
QString clipboard_text = QApplication::clipboard() -> text().trimmed();
bool may_be_diagram = clipboard_text.startsWith("<diagram")
&& clipboard_text.endsWith("</diagram>");
bool may_be_diagram = clipboard_text.startsWith(QStringLiteral("<diagram"))
&& clipboard_text.endsWith(QStringLiteral("</diagram>"));
return(may_be_diagram);
}
+1
View File
@@ -283,6 +283,7 @@ class Diagram : public QGraphicsScene
void findElementRequired(const ElementsLocation &);
void diagramActivated();
void diagramInformationChanged();
};
Q_DECLARE_METATYPE(Diagram *)
@@ -222,6 +222,11 @@ void DiagramEventAddElement::addElement()
element -> setPos(m_element->pos());
element -> setRotation(m_element -> rotation());
m_diagram -> addItem(element);
//The element is dropped by the user, the dynamic text field stored in m_converted_text_from_xml_description
//can be moved to m_dynamic_text_list, because we are sure fromXml will be not called.
element->m_dynamic_text_list.append(element->m_converted_text_from_xml_description.keys());
element->m_converted_text_from_xml_description.clear();
QUndoCommand *undo_object = new QUndoCommand(tr("Ajouter %1").arg(element->name()));
new AddGraphicsObjectCommand(element, m_diagram, m_element -> pos(), undo_object);
+10 -3
View File
@@ -1219,13 +1219,20 @@ QList<QAction *> DiagramView::contextMenuActions() const
*/
void DiagramView::contextMenuEvent(QContextMenuEvent *e)
{
if (QGraphicsItem *qgi = m_diagram->itemAt(mapToScene(e->pos()), transform()))
if (auto qgi = m_diagram->itemAt(mapToScene(e->pos()), transform()))
{
if (!qgi -> isSelected()) {
if (!qgi->isSelected()) {
m_diagram->clearSelection();
}
qgi->setSelected(true);
// At this step qgi can be deleted for exemple if qgi is a QetGraphicsHandlerItem.
// When we call clearSelection the parent item of the handler
// is deselected and so delete all handlers, in this case,
// qgi become a dangling pointer.
// we need to call again itemAt.
if (auto item_ = m_diagram->itemAt(mapToScene(e->pos()), transform())) {
item_->setSelected(true);
}
}
if (m_diagram->selectedItems().isEmpty())
+39 -34
View File
@@ -282,17 +282,13 @@ ChangeNamesCommand::~ChangeNamesCommand()
/// Annule le changement
void ChangeNamesCommand::undo()
{
auto data = m_scene->elementData();
data.m_names_list = names_before;
m_scene->setElementData(data);
m_scene -> setNames(names_before);
}
/// Refait le changement
void ChangeNamesCommand::redo()
{
auto data = m_scene->elementData();
data.m_names_list = names_after;
m_scene->setElementData(data);
m_scene -> setNames(names_after);
}
/**
@@ -457,17 +453,13 @@ ChangeInformationsCommand::~ChangeInformationsCommand()
/// Annule le changement d'autorisation pour les connexions internes
void ChangeInformationsCommand::undo()
{
auto data = m_scene->elementData();
data.m_drawing_information = old_informations_;
m_scene->setElementData(data);
m_scene -> setInformations(old_informations_);
}
/// Refait le changement d'autorisation pour les connexions internes
void ChangeInformationsCommand::redo()
{
auto data = m_scene->elementData();
data.m_drawing_information = new_informations_;
m_scene->setElementData(data);
m_scene -> setInformations(new_informations_);
}
/**
@@ -580,32 +572,45 @@ void ScalePartsCommand::adjustText()
setText(QObject::tr("redimensionnement de %1 primitives", "undo caption -- %1 always > 1").arg(scaled_primitives_.count()));
}
}
/**
* @brief changeElementDataCommand::changeElementDataCommand
* Change the properties of the drawed element
* @param scene : scene to belong the property
* @param old_data : old data
* @param new_data : new data
* @param parent : parent undo command
*/
changeElementDataCommand::changeElementDataCommand(ElementScene *scene,
ElementData old_data,
ElementData new_data,
QUndoCommand *parent) :
ElementEditionCommand(scene, nullptr, parent),
m_old(old_data),
m_new(new_data)
@brief ChangePropertiesCommand::ChangePropertiesCommand
Change the properties of the drawed element
@param scene : scene to belong the property
@param type : new type of element.
@param info
@param elmt_info : new info about type.
@param parent : parent undo
*/
ChangePropertiesCommand::ChangePropertiesCommand(
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent) :
ElementEditionCommand(scene, nullptr, parent)
{
setText(QObject::tr("Modifier les propriétées de l'élément"));
m_type << scene->m_elmt_type << type;
m_kind_info << scene->m_elmt_kindInfo << info;
m_elmt_info << scene->m_elmt_information << elmt_info;
setText(QObject::tr("Modifier les propriétés"));
}
void changeElementDataCommand::undo() {
m_scene->setElementData(m_old);
QUndoCommand::undo();
ChangePropertiesCommand::~ChangePropertiesCommand()
{}
void ChangePropertiesCommand::undo()
{
m_scene->m_elmt_type = m_type.first();
m_scene->m_elmt_kindInfo = m_kind_info.first();
m_scene->setElementInfo(m_elmt_info.first());
}
void changeElementDataCommand::redo() {
m_scene->setElementData(m_new);
QUndoCommand::redo();
void ChangePropertiesCommand::redo()
{
m_scene->m_elmt_type = m_type.last();
m_scene->m_elmt_kindInfo = m_kind_info.last();
m_scene->setElementInfo(m_elmt_info.last());
}
+13 -11
View File
@@ -262,21 +262,23 @@ class ScalePartsCommand : public ElementEditionCommand {
bool first_redo;
};
class changeElementDataCommand : public ElementEditionCommand
{
class ChangePropertiesCommand : public ElementEditionCommand {
public:
changeElementDataCommand(ElementScene *scene,
ElementData old_data,
ElementData new_data,
QUndoCommand *parent = nullptr);
~changeElementDataCommand() override {}
ChangePropertiesCommand (
ElementScene *scene,
const QString& type,
const DiagramContext& info,
const DiagramContext& elmt_info,
QUndoCommand *parent=nullptr);
~ChangePropertiesCommand () override;
void undo() override;
void redo() override;
void undo() override;
void redo() override;
private:
ElementData m_old,
m_new;
QList <QString> m_type;
QList <DiagramContext> m_kind_info;
QList < DiagramContext> m_elmt_info;
};
#endif
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementitemeditor.h"
#include "ui/qetelementeditor.h"
#include "qetelementeditor.h"
#include "editorcommands.h"
/**
+105 -55
View File
@@ -33,7 +33,7 @@
#include "graphicspart/partrectangle.h"
#include "graphicspart/partterminal.h"
#include "graphicspart/parttext.h"
#include "ui/qetelementeditor.h"
#include "qetelementeditor.h"
#include "ui/elementpropertieseditorwidget.h"
#include <QKeyEvent>
@@ -51,6 +51,7 @@
*/
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
QGraphicsScene(parent),
m_elmt_type("simple"),
m_qgi_manager(this),
m_element_editor(editor)
{
@@ -70,25 +71,7 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
connect(&m_undo_stack, SIGNAL(indexChanged(int)),
this, SLOT(managePrimitivesGroups()));
connect(this, SIGNAL(selectionChanged()),
this, SLOT(managePrimitivesGroups()));
}
/**
* @brief ElementScene::elementData
* @return the elementdata using by the scene
*/
ElementData ElementScene::elementData() {
return m_element_data;
}
void ElementScene::setElementData(ElementData data)
{
bool emit_ = m_element_data.m_informations != data.m_informations;
m_element_data = data;
if (emit_)
emit elementInfoChanged();
this, SLOT(managePrimitivesGroups()));
}
/**
@@ -454,7 +437,7 @@ const QDomDocument ElementScene::toXml(bool all_parts)
-(qRound(size.y() - (ymargin/2)))));
root.setAttribute("version", QET::version);
root.setAttribute("link_type", m_element_data.typeToString(m_element_data.m_type));
root.setAttribute("link_type", m_elmt_type);
//Uuid used to compare two elements
QDomElement uuid = xml_document.createElement("uuid");
@@ -462,29 +445,29 @@ const QDomDocument ElementScene::toXml(bool all_parts)
root.appendChild(uuid);
//names of element
root.appendChild(m_element_data.m_names_list.toXml(xml_document));
root.appendChild(m_names_list.toXml(xml_document));
auto type_ = m_element_data.m_type;
if (type_ == ElementData::Slave ||
type_ == ElementData::Master ||
type_ == ElementData::Terminale)
if (m_elmt_type == "slave" || m_elmt_type == "master")
{
root.appendChild(m_element_data.kindInfoToXml(xml_document));
QDomElement kindInfo = xml_document.createElement("kindInformations");
m_elmt_kindInfo.toXml(kindInfo, "kindInformation");
root.appendChild(kindInfo);
}
if(type_ == ElementData::Simple ||
type_ == ElementData::Master ||
type_ == ElementData::Terminale)
if(
m_elmt_type == "simple"
|| m_elmt_type == "master"
|| m_elmt_type == "terminal")
{
QDomElement element_info = xml_document.createElement("elementInformations");
m_element_data.m_informations.toXml(element_info, "elementInformation");
m_elmt_information.toXml(element_info, "elementInformation");
root.appendChild(element_info);
}
//complementary information about the element
QDomElement informations_element = xml_document.createElement("informations");
root.appendChild(informations_element);
informations_element.appendChild(xml_document.createTextNode(m_element_data.m_drawing_information));
informations_element.appendChild(xml_document.createTextNode(informations()));
QDomElement description = xml_document.createElement("description");
@@ -562,16 +545,9 @@ void ElementScene::fromXml(
{
bool state = true;
//Consider the informations of the element
if (consider_informations)
{
// Root must be an element definition
QDomElement root = xml_document.documentElement();
if (root.tagName() == "definition" &&
root.attribute("type") == "element") {
m_element_data.fromXml(root);
}
//Consider the informations of the element
if (consider_informations) {
state = applyInformations(xml_document);
}
if (state)
@@ -723,6 +699,19 @@ QETElementEditor* ElementScene::editor() const
return m_element_editor;
}
/**
@brief ElementScene::setElementInfo
@param dc
*/
void ElementScene::setElementInfo(const DiagramContext& dc)
{
if(m_elmt_information != dc)
{
m_elmt_information = dc;
emit elementInfoChanged();
}
}
/**
@brief ElementScene::slot_select
Select the item in content,
@@ -844,7 +833,7 @@ void ElementScene::slot_editAuthorInformations()
// ajoute un QTextEdit au dialogue
QTextEdit *text_field = new QTextEdit();
text_field -> setAcceptRichText(false);
text_field -> setPlainText(m_element_data.m_drawing_information);
text_field -> setPlainText(informations());
text_field -> setReadOnly(is_read_only);
dialog_layout -> addWidget(text_field);
@@ -862,10 +851,10 @@ void ElementScene::slot_editAuthorInformations()
if (dialog_author.exec() == QDialog::Accepted && !is_read_only)
{
QString new_infos = text_field -> toPlainText().remove(QChar(13)); // CR-less text
if (new_infos != m_element_data.m_drawing_information)
if (new_infos != informations())
{
undoStack().push(new ChangeInformationsCommand(
this, m_element_data.m_drawing_information, new_infos));
this, informations(), new_infos));
}
}
}
@@ -876,15 +865,20 @@ void ElementScene::slot_editAuthorInformations()
*/
void ElementScene::slot_editProperties()
{
ElementPropertiesEditorWidget epew(m_element_data);
QString type = m_elmt_type;
DiagramContext kind_info = m_elmt_kindInfo;
DiagramContext elmt_info = m_elmt_information;
ElementPropertiesEditorWidget epew(type, kind_info, elmt_info);
epew.exec();
if (m_element_data != epew.editedData())
{
undoStack().push(new changeElementDataCommand(this,
m_element_data,
epew.editedData()));
}
if (type != m_elmt_type ||
kind_info != m_elmt_kindInfo ||
elmt_info != m_elmt_information)
undoStack().push(new ChangePropertiesCommand(this,
type,
kind_info,
elmt_info));
}
/**
@@ -904,15 +898,15 @@ void ElementScene::slot_editNames()
dialog_.setInformationText(tr("Vous pouvez spécifier le nom de l'élément dans plusieurs langues."));
NameListWidget *nlw_ = dialog_.namelistWidget();
nlw_->setNames(m_element_data.m_names_list);
nlw_->setNames(m_names_list);
nlw_->setReadOnly(is_read_only);
if (dialog_.exec() == QDialog::Accepted && !is_read_only && !nlw_->isEmpty())
{
NamesList new_names = nlw_->names();
if (new_names != m_element_data. m_names_list) {
if (new_names != m_names_list) {
undoStack().push(new ChangeNamesCommand(this,
m_element_data.m_names_list,
m_names_list,
new_names));
}
}
@@ -1093,6 +1087,62 @@ QRectF ElementScene::elementContentBoundingRect(
return(bounding_rect);
}
/**
@brief ElementScene::applyInformations
Applies the information (dimensions, hostpot, orientations,
internal connections, names and additional information)
contained in an XML document.
\~French Applique les informations (dimensions, hostpot, orientations,
connexions internes, noms et informations complementaires)
contenu dans un document XML.
\~ @param xml_document : Document XML a analyser
\~ @return
true if reading and applying the information went well, false otherwise.
\~French true si la lecture et l'application
des informations s'est bien passee, false sinon.
*/
bool ElementScene::applyInformations(const QDomDocument &xml_document)
{
// Root must be an element definition
QDomElement root = xml_document.documentElement();
if (
root.tagName() != "definition"
||
root.attribute("type") != "element")
return(false);
//Extract info about element type
m_elmt_type = root.attribute("link_type", "simple");
m_elmt_kindInfo.fromXml(
root.firstChildElement("kindInformations"),
"kindInformation");
//Extract info of element
m_elmt_information.fromXml(
root.firstChildElement("elementInformations"),
"elementInformation");
//Extract names of xml definition
m_names_list.fromXml(root);
//extract additional informations
setInformations(QString());
for (QDomNode node = root.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
{
QDomElement elmt = node.toElement();
if (elmt.isNull()) continue;
if (elmt.tagName() == "informations")
{
setInformations(elmt.text());
break;
}
}
return(true);
}
/**
@brief ElementScene::loadContent
Create and load the content describe in the xml document.
+50 -8
View File
@@ -21,7 +21,6 @@
#include "../diagramcontext.h"
#include "../qgimanager.h"
#include "elementcontent.h"
#include "../properties/elementdata.h"
#include <QtWidgets>
#include <QtXml>
@@ -66,7 +65,11 @@ class ElementScene : public QGraphicsScene
// attributes
private:
ElementData m_element_data; ///ElementData. Actualy in transition with old data storage
NamesList m_names_list; /// List of localized names
QString m_informations; /// Extra informations
QString m_elmt_type; /// element type
DiagramContext m_elmt_kindInfo,
m_elmt_information; /// element kind info
QGIManager m_qgi_manager;
QUndoStack m_undo_stack;
@@ -87,20 +90,21 @@ class ElementScene : public QGraphicsScene
// methods
public:
ElementData elementData();
void setElementData(ElementData data);
void setEventInterface (ESEventInterface *event_interface);
void clearEventInterface();
void setBehavior (ElementScene::Behavior);
ElementScene::Behavior behavior() const;
QPointF snapToGrid(QPointF point);
void setNames(const NamesList &);
NamesList names() const;
QString informations() const;
void setInformations(const QString &);
QString elementType () const {return m_elmt_type;}
DiagramContext elementKindInfo () const {return m_elmt_kindInfo;}
DiagramContext elementInformation() const {return m_elmt_information;}
virtual int xGrid() const;
virtual int yGrid() const;
virtual void setGrid(int, int);
virtual const QDomDocument toXml(bool = true);
virtual QRectF boundingRectFromXml(const QDomDocument &);
virtual void fromXml(const QDomDocument &,
@@ -124,6 +128,7 @@ class ElementScene : public QGraphicsScene
void cut();
void copy();
QETElementEditor* editor() const;
void setElementInfo(const DiagramContext& dc);
protected:
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
@@ -132,10 +137,12 @@ class ElementScene : public QGraphicsScene
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
void keyPressEvent (QKeyEvent *event) override;
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
void drawForeground(QPainter *, const QRectF &) override;
private:
QRectF elementContentBoundingRect(const ElementContent &) const;
bool applyInformations(const QDomDocument &);
ElementContent loadContent(const QDomDocument &);
ElementContent addContent(const ElementContent &);
ElementContent addContentAtPos(const ElementContent &, const QPointF &);
@@ -173,4 +180,39 @@ class ElementScene : public QGraphicsScene
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
/**
@brief ElementScene::setNames
@param nameslist New set of naes for the currently edited element
*/
inline void ElementScene::setNames(const NamesList &nameslist) {
m_names_list = nameslist;
}
/**
@brief ElementScene::names
@return the list of names of the currently edited element
*/
inline NamesList ElementScene::names() const
{
return(m_names_list);
}
/**
@brief ElementScene::informations
@return extra informations of the currently edited element
*/
inline QString ElementScene::informations() const
{
return(m_informations);
}
/**
@brief ElementScene::setInformations
@param infos new extra information for the currently edited element
*/
inline void ElementScene::setInformations(const QString &infos) {
m_informations = infos;
}
#endif
+1 -1
View File
@@ -19,7 +19,7 @@
#include "../qetapp.h"
#include "UndoCommand/pastepartscommand.h"
#include "ui/qetelementeditor.h"
#include "qetelementeditor.h"
/**
Constructeur
@param scene ElementScene visualisee par cette ElementView
+1 -1
View File
@@ -20,7 +20,7 @@
#include "../editorcommands.h"
#include "../elementscene.h"
#include "../graphicspart/partline.h"
#include "../ui/qetelementeditor.h"
#include "../qetelementeditor.h"
#include <QGraphicsSceneMouseEvent>
#include <QObject>
+9 -10
View File
@@ -18,8 +18,7 @@
#include "eseventinterface.h"
#include "../elementscene.h"
#include "../ui/qetelementeditor.h"
#include "../elementview.h"
#include "../qetelementeditor.h"
#include <QGraphicsSceneMouseEvent>
@@ -41,7 +40,7 @@ ESEventInterface::ESEventInterface(ElementScene *scene) :
void ESEventInterface::init()
{
m_scene->setBehavior(ElementScene::Behavior::AddPart);
m_editor->elementView()->setDragMode(QGraphicsView::NoDrag);
m_editor->slot_setNoDragToView();
}
/**
@@ -54,31 +53,31 @@ ESEventInterface::~ESEventInterface()
delete m_help_verti;
m_scene->setBehavior(ElementScene::Behavior::Normal);
m_editor->elementView()->setDragMode(QGraphicsView::RubberBandDrag);
m_editor->slot_setRubberBandToView();
}
bool ESEventInterface::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mousePressEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
bool ESEventInterface::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
bool ESEventInterface::wheelEvent(QGraphicsSceneWheelEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
@@ -98,7 +97,7 @@ bool ESEventInterface::keyPressEvent(QKeyEvent *event) {
}
bool ESEventInterface::KeyReleaseEvent(QKeyEvent *event) {
Q_UNUSED (event)
Q_UNUSED (event);
return false;
}
@@ -1264,6 +1264,24 @@ void CustomElementGraphicPart::drawShadowShape(QPainter *painter)
painter -> restore ();
}
/**
@brief CustomElementGraphicPart::itemChange
Reimplemented from QGraphicsObject.
If the item position change call updateCurrentPartEditor()
the change is always send to QGraphicsObject
@param change
@param value
@return the returned value of QGraphicsObject::itemChange
*/
QVariant CustomElementGraphicPart::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (scene())
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemPositionHasChanged)
updateCurrentPartEditor();
return(QGraphicsObject::itemChange(change, value));
}
/**
@brief CustomElementGraphicPart::hoverEnterEvent
Reimplemented from QGraphicsObject.
@@ -1290,14 +1308,29 @@ void CustomElementGraphicPart::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void CustomElementGraphicPart::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
if(event->button() == Qt::LeftButton) {
m_origin_pos = this->pos();
m_first_move = true;
}
QGraphicsObject::mousePressEvent(event);
}
void CustomElementGraphicPart::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
//m_first_move is used to avoid an unwanted behavior
//when the properties dock widget is displayed :
//1 there is no selection
//2 the dock widget width is set to minimum
//3 select a part, the dock widget gain new widgets used to edit
//the current selected part and the width of the dock grow
//so the width of the QGraphicsView is reduced and cause a mouse move event.
//When this case occur the part is moved but they should not. This bool fix it.
if (Q_UNLIKELY(m_first_move)) {
m_first_move = false;
return;
}
if((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable))
{
QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
@@ -309,6 +309,8 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
void applyStylesToQPainter(QPainter &) const;
void drawShadowShape (QPainter *painter);
QVariant itemChange(GraphicsItemChange change,
const QVariant &value) override;
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
@@ -326,6 +328,7 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
Color _color;
bool _antialiased;
QPointF m_origin_pos;
bool m_first_move;
};
typedef CustomElementGraphicPart CEGP;
@@ -17,8 +17,7 @@
*/
#include "customelementpart.h"
#include "../ui/qetelementeditor.h"
#include "../elementscene.h"
#include "../qetelementeditor.h"
/// @return le QETElementEditor auquel cet editeur appartient
QETElementEditor *CustomElementPart::elementEditor() const
@@ -318,7 +318,7 @@ void PartDynamicTextField::setText(const QString &text) {
void PartDynamicTextField::setInfoName(const QString &info_name) {
m_info_name = info_name;
if(m_text_from == DynamicElementTextItem::ElementInfo && elementScene())
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
emit infoNameChanged(m_info_name);
}
@@ -338,7 +338,7 @@ QString PartDynamicTextField::infoName() const{
void PartDynamicTextField::setCompositeText(const QString &text) {
m_composite_text = text;
if(m_text_from == DynamicElementTextItem::CompositeText && elementScene())
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene()->elementData().m_informations));
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene() -> elementInformation()));
emit compositeTextChanged(m_composite_text);
}
@@ -551,10 +551,10 @@ void PartDynamicTextField::elementInfoChanged()
return;
if(m_text_from == DynamicElementTextItem::ElementInfo)
setPlainText(elementScene()->elementData().m_informations.value(m_info_name).toString());
setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
setPlainText(autonum::AssignVariables::replaceVariable(
m_composite_text, elementScene()->elementData().m_informations));
m_composite_text, elementScene() -> elementInformation()));
}
void PartDynamicTextField::prepareAlignment()
+1 -1
View File
@@ -22,7 +22,7 @@
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
#include "../../qeticons.h"
#include "../elementscene.h"
#include "../ui/qetelementeditor.h"
#include "../qetelementeditor.h"
/**
@brief PartPolygon::PartPolygon
+8 -22
View File
@@ -72,7 +72,7 @@ void PartTerminal::paint(
const QStyleOptionGraphicsItem *options,
QWidget *widget)
{
Q_UNUSED(widget)
Q_UNUSED(widget);
painter -> save();
// annulation des renderhints
@@ -98,7 +98,7 @@ void PartTerminal::paint(
// dessin de la borne en rouge
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
painter -> setPen(t);
painter -> drawLine(QPointF(0.0, 0.0), d -> m_second_point);
painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
// dessin du point d'amarrage au conducteur en bleu
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
@@ -118,7 +118,7 @@ void PartTerminal::paint(
QPainterPath PartTerminal::shape() const
{
QPainterPath shape;
shape.lineTo(d -> m_second_point);
shape.lineTo(d -> second_point);
QPainterPathStroker pps;
pps.setWidth(1);
@@ -132,7 +132,7 @@ QPainterPath PartTerminal::shape() const
*/
QRectF PartTerminal::boundingRect() const
{
QRectF br(QPointF(0, 0), d -> m_second_point);
QRectF br(QPointF(0, 0), d -> second_point);
br = br.normalized();
qreal adjust = (SHADOWS_HEIGHT + 1) / 2;
@@ -161,20 +161,6 @@ void PartTerminal::setName(QString& name) {
emit nameChanged();
}
/**
* @brief PartTerminal::setTerminalType
* Set the type of terminal to 'type'
* @param type
*/
void PartTerminal::setTerminalType(TerminalData::Type type)
{
if (d->m_type == type) {
return;
}
d->m_type = type;
emit terminalTypeChanged();
}
void PartTerminal::setNewUuid()
{
d -> m_uuid = QUuid::createUuid();
@@ -188,10 +174,10 @@ void PartTerminal::updateSecondPoint()
{
qreal ts = 4.0; // terminal size
switch(d -> m_orientation) {
case Qet::North: d -> m_second_point = QPointF(0.0, ts); break;
case Qet::East : d -> m_second_point = QPointF(-ts, 0.0); break;
case Qet::South: d -> m_second_point = QPointF(0.0, -ts); break;
case Qet::West : d -> m_second_point = QPointF(ts, 0.0); break;
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
case Qet::East : d -> second_point = QPointF(-ts, 0.0); break;
case Qet::South: d -> second_point = QPointF(0.0, -ts); break;
case Qet::West : d -> second_point = QPointF(ts, 0.0); break;
}
}
+2 -10
View File
@@ -27,13 +27,10 @@
This class represents a terminal which may be used to compose the drawing of
an electrical element within the element editor.
*/
class PartTerminal : public CustomElementGraphicPart
{
class PartTerminal : public CustomElementGraphicPart {
Q_OBJECT
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(TerminalData::Type terminal_type READ terminalType WRITE setTerminalType)
public:
// constructors, destructor
@@ -45,7 +42,6 @@ class PartTerminal : public CustomElementGraphicPart
signals:
void orientationChanged();
void nameChanged();
void terminalTypeChanged();
// methods
public:
@@ -55,6 +51,7 @@ class PartTerminal : public CustomElementGraphicPart
@return the QGraphicsItem type
*/
int type() const override { return Type; }
QString name() const override { return d -> m_name; }
QString xmlName() const override { return(QString("terminal")); }
void fromXml(const QDomElement &) override;
const QDomElement toXml(QDomDocument &) const override;
@@ -74,12 +71,7 @@ class PartTerminal : public CustomElementGraphicPart
Qet::Orientation orientation() const {return d -> m_orientation;}
void setOrientation(Qet::Orientation ori);
QString name() const override { return d -> m_name; }
void setName(QString& name);
TerminalData::Type terminalType() const {return d->m_type;}
void setTerminalType(TerminalData::Type type);
void setNewUuid();
private:
File diff suppressed because it is too large Load Diff
+189
View File
@@ -0,0 +1,189 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef CUSTOM_ELEMENT_EDITOR_H
#define CUSTOM_ELEMENT_EDITOR_H
#include "../ElementsCollection/elementslocation.h"
#include "../qet.h"
#include "../qetmainwindow.h"
#include "elementscene.h"
class ElementItemEditor;
class ElementView;
/**
This class represents an element editor, allowing users to draw, change and
configure a particular electrical element.
*/
class QETElementEditor : public QETMainWindow {
Q_OBJECT
// constructor, destructor
public:
QETElementEditor(QWidget * = nullptr);
~QETElementEditor() override;
private:
QETElementEditor(const QETElementEditor &);
void setupActions();
void setupMenus();
void setupInterface();
// attributes
private:
/// whether the editor is "read-only"
bool read_only;
/// menus
QMenu *file_menu, *edit_menu, *paste_from_menu, *display_menu, *tools_menu;
/// view widget for the editing scene
ElementView *m_view;
/// editing scene
ElementScene *m_elmt_scene;
/// container for widgets dedicated to primitive edition
QDockWidget *m_tools_dock;
/// Stack of widgets for tools_dock
QStackedWidget *m_tools_dock_stack;
/// label displayed when several primitives are selected
QLabel *m_default_informations;
/// Hash associating primitive names with their matching edition widget
QHash<QString, ElementItemEditor *> m_editors;
/// container for the undo list
QDockWidget *m_undo_dock;
/// Container for the list of existing primitives
QDockWidget *m_parts_dock;
/// List of primitives
QListWidget *m_parts_list;
/// actions for the "file" menu
QAction *new_element, *open, *open_dxf, *open_file, *save, *save_as, *save_as_file, *reload, *quit;
/// actions for the "edit" menu
QAction *selectall, *deselectall, *inv_select;
QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt;
QAction *undo, *redo;
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_author, *m_edit_properties;
/// toolbars
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
/// Action group
QActionGroup *parts, *m_zoom_ag, *m_depth_action_group;
/// minimum window title
QString min_title;
/// filename of the currently edited element
QString filename_;
/// location of the currently edited element
ElementsLocation location_;
/// whether the currently edited element comes from a file or a location
bool opened_from_file;
// methods
public:
void setNames(const NamesList &);
void setLocation(const ElementsLocation &);
ElementsLocation location() const;
void setFileName(const QString &);
QString fileName() const;
void setReadOnly(bool);
bool isReadOnly() const;
void fromFile(const QString &);
void fromLocation(const ElementsLocation &);
bool toFile(const QString &);
bool toLocation(const ElementsLocation &location);
bool isEditing(const ElementsLocation &);
bool isEditing(const QString &);
ElementScene *elementScene() const;
void readSettings();
void writeSettings();
static QPointF pasteOffset();
static QString getOpenElementFileName(QWidget * = nullptr, const QString & = QString());
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction*>());
signals:
void saveToLocation(ElementsLocation loc);
protected:
void closeEvent(QCloseEvent *) override;
void firstActivation(QEvent *) override;
private:
bool canClose();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &);
public slots:
void addLine();
void addRect();
void addEllipse();
void addPolygon();
void addArc();
void addText();
void addTerminal();
void addDynamicTextField();
void UncheckAddPrimitive();
void slot_new();
void slot_open();
void slot_openDxf();
void slot_openFile();
void openRecentFile(const QString &);
void openElement(const QString &);
void slot_reload();
bool slot_save();
bool slot_saveAs();
bool slot_saveAsFile();
void slot_setRubberBandToView();
void slot_setNoDragToView();
void slot_updateInformations();
void slot_updateMenus();
void slot_updateTitle();
void slot_createPartsList();
void slot_updatePartsList();
void slot_updateSelectionFromPartsList();
bool checkElement();
void pasteFromFile();
void pasteFromElement();
void updateCurrentPartEditor();
};
/**
@param nameslist the new list of names for the currently edited element
*/
inline void QETElementEditor::setNames(const NamesList &nameslist) {
m_elmt_scene -> setNames(nameslist);
}
/**
@return the location of the currently edited element
*/
inline ElementsLocation QETElementEditor::location() const
{
return(location_);
}
/**
@return the filename of the currently edited element
*/
inline QString QETElementEditor::fileName() const
{
return(filename_);
}
/**
@return the editing scene
*/
inline ElementScene *QETElementEditor::elementScene() const
{
return(m_elmt_scene);
}
#endif
+6 -6
View File
@@ -389,12 +389,12 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
auto grid_layout = new QGridLayout(this);
grid_layout->addWidget(new QLabel(tr("Contour :")), 0,0, Qt::AlignRight);
grid_layout->addWidget(outline_color, 0, 1);
grid_layout->addWidget(new QLabel(tr("Remplissage :")), 0, 2, Qt::AlignRight);
grid_layout->addWidget(filling_color, 0, 3);
grid_layout->addWidget(new QLabel(tr("Style :")), 1, 0, Qt::AlignRight);
grid_layout->addWidget(line_style, 1, 1);
grid_layout->addWidget(new QLabel(tr("Épaisseur :")), 1, 2, Qt::AlignRight);
grid_layout->addWidget(size_weight, 1 ,3);
grid_layout->addWidget(new QLabel(tr("Remplissage :")), 1, 0, Qt::AlignRight);
grid_layout->addWidget(filling_color, 1, 1);
grid_layout->addWidget(new QLabel(tr("Style :")), 2, 0, Qt::AlignRight);
grid_layout->addWidget(line_style, 2, 1);
grid_layout->addWidget(new QLabel(tr("Épaisseur :")), 3, 0, Qt::AlignRight);
grid_layout->addWidget(size_weight, 3 ,1);
main_layout->addItem(grid_layout);
main_layout -> addWidget(antialiasing);
+322
View File
@@ -0,0 +1,322 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaleditor.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../editor/graphicspart/partterminal.h"
#include "../qeticons.h"
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
/**
@brief TerminalEditor::TerminalEditor
@param editor
@param parent
*/
TerminalEditor::TerminalEditor(QETElementEditor* editor, QWidget* parent):
ElementItemEditor(editor, parent) {
m_part = nullptr;
m_terminals.clear();
init();
}
/**
@brief TerminalEditor::TerminalEditor
Constructeur
@param editor :
L'editeur d'element concerne
@param terms :
La borne a editer
@param parent :
QWidget parent de ce widget
*/
TerminalEditor::TerminalEditor(
QETElementEditor *editor,
QList<PartTerminal *> &terms,
QWidget *parent) :
ElementItemEditor(editor, parent),
m_terminals(terms),
m_part(terms.first()) {
init();
}
/**
@brief TerminalEditor::init
*/
void TerminalEditor::init()
{
qle_x = new QDoubleSpinBox();
qle_y = new QDoubleSpinBox();
name = new QLineEdit();
qle_x -> setRange(-5000, 5000);
qle_y -> setRange(-5000, 5000);
orientation = new QComboBox();
orientation -> addItem(QET::Icons::North, tr("Nord"), Qet::North);
orientation -> addItem(QET::Icons::East, tr("Est"), Qet::East);
orientation -> addItem(QET::Icons::South, tr("Sud"), Qet::South);
orientation -> addItem(QET::Icons::West, tr("Ouest"), Qet::West);
QVBoxLayout *main_layout = new QVBoxLayout();
main_layout -> addWidget(new QLabel(tr("Position : ")));
QHBoxLayout *position = new QHBoxLayout();
position -> addWidget(new QLabel(tr("x : ")));
position -> addWidget(qle_x );
position -> addWidget(new QLabel(tr("y : ")));
position -> addWidget(qle_y );
main_layout -> addLayout(position);
QHBoxLayout *ori = new QHBoxLayout();
ori -> addWidget(new QLabel(tr("Orientation : ")));
ori -> addWidget(orientation );
main_layout -> addLayout(ori);
QHBoxLayout *lay_name = new QHBoxLayout();
lay_name -> addWidget(new QLabel(tr("Name : ")));
lay_name -> addWidget(name);
main_layout -> addLayout(lay_name);
main_layout -> addStretch();
setLayout(main_layout);
activeConnections(true);
updateForm();
}
/**
@brief TerminalEditor::~TerminalEditor
Destructeur
*/
TerminalEditor::~TerminalEditor()
{
}
/**
Permet de specifier a cet editeur quelle primitive il doit editer. A noter
qu'un editeur peut accepter ou refuser d'editer une primitive.
L'editeur de borne acceptera d'editer la primitive new_part s'il s'agit d'un
objet de la classe PartTerminal.
@param new_part Nouvelle primitive a editer
@return true si l'editeur a accepter d'editer la primitive, false sinon
*/
bool TerminalEditor::setPart(CustomElementPart* new_part) {
m_terminals.clear();
if (!new_part) {
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(new_part)) {
if(m_part == part_terminal) return true;
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = part_terminal;
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
}
bool TerminalEditor::setParts(QList<CustomElementPart *> parts) {
if (parts.isEmpty()) {
m_terminals.clear();
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = static_cast<PartTerminal *>(parts.first())) {
if (m_part) {
disconnect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
}
m_part = part_terminal;
m_terminals.clear();
m_terminals.append(part_terminal);
for (int i=1; i < parts.length(); i++) {
m_terminals.append(static_cast<PartTerminal*>(parts[i]));
}
updateForm();
connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
return(true);
}
return(false);
}
/**
@return la primitive actuellement editee, ou 0 si ce widget n'en edite pas
*/
CustomElementPart *TerminalEditor::currentPart() const
{
return(m_part);
}
QList<CustomElementPart*> TerminalEditor::currentParts() const
{
QList<CustomElementPart*> parts;
for (auto term: m_terminals) {
parts.append(static_cast<CustomElementPart*>(term));
}
return parts;
}
/// Met a jour l'orientation de la borne et cree un objet d'annulation
void TerminalEditor::updateTerminalO()
{
if (m_locked) return;
m_locked = true;
QVariant var(orientation -> itemData(orientation -> currentIndex()));
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("orientation"))
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "orientation", term->property("orientation"), var);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
}
m_locked = false;
}
/**
@brief TerminalEditor::updateXPos
*/
void TerminalEditor::updateXPos()
{
if (m_locked) return;
m_locked = true;
QPointF new_pos(qle_x->value(), 0);
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setY(term->pos().y()); // change only x value
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
/**
@brief TerminalEditor::updateYPos
*/
void TerminalEditor::updateYPos()
{
if (m_locked) return;
m_locked = true;
QPointF new_pos(0, qle_y->value()); // change only y value
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
new_pos.setX(term->pos().x());
if (term->pos() != new_pos) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(term, "pos", term->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->enableAnimation();
undoStack().push(undo);
}
}
m_locked=false;
}
/**
@brief TerminalEditor::updateName
SLOT set name to Terminal
*/
void TerminalEditor::updateName() {
if (m_locked) return;
m_locked = true;
QVariant var(name->text());
for (int i=0; i < m_terminals.length(); i++) {
PartTerminal* term = m_terminals[i];
if (var != term->property("name"))
{
QPropertyUndoCommand *undo;
undo = new QPropertyUndoCommand(term,
"name",
term->property("name"),
var);
undo->setText(tr("Modifier le nom du terminal"));
undoStack().push(undo);
}
}
m_locked=false;
}
/// update Number and name, create cancel object
/**
Met a jour le formulaire d'edition
*/
void TerminalEditor::updateForm()
{
if (!m_part) return;
activeConnections(false);
qle_x -> setValue(m_part->property("x").toReal());
qle_y -> setValue(m_part->property("y").toReal());
orientation -> setCurrentIndex(orientation->findData(m_part->property("orientation")));
name -> setText(m_part->name());
activeConnections(true);
}
/**
Active ou desactive les connexionx signaux/slots entre les widgets internes.
@param active true pour activer les connexions, false pour les desactiver
*/
void TerminalEditor::activeConnections(bool active) {
if (active) {
connect(qle_x,
&QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateXPos);
connect(qle_y,
&QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateYPos);
connect(orientation,
QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::updateTerminalO);
connect(name, &QLineEdit::editingFinished,
this, &TerminalEditor::updateName);
}
else {
disconnect(qle_x, &QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateXPos);
disconnect(qle_y, &QDoubleSpinBox::editingFinished,
this, &TerminalEditor::updateYPos);
disconnect(orientation, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::updateTerminalO);
disconnect(name, &QLineEdit::editingFinished,
this, &TerminalEditor::updateName);
}
}
+76
View File
@@ -0,0 +1,76 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINAL_EDITOR_H
#define TERMINAL_EDITOR_H
#include "elementitemeditor.h"
#include <QLineEdit>
class PartTerminal;
class QDoubleSpinBox;
class QComboBox;
/**
@brief The TerminalEditor class
This class provides a widget to edit terminals within the element editor.
The class is capable to change the values of multiple parts of the same time.
The displayed values are from the first selected element
*/
class TerminalEditor : public ElementItemEditor {
Q_OBJECT
// Constructors, destructor
public:
TerminalEditor(
QETElementEditor *,
QList<PartTerminal *>& terms,
QWidget * = nullptr);
TerminalEditor(QETElementEditor *, QWidget * = nullptr);
~TerminalEditor() override;
private:
TerminalEditor(const TerminalEditor &);
void init();
// attributes
private:
QList<PartTerminal *> m_terminals;
PartTerminal *m_part{nullptr};
QDoubleSpinBox *qle_x, *qle_y;
QComboBox *orientation;
QLineEdit *name;
bool m_locked{false};
// methods
public:
bool setPart(CustomElementPart *) override;
bool setParts(QList<CustomElementPart *> parts) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart*> currentParts() const override;
public slots:
void updateTerminalO();
void updateXPos();
void updateYPos();
void updateName();
void updateForm() override;
private:
void activeConnections(bool);
};
#endif
+5 -6
View File
@@ -24,8 +24,7 @@
#include "../../qetinformation.h"
#include "../../ui/alignmenttextdialog.h"
#include "../../ui/compositetexteditdialog.h"
#include "../ui/qetelementeditor.h"
#include "../elementscene.h"
#include "../qetelementeditor.h"
#include "ui_dynamictextfieldeditor.h"
#include <QColorDialog>
@@ -225,9 +224,9 @@ void DynamicTextFieldEditor::fillInfoComboBox()
ui -> m_elmt_info_cb -> clear();
QStringList strl;
auto type = elementEditor()->elementScene()->elementData().m_type;
QString type = elementEditor() -> elementScene() -> elementType();
if(type & ElementData::AllReport) {
if(type.contains("report")) {
strl = QETInformation::folioReportInfoKeys();
}
else {
@@ -333,8 +332,8 @@ void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
undo->setText(tr("Modifier l'information d'un texte"));
undoStack().push(undo);
m_parts[i]->setPlainText(
elementEditor()->elementScene()->elementData().m_informations.value(m_parts[i] -> infoName()).toString());
m_parts[i] -> setPlainText(
elementEditor() -> elementScene() -> elementInformation().value(m_parts[i] -> infoName()).toString());
}
}
}
@@ -1,4 +1,4 @@
/*
/*
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
@@ -20,7 +20,6 @@
#include "../../qetapp.h"
#include "../../qetinformation.h"
#include "ui_elementpropertieseditorwidget.h"
#include "../../qetinformation.h"
#include <QItemDelegate>
@@ -38,7 +37,7 @@ class EditorDelegate : public QItemDelegate
QWidget* createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const override
const QModelIndex &index) const
{
if(index.column() == 1)
{
@@ -51,14 +50,23 @@ class EditorDelegate : public QItemDelegate
};
/**
* @brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
* @param data
* @param parent
*/
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(ElementData data, QWidget *parent) :
@brief ElementPropertiesEditorWidget::ElementPropertiesEditorWidget
Default constructor
@param basic_type : QString of the drawed element
@param kind_info : DiagramContext to store kindInfo of drawed element
@param elmt_info : the information of element (label, manufacturer etc...]
@param parent : parent widget
*/
ElementPropertiesEditorWidget::ElementPropertiesEditorWidget(
QString &basic_type,
DiagramContext &kind_info,
DiagramContext &elmt_info,
QWidget *parent) :
QDialog(parent),
ui(new Ui::ElementPropertiesEditorWidget),
m_data(data)
m_basic_type(basic_type),
m_kind_info (kind_info),
m_elmt_info (elmt_info)
{
ui->setupUi(this);
setUpInterface();
@@ -82,29 +90,22 @@ void ElementPropertiesEditorWidget::upDateInterface()
{
ui->m_base_type_cb->setCurrentIndex(
ui->m_base_type_cb->findData(
m_data.m_type));
QVariant(m_basic_type)));
if (m_data.m_type == ElementData::Slave)
if (m_basic_type == "slave")
{
ui->m_state_cb->setCurrentIndex(
ui->m_state_cb->findData(
m_data.m_slave_state));
m_kind_info["state"].toString()));
ui->m_type_cb->setCurrentIndex (
ui->m_type_cb->findData(
m_data.m_slave_type));
ui->m_number_ctc->setValue(m_data.m_contact_count);
m_kind_info["type"].toString()));
ui->m_number_ctc->setValue(m_kind_info["number"].toInt());
}
else if (m_data.m_type == ElementData::Master) {
else if (m_basic_type == "master") {
ui->m_master_type_cb->setCurrentIndex(
ui->m_master_type_cb->findData (
m_data.m_master_type));
} else if (m_data.m_type == ElementData::Terminale) {
ui->m_terminal_type_cb->setCurrentIndex(
ui->m_terminal_type_cb->findData(
m_data.m_terminal_type));
ui->m_terminal_func_cb->setCurrentIndex(
ui->m_terminal_func_cb->findData(
m_data.m_terminal_function));
m_kind_info["type"]));
}
on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex());
@@ -116,39 +117,33 @@ void ElementPropertiesEditorWidget::upDateInterface()
void ElementPropertiesEditorWidget::setUpInterface()
{
// Type combo box
ui->m_base_type_cb->addItem (tr("Simple"), ElementData::Simple);
ui->m_base_type_cb->addItem (tr("Maître"), ElementData::Master);
ui->m_base_type_cb->addItem (tr("Esclave"), ElementData::Slave);
ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"), ElementData::NextReport);
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"), ElementData::PreviousReport);
ui->m_base_type_cb->addItem (tr("Bornier"), ElementData::Terminale);
ui->m_base_type_cb->addItem (tr("Simple"), QVariant("simple"));
ui->m_base_type_cb->addItem (tr("Maître"), QVariant("master"));
ui->m_base_type_cb->addItem (tr("Esclave"), QVariant("slave"));
ui->m_base_type_cb->addItem (tr("Renvoi de folio suivant"),
QVariant("next_report"));
ui->m_base_type_cb->addItem (tr("Renvoi de folio précédent"),
QVariant("previous_report"));
ui->m_base_type_cb->addItem (tr("Bornier"), QVariant("terminal"));
// Slave option
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
ui->m_state_cb->addItem(tr("Normalement fermé"), ElementData::NC);
ui->m_state_cb->addItem(tr("Inverseur"), ElementData::SW);
ui->m_type_cb->addItem(tr("Simple"), ElementData::SSimple);
ui->m_type_cb->addItem(tr("Puissance"), ElementData::Power);
ui->m_type_cb->addItem(tr("Temporisé travail"), ElementData::DelayOn);
ui->m_type_cb->addItem(tr("Temporisé repos"), ElementData::DelayOff);
ui->m_type_cb->addItem(tr("Temporisé travail & repos"), ElementData::delayOnOff);
ui->m_state_cb->addItem(tr("Normalement ouvert"),QVariant("NO"));
ui->m_state_cb->addItem(tr("Normalement fermé"), QVariant("NC"));
ui->m_state_cb->addItem(tr("Inverseur"), QVariant("SW"));
ui->m_type_cb->addItem(tr("Simple"), QVariant("simple"));
ui->m_type_cb->addItem(tr("Puissance"), QVariant("power"));
ui->m_type_cb->addItem(tr("Temporisé travail"), QVariant("delayOn"));
ui->m_type_cb->addItem(tr("Temporisé repos"), QVariant("delayOff"));
ui->m_type_cb->addItem(tr("Temporisé travail & repos"),
QVariant("delayOnOff"));
//Master option
ui->m_master_type_cb->addItem(tr("Bobine"), ElementData::Coil);
ui->m_master_type_cb->addItem(tr("Organe de protection"), ElementData::Protection);
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"), ElementData::Commutator);
//Terminal option
ui->m_terminal_type_cb->addItem(tr("Générique"), ElementData::TTGeneric);
ui->m_terminal_type_cb->addItem(tr("Fusible"), ElementData::Fuse);
ui->m_terminal_type_cb->addItem(tr("Séctionnable"), ElementData::Sectional);
ui->m_terminal_type_cb->addItem(tr("Diode"), ElementData::Diode);
ui->m_terminal_func_cb->addItem(tr("Générique"), ElementData::TFGeneric);
ui->m_terminal_func_cb->addItem(tr("Phase"), ElementData::Phase);
ui->m_terminal_func_cb->addItem(tr("Neutre"), ElementData::Neutral);
ui->m_terminal_func_cb->addItem(tr("Terre"), ElementData::PE);
ui->m_master_type_cb->addItem(tr("Bobine"), QVariant("coil"));
ui->m_master_type_cb->addItem(tr("Organe de protection"),
QVariant("protection"));
ui->m_master_type_cb->addItem(tr("Commutateur / bouton"),
QVariant("commutator"));
//Disable the edition of the first column of the information tree
//by this little workaround
ui->m_tree->setItemDelegate(new EditorDelegate(this));
@@ -158,28 +153,21 @@ void ElementPropertiesEditorWidget::setUpInterface()
void ElementPropertiesEditorWidget::updateTree()
{
auto type_ = ui->m_base_type_cb->currentData().value<ElementData::Type>();
switch (type_) {
case ElementData::Simple:
ui->m_tree->setEnabled(true);
break;
case ElementData::NextReport:
ui->m_tree->setDisabled(true);
break;
case ElementData::PreviousReport:
ui->m_tree->setDisabled(true);
break;
case ElementData::Master:
ui->m_tree->setEnabled(true);
break;
case ElementData::Slave:
ui->m_tree->setDisabled(true);
break;
case ElementData::Terminale:
ui->m_tree->setEnabled(true);
break;
}
QString type = ui->m_base_type_cb->itemData(
ui->m_base_type_cb->currentIndex()).toString();
if (type == "master")
ui->m_tree->setEnabled(true);
else if (type == "slave")
ui->m_tree->setDisabled(true);
else if (type == "simple")
ui->m_tree->setEnabled(true);
else if (type == "next_report")
ui->m_tree->setDisabled(true);
else if (type == "previous_report")
ui->m_tree->setDisabled(true);
else if (type == "terminal")
ui->m_tree->setEnabled(true);
}
/**
@@ -187,16 +175,20 @@ void ElementPropertiesEditorWidget::updateTree()
Create QTreeWidgetItem of the tree widget and populate it
*/
void ElementPropertiesEditorWidget::populateTree()
{
const auto keys = QETInformation::elementEditorElementInfoKeys();
{
QStringList keys{"label", "plant", "comment", "description",
"designation", "manufacturer",
"manufacturer_reference", "supplier", "quantity",
"unity", "machine_manufacturer_reference"};
for(const QString& key : keys)
{
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree);
qtwi->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
qtwi->setData(0, Qt::DisplayRole,
QETInformation::translatedInfoKey(key));
QETInformation::translatedInfoKey(key));
qtwi->setData(0, Qt::UserRole, key);
qtwi->setText(1, m_data.m_informations.value(key).toString());
qtwi->setText(1, m_elmt_info.value(key).toString());
}
}
@@ -206,21 +198,23 @@ void ElementPropertiesEditorWidget::populateTree()
*/
void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
{
m_data.m_type = ui->m_base_type_cb->currentData().value<ElementData::Type>();
if (m_data.m_type == ElementData::Slave)
m_basic_type = ui->m_base_type_cb->itemData(
ui->m_base_type_cb->currentIndex()).toString();
if (m_basic_type == "slave")
{
m_data.m_slave_state = ui->m_state_cb->currentData().value<ElementData::SlaveState>();
m_data.m_slave_type = ui->m_type_cb->currentData().value<ElementData::SlaveType>();
m_data.m_contact_count = ui->m_number_ctc->value();
m_kind_info.addValue("state",
ui->m_state_cb->itemData(
ui->m_state_cb->currentIndex()));
m_kind_info.addValue("type",
ui->m_type_cb->itemData(
ui->m_type_cb->currentIndex()));
m_kind_info.addValue("number",
QVariant(ui->m_number_ctc->value()));
}
else if (m_data.m_type == ElementData::Master) {
m_data.m_master_type = ui->m_master_type_cb->currentData().value<ElementData::MasterType>();
}
else if (m_data.m_type == ElementData::Terminale)
{
m_data.m_terminal_type = ui->m_terminal_type_cb->currentData().value<ElementData::TerminalType>();
m_data.m_terminal_function = ui->m_terminal_func_cb->currentData().value<ElementData::TerminalFunction>();
else if(m_basic_type == "master") {
m_kind_info.addValue("type",
ui->m_master_type_cb->itemData(
ui->m_master_type_cb->currentIndex()));
}
for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren())
@@ -230,8 +224,8 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
txt.remove("\r");
txt.remove("\n");
m_data.m_informations.addValue(qtwi->data(0, Qt::UserRole).toString(),
txt);
m_elmt_info.addValue(qtwi->data(0, Qt::UserRole).toString(),
txt);
}
this->close();
@@ -241,23 +235,18 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted()
@brief ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged
@param index : Action when combo-box base type index change
*/
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(int index)
void ElementPropertiesEditorWidget::on_m_base_type_cb_currentIndexChanged(
int index)
{
bool slave = false , master = false, terminal = false;
bool slave = false , master = false;
auto type_ = ui->m_base_type_cb->itemData(index).value<ElementData::Type>();
if (type_ == ElementData::Slave)
if (ui->m_base_type_cb->itemData(index).toString() == "slave")
slave = true;
else if (type_ == ElementData::Master)
else if (ui->m_base_type_cb->itemData(index).toString() == "master")
master = true;
else if (type_ == ElementData::Terminale)
terminal = true;
ui->m_slave_gb->setVisible(slave);
ui->m_master_gb->setVisible(master);
ui->m_terminal_gb->setVisible(terminal);
ui->tabWidget->setTabVisible(1,
(type_ == ElementData::Simple ||
type_ == ElementData::Master));
updateTree();
}
@@ -19,7 +19,6 @@
#define ELEMENTPROPERTIESEDITORWIDGET_H
#include "../../diagramcontext.h"
#include "../../properties/elementdata.h"
#include <QAbstractButton>
#include <QDialog>
@@ -39,13 +38,12 @@ class ElementPropertiesEditorWidget : public QDialog
//METHODS
public:
explicit ElementPropertiesEditorWidget(ElementData data, QWidget *parent = nullptr);
explicit ElementPropertiesEditorWidget(QString &basic_type, DiagramContext &kind_info, DiagramContext &elmt_info, QWidget *parent = nullptr);
~ElementPropertiesEditorWidget() override;
ElementData editedData() {return m_data;}
void upDateInterface();
private:
void upDateInterface();
void setUpInterface();
void updateTree();
void populateTree();
@@ -58,7 +56,9 @@ class ElementPropertiesEditorWidget : public QDialog
//ATTRIBUTES
private:
Ui::ElementPropertiesEditorWidget *ui;
ElementData m_data;
QString &m_basic_type;
DiagramContext &m_kind_info,
&m_elmt_info;
};
#endif // ELEMENTPROPERTIESEDITORWIDGET_H
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<height>442</height>
<width>450</width>
<height>321</height>
</rect>
</property>
<property name="windowTitle">
@@ -107,35 +107,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_terminal_gb">
<property name="title">
<string>Élément bornier</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fonction</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_terminal_type_cb"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_terminal_func_cb"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
File diff suppressed because it is too large Load Diff
-163
View File
@@ -1,163 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef QETELEMENTEDITOR_H
#define QETELEMENTEDITOR_H
#include <QMainWindow>
#include "../../ElementsCollection/elementslocation.h"
class ElementScene;
class QActionGroup;
class ElementItemEditor;
class ElementView;
class QListWidget;
class QStackedWidget;
class QLabel;
namespace Ui {
class QETElementEditor;
}
class QETElementEditor : public QMainWindow
{
Q_OBJECT
signals:
void saveToLocation(ElementsLocation loc);
public:
explicit QETElementEditor(QWidget *parent = nullptr);
~QETElementEditor() override;
void contextMenu(QPoint p, QList<QAction *> actions = QList<QAction *>());
void setNames(const NamesList &name_list);
void setLocation(const ElementsLocation &location);
ElementsLocation location() const;
void setFileName(const QString &file_name);
QString fileName() const;
void setReadOnly(bool ro);
bool isReadOnly() const;
void fromFile(const QString &filepath);
bool toFile(const QString &filepath);
void fromLocation(const ElementsLocation &location);
bool toLocation(const ElementsLocation &location);
bool isEditing(const ElementsLocation &location);
bool isEditing(const QString &filepath);
ElementScene *elementScene() const;
ElementView *elementView() const;
static QPointF pasteOffset();
static QString getOpenElementFileName(QWidget *parent = nullptr, const QString &dir = QString());
void updateTitle();
void fillPartsList();
void UncheckAddPrimitive();
void updateCurrentPartEditor();
void updateInformations();
void updatePartsList();
void updateSelectionFromPartsList();
void openElement(const QString &filepath);
bool checkElement();
protected:
bool event(QEvent *event) override;
void closeEvent(QCloseEvent *) override;
private slots:
bool on_m_save_action_triggered();
bool on_m_save_as_action_triggered();
void on_m_select_all_act_triggered();
void on_m_edit_element_properties_action_triggered();
void on_m_new_action_triggered();
void on_m_open_action_triggered();
void on_m_open_from_file_action_triggered();
void on_m_open_dxf_action_triggered();
bool on_m_save_as_file_action_triggered();
void on_m_reload_action_triggered();
void on_m_quit_action_triggered();
void on_m_deselect_all_action_triggered();
void on_m_cut_action_triggered();
void on_m_copy_action_triggered();
void on_m_paste_action_triggered();
void on_m_paste_in_area_action_triggered();
void on_m_paste_from_file_action_triggered();
void on_m_paste_from_element_action_triggered();
void on_m_revert_selection_action_triggered();
void on_m_delete_action_triggered();
void on_m_edit_names_action_triggered();
void on_m_edit_author_action_triggered();
void on_m_zoom_in_action_triggered();
void on_m_zoom_out_action_triggered();
void on_m_zoom_fit_best_action_triggered();
void on_m_zoom_original_action_triggered();
void on_m_about_qet_action_triggered();
void on_m_online_manual_triggered();
void on_m_youtube_action_triggered();
void on_m_donate_action_triggered();
void on_m_about_qt_action_triggered();
private:
bool canClose();
void readSettings();
void writeSettings() const;
void setupActions();
void updateAction();
void setupConnection();
void initGui();
QWidget *clearToolsDock();
void copyAndPasteXml(const QDomDocument &xml_document);
private:
Ui::QETElementEditor *ui;
bool
m_read_only = false,
m_opened_from_file = false,
m_first_activation = true;
ElementScene *m_elmt_scene = nullptr;
QActionGroup
*m_add_part_action_grp = nullptr,
*m_depth_action_group = nullptr;
QList<QAction *> m_context_menu_action_list;
QAction
*m_undo_action = nullptr,
*m_redo_action = nullptr;
/// Hash associating primitive names with their matching edition widget
QHash<QString, ElementItemEditor *> m_editors;
ElementsLocation m_location;
QString
m_file_name,
m_min_title;
ElementView *m_view = nullptr;
QListWidget *m_parts_list = nullptr;
QStackedWidget *m_tools_dock_stack = nullptr;
QLabel *m_default_informations = nullptr;
};
#endif // QETELEMENTEDITOR_H
-496
View File
@@ -1,496 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QETElementEditor</class>
<widget class="QMainWindow" name="QETElementEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>QElectroTech - Éditeur d'élément</string>
</property>
<property name="windowIcon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="m_file_menu">
<property name="title">
<string>&amp;Fichier</string>
</property>
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_open_from_file_action"/>
<addaction name="m_open_dxf_action"/>
<addaction name="m_save_action"/>
<addaction name="m_save_as_action"/>
<addaction name="m_save_as_file_action"/>
<addaction name="separator"/>
<addaction name="m_reload_action"/>
<addaction name="separator"/>
<addaction name="m_quit_action"/>
</widget>
<widget class="QMenu" name="m_edit_menu">
<property name="title">
<string>&amp;Édition</string>
</property>
<widget class="QMenu" name="m_paste_from_menu">
<property name="title">
<string>Coller depuis...</string>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<addaction name="m_paste_from_file_action"/>
<addaction name="m_paste_from_element_action"/>
</widget>
<addaction name="separator"/>
<addaction name="m_select_all_act"/>
<addaction name="m_deselect_all_action"/>
<addaction name="m_revert_selection_action"/>
<addaction name="separator"/>
<addaction name="m_cut_action"/>
<addaction name="m_copy_action"/>
<addaction name="m_paste_action"/>
<addaction name="m_paste_in_area_action"/>
<addaction name="m_paste_from_menu"/>
<addaction name="separator"/>
<addaction name="m_delete_action"/>
<addaction name="separator"/>
<addaction name="m_edit_names_action"/>
<addaction name="m_edit_author_action"/>
<addaction name="m_edit_element_properties_action"/>
</widget>
<widget class="QMenu" name="m_display_menu">
<property name="title">
<string>Afficha&amp;ge</string>
</property>
<addaction name="m_zoom_in_action"/>
<addaction name="m_zoom_out_action"/>
<addaction name="m_zoom_fit_best_action"/>
<addaction name="m_zoom_original_action"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_Aide">
<property name="title">
<string>&amp;Aide</string>
</property>
<addaction name="separator"/>
<addaction name="m_about_qet_action"/>
<addaction name="m_online_manual"/>
<addaction name="m_youtube_action"/>
<addaction name="m_donate_action"/>
<addaction name="m_about_qt_action"/>
</widget>
<addaction name="m_file_menu"/>
<addaction name="m_edit_menu"/>
<addaction name="m_display_menu"/>
<addaction name="menu_Aide"/>
</widget>
<widget class="QDockWidget" name="m_undo_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Annulations</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents"/>
</widget>
<widget class="QDockWidget" name="m_parts_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Parties</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2"/>
</widget>
<widget class="QDockWidget" name="m_tools_dock">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Informations</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3"/>
</widget>
<widget class="QToolBar" name="m_main_toolbar">
<property name="windowTitle">
<string>Outils</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_new_action"/>
<addaction name="m_open_action"/>
<addaction name="m_save_action"/>
<addaction name="m_save_as_action"/>
<addaction name="m_reload_action"/>
<addaction name="m_delete_action"/>
</widget>
<widget class="QToolBar" name="m_view_toolbar">
<property name="windowTitle">
<string>Affichage</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_zoom_in_action"/>
<addaction name="m_zoom_out_action"/>
<addaction name="m_zoom_fit_best_action"/>
<addaction name="m_zoom_original_action"/>
</widget>
<widget class="QToolBar" name="m_element_toolbar">
<property name="windowTitle">
<string>Élément</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="m_edit_names_action"/>
<addaction name="m_edit_element_properties_action"/>
</widget>
<widget class="QToolBar" name="m_undo_toolbar">
<property name="windowTitle">
<string>Annulation</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<action name="m_select_all_act">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
</property>
<property name="text">
<string>Tout sélectionner</string>
</property>
</action>
<action name="m_new_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-new.png</normaloff>:/ico/22x22/document-new.png</iconset>
</property>
<property name="text">
<string>&amp;Nouveau</string>
</property>
</action>
<action name="m_open_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
</property>
<property name="text">
<string>&amp;Ouvrir</string>
</property>
</action>
<action name="m_open_from_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/folder-open.png</normaloff>:/ico/22x22/folder-open.png</iconset>
</property>
<property name="text">
<string>&amp;Ouvrir depuis un fichier</string>
</property>
</action>
<action name="m_open_dxf_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/run-dxf.png</normaloff>:/ico/16x16/run-dxf.png</iconset>
</property>
<property name="text">
<string>&amp;Lancer le plugin convertisseur DXF</string>
</property>
</action>
<action name="m_save_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
</property>
<property name="text">
<string>&amp;Enregistrer</string>
</property>
</action>
<action name="m_save_as_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save-as.png</normaloff>:/ico/22x22/document-save-as.png</iconset>
</property>
<property name="text">
<string>Enregistrer sous</string>
</property>
</action>
<action name="m_save_as_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/document-save.png</normaloff>:/ico/22x22/document-save.png</iconset>
</property>
<property name="text">
<string>Enregistrer dans un fichier</string>
</property>
</action>
<action name="m_reload_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/view-refresh.png</normaloff>:/ico/22x22/view-refresh.png</iconset>
</property>
<property name="text">
<string>Recharger</string>
</property>
</action>
<action name="m_quit_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/application-exit.png</normaloff>:/ico/16x16/application-exit.png</iconset>
</property>
<property name="text">
<string>&amp;Quitter</string>
</property>
</action>
<action name="m_deselect_all_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-none.png</normaloff>:/ico/16x16/edit-select-none.png</iconset>
</property>
<property name="text">
<string>Désélectionner tout</string>
</property>
</action>
<action name="m_cut_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-cut.png</normaloff>:/ico/16x16/edit-cut.png</iconset>
</property>
<property name="text">
<string>Co&amp;uper</string>
</property>
</action>
<action name="m_copy_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-copy.png</normaloff>:/ico/16x16/edit-copy.png</iconset>
</property>
<property name="text">
<string>Cop&amp;ier</string>
</property>
</action>
<action name="m_paste_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<property name="text">
<string>C&amp;oller</string>
</property>
</action>
<action name="m_paste_in_area_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-paste.png</normaloff>:/ico/16x16/edit-paste.png</iconset>
</property>
<property name="text">
<string>C&amp;oller dans la zone</string>
</property>
</action>
<action name="m_paste_from_file_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/text-xml.png</normaloff>:/ico/16x16/text-xml.png</iconset>
</property>
<property name="text">
<string>Un fichier</string>
</property>
</action>
<action name="m_paste_from_element_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/element.png</normaloff>:/ico/16x16/element.png</iconset>
</property>
<property name="text">
<string>Un élément</string>
</property>
</action>
<action name="m_revert_selection_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-invert.png</normaloff>:/ico/16x16/edit-select-invert.png</iconset>
</property>
<property name="text">
<string>Inverser la sélection</string>
</property>
</action>
<action name="m_delete_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/edit-delete.png</normaloff>:/ico/22x22/edit-delete.png</iconset>
</property>
<property name="text">
<string>&amp;Supprimer</string>
</property>
</action>
<action name="m_edit_names_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/names.png</normaloff>:/ico/22x22/names.png</iconset>
</property>
<property name="text">
<string>Éditer le nom et les traductions de l'élément</string>
</property>
</action>
<action name="m_edit_author_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/preferences-desktop-user.png</normaloff>:/ico/16x16/preferences-desktop-user.png</iconset>
</property>
<property name="text">
<string>Éditer les informations sur l'auteur</string>
</property>
</action>
<action name="m_edit_element_properties_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/element-edit.png</normaloff>:/ico/22x22/element-edit.png</iconset>
</property>
<property name="text">
<string>Éditer les propriétés de l'élément</string>
</property>
</action>
<action name="m_zoom_in_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-in.png</normaloff>:/ico/22x22/zoom-in.png</iconset>
</property>
<property name="text">
<string>Zoom avant</string>
</property>
</action>
<action name="m_zoom_out_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-out.png</normaloff>:/ico/22x22/zoom-out.png</iconset>
</property>
<property name="text">
<string>Zoom arrière</string>
</property>
</action>
<action name="m_zoom_fit_best_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-fit-best.png</normaloff>:/ico/22x22/zoom-fit-best.png</iconset>
</property>
<property name="text">
<string>Zoom adapté</string>
</property>
</action>
<action name="m_zoom_original_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/zoom-original.png</normaloff>:/ico/22x22/zoom-original.png</iconset>
</property>
<property name="text">
<string>Pas de zoom</string>
</property>
</action>
<action name="m_about_qet_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qet.png</normaloff>:/ico/16x16/qet.png</iconset>
</property>
<property name="text">
<string>À &amp;propos de QElectroTech</string>
</property>
<property name="statusTip">
<string>Affiche des informations sur QElectroTech</string>
</property>
</action>
<action name="m_online_manual">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/help-contents.png</normaloff>:/ico/16x16/help-contents.png</iconset>
</property>
<property name="text">
<string>Manuel en ligne</string>
</property>
<property name="statusTip">
<string>Lance le navigateur par défaut vers le manuel en ligne de QElectroTech</string>
</property>
</action>
<action name="m_youtube_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/kdenlive-show-video.png</normaloff>:/ico/16x16/kdenlive-show-video.png</iconset>
</property>
<property name="text">
<string>Chaine Youtube</string>
</property>
<property name="statusTip">
<string>Lance le navigateur par défaut vers la chaine Youtube de QElectroTech</string>
</property>
</action>
<action name="m_donate_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/help-donate.png</normaloff>:/ico/16x16/help-donate.png</iconset>
</property>
<property name="text">
<string>Soutenir le projet par un don</string>
</property>
<property name="statusTip">
<string>Soutenir le projet QElectroTech par un don</string>
</property>
</action>
<action name="m_about_qt_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/qt.png</normaloff>:/ico/16x16/qt.png</iconset>
</property>
<property name="text">
<string>À propos de &amp;Qt</string>
</property>
<property name="statusTip">
<string>Affiche des informations sur la bibliothèque Qt</string>
</property>
</action>
</widget>
<resources>
<include location="../../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>
-254
View File
@@ -1,254 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaleditor.h"
#include "ui_terminaleditor.h"
#include "../../qeticons.h"
#include "../../qet.h"
#include "../graphicspart/partterminal.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
/**
* @brief TerminalEditor::TerminalEditor
* Default constructor
* @param editor : element editor of which this terminal editor belong
* @param parent : parent widget
*/
TerminalEditor::TerminalEditor(QETElementEditor *editor, QWidget *parent) :
ElementItemEditor(editor, parent),
ui(new Ui::TerminalEditor)
{
ui->setupUi(this);
init();
}
/**
* @brief TerminalEditor::~TerminalEditor
* Destructor
*/
TerminalEditor::~TerminalEditor()
{
delete ui;
}
/**
* @brief TerminalEditor::updateForm
* Reimplemented from ElementItemEditor
* Update the content of this widget
*/
void TerminalEditor::updateForm()
{
if (!m_part) {
return;
}
activeConnections(false);
ui->m_x_dsb->setValue(m_part->property("x").toReal());
ui->m_y_dsb->setValue(m_part->property("y").toReal());
ui->m_orientation_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->property("orientation")));
ui->m_name_le->setText(m_part->name());
ui->m_type_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->terminalType()));
activeConnections(true);
}
/**
* @brief TerminalEditor::setPart
* Set the part to edit.
* The part must be a PartTerminal, in other case return false.
* @param new_part : the part to edit
* @return true if the part can be edited.
*/
bool TerminalEditor::setPart(CustomElementPart *new_part)
{
if (m_part == new_part) {
return true;
}
activeChangeConnections(false);
if (!new_part)
{
m_part = nullptr;
return(true);
}
if (PartTerminal *part_terminal = dynamic_cast<PartTerminal *>(new_part))
{
m_part = part_terminal;
updateForm();
activeChangeConnections(true);
return(true);
}
return(false);
}
/**
* @brief TerminalEditor::currentPart
* @return the current edited part
* or nullptr if there is no part or several part
* @see QList<CustomElementPart *> TerminalEditor::currentParts() const
*/
CustomElementPart *TerminalEditor::currentPart() const
{
return m_part;
}
/**
* @brief TerminalEditor::init
* Some init about this class
*/
void TerminalEditor::init()
{
ui->m_orientation_cb->addItem(QET::Icons::North, tr("Nord"), Qet::North);
ui->m_orientation_cb->addItem(QET::Icons::East, tr("Est"), Qet::East);
ui->m_orientation_cb->addItem(QET::Icons::South, tr("Sud"), Qet::South);
ui->m_orientation_cb->addItem(QET::Icons::West, tr("Ouest"), Qet::West);
ui->m_type_cb->addItem(tr("Générique"), TerminalData::Generic);
ui->m_type_cb->addItem(tr("Bornier intérieur"), TerminalData::Inner);
ui->m_type_cb->addItem(tr("Bornier extérieur"), TerminalData::Outer);
}
/**
* @brief TerminalEditor::posEdited
*/
void TerminalEditor::posEdited()
{
if (m_locked) {
return;
}
m_locked = true;
QPointF new_pos(ui->m_x_dsb->value(),
ui->m_y_dsb->value());
if (m_part->pos() != new_pos)
{
auto undo = new QPropertyUndoCommand(m_part, "pos", m_part->property("pos"), new_pos);
undo->setText(tr("Déplacer une borne"));
undo->setAnimated(true, false);
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::orientationEdited
*/
void TerminalEditor::orientationEdited()
{
if (m_locked) {
return;
}
m_locked = true;
auto ori_ = ui->m_orientation_cb->currentData();
if (m_part->orientation() != ori_)
{
auto undo = new QPropertyUndoCommand(m_part, "orientation", m_part->property("orientation"), ori_);
undo->setText(tr("Modifier l'orientation d'une borne"));
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::nameEdited
*/
void TerminalEditor::nameEdited()
{
if (m_locked) {
return;
}
m_locked = true;
QString name_(ui->m_name_le->text());
if (m_part->name() != name_)
{
auto undo = new QPropertyUndoCommand(m_part, "name", m_part->property("name"), name_);
undo->setText(tr("Modifier le nom du terminal"));
undoStack().push(undo);
}
m_locked=false;
}
/**
* @brief TerminalEditor::typeEdited
*/
void TerminalEditor::typeEdited()
{
if (m_locked) {
return;
}
m_locked = true;
auto type = ui->m_type_cb->currentData();
if (type != m_part->terminalType()) {
auto undo = new QPropertyUndoCommand(m_part, "terminal_type", m_part->terminalType(), type);
undo->setText(tr("Modifier le type d'une borne"));
undoStack().push(undo);
}
m_locked = false;
}
/**
* @brief TerminalEditor::activeConnections
* Active connection between the widgets used in this editor
* and method of this class.
* @param active
*/
void TerminalEditor::activeConnections(bool active)
{
if (active) {
m_editor_connections << connect(ui->m_x_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, &TerminalEditor::posEdited);
m_editor_connections << connect(ui->m_y_dsb, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, &TerminalEditor::posEdited);
m_editor_connections << connect(ui->m_orientation_cb, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::orientationEdited);
m_editor_connections << connect(ui->m_name_le, &QLineEdit::editingFinished,
this, &TerminalEditor::nameEdited);
m_editor_connections << connect(ui->m_type_cb, QOverload<int>::of(&QComboBox::activated),
this, &TerminalEditor::typeEdited);
} else {
for (auto const & con : qAsConst(m_editor_connections)) {
QObject::disconnect(con);
}
m_editor_connections.clear();
}
}
void TerminalEditor::activeChangeConnections(bool active)
{
if (active)
{
m_change_connections << connect(m_part, &PartTerminal::xChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::yChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::orientationChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::nameChanged, this, &TerminalEditor::updateForm);
m_change_connections << connect(m_part, &PartTerminal::terminalTypeChanged, this, &TerminalEditor::updateForm);
} else {
for (auto &con : m_change_connections) {
QObject::disconnect(con);
}
m_change_connections.clear();
}
}
-64
View File
@@ -1,64 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINALEDITOR_H
#define TERMINALEDITOR_H
#include <QWidget>
#include "../elementitemeditor.h"
namespace Ui {
class TerminalEditor;
}
class PartTerminal;
/**
* @brief The TerminalEditor class
* Provide a widget used to edit the properties of a PartTerminal
*/
class TerminalEditor : public ElementItemEditor
{
Q_OBJECT
public:
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
~TerminalEditor() override;
void updateForm() override;
bool setPart(CustomElementPart *new_part) override;
CustomElementPart *currentPart() const override;
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
private:
void init();
void posEdited();
void orientationEdited();
void nameEdited();
void typeEdited();
void activeConnections(bool active);
void activeChangeConnections(bool active);
private:
Ui::TerminalEditor *ui;
QVector<QMetaObject::Connection> m_editor_connections,
m_change_connections;
PartTerminal *m_part = nullptr;
bool m_locked = false;
};
#endif // TERMINALEDITOR_H
-98
View File
@@ -1,98 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TerminalEditor</class>
<widget class="QWidget" name="TerminalEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>511</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>y :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="m_x_dsb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_y_dsb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Orientation :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="m_name_le"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="m_orientation_cb"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>x :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Nom :</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Type :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="m_type_cb"/>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+25
View File
@@ -53,6 +53,31 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
cache_db_.exec("PRAGMA synchronous = OFF");
#if TODO_LIST
#pragma message("@TODO This code remove old table with mtime for create table with uuid, created at version 0,5")
#endif
//TODO This code remove old table with mtime for create table with uuid, created at version 0,5
//see to remove this code at version 0,6 or 0,7 when all users will table with uuid.
#if TODO_LIST
#pragma message("@TODO remove this code for qet 0.6 or later")
#endif
QSqlQuery table_name(cache_db_);
if (table_name.exec("PRAGMA table_info(names)"))
{
if (table_name.seek(2))
{
QString str = table_name.value(1).toString();
table_name.finish();
if (str == "mtime")
{
QSqlQuery error;
error = cache_db_.exec("DROP TABLE names");
error = cache_db_.exec("DROP TABLE pixmaps");
}
}
else
table_name.finish();
}
#if TODO_LIST
#pragma message("@TODO the tables could already exist, handle that case.")
#endif
//@TODO the tables could already exist, handle that case.
+1 -1
View File
@@ -18,7 +18,7 @@
#include "elementspanelwidget.h"
#include "diagram.h"
#include "editor/ui/qetelementeditor.h"
#include "editor/qetelementeditor.h"
#include "elementscategoryeditor.h"
#include "qetapp.h"
#include "qeticons.h"
+3 -4
View File
@@ -79,10 +79,9 @@ void QetGraphicsTableFactory::create(Diagram *diagram, AddTableDialog *dialog)
}
//Add new table if needed and option checked
dialog->addNewTableToNewDiagram();
table_->model()->rowCount();
table_->displayNRow();
if (dialog->addNewTableToNewDiagram() && table_->model()->rowCount() > table_->displayNRow())
if (dialog->addNewTableToNewDiagram()
&& table_->displayNRow() > 0
&& table_->model()->rowCount() > table_->displayNRow())
{
auto already_displayed_rows = table_->displayNRow();
auto project_ = diagram->project();
+23 -24
View File
@@ -29,20 +29,21 @@
#endif
#include "qet.h"
MachineInfo *MachineInfo::m_instance = nullptr;
/**
@brief Machine_info::Machine_info
@brief MachineInfo::MachineInfo
@param parent
*/
Machine_info::Machine_info(QObject *parent) : QObject(parent)
MachineInfo::MachineInfo()
{
init_get_Screen_info();
init_get_cpu_info();
}
/**
@brief Machine_info::send_info_to_debug
@brief MachineInfo::send_info_to_debug
*/
void Machine_info::send_info_to_debug()
void MachineInfo::send_info_to_debug()
{
qInfo()<<"debugging enabled:"
<< QLibraryInfo::isDebugBuild();
@@ -120,7 +121,7 @@ void Machine_info::send_info_to_debug()
#endif
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
qInfo()<< "QElectroTech V " + QET::displayedVersion;
qInfo()<< tr("Compilation : ") + pc.built.version;
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
qInfo()<< "Built with Qt " + pc.built.QT
+ " - Date : " + pc.built.date
+ " : " + pc.built.time;
@@ -151,10 +152,10 @@ void Machine_info::send_info_to_debug()
}
/**
@brief Machine_info::init_get_Screen_info
@brief MachineInfo::init_get_Screen_info
Finds the largest screen and saves the values
*/
void Machine_info::init_get_Screen_info()
void MachineInfo::init_get_Screen_info()
{
const auto screens = qApp->screens();
pc.screen.count=screens.count();
@@ -174,9 +175,9 @@ void Machine_info::init_get_Screen_info()
}
/**
@brief Machine_info::init_get_cpu_info
@brief MachineInfo::init_get_cpu_info
*/
void Machine_info::init_get_cpu_info()
void MachineInfo::init_get_cpu_info()
{
#ifdef __GNUC__
#ifdef __APPLE_CC__
@@ -191,9 +192,9 @@ void Machine_info::init_get_cpu_info()
}
/**
@brief Machine_info::init_get_cpu_info_linux
@brief MachineInfo::init_get_cpu_info_linux
*/
void Machine_info::init_get_cpu_info_linux()
void MachineInfo::init_get_cpu_info_linux()
{
QProcess linuxcpuinfo;
linuxcpuinfo.start("bash", QStringList()
@@ -237,9 +238,9 @@ void Machine_info::init_get_cpu_info_linux()
}
/**
@brief Machine_info::init_get_cpu_info_winnt
@brief MachineInfo::init_get_cpu_info_winnt
*/
void Machine_info::init_get_cpu_info_winnt()
void MachineInfo::init_get_cpu_info_winnt()
{
QProcess wincpuinfo;
wincpuinfo.start("wmic",
@@ -291,9 +292,9 @@ void Machine_info::init_get_cpu_info_winnt()
}
/**
@brief Machine_info::init_get_cpu_info_macos
@brief MachineInfo::init_get_cpu_info_macos
*/
void Machine_info::init_get_cpu_info_macos()
void MachineInfo::init_get_cpu_info_macos()
{
QProcess macoscpuinfo;
macoscpuinfo.start("bash",
@@ -317,30 +318,28 @@ void Machine_info::init_get_cpu_info_macos()
}
/**
@brief Machine_info::i_max_screen_width
@brief MachineInfo::i_max_screen_width
@return max screen width
*/
int32_t Machine_info::i_max_screen_width()
{
int32_t MachineInfo::i_max_screen_width() {
return pc.screen.Max_width;
}
/**
@brief Machine_info::i_max_screen_height
@brief MachineInfo::i_max_screen_height
@return max screen height
*/
int32_t Machine_info::i_max_screen_height()
{
int32_t MachineInfo::i_max_screen_height() {
return pc.screen.Max_height;
}
/**
@brief Machine_info::compilation_info
@brief MachineInfo::compilation_info
@return compilation_info
*/
QString Machine_info::compilation_info()
QString MachineInfo::compilation_info()
{
QString compilation_info = "<br />" + tr("Compilation : ");
QString compilation_info = "<br />" + QObject::tr("Compilation : ");
compilation_info +=pc.built.version;
compilation_info += "<br>Built with Qt " + pc.built.QT;
compilation_info += " - Date : " + pc.built.date;
+43 -17
View File
@@ -18,31 +18,57 @@
#ifndef MACHINE_INFO_H
#define MACHINE_INFO_H
#include <QObject>
#include <QThread>
#include <QMutex>
/**
@brief The Machine_info class
@brief The MachineInfo class
This class hold information from your PC.
*/
class Machine_info : public QObject
class MachineInfo
{
Q_OBJECT
public:
explicit Machine_info(QObject *parent = nullptr);
int32_t i_max_screen_width();
int32_t i_max_screen_height();
QString compilation_info();
void send_info_to_debug();
static MachineInfo *m_instance;
public:
static MachineInfo *instance()
{
static QMutex mutex;
if (!m_instance)
{
mutex.lock();
if (!m_instance) {
m_instance = new MachineInfo();
}
mutex.unlock();
}
signals:
return m_instance;
}
static void dropInstance()
{
static QMutex mutex;
if (m_instance) {
mutex.lock();
delete m_instance;
m_instance = nullptr;
mutex.unlock();
}
}
int32_t i_max_screen_width();
int32_t i_max_screen_height();
QString compilation_info();
void send_info_to_debug();
private:
MachineInfo();
void init_get_Screen_info();
void init_get_cpu_info();
void init_get_cpu_info_linux();
void init_get_cpu_info_winnt();
void init_get_cpu_info_macos();
private:
void init_get_Screen_info();
void init_get_cpu_info();
void init_get_cpu_info_linux();
void init_get_cpu_info_winnt();
void init_get_cpu_info_macos();
struct Pc
{
struct Screen
+27 -12
View File
@@ -18,10 +18,11 @@
#include "machine_info.h"
#include "qet.h"
#include "qetapp.h"
#include "singleapplication.h"
#include "utils/macosxopenevent.h"
#include <QStyleFactory>
#include <QApplication>
#include <QtConcurrent>
/**
@brief myMessageOutput
@@ -174,7 +175,7 @@ int main(int argc, char **argv)
#pragma message("@TODO remove code for QT 6 or later")
#endif
#endif
QApplication app(argc, argv, true);
SingleApplication app(argc, argv, true);
#ifdef Q_OS_MACOS
//Handle the opening of QET when user double click on a .qet .elmt .tbt file
//or drop these same files to the QET icon of the dock
@@ -182,19 +183,33 @@ int main(int argc, char **argv)
app.installEventFilter(&open_event);
app.setStyle(QStyleFactory::create("Fusion"));
#endif
if (app.isSecondary())
{
QStringList arg_list = app.arguments();
//Remove the first argument, it's the binary file
arg_list.takeFirst();
QETArguments qetarg(arg_list);
QString message = "launched-with-args: " + QET::joinWithSpaces(
QStringList(qetarg.arguments()));
app.sendMessage(message.toUtf8());
return 0;
}
QETApp qetapp;
QETApp::instance()->installEventFilter(&qetapp);
QObject::connect(&app, &SingleApplication::receivedMessage,
&qetapp, &QETApp::receiveMessage);
// for debugging
qInstallMessageHandler(myMessageOutput);
qInfo("Start-up");
// delete old log files of max 7 days old.
delete_old_log_files(7);
{
Machine_info *my_ma =new Machine_info();
my_ma->send_info_to_debug();
delete my_ma;
}
QtConcurrent::run([=]()
{
// for debugging
qInstallMessageHandler(myMessageOutput);
qInfo("Start-up");
// delete old log files of max 7 days old.
delete_old_log_files(7);
MachineInfo::instance()->send_info_to_debug();
});
return app.exec();
}
+1 -5
View File
@@ -20,14 +20,10 @@
#include "ElementsCollection/elementcollectionitem.h"
#include "ElementsCollection/elementscollectionmodel.h"
#include "NameList/ui/namelistwidget.h"
#include "editor/ui/qetelementeditor.h"
#include "editor/qetelementeditor.h"
#include "qetmessagebox.h"
#include "qfilenameedit.h"
#include <QTreeView>
#include <QVBoxLayout>
#include <QLabel>
/**
Constructeur
@param parent QWidget parent de ce dialogue
+1 -1
View File
@@ -21,7 +21,7 @@
#include "autoNum/assignvariables.h"
#include "diagram.h"
#include "diagramview.h"
#include "editor/ui/qetelementeditor.h"
#include "editor/qetelementeditor.h"
#include "exportdialog.h"
#include "qetapp.h"
#include "qeticons.h"
-406
View File
@@ -1,406 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "elementdata.h"
#include "../qetxml.h"
#include <QDebug>
void ElementData::toSettings(QSettings &settings, const QString prefix) const {
Q_UNUSED(settings)
Q_UNUSED(prefix)
}
void ElementData::fromSettings(const QSettings &settings, const QString prefix) {
Q_UNUSED(settings)
Q_UNUSED(prefix)
}
QDomElement ElementData::toXml(QDomDocument &xml_element) const {
Q_UNUSED(xml_element)
return QDomElement();
}
/**
* @brief ElementData::fromXml
* load properties from xml element.
* The tag name of xml_element must be definition
* and have an attribute "type"
* @param xml_element : tagName must be 'definition'
* @return true is successfuly loaded
*/
bool ElementData::fromXml(const QDomElement &xml_element)
{
if(xml_element.tagName() != "definition" ||
xml_element.attribute("type") != "element") {
return false;
}
m_type = typeFromString(xml_element.attribute("link_type", "simple"));
kindInfoFromXml(xml_element);
m_informations.fromXml(xml_element.firstChildElement("elementInformations"),
"elementInformation");
m_names_list.fromXml(xml_element);
auto xml_draw_info = xml_element.firstChildElement("informations");
if(xml_draw_info.tagName() == "informations") {
m_drawing_information = xml_draw_info.text();
}
return true;
}
QDomElement ElementData::kindInfoToXml(QDomDocument &document)
{
//kindInformations
auto returned_elmt = document.createElement("kindInformations");
if (m_type == ElementData::Master)
{
auto xml_type = document.createElement("kindInformation");
xml_type.setAttribute("name", "type");
auto type_txt = document.createTextNode(masterTypeToString(m_master_type));
xml_type.appendChild(type_txt);
returned_elmt.appendChild(xml_type);
}
else if (m_type == ElementData::Slave)
{
//type
auto xml_type = document.createElement("kindInformation");
xml_type.setAttribute("name", "type");
auto type_txt = document.createTextNode(slaveTypeToString(m_slave_type));
xml_type.appendChild(type_txt);
returned_elmt.appendChild(xml_type);
//state
auto xml_state = document.createElement("kindInformation");
xml_state.setAttribute("name", "state");
auto state_txt = document.createTextNode(slaveStateToString(m_slave_state));
xml_state.appendChild(state_txt);
returned_elmt.appendChild(xml_state);
//contact count
auto xml_count = document.createElement("kindInformation");
xml_count.setAttribute("name", "number");
auto count_txt = document.createTextNode(QString::number(m_contact_count));
xml_count.appendChild(count_txt);
returned_elmt.appendChild(xml_count);
}
else if (m_type == ElementData::Terminale)
{
//type
auto xml_type = document.createElement("kindInformation");
xml_type.setAttribute("name", "type");
auto type_txt = document.createTextNode(terminalTypeToString(m_terminal_type));
xml_type.appendChild(type_txt);
returned_elmt.appendChild(xml_type);
//function
auto xml_func = document.createElement("kindInformation");
xml_func.setAttribute("name", "function");
auto func_txt = document.createTextNode(terminalFunctionToString(m_terminal_function));
xml_func.appendChild(func_txt);
returned_elmt.appendChild(xml_func);
}
return returned_elmt;
}
bool ElementData::operator==(const ElementData &data) const
{
if (data.m_type != m_type) {
return false;
}
if (data.m_type == ElementData::Master) {
if(data.m_master_type != m_master_type) {
return false;
}
}
else if (data.m_type == ElementData::Slave) {
if (data.m_slave_state != m_slave_state ||
data.m_slave_type != m_slave_type ||
data.m_contact_count != m_contact_count) {
return false;
}
}
else if (data.m_type == ElementData::Terminale) {
if (data.m_terminal_type != m_terminal_type ||
data.m_terminal_function != m_terminal_function) {
return false;
}
}
if(data.m_informations != m_informations) {
return false;
}
if (data.m_names_list != m_names_list) {
return false;
}
if (m_drawing_information != m_drawing_information) {
return false;
}
return true;
}
bool ElementData::operator !=(const ElementData &data) const {
return !(*this == data);
}
QString ElementData::typeToString(ElementData::Type type)
{
switch (type) {
case ElementData::Simple :
return QString("simple");
case ElementData::NextReport :
return QString ("next_report");
case ElementData::PreviousReport :
return QString("previous_report");
case ElementData::Master :
return QString("master");
case ElementData::Slave :
return QString("slave");
case ElementData::Terminale :
return QString("terminal");
default:
qDebug() << "ElementData::typeToString : type don't exist"
<< "return failsafe value 'simple'";
return QString("simple");
}
}
ElementData::Type ElementData::typeFromString(const QString &string)
{
if (string == "simple") {
return ElementData::Simple;
} else if (string == "next_report") {
return ElementData::NextReport;
} else if (string == "previous_report") {
return ElementData::PreviousReport;
} else if (string == "master") {
return ElementData::Master;
} else if (string == "slave") {
return ElementData::Slave;
} else if (string == "terminal") {
return ElementData::Terminale;
}
//Return simple if nothing match
qDebug() << "ElementData::typeFromString : string "
<< string
<< " don't exist, return failsafe value 'simple";
return ElementData::Simple;
}
QString ElementData::masterTypeToString(ElementData::MasterType type)
{
switch (type) {
case ElementData::Coil:
return QString ("coil");
case ElementData::Protection:
return QString ("protection");
case ElementData::Commutator:
return QString ("commutator");
}
}
ElementData::MasterType ElementData::masterTypeFromString(const QString &string)
{
if (string == "coil") {
return ElementData::Coil;
} else if (string == "protection") {
return ElementData::Protection;
} else if (string == "commutator") {
return ElementData::Commutator;
}
qDebug() << "ElementData::masterTypeFromString : string "
<< string
<< " don't exist, return failsafe value 'coil'";
return ElementData::Coil;
}
QString ElementData::slaveTypeToString(ElementData::SlaveType type)
{
switch (type) {
case ElementData::SSimple:
return QString ("simple");
case ElementData::Power:
return QString ("power");
case ElementData::DelayOn:
return QString("delayOn");
case ElementData::DelayOff:
return QString("delayOff");
case ElementData::delayOnOff:
return QString("delayOnOff");
}
}
ElementData::SlaveType ElementData::slaveTypeFromString(const QString &string)
{
if (string == "simple") {
return ElementData::SSimple;
} else if (string == "power") {
return ElementData::Power;
} else if (string == "delayOn") {
return ElementData::DelayOn;
} else if (string == "delayOff") {
return ElementData::DelayOff;
} else if (string == "delayOnOff") {
return ElementData::delayOnOff;
}
qDebug() << "ElementData::slaveTypeFromSting : string "
<< string
<< " don't exist, return failsafe value 'simple'";
return ElementData::SSimple;
}
QString ElementData::slaveStateToString(ElementData::SlaveState type)
{
switch (type) {
case NO:
return QString("NO");
case NC:
return QString("NC");
case SW:
return QString("SW");
}
}
ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
{
if (string == "NO") {
return ElementData::NO;
} else if (string == "NC") {
return ElementData::NC;
} else if (string == "SW") {
return ElementData::SW;
}
qDebug() << "ElementData::slaveStateFromString : string : "
<< string
<< " don't exist, return failsafe value 'NO'";
return ElementData::NO;
}
QString ElementData::terminalTypeToString(ElementData::TerminalType type)
{
switch (type) {
case ElementData::TTGeneric :
return QString("generic");
case ElementData::Fuse :
return QString("fuse");
case ElementData::Sectional:
return QString("sectional");
case ElementData::Diode:
return QString("diode");
}
}
ElementData::TerminalType ElementData::terminalTypeFromString(const QString &string)
{
if (string == "generic") {
return ElementData::TTGeneric;
} else if (string == "fuse") {
return ElementData::Fuse;
} else if (string == "sectional") {
return ElementData::Sectional;
} else if (string == "diode") {
return ElementData::Diode;
}
qDebug() << "ElementData::terminalTypeFromString : string : "
<< string
<< " don't exist, return failsafe value 'generic'";
return ElementData::TTGeneric;
}
QString ElementData::terminalFunctionToString(ElementData::TerminalFunction function)
{
switch (function) {
case ElementData::TFGeneric:
return QString("generic");
case ElementData::Phase:
return QString ("phase");
case ElementData::Neutral:
return QString("neutral");
case ElementData::PE:
return QString("pe");
}
}
ElementData::TerminalFunction ElementData::terminalFunctionFromString(const QString &string)
{
if (string == "generic") {
return ElementData::TFGeneric;
} else if (string == "phase") {
return ElementData::Phase;
} else if (string == "neutral") {
return ElementData::Neutral;
} else if (string == "pe") {
return ElementData::PE;
}
qDebug() << "ElementData::terminalFunctionFromString : string : "
<< string
<< " don't exist, return failsafe value 'generic'";
return ElementData::TFGeneric;
}
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
{
if (m_type == ElementData::Master ||
m_type == ElementData::Slave ||
m_type == ElementData::Terminale)
{
auto xml_kind = xml_element.firstChildElement("kindInformations");
for (const auto &dom_elmt : QETXML::findInDomElement(xml_kind, "kindInformation"))
{
if (!dom_elmt.hasAttribute("name")) {
continue;
}
auto name = dom_elmt.attribute("name");
if (m_type == ElementData::Master &&
name == "type") {
m_master_type = masterTypeFromString(dom_elmt.text());
}
else if (m_type == ElementData::Slave ) {
if (name == "type") {
m_slave_type = slaveTypeFromString(dom_elmt.text());
} else if (name == "state") {
m_slave_state = slaveStateFromString(dom_elmt.text());
} else if (name == "number") {
m_contact_count = dom_elmt.text().toInt();
}
}
else if (m_type == ElementData::Terminale) {
if (name == "type") {
m_terminal_type = terminalTypeFromString(dom_elmt.text());
} else if (name == "function") {
m_terminal_function = terminalFunctionFromString(dom_elmt.text());
}
}
}
}
}
-135
View File
@@ -1,135 +0,0 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef ELEMENTDATA_H
#define ELEMENTDATA_H
#include "propertiesinterface.h"
#include "../diagramcontext.h"
#include "../NameList/nameslist.h"
/**
* @brief The ElementData class
* WARNING
* This class inherit from PropertiesInterface but
* only fromXml is actually reimplemented.
*/
class ElementData : public PropertiesInterface
{
Q_GADGET
public:
enum Type {
Simple = 1,
NextReport = 2,
PreviousReport = 4,
AllReport = 6,
Master = 8,
Slave = 16,
Terminale = 32};
Q_ENUM(Type)
enum MasterType {
Coil,
Protection,
Commutator
};
Q_ENUM(MasterType)
enum SlaveType {
SSimple,
Power,
DelayOn,
DelayOff,
delayOnOff
};
Q_ENUM(SlaveType)
enum SlaveState {
NO,
NC,
SW
};
Q_ENUM(SlaveState)
enum TerminalType {
TTGeneric,
Fuse,
Sectional,
Diode
};
Q_ENUM(TerminalType)
enum TerminalFunction {
TFGeneric,
Phase,
Neutral,
PE
};
Q_ENUM(TerminalFunction)
ElementData() {}
~ElementData() override {}
void toSettings(QSettings &settings, const QString prefix = QString()) const override;
void fromSettings(const QSettings &settings, const QString prefix = QString()) override;
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
QDomElement kindInfoToXml(QDomDocument &document);
bool operator==(const ElementData &data) const;
bool operator!=(const ElementData &data) const;
static QString typeToString(ElementData::Type type);
static ElementData::Type typeFromString(const QString &string);
static QString masterTypeToString(ElementData::MasterType type);
static ElementData::MasterType masterTypeFromString(const QString &string);
static QString slaveTypeToString (ElementData::SlaveType type);
static ElementData::SlaveType slaveTypeFromString(const QString &string);
static QString slaveStateToString(ElementData::SlaveState type);
static ElementData::SlaveState slaveStateFromString(const QString &string);
static QString terminalTypeToString(ElementData::TerminalType type);
static ElementData::TerminalType terminalTypeFromString(const QString &string);
static QString terminalFunctionToString(ElementData::TerminalFunction function);
static ElementData::TerminalFunction terminalFunctionFromString(const QString &string);
// must be public, because this class is a private member
// of Element/ element editor and they must access this data
ElementData::Type m_type = ElementData::Simple;
ElementData::MasterType m_master_type = ElementData::Coil;
ElementData::SlaveType m_slave_type = ElementData::SSimple;
ElementData::SlaveState m_slave_state = ElementData::NO;
ElementData::TerminalType m_terminal_type = ElementData::TTGeneric;
ElementData::TerminalFunction m_terminal_function = ElementData::TFGeneric;
int m_contact_count = 1;
DiagramContext m_informations;
NamesList m_names_list;
QString m_drawing_information;
private:
void kindInfoFromXml(const QDomElement &xml_element);
};
#endif // ELEMENTDATA_H
+9 -64
View File
@@ -1,24 +1,6 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#include "terminaldata.h"
#include <QGraphicsObject>
#include <QDebug>
TerminalData::TerminalData():
PropertiesInterface()
@@ -62,8 +44,8 @@ void TerminalData::setParent(QGraphicsObject* parent)
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
{
Q_UNUSED(settings)
Q_UNUSED(prefix)
Q_UNUSED(settings);
Q_UNUSED(prefix);
}
/**
@@ -76,8 +58,8 @@ void TerminalData::toSettings(QSettings &settings, const QString prefix) const
*/
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
{
Q_UNUSED(settings)
Q_UNUSED(prefix)
Q_UNUSED(settings);
Q_UNUSED(prefix);
}
/**
@@ -96,17 +78,20 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
{
QDomElement xml_element = xml_document.createElement("terminal");
// write the position of the terminal
// ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// Write name and number to XML
xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name);
// write the orientation of the terminal
// ecrit l'orientation de la borne
xml_element.setAttribute("orientation",
Qet::orientationToString(m_orientation));
xml_element.setAttribute("type", typeToString(m_type));
return(xml_element);
}
@@ -152,45 +137,5 @@ bool TerminalData::fromXml (const QDomElement &xml_element)
m_orientation = Qet::orientationFromString(
xml_element.attribute("orientation"));
m_type = typeFromString(xml_element.attribute("type"));
return true;
}
/**
* @brief TerminalData::typeToString
* @param type
* @return type into a QString
*/
QString TerminalData::typeToString(TerminalData::Type type)
{
switch (type) {
case Generic:
return QString("Generic");
case Inner :
return QString("Inner");
case Outer :
return QString("Outer");
}
}
/**
* @brief TerminalData::typeFromString
* @param string
* @return The type describe in string to TerminalData::Type.
* if string doesn't describe a type, TerminalData::Generic is returned
*/
TerminalData::Type TerminalData::typeFromString(const QString &string)
{
if (string == "Generic") {
return TerminalData::Generic;
} else if (string == "Inner") {
return TerminalData::Inner;
} else if (string == "Outer") {
return TerminalData::Outer;
} else {
qDebug() << "TerminalData::typeFromString, argument string is invalid"
" failsafe type 'TerminalData::Generic' is returned";
return TerminalData::Generic;
}
}
+2 -34
View File
@@ -1,20 +1,3 @@
/*
Copyright 2006-2021 The QElectroTech Team
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/>.
*/
#ifndef TERMINALDATA_H
#define TERMINALDATA_H
@@ -35,19 +18,10 @@ class QGraphicsObject;
*/
class TerminalData : public PropertiesInterface
{
Q_GADGET
public:
enum Type {
Generic,
Inner,
Outer
};
Q_ENUM(Type)
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData() override;
~TerminalData();
void init();
@@ -59,9 +33,6 @@ class TerminalData : public PropertiesInterface
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
static QString typeToString(TerminalData::Type type);
static TerminalData::Type typeFromString(const QString &string);
// must be public, because this class is a private member
// of PartTerminal/Terminal and they must access this data
public:
@@ -75,7 +46,7 @@ class TerminalData : public PropertiesInterface
Position of the second point of the terminal
in scene coordinates
*/
QPointF m_second_point;
QPointF second_point;
/**
@brief m_uuid
Uuid of the terminal.
@@ -109,9 +80,6 @@ class TerminalData : public PropertiesInterface
PartTerminal and Terminal have access to it.
*/
QPointF m_pos;
TerminalData::Type m_type = TerminalData::Generic;
private:
QGraphicsObject* q{nullptr};
};
+8 -7
View File
@@ -187,13 +187,14 @@ QHash<QString, XRefProperties> XRefProperties::defaultProperties()
}
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
return (m_show_power_ctc == xrp.m_show_power_ctc &&
m_display == xrp.m_display &&
m_snap_to == xrp.m_snap_to &&
m_prefix == xrp.m_prefix &&
m_master_label == xrp.m_master_label &&
m_offset == xrp.m_offset &&
m_xref_pos == xrp.m_xref_pos );
return (m_show_power_ctc == xrp.m_show_power_ctc
&& m_display == xrp.m_display
&& m_snap_to == xrp.m_snap_to
&& m_prefix == xrp.m_prefix
&& m_master_label== xrp.m_master_label
&& m_offset == xrp.m_offset
&& m_xref_pos == xrp.m_xref_pos
&& m_slave_label == xrp.m_slave_label);
}
bool XRefProperties::operator !=(const XRefProperties &xrp) const
+2 -2
View File
@@ -29,9 +29,9 @@ class QActionGroup;
*/
namespace QET {
/// QElectroTech version (as string, used to mark projects and elements XML documents)
const QString version = "0.90";
const QString version = "0.81";
/// QElectroTech displayed version
const QString displayedVersion = "0.90-DEV";
const QString displayedVersion = "0.81";
QString license();
//Describe the current state of a graphic item
+15 -5
View File
@@ -19,7 +19,7 @@
#include "configdialog.h"
#include "configpages.h"
#include "editor/ui/qetelementeditor.h"
#include "editor/qetelementeditor.h"
#include "elementscollectioncache.h"
#include "factory/elementfactory.h"
#include "factory/elementpicturefactory.h"
@@ -35,6 +35,7 @@
#include "titleblocktemplate.h"
#include "ui/aboutqetdialog.h"
#include "ui/configpage/generalconfigurationpage.h"
#include "machine_info.h"
#include <cstdlib>
#include <iostream>
@@ -70,6 +71,9 @@ QString QETApp::m_user_custom_elements_dir = QString();
QString QETApp::m_user_custom_tbt_dir = QString();
QETApp *QETApp::m_qetapp = nullptr;
bool lang_is_set = false;
QString system_language = QString();
/**
@brief QETApp::QETApp
@@ -146,6 +150,7 @@ QETApp::~QETApp()
ElementFactory::dropInstance();
ElementPictureFactory::dropInstance();
MachineInfo::dropInstance();
}
@@ -225,11 +230,16 @@ void QETApp::setLanguage(const QString &desired_language) {
*/
QString QETApp::langFromSetting()
{
QSettings settings;
QString system_language = settings.value("lang", "system").toString();
if(system_language == "system") {
system_language = QLocale::system().name().left(2);
if (!lang_is_set)
{
QSettings settings;
system_language = settings.value("lang", "system").toString();
if(system_language == "system") {
system_language = QLocale::system().name().left(2);
}
lang_is_set = true;
}
return system_language;
}
/**
@@ -84,7 +84,7 @@ class QetGraphicsHeaderItem : public QGraphicsObject
QRect m_current_rect;
QRectF m_bounding_rect;
QAbstractItemModel *m_model = nullptr;
QPointer<QAbstractItemModel> m_model;
QVector<int>
m_sections_minimum_width,
@@ -156,7 +156,17 @@ QetGraphicsTableItem::QetGraphicsTableItem(QGraphicsItem *parent) :
}
QetGraphicsTableItem::~QetGraphicsTableItem()
{}
{
if (m_previous_table) {
if (m_next_table) {
m_previous_table->setNextTable(m_next_table);
} else {
m_previous_table->setNextTable(nullptr);
}
} else if (m_next_table) {
m_next_table->setPreviousTable(nullptr);
}
}
/**
@brief QetGraphicsTableItem::setModel
@@ -175,7 +185,7 @@ void QetGraphicsTableItem::setModel(QAbstractItemModel *model)
this, &QetGraphicsTableItem::modelReseted);
}
m_model = model;
m_header_item->setModel(model);
m_header_item->setModel(m_model);
setUpColumnAndRowMinimumSize();
adjustSize();
@@ -200,7 +210,7 @@ void QetGraphicsTableItem::setModel(QAbstractItemModel *model)
*/
QAbstractItemModel *QetGraphicsTableItem::model() const
{
return m_model;
return m_model.data();
}
/**
@@ -270,8 +280,8 @@ void QetGraphicsTableItem::paint(
if (m_previous_table) //Remove the number of row already displayed by previous tables
row_count -= m_previous_table->displayNRowOffset();
if (m_number_of_displayed_row > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_displayed_row);
if (m_number_of_row_to_display > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_row_to_display);
//Draw horizontal lines
auto cell_height = static_cast<double>(m_current_size.height())/static_cast<double>(row_count);
@@ -364,8 +374,8 @@ QSize QetGraphicsTableItem::minimumSize() const
row_count -= m_previous_table->displayNRowOffset();
}
if (m_number_of_displayed_row > 0)
row_count = std::min(row_count, m_number_of_displayed_row);
if (m_number_of_row_to_display > 0)
row_count = std::min(row_count, m_number_of_row_to_display);
//m_minimum_column_width already take in count the minimum size of header
@@ -389,7 +399,7 @@ QSize QetGraphicsTableItem::minimumSize() const
*/
void QetGraphicsTableItem::setDisplayNRow(const int &number)
{
m_number_of_displayed_row = number;
m_number_of_row_to_display = number;
setToMinimumHeight();
if (m_next_table)
m_next_table->previousTableDisplayRowChanged();
@@ -402,7 +412,7 @@ void QetGraphicsTableItem::setDisplayNRow(const int &number)
*/
int QetGraphicsTableItem::displayNRow() const
{
return m_number_of_displayed_row;
return m_number_of_row_to_display;
}
/**
@@ -489,19 +499,41 @@ QString QetGraphicsTableItem::tableName() const
*/
int QetGraphicsTableItem::displayNRowOffset() const
{
auto offset_ = m_number_of_displayed_row;
auto offset_ = m_number_of_row_to_display;
if(m_previous_table)
offset_ += m_previous_table->displayNRowOffset();
return offset_;
}
QetGraphicsTableItem *QetGraphicsTableItem::previousTable() const
/**
* @brief QetGraphicsTableItem::displayedRowCount
* @return the number of row displayed by this table
*/
int QetGraphicsTableItem::displayedRowCount() const
{
if (!m_model) {
return 0;
}
//Calcule the number of rows to display.
auto row_count = m_model->rowCount();
if (m_previous_table) //Remove the number of row already displayed by previous tables
row_count -= m_previous_table->displayNRowOffset();
if (m_number_of_row_to_display > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_row_to_display);
return row_count;
}
QPointer<QetGraphicsTableItem> QetGraphicsTableItem::previousTable() const
{
return m_previous_table;
}
QetGraphicsTableItem *QetGraphicsTableItem::nextTable() const
QPointer<QetGraphicsTableItem> QetGraphicsTableItem::nextTable() const
{
return m_next_table;
}
@@ -555,7 +587,7 @@ QDomElement QetGraphicsTableItem::toXml(QDomDocument &dom_document) const
dom_table.setAttribute("height", QString::number(m_current_size.height()));
dom_table.setAttribute("uuid", m_uuid.toString());
dom_table.setAttribute("name", m_name);
dom_table.setAttribute("display_n_row", QString::number(m_number_of_displayed_row));
dom_table.setAttribute("display_n_row", QString::number(m_number_of_row_to_display));
//Add the header xml
dom_table.appendChild(m_header_item->toXml(dom_document));
@@ -571,7 +603,7 @@ QDomElement QetGraphicsTableItem::toXml(QDomDocument &dom_document) const
{
//Add model
auto dom_model = dom_document.createElement("model");
auto project_db_model = static_cast<ProjectDBModel *>(m_model);
auto project_db_model = static_cast<ProjectDBModel *>(m_model.data());
dom_model.appendChild(project_db_model->toXml(dom_document));
dom_table.appendChild(dom_model);
@@ -613,7 +645,7 @@ void QetGraphicsTableItem::fromXml(const QDomElement &dom_element)
"uuid",
QUuid::createUuid().toString()));
m_name = dom_element.attribute("name");
m_number_of_displayed_row = dom_element.attribute(
m_number_of_row_to_display = dom_element.attribute(
"display_n_row",
QString::number(0)).toInt();
@@ -678,8 +710,8 @@ bool QetGraphicsTableItem::toDXF(const QString &filepath)
if (m_previous_table) //Remove the number of row already displayed by previous tables
row_count -= m_previous_table->displayNRowOffset();
if (m_number_of_displayed_row > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_displayed_row);
if (m_number_of_row_to_display > 0) //User override the number of row to display
row_count = std::min(row_count, m_number_of_row_to_display);
//Draw horizontal lines
auto cell_height = static_cast<double>(m_current_size.height())/static_cast<double>(row_count);
@@ -806,13 +838,18 @@ QVariant QetGraphicsTableItem::itemChange(
return QetGraphicsItem::itemChange(change, value);
}
/**
* @brief QetGraphicsTableItem::modelReseted
*/
void QetGraphicsTableItem::modelReseted()
{
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
setToMinimumHeight();
if (!previousTable()) { //this is the head table
if (!previousTable()) //this is the head table
{
checkInsufficientRowsCount(this);
removeUselessNextTable();
}
}
@@ -1046,3 +1083,24 @@ void QetGraphicsTableItem::previousTableDisplayRowChanged()
m_next_table->previousTableDisplayRowChanged();
}
}
/**
* @brief QetGraphicsTableItem::removeUselessNextTable
* Remove next table if useless, an useless table with 0 row displayed.
* If \p recursive is true check and remove for all sub next table.
* @param recursive
*/
void QetGraphicsTableItem::removeUselessNextTable(bool recursive)
{
if (m_next_table)
{
if (recursive) {
m_next_table->removeUselessNextTable();
}
if (m_next_table->displayedRowCount() <= 0)
{
m_next_table.data()->deleteLater();
m_next_table.clear();
}
}
}
@@ -79,8 +79,9 @@ class QetGraphicsTableItem : public QetGraphicsItem
void setTableName(const QString &name);
QString tableName() const;
int displayNRowOffset() const;
QetGraphicsTableItem *previousTable() const;
QetGraphicsTableItem *nextTable() const;
int displayedRowCount() const;
QPointer<QetGraphicsTableItem> previousTable() const;
QPointer<QetGraphicsTableItem> nextTable() const;
void setToMinimumHeight();
void initLink();
QUuid uuid() const {return m_uuid;}
@@ -120,13 +121,14 @@ class QetGraphicsTableItem : public QetGraphicsItem
void headerSectionResized();
void adjustSize();
void previousTableDisplayRowChanged();
void removeUselessNextTable(bool recursive = true);
QAbstractItemModel *m_model= nullptr;
QPointer<QAbstractItemModel> m_model;
QVector<int> m_minimum_column_width;
int
m_minimum_row_height,
m_number_of_displayed_row = 0,
m_number_of_row_to_display = 0,
m_br_margin = 10;
QSize
@@ -139,9 +141,8 @@ class QetGraphicsTableItem : public QetGraphicsItem
QetGraphicsHandlerItem m_handler_item;
QetGraphicsHeaderItem *m_header_item = nullptr;
QetGraphicsTableItem
*m_previous_table = nullptr,
*m_next_table = nullptr;
QPointer<QetGraphicsTableItem> m_previous_table,
m_next_table;
QString m_name;
QUuid
+10 -5
View File
@@ -128,6 +128,15 @@ void CrossRefItem::setUpConnection()
m_update_connection << connect(m_element,
&Element::linkedElementChanged,
this, &CrossRefItem::linkedChanged);
auto diagram_ = dynamic_cast<Diagram *>(this->scene());
auto formula_ = m_properties.masterLabel();
if (diagram_ &&
formula_.contains("%F"))
{
m_update_connection << connect(diagram_ , &Diagram::diagramInformationChanged,
this, &CrossRefItem::updateLabel);
}
linkedChanged();
updateLabel();
}
@@ -161,13 +170,9 @@ QPainterPath CrossRefItem::shape() const{
QString CrossRefItem::elementPositionText(
const Element *elmt, const bool &add_prefix) const
{
XRefProperties xrp =
m_element->diagram()->project()->defaultXRefProperties(
m_element->kindInformations()["type"].toString());
QString formula = xrp.masterLabel();
autonum::sequentialNumbers seq;
QString txt = autonum::AssignVariables::formulaToLabel(
formula,
m_properties.masterLabel(),
seq, elmt->diagram(),
elmt);

Some files were not shown because too many files have changed in this diff Show More