mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Wrap code for better readability
This commit is contained in:
parent
d1c91a7fc2
commit
88686b3cbf
@ -33,8 +33,15 @@ class QObject;
|
||||
class QPropertyUndoCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, const QVariant &new_value, QUndoCommand *parent = nullptr);
|
||||
QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, QUndoCommand *parent = nullptr);
|
||||
QPropertyUndoCommand(QObject *object,
|
||||
const char *property_name,
|
||||
const QVariant &old_value,
|
||||
const QVariant &new_value,
|
||||
QUndoCommand *parent = nullptr);
|
||||
QPropertyUndoCommand(QObject *object,
|
||||
const char *property_name,
|
||||
const QVariant &old_value,
|
||||
QUndoCommand *parent = nullptr);
|
||||
QPropertyUndoCommand(const QPropertyUndoCommand *other);
|
||||
|
||||
void setNewValue(const QVariant &new_value);
|
||||
|
@ -76,7 +76,9 @@ QVector<QPointF> QetGraphicsHandlerUtility::pointsForLine(const QLineF &line) {
|
||||
@param span_angle : span angle in degree;
|
||||
@return
|
||||
*/
|
||||
QVector<QPointF> QetGraphicsHandlerUtility::pointsForArc(const QRectF &rect, qreal start_angle, qreal span_angle)
|
||||
QVector<QPointF> QetGraphicsHandlerUtility::pointsForArc(const QRectF &rect,
|
||||
qreal start_angle,
|
||||
qreal span_angle)
|
||||
{
|
||||
QVector<QPointF> vector;
|
||||
QPainterPath path;
|
||||
@ -101,7 +103,9 @@ QVector<QPointF> QetGraphicsHandlerUtility::pointsForArc(const QRectF &rect, qre
|
||||
If index is lower than 0 or higher than 7,
|
||||
this method return old_rect.
|
||||
*/
|
||||
QRectF QetGraphicsHandlerUtility::rectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
|
||||
QRectF QetGraphicsHandlerUtility::rectForPosAtIndex(const QRectF &old_rect,
|
||||
const QPointF &pos,
|
||||
int index)
|
||||
{
|
||||
if (index < 0 || index > 7) return old_rect;
|
||||
|
||||
@ -132,7 +136,10 @@ QRectF QetGraphicsHandlerUtility::rectForPosAtIndex(const QRectF &old_rect, cons
|
||||
If index is lower than 0 or higher than 7,
|
||||
this method return old_rect.
|
||||
*/
|
||||
QRectF QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
|
||||
QRectF QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(
|
||||
const QRectF &old_rect,
|
||||
const QPointF &pos,
|
||||
int index)
|
||||
{
|
||||
if (index < 0 || index > 7) return old_rect;
|
||||
|
||||
|
@ -246,7 +246,11 @@ void SearchAndReplaceWorker::replaceConductor(Conductor *conductor)
|
||||
@param texts :
|
||||
@param conductors :
|
||||
*/
|
||||
void SearchAndReplaceWorker::replaceAdvanced(QList<Diagram *> diagrams, QList<Element *> elements, QList<IndependentTextItem *> texts, QList<Conductor *> conductors)
|
||||
void SearchAndReplaceWorker::replaceAdvanced(
|
||||
QList<Diagram *> diagrams,
|
||||
QList<Element *> elements,
|
||||
QList<IndependentTextItem *> texts,
|
||||
QList<Conductor *> conductors)
|
||||
{
|
||||
QETProject *project_ = nullptr;
|
||||
|
||||
@ -364,7 +368,9 @@ void SearchAndReplaceWorker::replaceAdvanced(QList<Diagram *> diagrams, QList<El
|
||||
@param cb
|
||||
@param str
|
||||
*/
|
||||
void SearchAndReplaceWorker::setupLineEdit(QLineEdit *l, QCheckBox *cb, QString str)
|
||||
void SearchAndReplaceWorker::setupLineEdit(QLineEdit *l,
|
||||
QCheckBox *cb,
|
||||
QString str)
|
||||
{
|
||||
l->setText(str);
|
||||
cb->setChecked(str == eraseText() ? true : false);
|
||||
|
@ -61,16 +61,27 @@ class SearchAndReplaceWorker
|
||||
void replaceIndiText(IndependentTextItem *text);
|
||||
void replaceConductor(QList <Conductor *> list);
|
||||
void replaceConductor(Conductor *conductor);
|
||||
void replaceAdvanced (QList<Diagram *> diagrams = QList<Diagram *>(), QList<Element *> elements = QList<Element *>(),\
|
||||
QList<IndependentTextItem *> texts = QList<IndependentTextItem *>(), QList<Conductor *> conductors = QList<Conductor *>());
|
||||
void replaceAdvanced (
|
||||
QList<Diagram *> diagrams = QList<Diagram *>(),
|
||||
QList<Element *> elements = QList<Element *>(),
|
||||
QList<IndependentTextItem *>
|
||||
texts = QList<IndependentTextItem *>(),
|
||||
QList<Conductor *>
|
||||
conductors = QList<Conductor *>());
|
||||
|
||||
static QString eraseText() {return QString("XXXXXXXXXXXXXXXXXXX");}
|
||||
static QString eraseText()
|
||||
{return QString("XXXXXXXXXXXXXXXXXXX");}
|
||||
static QDate eraseDate() {return QDate(1900, 1, 1);}
|
||||
static void setupLineEdit(QLineEdit *l, QCheckBox *cb, QString str);
|
||||
static void setupLineEdit(QLineEdit *l,
|
||||
QCheckBox *cb,
|
||||
QString str);
|
||||
static ConductorProperties invalidConductorProperties();
|
||||
|
||||
static ConductorProperties applyChange(const ConductorProperties &original, const ConductorProperties &change);
|
||||
static QString applyChange(const QString &original, const QString &change);
|
||||
static ConductorProperties applyChange(
|
||||
const ConductorProperties &original,
|
||||
const ConductorProperties &change);
|
||||
static QString applyChange(const QString &original,
|
||||
const QString &change);
|
||||
|
||||
private:
|
||||
TitleBlockProperties replaceAdvanced (Diagram *diagram);
|
||||
|
@ -29,7 +29,9 @@ typedef SearchAndReplaceWorker sarw;
|
||||
@param properties
|
||||
@param parent
|
||||
*/
|
||||
ReplaceConductorDialog::ReplaceConductorDialog(const ConductorProperties &properties, QWidget *parent) :
|
||||
ReplaceConductorDialog::ReplaceConductorDialog(
|
||||
const ConductorProperties &properties,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ReplaceConductorDialog)
|
||||
{
|
||||
|
@ -35,7 +35,9 @@ class ReplaceConductorDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ReplaceConductorDialog(const ConductorProperties &properties, QWidget *parent = 0);
|
||||
explicit ReplaceConductorDialog(
|
||||
const ConductorProperties &properties,
|
||||
QWidget *parent = 0);
|
||||
~ReplaceConductorDialog();
|
||||
void updatePreview(bool b=true);
|
||||
void setProperties(const ConductorProperties &properties);
|
||||
|
@ -482,10 +482,13 @@ QList<CustomElementPart *> ScalePartsCommand::scaledPrimitives() const {
|
||||
/**
|
||||
@brief ScalePartsCommand::setTransformation
|
||||
Define the transformation applied by this command
|
||||
@param original_rect Bounding rectangle for all scaled primitives before the operation
|
||||
@param original_rect Bounding rectangle for all scaled primitives after the operation
|
||||
*/
|
||||
void ScalePartsCommand::setTransformation(const QRectF &original_rect, const QRectF &new_rect) {
|
||||
@param original_rect :
|
||||
Bounding rectangle for all scaled primitives before the operation
|
||||
@param new_rect :
|
||||
Bounding rectangle for all scaled primitives after the operation
|
||||
*/
|
||||
void ScalePartsCommand::setTransformation(const QRectF &original_rect,
|
||||
const QRectF &new_rect) {
|
||||
original_rect_ = original_rect;
|
||||
new_rect_ = new_rect;
|
||||
}
|
||||
|
@ -41,7 +41,10 @@ QetGraphicsTableFactory::QetGraphicsTableFactory()
|
||||
*/
|
||||
void QetGraphicsTableFactory::createAndAddNomenclature(Diagram *diagram)
|
||||
{
|
||||
QScopedPointer<AddTableDialog> d(new AddTableDialog(new ElementQueryWidget(), diagram->views().first()));
|
||||
QScopedPointer<AddTableDialog> d(
|
||||
new AddTableDialog(
|
||||
new ElementQueryWidget(),
|
||||
diagram->views().first()));
|
||||
d->setWindowTitle(QObject::tr("Ajouter une nomenclature"));
|
||||
|
||||
if (d->exec()) {
|
||||
@ -57,7 +60,10 @@ void QetGraphicsTableFactory::createAndAddNomenclature(Diagram *diagram)
|
||||
*/
|
||||
void QetGraphicsTableFactory::createAndAddSummary(Diagram *diagram)
|
||||
{
|
||||
QScopedPointer<AddTableDialog> d(new AddTableDialog(new SummaryQueryWidget(), diagram->views().first()));
|
||||
QScopedPointer<AddTableDialog> d(
|
||||
new AddTableDialog(
|
||||
new SummaryQueryWidget(),
|
||||
diagram->views().first()));
|
||||
d->setWindowTitle(QObject::tr("Ajouter un sommaire"));
|
||||
|
||||
if (d->exec()) {
|
||||
|
@ -1500,7 +1500,14 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
if(!dv)
|
||||
{
|
||||
QList <QAction *> action_list;
|
||||
action_list << m_conductor_reset << m_find_element << m_cut << m_copy << m_delete_selection << m_rotate_selection << m_edit_selection << m_group_selected_texts;
|
||||
action_list << m_conductor_reset
|
||||
<< m_find_element
|
||||
<< m_cut
|
||||
<< m_copy
|
||||
<< m_delete_selection
|
||||
<< m_rotate_selection
|
||||
<< m_edit_selection
|
||||
<< m_group_selected_texts;
|
||||
for(QAction *action : action_list)
|
||||
action->setEnabled(false);
|
||||
|
||||
@ -1532,8 +1539,18 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
QList<DiagramTextItem *> texts = DiagramContent(diagram_).selectedTexts();
|
||||
QList<ElementTextItemGroup *> groups = DiagramContent(diagram_).selectedTextsGroup();
|
||||
int selected_texts = texts.count();
|
||||
int selected_conductor_texts = 0; for(DiagramTextItem *dti : texts) {if(dti->type() == ConductorTextItem::Type) selected_conductor_texts++;}
|
||||
int selected_dynamic_elmt_text = 0; for(DiagramTextItem *dti : texts) {if(dti->type() == DynamicElementTextItem::Type) selected_dynamic_elmt_text++;}
|
||||
int selected_conductor_texts = 0;
|
||||
for(DiagramTextItem *dti : texts)
|
||||
{
|
||||
if(dti->type() == ConductorTextItem::Type)
|
||||
selected_conductor_texts++;
|
||||
}
|
||||
int selected_dynamic_elmt_text = 0;
|
||||
for(DiagramTextItem *dti : texts)
|
||||
{
|
||||
if(dti->type() == DynamicElementTextItem::Type)
|
||||
selected_dynamic_elmt_text++;
|
||||
}
|
||||
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
||||
|
||||
//Action that need only element text selected
|
||||
@ -1556,11 +1573,13 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
int selected_image = dc.count(DiagramContent::Images);
|
||||
|
||||
int selected_shape = dc.count(DiagramContent::Shapes);
|
||||
int selected_editable = selected_elements_count +
|
||||
(selected_texts - selected_conductor_texts - selected_dynamic_elmt_text) +
|
||||
selected_image +
|
||||
selected_shape +
|
||||
selected_conductors_count;
|
||||
int selected_editable = selected_elements_count
|
||||
+ (selected_texts
|
||||
- selected_conductor_texts
|
||||
- selected_dynamic_elmt_text)
|
||||
+ selected_image
|
||||
+ selected_shape
|
||||
+ selected_conductors_count;
|
||||
|
||||
if (selected_editable == 1)
|
||||
{
|
||||
@ -1568,41 +1587,47 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
//edit element
|
||||
if (selected_elements_count)
|
||||
{
|
||||
m_edit_selection -> setText(tr("Éditer l'élement", "edit element"));
|
||||
m_edit_selection -> setText(tr("Éditer l'élement",
|
||||
"edit element"));
|
||||
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
|
||||
}
|
||||
//edit text field
|
||||
else if (selected_texts)
|
||||
{
|
||||
m_edit_selection -> setText(tr("Éditer le champ de texte", "edit text field"));
|
||||
m_edit_selection -> setText(tr("Éditer le champ de texte",
|
||||
"edit text field"));
|
||||
m_edit_selection -> setIcon(QET::Icons::EditText);
|
||||
}
|
||||
//edit image
|
||||
else if (selected_image)
|
||||
{
|
||||
m_edit_selection -> setText(tr("Éditer l'image", "edit image"));
|
||||
m_edit_selection -> setText(tr("Éditer l'image",
|
||||
"edit image"));
|
||||
m_edit_selection -> setIcon(QET::Icons::resize_image);
|
||||
}
|
||||
//edit conductor
|
||||
else if (selected_conductors_count)
|
||||
{
|
||||
m_edit_selection -> setText(tr("Éditer le conducteur", "edit conductor"));
|
||||
m_edit_selection -> setText(tr("Éditer le conducteur",
|
||||
"edit conductor"));
|
||||
m_edit_selection -> setIcon(QET::Icons::ConductorEdit);
|
||||
}
|
||||
}
|
||||
//not an editable item
|
||||
else
|
||||
{
|
||||
m_edit_selection -> setText(tr("Éditer l'objet sélectionné", "edit selected item"));
|
||||
m_edit_selection -> setText(tr("Éditer l'objet sélectionné",
|
||||
"edit selected item"));
|
||||
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
|
||||
m_edit_selection -> setEnabled(false);
|
||||
}
|
||||
|
||||
//Actions for edit Z value
|
||||
QList<QGraphicsItem *> list = dc.items(DiagramContent::SelectedOnly | \
|
||||
DiagramContent::Elements | \
|
||||
DiagramContent::Shapes | \
|
||||
DiagramContent::Images);
|
||||
//Actions for edit Z value
|
||||
QList<QGraphicsItem *> list = dc.items(
|
||||
DiagramContent::SelectedOnly
|
||||
| DiagramContent::Elements
|
||||
| DiagramContent::Shapes
|
||||
| DiagramContent::Images);
|
||||
m_depth_action_group->setEnabled(list.isEmpty()? false : true);
|
||||
}
|
||||
|
||||
@ -1668,24 +1693,32 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
||||
foreach(DiagramView *dv, project_view -> diagram_views())
|
||||
diagramWasAdded(dv);
|
||||
|
||||
//Manage the close event of project
|
||||
connect(project_view, SIGNAL(projectClosed(ProjectView*)), this, SLOT(projectWasClosed(ProjectView *)));
|
||||
//Manage the adding of diagram
|
||||
connect(project_view, SIGNAL(diagramAdded(DiagramView *)), this, SLOT(diagramWasAdded(DiagramView *)));
|
||||
//Manage the close event of project
|
||||
connect(project_view, SIGNAL(projectClosed(ProjectView*)),
|
||||
this, SLOT(projectWasClosed(ProjectView *)));
|
||||
//Manage the adding of diagram
|
||||
connect(project_view, SIGNAL(diagramAdded(DiagramView *)),
|
||||
this, SLOT(diagramWasAdded(DiagramView *)));
|
||||
|
||||
if (QETProject *project = project_view -> project())
|
||||
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)), this, SLOT(slot_updateActions()));
|
||||
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)),
|
||||
this, SLOT(slot_updateActions()));
|
||||
|
||||
//Manage request for edit or find element and titleblock
|
||||
connect (project_view, &ProjectView::findElementRequired, this, &QETDiagramEditor::findElementInPanel);
|
||||
connect (project_view, &ProjectView::editElementRequired, this, &QETDiagramEditor::editElementInEditor);
|
||||
//Manage request for edit or find element and titleblock
|
||||
connect (project_view, &ProjectView::findElementRequired,
|
||||
this, &QETDiagramEditor::findElementInPanel);
|
||||
connect (project_view, &ProjectView::editElementRequired,
|
||||
this, &QETDiagramEditor::editElementInEditor);
|
||||
|
||||
// display error messages sent by the project view
|
||||
connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &)));
|
||||
// display error messages sent by the project view
|
||||
connect(project_view, SIGNAL(errorEncountered(QString)),
|
||||
this, SLOT(showError(const QString &)));
|
||||
|
||||
//We maximise the new window if the current window is inexistent or maximized
|
||||
QWidget *current_window = m_workspace.activeSubWindow();
|
||||
bool maximise = ((!current_window) || (current_window -> windowState() & Qt::WindowMaximized));
|
||||
bool maximise = ((!current_window)
|
||||
|| (current_window -> windowState()
|
||||
& Qt::WindowMaximized));
|
||||
|
||||
//Add the new window
|
||||
QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
|
||||
@ -2129,8 +2162,15 @@ void QETDiagramEditor::removeDiagramFromProject()
|
||||
*/
|
||||
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
|
||||
{
|
||||
connect(dv->diagram(), &QGraphicsScene::selectionChanged, this, &QETDiagramEditor::selectionChanged, Qt::DirectConnection);
|
||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
||||
connect(dv->diagram(),
|
||||
&QGraphicsScene::selectionChanged,
|
||||
this,
|
||||
&QETDiagramEditor::selectionChanged,
|
||||
Qt::DirectConnection);
|
||||
connect(dv,
|
||||
SIGNAL(modeChanged()),
|
||||
this,
|
||||
SLOT(slot_updateModeActions()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2148,7 +2188,8 @@ void QETDiagramEditor::findElementInPanel(const ElementsLocation &location)
|
||||
@param location Emplacement de l'element a editer
|
||||
*/
|
||||
void QETDiagramEditor::editElementInEditor(const ElementsLocation &location) {
|
||||
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
|
||||
QETApp::instance() -> openElementLocations(QList<ElementsLocation>()
|
||||
<< location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,8 @@ static int no_model_width = 40;
|
||||
@param table : table to adjust
|
||||
@param margins : margins between table and folio.
|
||||
*/
|
||||
void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins)
|
||||
void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table,
|
||||
QMargins margins)
|
||||
{
|
||||
if (!table->diagram()) {
|
||||
return;
|
||||
@ -68,7 +69,8 @@ void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table, QMarg
|
||||
if not open a dialog to advise user what to do.
|
||||
@param table
|
||||
*/
|
||||
void QetGraphicsTableItem::checkInsufficientRowsCount(QetGraphicsTableItem *table)
|
||||
void QetGraphicsTableItem::checkInsufficientRowsCount(
|
||||
QetGraphicsTableItem *table)
|
||||
{
|
||||
if (!table->diagram() || !table->model()) {
|
||||
return;
|
||||
|
@ -794,7 +794,9 @@ void QETProject::autoFolioNumberingNewFolios(){
|
||||
@param autonum : used, index from selected tabs "from" and "to"
|
||||
rename folios with selected autonum
|
||||
*/
|
||||
void QETProject::autoFolioNumberingSelectedFolios(int from, int to, const QString& autonum){
|
||||
void QETProject::autoFolioNumberingSelectedFolios(int from,
|
||||
int to,
|
||||
const QString& autonum){
|
||||
int total_folio = m_diagrams_list.count();
|
||||
DiagramContext project_wide_properties = m_project_properties;
|
||||
for (int i=from; i<=to; i++) {
|
||||
@ -802,8 +804,13 @@ void QETProject::autoFolioNumberingSelectedFolios(int from, int to, const QStrin
|
||||
NumerotationContext nC = folioAutoNum(autonum);
|
||||
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
||||
m_diagrams_list[i] -> border_and_titleblock.setFolio("%autonum");
|
||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
||||
m_diagrams_list[i] -> project() -> addFolioAutoNum(autonum,nCC.next());
|
||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(
|
||||
i + 1,
|
||||
total_folio,
|
||||
nCC.toRepresentedString(),
|
||||
project_wide_properties);
|
||||
m_diagrams_list[i] -> project() -> addFolioAutoNum(
|
||||
autonum,nCC.next());
|
||||
m_diagrams_list[i] -> update();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user