Call Lite Parse each time when add object inside of file.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-07 14:55:01 +03:00
parent c0bae287be
commit 628fdd4217
5 changed files with 53 additions and 29 deletions

View File

@ -99,9 +99,9 @@ void DialogHistory::cellClicked(int row, int column)
item = ui->tableWidget->item(row, 0); item = ui->tableWidget->item(row, 0);
cursorRow = row; cursorRow = row;
item->setIcon(QIcon("://icon/32x32/put_after.png")); item->setIcon(QIcon("://icon/32x32/put_after.png"));
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); const quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
doc->blockSignals(true); doc->blockSignals(true);
doc->setCursor(id); row == ui->tableWidget->rowCount()-1 ? doc->setCursor(0) : doc->setCursor(id);
doc->blockSignals(false); doc->blockSignals(false);
} }
else else
@ -185,7 +185,7 @@ void DialogHistory::FillTable()
ui->tableWidget->setRowCount(count);//Real row count ui->tableWidget->setRowCount(count);//Real row count
if (count>0) if (count>0)
{ {
cursorRow = currentRow; cursorRow = CursorRow();
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
SCASSERT(item != nullptr); SCASSERT(item != nullptr);
item->setIcon(QIcon("://icon/32x32/put_after.png")); item->setIcon(QIcon("://icon/32x32/put_after.png"));
@ -492,3 +492,24 @@ void DialogHistory::RetranslateUi()
cursorRow = currentRow; cursorRow = currentRow;
cellClicked(cursorRow, 0); cellClicked(cursorRow, 0);
} }
//---------------------------------------------------------------------------------------------------------------------
int DialogHistory::CursorRow() const
{
const quint32 cursor = doc->getCursor();
if (cursor == 0)
{
return ui->tableWidget->rowCount()-1;
}
for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 0);
const quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
if (cursor == id)
{
return i;
}
}
return ui->tableWidget->rowCount()-1;
}

View File

@ -91,6 +91,7 @@ private:
QString PointName(quint32 pointId); QString PointName(quint32 pointId);
quint32 AttrUInt(const QDomElement &domElement, const QString &name); quint32 AttrUInt(const QDomElement &domElement, const QString &name);
void RetranslateUi(); void RetranslateUi();
int CursorRow() const;
}; };
#endif // DIALOGHISTORY_H #endif // DIALOGHISTORY_H

View File

