#include "dcreceptor.h"
#include "command/dccommandevent.h"
+#include "command/dccommand.h"
+
#include "utils/dcdialogutil.h"
#include "utils/dccommandutil.h"
#include "dialog/dcinputreceptornamedialog.h"
+#include "dctoolwindowcellcodeeditor.h"
+
#include <QUndoCommand>
#include <map>
d_persMode(DC_PERSMODE_PAGEEDIT), d_contentRootPath("")
{
d_undoStack = new QUndoStack(this);
+ d_cellCodeEditor = new DCToolWindowCellCodeEditor(this);
}
DCCreator::~DCCreator()
emit contentRootPathChanged(this, d_contentRootPath);
emit sceneChanged(this, d_scene);
initMode();
+
+ getMainWindow()->statusBar()->showMessage(tr("Content loaded"), 2000);
+
return true;
}
else
}
}
-bool DCCreator::saveAll()
+bool DCCreator::savePage(DCVCPage *page, bool showResultInMessageBox)
{
bool r = false;
if (d_scene && d_vcontent)
{
- r = d_vcontent->saveAll(d_vcontent->getContentRootPath());
+ if (d_scene->getEditMode() == DCScene::DCV_EDITMODE_CELLCODE)
+ {
+ if (d_scene->getEditCellCodeCell()->getPageBelonging() == page)
+ {
+ getCellCodeEditor()->saveScriptToFile();
+ }
+ }
+ r = d_vcontent->saveForPage(d_vcontent->getContentRootPath(), page);
}
- QMessageBox msgBox;
- if (r)
+ if (showResultInMessageBox)
{
- msgBox.setText(tr("Content is saved successfully"));
+ QMessageBox msgBox;
+ if (r)
+ {
+ msgBox.setText(tr("Page is saved successfully"));
+ }
+ else
+ {
+ msgBox.setText(tr("Error!! Failed to save the page file"));
+ }
+ msgBox.exec();
}
- else
+ return r;
+}
+
+bool DCCreator::saveAll(bool showResultInMessageBox)
+{
+ bool r = false;
+
+ if (getCellCodeEditor()->getIsOnStage())
+ getCellCodeEditor()->saveScriptToFile();
+
+
+ if (d_scene && d_vcontent)
{
- msgBox.setText(tr("Error!! Failed to save content files"));
+ r = d_vcontent->saveAll(d_vcontent->getContentRootPath());
}
- msgBox.exec();
- return false;
+ if (showResultInMessageBox)
+ {
+ QMessageBox msgBox;
+ if (r)
+ {
+ msgBox.setText(tr("Content is saved successfully"));
+ }
+ else
+ {
+ msgBox.setText(tr("Error!! Failed to save content files"));
+ }
+ msgBox.exec();
+ }
+ getMainWindow()->statusBar()->showMessage(tr("Content saved"), 2000);
+
+ return r;
}
DCCommandUtil::postUndoRequestCommand(requester, this);
}
-void DCCreator::doCommandDeleteAxonTerminal(const void *requester, DCCell *axonCell, DCAxonTerminal *axonTerminal)
+void DCCreator::doCommandRemoveAxonTerminal(const void *requester, DCCell *axonCell, DCAxonTerminal *axonTerminal)
{
- DCReceptor *receptor = dynamic_cast<DCReceptor*>(axonTerminal->getTarget());
+ DCReceptor *receptor = axonTerminal->getTarget();
if (!receptor)
return;
- DCCell *targetCell = dynamic_cast<DCCell*>(receptor->getOwnerCell());
+ DCCell *targetCell = receptor->getOwnerCell();
if (!targetCell)
return;
if (ret == QMessageBox::Yes)
{
- DCCommandUtil::postDeleteAxonTerminalCommand(requester, this, axonCell, axonTerminal);
+ DCCommandUtil::postRemoveAxonTerminalCommand(requester, this, axonCell, axonTerminal);
}
}
-void DCCreator::doCommandDeleteAxonTerminal(const void *requester, DCCell *receptorCell, const QString& receptorName)
+void DCCreator::doCommandRemoveAxonTerminal(const void *requester, DCCell *receptorCell, const QString& receptorName)
{
QMessageBox msgBox;
if (ret == QMessageBox::Yes)
{
- DCCommandUtil::postDeleteAxonTerminalCommand(requester, this, receptorCell, receptorName);
+ DCCommandUtil::postRemoveAxonTerminalCommand(requester, this, receptorCell, receptorName);
}
}
DCCommandUtil::postStartCellCodeEditCommand(requester, this, cell);
}
-void DCCreator::doCommandStopEditCellCode(const void *requester)
+void DCCreator::doCommandFinishEditCellCode(const void *requester)
{
- DCCommandUtil::postStopCellCodeEditCommand(requester, this);
+ DCCommandUtil::postFinishCellCodeEditCommand(requester, this);
}
-void DCCreator::doCommandSetCellCodeClass(const void *requester, DCCell *cell, DCCellCode *cellCode)
+void DCCreator::doCommandAssignCellCodeClassToCell(const void *requester, DCCell *cell, DCCellCode *cellCode)
{
- DCCommandUtil::postSetCellCodeClassCommand(requester, this, cell, cellCode);
+ DCCommandUtil::postAssignCellCodeClassToCellCommand(requester, this, cell, cellCode);
}
-void DCCreator::doCommandUnsetCellCodeClass(const void *requester, DCCell *cell)
+void DCCreator::doCommandUnassignCellCodeClassFromCell(const void *requester, DCCell *cell)
{
- DCCommandUtil::postUnsetCellCodeClassCommand(requester, this, cell);
+ DCCommandUtil::postUnassignCellCodeClassFromCellCommand(requester, this, cell);
}
void DCCreator::doCommandAddCellCodeClass(const void *requester, DCContainer *container, const QString& name, const QString& type)
DCCommandUtil::postAddCellCodeClassCommand(requester, this, container, name, type);
}
-void DCCreator::doCommandAddCell(const void *requester, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type)
+void DCCreator::doCommandChangeCellCodeClassType(const void *requester, DCCellCode* cellCode, const QString &newType)
+{
+ DCCommandUtil::postChangeCellCodeClassTypeCommand(requester, this, cellCode, newType);
+}
+
+void DCCreator::doCommandAddCell(const void *requester, DCContainer *container, const QString &containerBasedPath, const QString &name, const QString &type, float pageX, float pageY)
+{
+ DCCommandUtil::postAddCellCommand(requester, this, container, containerBasedPath, name, type, pageX, pageY);
+}
+
+void DCCreator::doCommandChangeCellType(const void *requester, DCCell *cell, const QString &newType)
{
- DCCommandUtil::postAddCellCommand(requester, this, container, containerBasedPath, name, type);
+ DCCommandUtil::postChangeCellTypeCommand(requester, this, cell, newType);
+}
+
+void DCCreator::doCommandRenameCell(const void *requester, DCCell *cell, const QString &newContainerBasedPath, const QString &newName)
+{
+ DCCommandUtil::postRenameCellCommand(requester, this, cell, newContainerBasedPath, newName);
+}
+
+void DCCreator::doCommandRemoveCell(const void *requester, DCContainer *container, DCCell *cell)
+{
+ DCCommandUtil::postRemoveCellCommand(requester, this, container, cell);
}
void DCCreator::doCommandAddPage(const void *requester, const QString &containerBasedPath)
DCCommandUtil::postAddPageCommand(requester, this, containerBasedPath);
}
+void DCCreator::doCommandMovePage(const void *requester, const QString &oldContainerBasedPath, const QString &newContainerBasedPath)
+{
+ DCCommandUtil::postMovePageCommand(requester, this, oldContainerBasedPath, newContainerBasedPath);
+}
+
+void DCCreator::doCommandRemovePage(const void *requester, DCVCPage *page)
+{
+ DCCommandUtil::postRemovePageCommand(requester, this, page);
+}
+
void DCCreator::doCommandAddDirectory(const void *requester, const QString &sysFilePath)
{
DCCommandUtil::postAddDirectoryCommand(requester, this, sysFilePath);
}
+void DCCreator::doCommandRenameDirectory(const void *requester, const QString &oldSysFilePath, const QString &newSysFilePath)
+{
+ DCCommandUtil::postRenameDirectoryCommand(requester, this, oldSysFilePath, newSysFilePath);
+}
+
void DCCreator::doCommandRemoveDirectory(const void *requester, const QString &sysFilePath)
{
DCCommandUtil::postRemoveDirectoryCommand(requester, this, sysFilePath);
}
-bool DCCreator::doCommandRenameDirectoryImmidiate(const void *requester, const QString &containerBasedPath, const QString &oldName, const QString &newName)
+bool DCCreator::doCommandRenameReceptorName(const void *requester, DCCell *cell, const QString &oldName, const QString &newName, bool doImmediate)
{
- //TODO
- QMessageBox msgBox;
- msgBox.setText("This command isn't implemented yet");
- msgBox.exec();
- return false;
+ if (doImmediate)
+ {
+ DCCommand *command = DCCommandUtil::createRenameReceptorNameCommand(requester, this, cell, oldName, newName);
+ d_undoStack->push(command);
+ return command->getCommandResult() == DCCommand::DCCOMMAND_SUCCEEDED;
+ }
+ else
+ {
+ DCCommandUtil::postRenameReceptorNameCommand(requester, this, cell, oldName, newName);
+ return true;
+ }
}
DCContainer* DCCreator::getCurrentContainer() const