54 #include "ui_history_dialog.h"
56 #include "../vgeometry/varc.h"
57 #include "../vgeometry/vellipticalarc.h"
58 #include "../vgeometry/vcubicbezier.h"
59 #include "../vgeometry/vsplinepath.h"
60 #include "../vgeometry/vcubicbezierpath.h"
61 #include "../vgeometry/vpointf.h"
62 #include "../vmisc/diagnostic.h"
63 #include "../vmisc/vabstractapplication.h"
64 #include "../vtools/tools/vabstracttool.h"
65 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h"
66 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
67 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h"
68 #include "../xml/vpattern.h"
70 #include <QApplication>
72 #include <QCloseEvent>
87 , m_cursorToolRecordRow(0)
90 setWindowFlags(Qt::Window);
91 setWindowFlags((windowFlags() | Qt::WindowStaysOnTopHint | Qt::WindowMaximizeButtonHint) & ~Qt::WindowContextHelpButtonHint);
93 ui->find_LineEdit->installEventFilter(
this);
95 qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
100 ok_Button =
ui->buttonBox->button(QDialogButtonBox::Ok);
128 quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
143 QTableWidgetItem *item =
ui->tableWidget->item(
m_cursorRow, 0);
144 item->setIcon(QIcon());
146 item =
ui->tableWidget->item(row, 0);
148 item->setIcon(QIcon(
"://icon/24x24/left_to_right_arrow.png"));
149 const quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
150 m_doc->blockSignals(
true);
152 m_doc->blockSignals(
false);
157 quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
162 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
174 for (qint32 i = 0; i<
ui->tableWidget->rowCount(); ++i)
176 QTableWidgetItem *item =
ui->tableWidget->item(i, 0);
177 quint32 rId = qvariant_cast<quint32>(item->data(Qt::UserRole));
180 QTableWidgetItem *oldCursorItem =
ui->tableWidget->item(
m_cursorRow, 0);
181 oldCursorItem->setIcon(QIcon());
183 item->setIcon(QIcon(
"://icon/24x24/left_to_right_arrow.png"));
204 ui->tableWidget->clear();
206 qint32 currentRow = -1;
208 ui->tableWidget->setRowCount(history.size());
210 for (qint32 i = 0; i< history.size(); ++i)
214 if (!rowData.
tool.isEmpty())
219 QTableWidgetItem *item =
new QTableWidgetItem(QString().setNum(rowData.
id));
220 item->setTextAlignment(Qt::AlignRight);
221 item->setSizeHint(QSize(80, 24));
222 item->setData(Qt::UserRole, rowData.
id);
223 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
224 ui->tableWidget->setItem(currentRow, 0, item);
228 QTableWidgetItem *item =
new QTableWidgetItem(QString(rowData.
name));
229 item->setTextAlignment(Qt::AlignHCenter);
230 item->setSizeHint(QSize(100, 24));
231 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
232 ui->tableWidget->setItem(currentRow, 1, item);
235 QTableWidgetItem *item =
new QTableWidgetItem(rowData.
tool);
236 item->setTextAlignment(Qt::AlignLeft);
237 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
238 item->setIcon(QIcon(rowData.
icon));
239 ui->tableWidget->setItem(currentRow, 2, item);
243 ui->tableWidget->setRowCount(count);
247 QTableWidgetItem *item =
ui->tableWidget->item(
m_cursorRow, 0);
249 item->setIcon(QIcon(
"://icon/24x24/left_to_right_arrow.png"));
252 ui->tableWidget->resizeColumnsToContents();
253 ui->tableWidget->resizeRowsToContents();
254 ui->tableWidget->verticalHeader()->setDefaultSectionSize(24);
259 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
271 const quint32 &toolId = tool.getId();
273 const QDomElement domElement = m_doc->elementById(toolId);
274 if (domElement.isElement() ==
false)
276 qDebug()<<
"Can't find element by id"<<Q_FUNC_INFO;
281 switch (tool.getTypeTool())
296 rowData.
icon =
":/toolicon/32x32/point_basepoint_icon.png";
297 rowData.
name = tr(
"%1").arg(getPointName(toolId));
298 rowData.
tool = tr(
"Base Point");
302 rowData.
icon =
":/toolicon/32x32/segment.png";
303 rowData.
name = tr(
"%1").arg(getPointName(toolId));
304 rowData.
tool = tr(
"Point Length and Angle from point %1")
309 rowData.
icon =
":/toolicon/32x32/line.png";
310 rowData.
name = tr(
"Line_%1_%2")
313 rowData.
tool = tr(
"Line from %1 to %2")
319 rowData.
icon =
":/toolicon/32x32/along_line.png";
320 rowData.
name = tr(
"%1").arg(getPointName(toolId));
321 rowData.
tool = tr(
"Point On Line %1_%2")
327 rowData.
icon =
":/toolicon/32x32/shoulder.png";
328 rowData.
name = tr(
"%1").arg(getPointName(toolId));
329 rowData.
tool = tr(
"Point Length to Line");
333 rowData.
icon =
":/toolicon/32x32/normal.png";
334 rowData.
name = tr(
"%1").arg(getPointName(toolId));
335 rowData.
tool = tr(
"Point On Perpendicular %1_%2")
341 rowData.
icon =
":/toolicon/32x32/bisector.png";
342 rowData.
name = tr(
"%1").arg(getPointName(toolId));
343 rowData.
tool = tr(
"Point On Bisector %1_%2_%3")
350 rowData.
icon =
":/toolicon/32x32/intersect.png";
351 rowData.
name = tr(
"%1").arg(getPointName(toolId));
352 rowData.
tool = tr(
"Point Intersect Lines %1_%2 and %3_%4")
353 .arg(getPointName(attrUInt(domElement,
AttrP1Line1)))
354 .arg(getPointName(attrUInt(domElement,
AttrP2Line1)))
355 .arg(getPointName(attrUInt(domElement,
AttrP1Line2)))
356 .arg(getPointName(attrUInt(domElement,
AttrP2Line2)));
363 rowData.
icon =
":/toolicon/32x32/spline.png";
364 rowData.
name = tr(
"%1").arg(spl->NameForHistory(tr(
"Spl_")));
365 rowData.
tool = tr(
"Curve Interactive");
373 rowData.
icon =
":/toolicon/32x32/cubic_bezier.png";
374 rowData.
name = tr(
"%1").arg(spl->NameForHistory(tr(
"Spl_")));
375 rowData.
tool = tr(
"Curve Fixed");
383 rowData.
icon =
":/toolicon/32x32/arc.png";
384 rowData.
name = tr(
"%1").arg(arc->NameForHistory(tr(
"Arc_")));
385 rowData.
tool = tr(
"Arc Radius & Angles");
393 rowData.
icon =
":/toolicon/32x32/arc_with_length.png";
394 rowData.
name =tr(
"%1").arg(arc->NameForHistory(tr(
"Arc_")));
395 rowData.
tool =tr(
"Arc Radius & Length %1") .arg(arc->NameForHistory(tr(
"Arc_")));
403 rowData.
icon =
":/toolicon/32x32/splinePath.png";
404 rowData.
name = tr(
"%1").arg(
splPath->NameForHistory(tr(
"SplPath_")));
405 rowData.
tool = tr(
"Spline Interactive");
413 rowData.
icon =
":/toolicon/32x32/cubic_bezier_path.png";
414 rowData.
name = tr(
"%1").arg(
splPath->NameForHistory(tr(
"SplPath_")));
415 rowData.
tool = tr(
"Spline Fixed");
420 rowData.
icon =
":/toolicon/32x32/point_of_contact.png";
421 rowData.
name = tr(
"%1").arg(getPointName(toolId));
422 rowData.
tool = tr(
"Point Intersect Arc with center %1 & Line %2_%3")
423 .arg(getPointName(attrUInt(domElement,
AttrCenter)))
429 rowData.
icon =
":/toolicon/32x32/height.png";
430 rowData.
name = tr(
"%1").arg(getPointName(toolId));
431 rowData.
tool = tr(
"Point Intersect Line %1_%2 & Perpendicular %3")
432 .arg(getPointName(attrUInt(domElement,
AttrP1Line)))
433 .arg(getPointName(attrUInt(domElement,
AttrP2Line)))
438 rowData.
icon =
":/toolicon/32x32/triangle.png";
439 rowData.
name = tr(
"%1").arg(getPointName(toolId));
440 rowData.
tool = tr(
"Point Intersect Axis %1_%2 & Triangle points %3 and %4")
441 .arg(getPointName(attrUInt(domElement,
AttrAxisP1)))
442 .arg(getPointName(attrUInt(domElement,
AttrAxisP2)))
448 rowData.
icon =
":/toolicon/32x32/point_intersectxy_icon.png";
449 rowData.
name = tr(
"%1").arg(getPointName(toolId));
450 rowData.
tool = tr(
"Point Intersect XY of points %1 and %2")
459 rowData.
icon =
":/toolicon/32x32/arc_cut.png";
460 rowData.
name = tr(
"%1").arg(getPointName(toolId));
461 rowData.
tool = tr(
"Point On Arc");
470 rowData.
icon =
":/toolicon/32x32/spline_cut_point.png";
471 rowData.
name = tr(
"%1").arg(getPointName(toolId));
472 rowData.
tool = tr(
"Point On Curve");
482 rowData.
icon =
":/toolicon/32x32/splinePath_cut_point.png";
483 rowData.
name = tr(
"%1").arg(getPointName(toolId));
484 rowData.
tool = tr(
"Point On Spline");
489 rowData.
icon =
":/toolicon/32x32/line_intersect_axis.png";
490 rowData.
name = tr(
"%1").arg(getPointName(toolId));
491 rowData.
tool = tr(
"%Point Intersect Line & %1_%2 and Axis through point %3")
492 .arg(getPointName(attrUInt(domElement,
AttrP1Line)))
493 .arg(getPointName(attrUInt(domElement,
AttrP2Line)))
498 rowData.
icon =
":/toolicon/32x32/arc_intersect_axis.png";
499 rowData.
name = tr(
"%1").arg(getPointName(toolId));
500 rowData.
tool = tr(
"Point Intersect Curve & Axis through point %1")
505 rowData.
icon =
":/toolicon/32x32/point_of_intersection_arcs.png";
506 rowData.
name = tr(
"%1").arg(getPointName(toolId));
507 rowData.
tool = tr(
"Point Intersect Arcs");
511 rowData.
icon =
":/toolicon/32x32/point_of_intersection_circles.png";
512 rowData.
name = tr(
"%1").arg(getPointName(toolId));
513 rowData.
tool = tr(
"%1 - Point Intersect Circles");
517 rowData.
icon =
":/toolicon/32x32/intersection_curves.png";
518 rowData.
name = tr(
"%1").arg(getPointName(toolId));
519 rowData.
tool = tr(
"Point Intersect Curves");
523 rowData.
icon =
":/toolicon/32x32/point_from_circle_and_tangent.png";
524 rowData.
name = tr(
"%1").arg(getPointName(toolId));
525 rowData.
tool = tr(
"Point Intersect Circle & Tangent");
529 rowData.
icon =
":/toolicon/32x32/point_from_arc_and_tangent.png";
530 rowData.
name = tr(
"%1").arg(getPointName(toolId));
531 rowData.
tool = tr(
"Point Intersect Arc & Tangent");
535 rowData.
icon =
":/toolicon/32x32/true_darts.png";
536 rowData.
name = tr(
"");
537 rowData.
tool = tr(
"True Dart %1_%2_%3")
538 .arg(getPointName(attrUInt(domElement,
AttrDartP1)))
539 .arg(getPointName(attrUInt(domElement,
AttrDartP2)))
540 .arg(getPointName(attrUInt(domElement,
AttrDartP2)));
547 rowData.
icon =
":/toolicon/32x32/el_arc.png";
548 rowData.
name = tr(
"%1").arg(elArc->NameForHistory(tr(
"ElArc_")));
549 rowData.
tool = tr(
"Arc Elliptical with length %1").arg(elArc->GetLength());
554 rowData.
icon =
":/toolicon/32x32/rotation.png";
555 rowData.
name = tr(
"");
556 rowData.
tool = tr(
"Rotation around point %1. Suffix %2")
557 .arg(getPointName(attrUInt(domElement,
AttrCenter)),
558 m_doc->GetParametrString(domElement,
AttrSuffix, QString()));
562 rowData.
icon =
":/toolicon/32x32/mirror_by_line.png";
563 rowData.
name = tr(
"");
564 rowData.
tool = tr(
"Mirror by Line %1_%2. Suffix %3")
565 .arg(getPointName(attrUInt(domElement,
AttrP1Line)))
566 .arg(getPointName(attrUInt(domElement,
AttrP2Line)),
567 m_doc->GetParametrString(domElement,
AttrSuffix, QString()));
571 rowData.
icon =
":/toolicon/32x32/mirror_by_axis.png";
572 rowData.
name = tr(
"");
573 rowData.
tool = tr(
"Mirror by Axis through %1 point. Suffix %2")
574 .arg(getPointName(attrUInt(domElement,
AttrCenter)),
575 m_doc->GetParametrString(domElement,
AttrSuffix, QString()));
579 rowData.
icon =
":/toolicon/32x32/move.png";
580 rowData.
name = tr(
"");
581 rowData.
tool = tr(
"Move - rotate around point %1. Suffix %2")
582 .arg(getPointName(attrUInt(domElement,
AttrCenter)),
583 m_doc->GetParametrString(domElement,
AttrSuffix, QString()));
608 qDebug()<<
"Can't create history record for the tool.";
620 ui->tableWidget->setSortingEnabled(
false);
621 ui->tableWidget->verticalHeader()->setDefaultAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
622 ui->tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
623 ui->tableWidget->setHorizontalHeaderItem(0,
new QTableWidgetItem(
"Id"));
624 ui->tableWidget->setHorizontalHeaderItem(1,
new QTableWidgetItem(tr(
"Name")));
625 ui->tableWidget->setHorizontalHeaderItem(2,
new QTableWidgetItem(tr(
"Description")));
635 if (!history->empty())
637 QTableWidgetItem *item =
ui->tableWidget->item(0, 1);
638 item->setSelected(
true);
640 item =
ui->tableWidget->item(0, 0);
641 quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
673 quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
681 if (event->type() == QEvent::LanguageChange)
684 ui->retranslateUi(
this);
689 QDialog::changeEvent(event);
695 if (QLineEdit *textEdit = qobject_cast<QLineEdit *>(
object))
697 if (event->type() == QEvent::KeyPress)
699 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(event);
700 if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
702 if (
qApp->Settings()->GetOsSeparator())
704 textEdit->insert(QLocale().decimalPoint());
708 textEdit->insert(QLocale::c().decimalPoint());
728 QTableWidgetItem *item =
ui->tableWidget->item(
m_cursorRow, 0);
730 item->setIcon(QIcon(
""));
742 return ui->tableWidget->rowCount()-1;
745 for (
int i = 0; i <
ui->tableWidget->rowCount(); ++i)
747 QTableWidgetItem *item =
ui->tableWidget->item(i, 0);
748 const quint32
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
754 return ui->tableWidget->rowCount()-1;
767 for (
int i = 0; i < items.count(); ++i)
769 items.at(i)->setBackground(QColor(
"#b2cbe5"));
779 QItemSelectionModel *model =
ui->tableWidget->selectionModel();
780 QModelIndexList selectedIndexes = model->selectedIndexes();
782 QString clipboardString;
784 for (
int i = 0; i < selectedIndexes.count(); ++i)
786 QModelIndex current = selectedIndexes[i];
787 QString displayText = current.data(Qt::DisplayRole).toString();
790 if (i + 1 < selectedIndexes.count())
792 QModelIndex next = selectedIndexes[i+1];
795 if (next.row() != current.row())
797 displayText.append(
"\n");
802 displayText.append(
" , ");
805 clipboardString.append(displayText);
808 QClipboard *clipboard = QApplication::clipboard();
809 clipboard->setText(clipboardString);
The HistoryDialog class show dialog history.
VPattern * m_doc
ui keeps information about user interface
void updateHistory()
updateHistory update history table
void showTool()
showTool show selected point
void changedCursor(quint32 id)
changedCursor changed cursor of input. Cursor show after which record we will insert new object
void findText(const QString &text)
qint32 m_cursorRow
doc dom document container
qint32 m_cursorToolRecordRow
cursorRow save number of row where is cursor
virtual void DialogAccepted() Q_DECL_OVERRIDE
DialogAccepted save data and emit signal about closed dialog.
virtual ~HistoryDialog() Q_DECL_OVERRIDE
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
void initializeTable()
initializeTable set initial option of table
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void cellClicked(int row, int column)
cellClicked changed history record
quint32 attrUInt(const QDomElement &domElement, const QString &name)
RowData record(const VToolRecord &tool)
Record return description for record.
HistoryDialog(VContainer *data, VPattern *doc, QWidget *parent=nullptr)
HistoryDialog create dialog.
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when windows is closing
void showHistoryTool(quint32 id, bool enable)
showHistoryTool signal change color of selected in records tool
void fillTable()
cursorToolRecordRow save number of row selected record
void copyToClipboard()
copyToClipboard copy dialog selection to clipboard as comma separated values.
void ChangedCursor(quint32 id)
ChangedCursor change cursor position.
void ShowTool(quint32 id, bool enable)
ShowTool highlight tool.
void patternChanged(bool saved)
patternChanged emit if we have unsaved change.
QVector< VToolRecord > getBlockHistory() const
void setCursor(const quint32 &value)
quint32 getCursor() const
QVector< VToolRecord > * getHistory()
getHistory return list with list of history records.
VArc class for anticlockwise arc.
The VContainer class container of all variables.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
static quint32 GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
The VExceptionBadId class for exception bad id.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
The VPattern class working with pattern file.
The VPointF class keep data of point.
The VSplinePath class keep information about splinePath.
VSpline class that implements the spline.
@ PointOfIntersectionCurves
@ PointOfIntersectionCircles
@ PointFromCircleAndTangent
@ PointOfIntersectionArcs
const QString AttrBasePoint
const QString AttrSecondPoint
const QString AttrFirstPoint
const QString AttrP1Line1
const QString AttrThirdPoint
const QString AttrP2Line2
const QString AttrP1Line2
const QString AttrP2Line1