@ -570,10 +570,10 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene); VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool.data(), &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject); connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
ui->view->itemClicked(nullptr); ui->view->itemClicked(nullptr);
} }
else else
@ -629,11 +629,11 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene); VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool.data(), &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject); connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot); connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
connect(ui->view, &VMainGraphicsView::MouseRelease, this, &MainWindow::ClickEndVisualization); connect(ui->view, &VMainGraphicsView::MouseRelease, this, &MainWindow::ClickEndVisualization);
ui->view->itemClicked(nullptr); ui->view->itemClicked(nullptr);
} }
@ -653,7 +653,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ClosedDialog(int result) void MainWindow::ClosedDialog(int result)
{ {
SCASSERT(dialogTool != nullptr); SCASSERT(not dialogTool.isNull());
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
{ {
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene); VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
@ -673,7 +673,7 @@ void MainWindow::ClosedDialog(int result)
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ClosedDialogWithApply(int result) void MainWindow::ClosedDialogWithApply(int result)
{ {
SCASSERT(dialogTool != nullptr); SCASSERT(not dialogTool.isNull());
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
{ {
// Only create tool if not already created with apply // Only create tool if not already created with apply
@ -691,7 +691,7 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->FullUpdateFromGuiApply(); vtool->FullUpdateFromGuiApply();
} }
} }
SCASSERT(dialogTool != nullptr); SCASSERT(not dialogTool.isNull());
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool()); QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool());
ui->view->itemClicked(tool); ui->view->itemClicked(tool);
if (dialogTool->GetAssociatedTool() != nullptr) if (dialogTool->GetAssociatedTool() != nullptr)
@ -700,6 +700,15 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->DialogLinkDestroy(); vtool->DialogLinkDestroy();
} }
ArrowTool(); ArrowTool();
// If insert not to the end of file call lite parse
if (doc->getCursor() > 0)
{
doc->LiteParseTree(Document::LiteParse);
if (dialogHistory)
{
dialogHistory->UpdateHistory();
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -709,7 +718,7 @@ void MainWindow::ClosedDialogWithApply(int result)
template <typename DrawTool> template <typename DrawTool>
void MainWindow::ApplyDialog() void MainWindow::ApplyDialog()
{ {
SCASSERT(dialogTool != nullptr); SCASSERT(not dialogTool.isNull());
// Only create tool if not already created with apply // Only create tool if not already created with apply
if (dialogTool->GetAssociatedTool() == nullptr) if (dialogTool->GetAssociatedTool() == nullptr)
@ -1834,7 +1843,6 @@ void MainWindow::CancelTool()
qCDebug(vMainWindow, "Canceling tool."); qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool; delete dialogTool;
dialogTool = nullptr;
qCDebug(vMainWindow, "Dialog closed."); qCDebug(vMainWindow, "Dialog closed.");
currentScene->setFocus(Qt::OtherFocusReason); currentScene->setFocus(Qt::OtherFocusReason);
@ -3090,8 +3098,8 @@ void MainWindow::ActionHistory(bool checked)
{ {
dialogHistory = new DialogHistory(pattern, doc, this); dialogHistory = new DialogHistory(pattern, doc, this);
dialogHistory->setWindowFlags(Qt::Window); dialogHistory->setWindowFlags(Qt::Window);
connect(this, &MainWindow::RefreshHistory, dialogHistory, &DialogHistory::UpdateHistory); connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory);
connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory); connect(dialogHistory.data(), &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory);
dialogHistory->show(); dialogHistory->show();
} }
else else
@ -4254,7 +4262,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::EndVisualization(bool click) void MainWindow::EndVisualization(bool click)
{ {
if (dialogTool != nullptr) if (not dialogTool.isNull())
{ {
dialogTool->ShowDialog(click); dialogTool->ShowDialog(click);
} }

View File

@ -243,8 +243,8 @@ private:
bool patternReadOnly; bool patternReadOnly;
DialogIncrements *dialogTable; DialogIncrements *dialogTable;
DialogTool *dialogTool; QPointer<DialogTool> dialogTool;
DialogHistory *dialogHistory; QPointer<DialogHistory> dialogHistory;
/** @brief comboBoxDraws comboc who show name of pattern peaces. */ /** @brief comboBoxDraws comboc who show name of pattern peaces. */
QComboBox *comboBoxDraws; QComboBox *comboBoxDraws;

View File

@ -49,7 +49,6 @@ void AddToCalc::undo()
qCDebug(vUndo, "Undo."); qCDebug(vUndo, "Undo.");
doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change
doc->setCursor(cursor);
QDomElement calcElement; QDomElement calcElement;
if (doc->GetActivNodeElement(VAbstractPattern::TagCalculation, calcElement)) if (doc->GetActivNodeElement(VAbstractPattern::TagCalculation, calcElement))
@ -74,10 +73,6 @@ void AddToCalc::undo()
qCDebug(vUndo, "Can't find tag Calculation."); qCDebug(vUndo, "Can't find tag Calculation.");
return; return;
} }
if (cursor > 0)
{
doc->setCursor(0);
}
emit NeedFullParsing(); emit NeedFullParsing();
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
@ -104,7 +99,6 @@ void AddToCalc::redo()
if (refElement.isElement()) if (refElement.isElement())
{ {
calcElement.insertAfter(xml, refElement); calcElement.insertAfter(xml, refElement);
doc->setCursor(0);
} }
else else
{ {