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);
cursorRow = row;
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->setCursor(id);
row == ui->tableWidget->rowCount()-1 ? doc->setCursor(0) : doc->setCursor(id);
doc->blockSignals(false);
}
else
@ -185,7 +185,7 @@ void DialogHistory::FillTable()
ui->tableWidget->setRowCount(count);//Real row count
if (count>0)
{
cursorRow = currentRow;
cursorRow = CursorRow();
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
SCASSERT(item != nullptr);
item->setIcon(QIcon("://icon/32x32/put_after.png"));
@ -492,3 +492,24 @@ void DialogHistory::RetranslateUi()
cursorRow = currentRow;
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);
quint32 AttrUInt(const QDomElement &domElement, const QString &name);
void RetranslateUi();
int CursorRow() const;
};
#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);
SCASSERT(scene != nullptr);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool.data(), &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject);
connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
ui->view->itemClicked(nullptr);
}
else
@ -629,11 +629,11 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
SCASSERT(scene != nullptr);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot);
connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool.data(), &DialogTool::ChosenObject);
connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject);
connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot);
connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot);
connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip);
connect(ui->view, &VMainGraphicsView::MouseRelease, this, &MainWindow::ClickEndVisualization);
ui->view->itemClicked(nullptr);
}
@ -653,7 +653,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
template <typename DrawTool>
void MainWindow::ClosedDialog(int result)
{
SCASSERT(dialogTool != nullptr);
SCASSERT(not dialogTool.isNull());
if (result == QDialog::Accepted)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
@ -673,7 +673,7 @@ void MainWindow::ClosedDialog(int result)
template <typename DrawTool>
void MainWindow::ClosedDialogWithApply(int result)
{
SCASSERT(dialogTool != nullptr);
SCASSERT(not dialogTool.isNull());
if (result == QDialog::Accepted)
{
// Only create tool if not already created with apply
@ -691,7 +691,7 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->FullUpdateFromGuiApply();
}
}
SCASSERT(dialogTool != nullptr);
SCASSERT(not dialogTool.isNull());
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool());
ui->view->itemClicked(tool);
if (dialogTool->GetAssociatedTool() != nullptr)
@ -700,6 +700,15 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->DialogLinkDestroy();
}
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>
void MainWindow::ApplyDialog()
{
SCASSERT(dialogTool != nullptr);
SCASSERT(not dialogTool.isNull());
// Only create tool if not already created with apply
if (dialogTool->GetAssociatedTool() == nullptr)
@ -1834,7 +1843,6 @@ void MainWindow::CancelTool()
qCDebug(vMainWindow, "Canceling tool.");
delete dialogTool;
dialogTool = nullptr;
qCDebug(vMainWindow, "Dialog closed.");
currentScene->setFocus(Qt::OtherFocusReason);
@ -3090,8 +3098,8 @@ void MainWindow::ActionHistory(bool checked)
{
dialogHistory = new DialogHistory(pattern, doc, this);
dialogHistory->setWindowFlags(Qt::Window);
connect(this, &MainWindow::RefreshHistory, dialogHistory, &DialogHistory::UpdateHistory);
connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory);
connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory);
connect(dialogHistory.data(), &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory);
dialogHistory->show();
}
else
@ -4254,7 +4262,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::EndVisualization(bool click)
{
if (dialogTool != nullptr)
if (not dialogTool.isNull())
{
dialogTool->ShowDialog(click);
}

View File

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

View File

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