OSDN Git Service

[denncoCreator] implemented rename file functionality
authortkawata <tkawata@users.sourceforge.jp>
Thu, 11 Oct 2012 12:28:31 +0000 (21:28 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Thu, 11 Oct 2012 12:28:31 +0000 (21:28 +0900)
35 files changed:
Source/command/dccommand.cpp
Source/command/dccommand.h
Source/command/dceditcommands.cpp
Source/command/dceditcommands.h
Source/dccell.cpp
Source/dccell.h
Source/dccellcode.cpp
Source/dccellcode.h
Source/dccontainer.cpp
Source/dccontainer.h
Source/dccontainersaver.cpp
Source/dccreator.cpp
Source/dccreator.h
Source/dialog/dcinputnewpagenamedialog.cpp
Source/dialog/dcinputnewpagenamedialog.h
Source/engine/layer1/TKCellCode.h
Source/engine/layer1/TKContainer.h
Source/treeview/dctreeviewwidget.cpp
Source/treeview/dctreeviewwidget.h
Source/utils/dccommandutil.cpp
Source/utils/dccommandutil.h
Source/utils/dccomponentutil.cpp
Source/utils/dccomponentutil.h
Source/utils/dcutil.cpp
Source/utils/dcutil.h
Source/visualizer/component/dcvccell.cpp
Source/visualizer/component/dcvccell.h
Source/visualizer/component/dcvccellcode.cpp
Source/visualizer/component/dcvccellcode.h
Source/visualizer/component/dcvcpage.cpp
Source/visualizer/component/dcvcpage.h
Source/visualizer/dcscene.cpp
Source/visualizer/dcscene.h
Source/visualizer/toolwindow/dctoolwindowcellcodeeditor.cpp
Source/visualizer/toolwindow/dctoolwindowcelleditor.cpp

index c62595a..6382d05 100644 (file)
@@ -21,7 +21,7 @@
 #include "dccreator.h"
 
 DCCommand::DCCommand(const void *requester, DCCreator *creator)
-    : d_requester(requester), d_controller(creator)
+    : d_requester(requester), d_controller(creator), d_commandResult(DCCOMMAND_NOT_EXECUTED)
 {
     if (creator)
     {
index ee56530..359eeee 100644 (file)
@@ -26,17 +26,26 @@ class DCScene;
 
 class DCCommand : public QUndoCommand
 {
-    const void  *d_requester;
-    DCCreator   *d_controller;
-    DCScene     *d_scene;
+public:
+    enum E_DCCOMMAND_RESULT {DCCOMMAND_NOT_EXECUTED, DCCOMMAND_SUCCEEDED, DCCOMMAND_FAILED };
+
+private:
+    const void          *d_requester;
+    DCCreator           *d_controller;
+    DCScene             *d_scene;
+    E_DCCOMMAND_RESULT  d_commandResult;
 
 public:
     DCCommand(const void *requester, DCCreator *creator);
     virtual ~DCCommand() {}
 
-    const void *    getRequester() const { return d_requester; }
-    DCCreator *     getController() const { return d_controller; }
-    DCScene *       getScene() const { return d_scene; }
+    const void *        getRequester() const { return d_requester; }
+    DCCreator *         getController() const { return d_controller; }
+    DCScene *           getScene() const { return d_scene; }
+    E_DCCOMMAND_RESULT  getCommandResult() const { return d_commandResult; }
+
+protected:
+    void                setCommandResult(E_DCCOMMAND_RESULT result) { d_commandResult = result; }
 };
 
 #endif // DCCOMMAND_H
index a3fd1f0..bbe1946 100644 (file)
@@ -42,7 +42,9 @@ DCStartAddAxonTerminalCommandFromAxon::DCStartAddAxonTerminalCommandFromAxon(con
 void DCStartAddAxonTerminalCommandFromAxon::redo()
 {
     DCAxon *axon = d_ownerCell->getAxon();
-    getScene()->startTerminalEditForAxon(getRequester(), axon);
+    bool r = getScene()->startTerminalEditForAxon(getRequester(), axon);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+
 }
 
 void DCStartAddAxonTerminalCommandFromAxon::undo()
@@ -61,7 +63,8 @@ DCStartAddAxonTerminalCommandFromReceptor::DCStartAddAxonTerminalCommandFromRece
 void DCStartAddAxonTerminalCommandFromReceptor::redo()
 {
     DCReceptor *receptor = d_ownerCell->createReceptor(d_receptorName);
-    getScene()->startTerminalEditForReceptor(getRequester(), receptor);
+    bool r = getScene()->startTerminalEditForReceptor(getRequester(), receptor);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCStartAddAxonTerminalCommandFromReceptor::undo()
@@ -86,10 +89,11 @@ DCCommitAddAxonTerminalCommand::DCCommitAddAxonTerminalCommand(const void *reque
 
 void DCCommitAddAxonTerminalCommand::redo()
 {
+    bool r = false;
     if (!d_receptor)
     {
         d_isAdded = d_axonCell->connectTo(d_receptorName.toStdString(), d_receptorCell);
-        getScene()->finishTerminalEdit(getRequester());
+        r = getScene()->finishTerminalEdit(getRequester());
     }
     else
     {
@@ -99,8 +103,9 @@ void DCCommitAddAxonTerminalCommand::redo()
             d_receptor->setTarget(terminal);
             d_isAdded = true;
         }
-        getScene()->finishTerminalEdit(getRequester());
+        r = getScene()->finishTerminalEdit(getRequester());
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCCommitAddAxonTerminalCommand::undo()
@@ -146,6 +151,7 @@ DCRemoveAxonTerminalCommand::DCRemoveAxonTerminalCommand(const void *requester,
 
 void DCRemoveAxonTerminalCommand::redo()
 {
+    bool r = false;
     if (d_axonTerminal)
     {
         //delete from axon terminal
@@ -157,7 +163,7 @@ void DCRemoveAxonTerminalCommand::redo()
             QString receptorName = QString::fromStdString(targetCell->getReceptorName(receptor));
             d_isDeleted = targetCell->removeReceptor(receptorName);
             if (d_isDeleted)
-                axon->removeAxonTerminal(d_axonTerminal);
+                r = axon->removeAxonTerminal(d_axonTerminal);
         }
     }
     else
@@ -168,8 +174,9 @@ void DCRemoveAxonTerminalCommand::redo()
         DCAxon *axon = dynamic_cast<DCAxon*>(terminal->getOwner());
         d_isDeleted = d_cell->removeReceptor(d_receptorName);
         if (d_isDeleted)
-            axon->removeAxonTerminal(terminal);
+            r = axon->removeAxonTerminal(terminal);
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCRemoveAxonTerminalCommand::undo()
@@ -187,8 +194,8 @@ DCStartCellCodeEditCommand::DCStartCellCodeEditCommand(const void *requester, DC
 
 void DCStartCellCodeEditCommand::redo()
 {
-    getScene()->startCellCodeEdit(getRequester(), d_cell);
-
+    bool r =getScene()->startCellCodeEdit(getRequester(), d_cell);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCStartCellCodeEditCommand::undo()
@@ -205,8 +212,8 @@ DCFinishCellCodeEditCommand::DCFinishCellCodeEditCommand(const void *requester,
 
 void DCFinishCellCodeEditCommand::redo()
 {
-    getScene()->finishCellCodeEdit(getRequester());
-
+    bool r = getScene()->finishCellCodeEdit(getRequester());
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCFinishCellCodeEditCommand::undo()
@@ -224,11 +231,13 @@ DCAssignCellCodeClassToCellCommand::DCAssignCellCodeClassToCellCommand(const voi
 
 void DCAssignCellCodeClassToCellCommand::redo()
 {
+    bool r = false;
     if (d_cell)
     {
         d_prevClass = d_cell->getCellCode();
-        d_cell->setCellCode(d_cellCode, NULL);
+        r = d_cell->setCellCode(d_cellCode, NULL);
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCAssignCellCodeClassToCellCommand::undo()
@@ -250,11 +259,13 @@ DCUnassignCellCodeClassFromCellCommand::DCUnassignCellCodeClassFromCellCommand(c
 
 void DCUnassignCellCodeClassFromCellCommand::redo()
 {
+    bool r = false;
     if (d_cell)
     {
         d_prevClass = d_cell->getCellCode();
-        d_cell->setCellCode(getController()->getCurrentContainer()->getEmptyCellCodeClass(), NULL);
+        r = d_cell->setCellCode(getController()->getCurrentContainer()->getEmptyCellCodeClass(), NULL);
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCUnassignCellCodeClassFromCellCommand::undo()
@@ -277,7 +288,8 @@ DCAddCellCodeClassCommand::DCAddCellCodeClassCommand(const void *requester, DCCr
 
 void DCAddCellCodeClassCommand::redo()
 {
-    d_container->addCellCode(d_name.toStdString(), d_type.toStdString(), "\n");
+    bool r = d_container->addCellCode(d_name.toStdString(), d_type.toStdString(), "\n") != NULL;
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCAddCellCodeClassCommand::undo()
@@ -286,8 +298,35 @@ void DCAddCellCodeClassCommand::undo()
 
 /*--------------------------------*/
 
+DCMoveCellCodeClassCommand::DCMoveCellCodeClassCommand(const void *requester, DCCreator *creator, const QString &name, const QString &type)
+    : DCCommand(requester, creator), d_name(name), d_type(type)
+{
+}
+
+DCMoveCellCodeClassCommand::~DCMoveCellCodeClassCommand()
+{
+}
+
+void DCMoveCellCodeClassCommand::redo()
+{
+
+}
+
+void DCMoveCellCodeClassCommand::undo()
+{
+
+}
+
+/*--------------------------------*/
+
 DCRemoveCellCodeClassCommand::DCRemoveCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCellCode *cellCode)
-    : DCCommand(requester, creator), d_container(container), d_cellCode(cellCode)
+    : DCCommand(requester, creator), d_container(container)
+{
+    d_cellCodes.append(cellCode);
+}
+
+DCRemoveCellCodeClassCommand::DCRemoveCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCellCode *> &cellcodes)
+    : DCCommand(requester, creator), d_container(container), d_cellCodes(cellcodes)
 {
 }
 
@@ -297,7 +336,17 @@ DCRemoveCellCodeClassCommand::~DCRemoveCellCodeClassCommand()
 
 void DCRemoveCellCodeClassCommand::redo()
 {
-    d_container->removeCellCode(d_cellCode);
+    bool r = false;
+
+    for (int i = 0; i < d_cellCodes.length(); i++)
+    {
+        if (!d_container->removeCellCode(d_cellCodes.at(i)))
+        {
+            r = false;
+        }
+    }
+
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCRemoveCellCodeClassCommand::undo()
@@ -315,9 +364,12 @@ DCAddCellCommand::DCAddCellCommand(const void *requester, DCCreator *creator, DC
 
 void DCAddCellCommand::redo()
 {
+    bool r = false;
+
     DCCell *cell = dynamic_cast<DCCell*>(d_container->addCell(d_path.toStdString(), d_name.toStdString(), d_type.toStdString(), ""));
     if (cell)
     {
+        r = true;
         cell->getVComponent()->setSelected(true,true);
         getController()->selectPage(this, cell->getPageBelonging(), false);
         if (getController()->getPersMode() != DCCreator::DC_PERSMODE_PAGEEDIT)
@@ -325,6 +377,7 @@ void DCAddCellCommand::redo()
             getController()->changePersMode(this, DCCreator::DC_PERSMODE_PAGEEDIT);
         }
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCAddCellCommand::undo()
@@ -334,25 +387,94 @@ void DCAddCellCommand::undo()
 
 /*--------------------------------*/
 
-DCRemoveCellsCommand::DCRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
+DCRenameCellCommand::DCRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newName)
+    : DCCommand(requester, creator), d_cell(cell), d_name(newName)
+{
+
+}
+
+DCRenameCellCommand::~DCRenameCellCommand()
+{
+
+}
+
+void DCRenameCellCommand::redo()
+{
+    bool r = false;
+    DCContainer *container = getController()->getCurrentContainer();
+    if (container)
+        r = container->renameCell(d_cell, d_name);
+
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+}
+
+void DCRenameCellCommand::undo()
+{
+
+}
+
+/*--------------------------------*/
+
+DCMoveCellCommand::DCMoveCellCommand(const void *requester, DCCreator *creator, DCCell *cell, DCVCPage *newPage)
+    : DCCommand(requester, creator), d_cell(cell), d_page(newPage)
+{
+}
+
+DCMoveCellCommand::~DCMoveCellCommand()
+{
+
+}
+
+void DCMoveCellCommand::redo()
+{
+    bool r = false;
+
+    if (d_page && d_cell)
+    {
+        d_cell->getVComponent()->changePageBelonging(d_page);
+        r = true;
+    }
+
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+}
+
+void DCMoveCellCommand::undo()
+{
+
+}
+
+/*--------------------------------*/
+
+DCRemoveCellCommand::DCRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCell* cell)
+    : DCCommand(requester, creator), d_container(container)
+{
+    d_cells.append(cell);
+}
+
+DCRemoveCellCommand::DCRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
     : DCCommand(requester, creator), d_container(container), d_cells(cells)
 {
 }
 
-DCRemoveCellsCommand::~DCRemoveCellsCommand()
+DCRemoveCellCommand::~DCRemoveCellCommand()
 {
 
 }
 
-void DCRemoveCellsCommand::redo()
+void DCRemoveCellCommand::redo()
 {
+    bool r = true;
     for (int i = 0; i < d_cells.length(); i++)
     {
-        d_container->removeCell(d_cells.at(i));
+        if (!d_container->removeCell(d_cells.at(i)))
+        {
+            r = false;
+        }
     }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
-void DCRemoveCellsCommand::undo()
+void DCRemoveCellCommand::undo()
 {
 
 }
@@ -368,8 +490,9 @@ void DCAddPageCommand::redo()
 {
     DCTreeViewWidget::requestSelectionWhenRowAdded();
     d_page = getScene()->addPage(d_path.toStdString());
-    getController()->savePage(d_page);
+    bool r = getController()->savePage(d_page);
     getController()->selectPage(getRequester(), d_page, false);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCAddPageCommand::undo()
@@ -378,6 +501,62 @@ void DCAddPageCommand::undo()
 }
 
 /*--------------------------------*/
+DCMovePageCommand::DCMovePageCommand(const void *requester, DCCreator *creator, const QString &oldContainerBasedPathName, const QString &newContainerBasedPathName)
+    : DCCommand(requester, creator), d_oldPath(oldContainerBasedPathName), d_newPath(newContainerBasedPathName)
+{
+}
+
+DCMovePageCommand::~DCMovePageCommand()
+{
+    qDebug() << "DCRenamePageCommand removed..";
+}
+
+void DCMovePageCommand::redo()
+{
+    bool r = false;
+
+    DCContainer *container = getController()->getCurrentContainer();
+    DCVCPage *oldPage = getScene()->getPage(d_oldPath.toStdString());
+    if (container && oldPage && !getScene()->getIsPageExist(d_newPath.toStdString()))
+    {
+        DCTreeViewWidget::requestSelectionWhenRowAdded();
+        DCVCPage *newPage = container->movePage(d_oldPath, d_newPath);
+        getController()->selectPage(getRequester(), newPage, false);
+
+        if (newPage)
+        {
+            r = getController()->saveAll(false);
+        }
+        if (r)
+        {
+            QString filePath = QString::fromStdString(container->getContainerRootPath());
+            filePath.append(d_oldPath);
+
+            QString sceneSettingFilePath = getScene()->getSceneSettingFilePathForPage(oldPage);
+
+            if (!DCTreeViewWidget::removeFile(filePath))
+            {
+                r = false;
+            }
+            QDir dir;
+            dir.remove(sceneSettingFilePath);
+
+            if (!getScene()->removePage(oldPage))
+            {
+                r = false;
+            }
+        }
+    }
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+}
+
+void DCMovePageCommand::undo()
+{
+
+}
+
+
+/*--------------------------------*/
 DCRemovePageCommand::DCRemovePageCommand(const void *requester, DCCreator *creator, DCVCPage *page)
     : DCCommand(requester, creator), d_page(page)
 {
@@ -391,16 +570,28 @@ DCRemovePageCommand::~DCRemovePageCommand()
 
 void DCRemovePageCommand::redo()
 {
+    bool r = false;
+
     const QList<DCVPageComponent*> *vcells = d_page->getCells();
-    const QList<DCVPageComponent*> *cellCodeClasses = d_page->getCellCodeClasses();
+    const QList<DCVPageComponent*> *vcellCodeClasses = d_page->getCellCodeClasses();
 
     DCContainer *container = getController()->getCurrentContainer();
 
-    for (int i = 0; i < cellCodeClasses->length(); i++)
+    QList<DCCellCode*> cellcodes;
+    for (int i = 0; i < vcellCodeClasses->length(); i++)
+    {
+        DCCellCode *cellCode = dynamic_cast<DCVCCellCode*>(vcellCodeClasses->at(i))->getOwnerCellCodeClass();
+        if (cellCode)
+            cellcodes.append(cellCode);
+    }
+
+    if (cellcodes.length()>0)
     {
-        DCCellCode *cellCode = dynamic_cast<DCVCCellCode*>(cellCodeClasses->at(i))->getOwnerCellCodeClass();
-        DCCommand *command = new DCRemoveCellCodeClassCommand(getRequester(), getController(), container, cellCode);
+        DCCommand *command = new DCRemoveCellCodeClassCommand(getRequester(), getController(), container, cellcodes);
         d_undoStack.push(command);
+
+        if (command->getCommandResult() != DCCommand::DCCOMMAND_SUCCEEDED)
+            r = false;
     }
 
     QList<DCCell*> cells;
@@ -411,8 +602,14 @@ void DCRemovePageCommand::redo()
             cells.append(cell);
     }
 
-    DCCommand *removeCellCommand = new DCRemoveCellsCommand(getRequester(), getController(), container, cells);
-    d_undoStack.push(removeCellCommand);
+    if (cells.length()>0)
+    {
+        DCCommand *command = new DCRemoveCellCommand(getRequester(), getController(), container, cells);
+        d_undoStack.push(command);
+
+        if (command->getCommandResult() != DCCommand::DCCOMMAND_SUCCEEDED)
+            r = false;
+    }
 
     QString filePath = QString::fromStdString(getController()->getCurrentContainer()->getContainerRootPath());
     filePath.append(d_page->getLocationPath());
@@ -420,10 +617,18 @@ void DCRemovePageCommand::redo()
     QString sceneSettingFilePath = getScene()->getSceneSettingFilePathForPage(d_page);
 
     QDir dir;
-    dir.remove(filePath);
+    if (!dir.remove(filePath))
+    {
+        r = false;
+    }
     dir.remove(sceneSettingFilePath);
 
-    getScene()->removePage(d_page);
+    if (!getScene()->removePage(d_page))
+    {
+        r = false;
+    }
+
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCRemovePageCommand::undo()
@@ -440,7 +645,8 @@ DCAddDirectoryCommand::DCAddDirectoryCommand(const void *requester, DCCreator *c
 
 void DCAddDirectoryCommand::redo()
 {
-    DCTreeViewWidget::addDirectory(d_path);
+    bool r = DCTreeViewWidget::addDirectory(d_path);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCAddDirectoryCommand::undo()
@@ -449,6 +655,25 @@ void DCAddDirectoryCommand::undo()
 }
 
 /*--------------------------------*/
+DCRenameDirectoryCommand::DCRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysOldFilePath, const QString &sysNewFilePath)
+    : DCCommand(requester, creator), d_oldPath(sysOldFilePath), d_newPath(sysNewFilePath)
+{
+
+}
+
+void DCRenameDirectoryCommand::redo()
+{
+    DCContainer *container = getController()->getCurrentContainer();
+    //TODO
+}
+
+void DCRenameDirectoryCommand::undo()
+{
+
+}
+
+
+/*--------------------------------*/
 DCRemoveDirectoryCommand::DCRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
     : DCCommand(requester, creator), d_path(sysFilePath)
 {
@@ -457,7 +682,8 @@ DCRemoveDirectoryCommand::DCRemoveDirectoryCommand(const void *requester, DCCrea
 
 void DCRemoveDirectoryCommand::redo()
 {
-    DCTreeViewWidget::removeDirectory(d_path);
+    bool r = DCTreeViewWidget::removeDirectory(d_path);
+    setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
 }
 
 void DCRemoveDirectoryCommand::undo()
index 29eebaa..a762056 100644 (file)
@@ -155,14 +155,29 @@ public:
 
 //------------------------------------------
 
-class DCRemoveCellCodeClassCommand : public DCCommand
+class DCMoveCellCodeClassCommand : public DCCommand
 {
-    DCContainer *d_container;
-    DCCellCode  *d_cellCode;
+    QString     d_name;
     QString     d_type;
 
 public:
+    DCMoveCellCodeClassCommand(const void *requester, DCCreator *creator, const QString& name, const QString &type);
+    virtual ~DCMoveCellCodeClassCommand();
+    void undo();
+    void redo();
+};
+
+//------------------------------------------
+
+class DCRemoveCellCodeClassCommand : public DCCommand
+{
+    DCContainer         *d_container;
+    QList<DCCellCode*>  d_cellCodes;
+    QString             d_type;
+
+public:
     DCRemoveCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCellCode* cellCode);
+    DCRemoveCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCellCode*> &cellcodes);
     virtual ~DCRemoveCellCodeClassCommand();
     void undo();
     void redo();
@@ -186,14 +201,43 @@ public:
 
 //------------------------------------------
 
-class DCRemoveCellsCommand : public DCCommand
+class DCRenameCellCommand : public DCCommand
+{
+    DCCell      *d_cell;
+    QString     d_name;
+
+public:
+    DCRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString& newName);
+    virtual ~DCRenameCellCommand();
+    void undo();
+    void redo();
+};
+
+//------------------------------------------
+
+class DCMoveCellCommand : public DCCommand
+{
+    DCCell      *d_cell;
+    DCVCPage    *d_page;
+
+public:
+    DCMoveCellCommand(const void *requester, DCCreator *creator, DCCell *cell, DCVCPage *newPage);
+    virtual ~DCMoveCellCommand();
+    void undo();
+    void redo();
+};
+
+//------------------------------------------
+
+class DCRemoveCellCommand : public DCCommand
 {
     DCContainer     *d_container;
     QList<DCCell*>  d_cells;
 
 public:
-    DCRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells);
-    virtual ~DCRemoveCellsCommand();
+    DCRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCell *cell);
+    DCRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells);
+    virtual ~DCRemoveCellCommand();
     void undo();
     void redo();
 };
@@ -213,6 +257,20 @@ public:
 
 //------------------------------------------
 
+class DCMovePageCommand : public DCCommand
+{
+    QString     d_oldPath;
+    QString     d_newPath;
+
+public:
+    DCMovePageCommand(const void *requester, DCCreator *creator, const QString& oldContainerBasedPathName, const QString& newContainerBasedPathName);
+    virtual ~DCMovePageCommand();
+    void undo();
+    void redo();
+};
+
+//------------------------------------------
+
 class DCRemovePageCommand : public DCCommand
 {
     DCVCPage    *d_page;
@@ -239,6 +297,20 @@ public:
 
 //------------------------------------------
 
+class DCRenameDirectoryCommand : public DCCommand
+{
+    QString d_oldPath;
+    QString d_newPath;
+
+public:
+    DCRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysOldFilePath, const QString& sysNewFilePath);
+    virtual ~DCRenameDirectoryCommand() {}
+    void undo();
+    void redo();
+};
+
+//------------------------------------------
+
 class DCRemoveDirectoryCommand : public DCCommand
 {
     QString d_path;
index 818bd64..85102bf 100644 (file)
@@ -276,3 +276,13 @@ bool DCCell::removeAllConnections()
     }
     return true;
 }
+
+void DCCell::changeName(const QString &newName)
+{
+    mName = newName.toStdString();
+}
+
+void DCCell::changePath(const QString &newPath)
+{
+    mLocation = newPath.toStdString();
+}
index fcce41b..208af75 100644 (file)
@@ -38,6 +38,8 @@ class DCCell : public QObject, public TKCell
     Q_OBJECT
 
     friend class DCComponentUtil;
+    friend class DCContainer;
+
     DCCell(DCContainer *container, std::string location, std::string name, std::string type, bool canInterface);
     void bindComponent(DCVPageComponent *component);
 
@@ -52,6 +54,19 @@ class DCCell : public QObject, public TKCell
 
     bool                removeAllConnections();
 
+    /**
+      * Change name of this cell.
+      * DCContainer will call this method.
+      */
+    void                changeName(const QString& newName);
+
+    /**
+      * Change the location path for this cell.
+      * DCContainer will call this method.
+      */
+    void                changePath(const QString& newPath);
+
+
 public:
     virtual ~DCCell();
 
@@ -81,14 +96,27 @@ public:
     void                setViewHeight(float height);
     bool                saveCustomScript(const QString& script);
 
-    /* This method is exepected to be called from command classes (defined in dceditcommands.h).
-     * This will remove receptor from the list
-     * This will remove receptor object but won't remove the axon terminal connected to the receptor
+    /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
+     */
+
+    /**
+     * Remove receptor from the list
+     * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
+     * This method is expected to be only called from command classes (defined in dceditcommands.h )
      */
     bool                removeReceptor(const QString &name);
+
+
+    /**
+     * Remove receptor from the list
+     * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
+     * This method is expected to be only called from command classes (defined in dceditcommands.h )
+     */
     bool                removeReceptor(DCReceptor *receptor);
 
-    /* This method is exepected to be called from command.
+    /**
+     * Create a receptor with the given name and register it into this cell.
+     * This method is expected to be only called from command classes (defined in dceditcommands.h )
      */
     virtual DCReceptor* createReceptor(const QString &receptorName);
 
index 3fa771e..89dcc9e 100644 (file)
 
 #include "dcvccellcode.h"
 #include "dccontainer.h"
+#include "utils/dcutil.h"
 
-DCCellCode::DCCellCode(std::string theName, std::string theCellAPIName)
-    : TKCellCode(theName, theCellAPIName)
+DCCellCode::DCCellCode(DCContainer *container, std::string theName, std::string theCellAPIName)
+    : TKCellCode(theName, theCellAPIName), d_container(container)
 {
 }
 
@@ -30,17 +31,31 @@ DCCellCode::~DCCellCode()
 {
 }
 
-QString DCCellCode::getOwnScript(DCContainer *container) const
+QString DCCellCode::getOwnScript() const
 {
-    return container->readCellCodeScriptFromFile(this);
+    return d_container->readCellCodeScriptFromFile(this);
 }
 
-void DCCellCode::saveScript(DCContainer *container, const QString &script)
+void DCCellCode::saveScript(const QString &script)
 {
-    container->saveClassScriptToWorkFile(this, script.toStdString());
+    d_container->saveClassScriptToWorkFile(this, script.toStdString());
 }
 
 DCVCPage* DCCellCode::getPageBelonging() const
 {
-    return mVComponent->getPageBelonging();
+    return d_vComponent->getPageBelonging();
 }
+
+void DCCellCode::changeName(const QString &newName)
+{
+    QString fqnString = DCUtil::getFQNPath(getPageBelonging()->getLocationPath(), newName);
+    mFQNName = fqnString.toStdString();
+}
+
+void DCCellCode::changePath(const QString& newPath)
+{
+    QString name = DCUtil::getNameFromFQNPath(QString::fromStdString(mFQNName));
+    QString fqnString = DCUtil::getFQNPath(newPath, name);
+    mFQNName = fqnString.toStdString();
+}
+
index d32955c..6524579 100644 (file)
@@ -32,20 +32,35 @@ class DCVCPage;
 class DCCellCode : public TKCellCode
 {
     friend class DCComponentUtil;
-    DCCellCode(std::string theName, std::string theCellAPIName);
-    void bindComponent(DCVPageComponent *component) { mVComponent = component; }
+    friend class DCContainer;
 
-    DCVPageComponent    *mVComponent;
+    DCCellCode(DCContainer *container, std::string theName, std::string theCellAPIName);
+    void bindComponent(DCVPageComponent *component) { d_vComponent = component; }
+
+    DCVPageComponent    *d_vComponent;
+    DCContainer         *d_container;
+
+    /**
+      * Change name of this cell code.
+      * DCContainer will call this method.
+      */
+    void                changeName(const QString& newName);
+
+    /**
+      * Change the location path for this cell code.
+      * DCContainer will call this method.
+      */
+    void                changePath(const QString& newPath);
 
 public:
     virtual ~DCCellCode();
     virtual TKCellCodeInstance* createCellCodeInstance(TKCell *owner, const void *data) { return 0; }
 
-    void saveScript(DCContainer *container, const QString& script);
-    DCVPageComponent *getVComponent() const { return mVComponent; }
-    DCVCPage* getPageBelonging() const;
-    QString getOwnScript(DCContainer *container) const;
-
+    void                saveScript(const QString& script);
+    DCVPageComponent*   getVComponent() const { return d_vComponent; }
+    DCVCPage*           getPageBelonging() const;
+    QString             getOwnScript() const;
+    DCContainer*        getContainer() const { return d_container; }
 };
 
 #endif // DCCELLCODE_H
index 3fe6f44..7b5581f 100644 (file)
@@ -23,7 +23,6 @@
 #include "dcaxon.h"
 #include "dcaxonterminal.h"
 #include "dcreceptor.h"
-#include "DNUtils.h"
 #include "dcscene.h"
 #include "dccontent.h"
 #include "dccreator.h"
@@ -38,6 +37,7 @@
 #include <QDir>
 #include <QDirIterator>
 
+
 //static
 TKContainer* TKContainer::createContainer()
 {
@@ -198,7 +198,7 @@ TKCell* DCContainer::cellFactory(std::string location, std::string name, std::st
 {
     if (location != d_factoryCachedLocation || d_factoryCachedPageObject.ref() == NULL)
     {
-        d_factoryCachedPageObject.assign(d_scene->findPage(location));
+        d_factoryCachedPageObject.assign(d_scene->getPage(location));
         if (d_factoryCachedPageObject.ref() == NULL)
         {
             d_factoryCachedPageObject.assign(d_scene->addPage(location));
@@ -239,7 +239,7 @@ TKCellCode* DCContainer::cellCodeFactory(std::string name, std::string cellapi,
         }
         if (location != d_factoryCachedLocation || d_factoryCachedPageObject.ref() == NULL)
         {
-            d_factoryCachedPageObject.assign(d_scene->findPage(location));
+            d_factoryCachedPageObject.assign(d_scene->getPage(location));
             if (d_factoryCachedPageObject.ref() == NULL)
             {
                 d_factoryCachedPageObject.assign(d_scene->addPage(location));
@@ -248,7 +248,7 @@ TKCellCode* DCContainer::cellCodeFactory(std::string name, std::string cellapi,
         d_factoryCachedLocation = location;
         page = dynamic_cast<DCVCPage*>(d_factoryCachedPageObject.ref());
     }
-    return DCComponentUtil::createCellCode(page, name, cellapi);
+    return DCComponentUtil::createCellCode(this, page, name, cellapi);
 }
 
 void DCContainer::beganParsePage(const char *docRoot, const char *path)
@@ -265,7 +265,7 @@ void DCContainer::beganParsePage(const char *docRoot, const char *path)
     }
 
     std::string location = path;
-    d_factoryCachedPageObject.assign(d_scene->findPage(location));
+    d_factoryCachedPageObject.assign(d_scene->getPage(location));
     if (d_factoryCachedPageObject.ref() == NULL)
     {
         d_factoryCachedPageObject.assign(d_scene->addPage(location));
@@ -356,20 +356,9 @@ bool DCContainer::saveCustomScriptToWorkFile(TKCell *cell, std::string customScr
 
 bool DCContainer::saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code)
 {
-    QString qNamePath = QString::fromStdString(cellCode->getName());
-    int idx = qNamePath.lastIndexOf("#");
-    QString path;
-    QString name;
-    if (idx >= 0)
-    {
-        path = qNamePath.left(idx);
-        name = qNamePath.mid(idx + 1);
-    }
-    else
-    {
-        path = "";
-        name = qNamePath;
-    }
+    QString qNamePath = QString::fromStdString(cellCode->getFQNName());
+    QString path = DCUtil::getContainerBasedPathFromFQNPath(qNamePath);
+    QString name = DCUtil::getNameFromFQNPath(qNamePath);
 
     QDir workdir(d_workDirCellCodeRoot + "/" + path);
     if (!workdir.exists())
@@ -403,20 +392,9 @@ QString DCContainer::readCustomScriptFromWorkFile(const DCCell *cell)
 
 QString DCContainer::readCellCodeScriptFromFile(const DCCellCode *cellCode)
 {
-    QString qNamePath = QString::fromStdString(cellCode->getName());
-    int idx = qNamePath.lastIndexOf("#");
-    QString path;
-    QString name;
-    if (idx >= 0)
-    {
-        path = qNamePath.left(idx);
-        name = qNamePath.mid(idx + 1);
-    }
-    else
-    {
-        path = "";
-        name = qNamePath;
-    }
+    QString qNamePath = QString::fromStdString(cellCode->getFQNName());
+    QString path = DCUtil::getContainerBasedPathFromFQNPath(qNamePath);
+    QString name = DCUtil::getNameFromFQNPath(qNamePath);
 
     QFile file(d_workDirCellCodeRoot + "/" + path + "/" + name + ".js");
     if (!file.exists())
@@ -432,3 +410,76 @@ QString DCContainer::readCellCodeScriptFromFile(const DCCellCode *cellCode)
     return out;
 }
 
+QString DCContainer::sysFilePathToContainerBasedPath(const QString &sysFilePath)
+{
+    QString containerPath = QString::fromStdString(getContainerRootPath());
+    return "/" + QDir(containerPath).relativeFilePath(sysFilePath);
+}
+
+bool DCContainer::renameCell(DCCell *cell, const QString &newName)
+{
+    QString fqnName = DCUtil::getFQNPath(cell->getLocation(), cell->getName());
+    mCells.erase(fqnName.toStdString());
+
+    cell->changeName(newName);
+
+    QString newFqnName = DCUtil::getFQNPath(cell->getLocation(), cell->getName());
+    std::pair<TKCellMap::iterator, bool> r = mCells.insert(TKCellMap::value_type(newFqnName.toStdString(), cell));
+
+    return r.second;
+}
+
+bool DCContainer::moveCell(DCCell *cell, const QString& pageNewContainerBasedPathName)
+{
+    QString fqnName = DCUtil::getFQNPath(cell->getLocation(), cell->getName());
+    QString customScript = readCustomScriptFromWorkFile(cell);
+    mCells.erase(fqnName.toStdString());
+
+    cell->changePath(pageNewContainerBasedPathName);
+    saveCustomScriptToWorkFile(cell, customScript.toStdString());
+
+    QString newFqnName = DCUtil::getFQNPath(pageNewContainerBasedPathName.toStdString(), cell->getName());
+    std::pair<TKCellMap::iterator, bool> r = mCells.insert(TKCellMap::value_type(newFqnName.toStdString(), cell));
+    return r.second;
+}
+
+bool DCContainer::renameCellCodeClass(DCCellCode *cellcode, const QString &newName)
+{
+    mCellCodes.erase(cellcode->getFQNName());
+    cellcode->changeName(newName);
+    std::pair<TKCellCodeMap::iterator, bool> r = mCellCodes.insert(TKCellCodeMap::value_type(cellcode->getFQNName(), cellcode));
+
+    return r.second;
+}
+
+bool DCContainer::moveCellCodeClass(DCCellCode *cellcode, const QString& pageNewContainerBasedPathName)
+{
+    QString script = readCellCodeScriptFromFile(cellcode);
+    mCellCodes.erase(cellcode->getFQNName());
+
+    cellcode->changePath(pageNewContainerBasedPathName);
+    saveClassScriptToWorkFile(cellcode, script.toStdString());
+
+    std::pair<TKCellCodeMap::iterator, bool> r = mCellCodes.insert(TKCellCodeMap::value_type(cellcode->getFQNName(), cellcode));
+
+    return r.second;
+}
+
+DCVCPage* DCContainer::movePage(const QString &oldContainerBasedPathName, const QString &newContainerBasedPathName)
+{
+    bool r = false;
+    DCVCPage *newPage = NULL;
+    DCScene *scene = getScene();
+    if (scene)
+    {
+        DCVCPage *oldPage = getScene()->getPage(oldContainerBasedPathName.toStdString());
+        newPage = getScene()->addPage(newContainerBasedPathName.toStdString());
+
+        if (oldPage && newPage)
+        {
+            r = oldPage->moveComponentsTo(newPage);
+        }
+    }
+
+    return r ? newPage : NULL;
+}
index 1ecd36f..0ce5c50 100644 (file)
@@ -61,19 +61,68 @@ public:
     virtual TKAxonTerminal* axonTerminalFactory(TKAxon *theOwner);
     virtual TKCellCode*     cellCodeFactory(std::string name, std::string cellapi, std::string code);
 
-    /*
-     * remove cell code from container and the page (DCVCPage) belonging.
+    /**
+     * @brief remove cell from container and the page (DCVCPage) belonging.
+     * @param cell
+     *
+     * All the axon terminals connected to this cell will also be removed after this.
+     * This expected to only be called from command classes which are defined in dceditcommands.h
+     *
+     * @return true for success, false for failure
+     */
+    bool                    removeCell(DCCell *cell);
+
+    /**
+     * @brief remove cell code from container and the page (DCVCPage) belonging.
+     * @param cellcode
+     *
      * The cells which use the deleting cell code will have empty cell code after this.
      * This expected to only be called from command classes which are defined in dceditcommands.h
+     *
+     * @return true for success, false for failure
      */
     bool                    removeCellCode(DCCellCode *cellcode);
 
-    /*
-     * remove cell from container and the page (DCVCPage) belonging.
-     * All the axon terminals connected to this cell will also be removed after this.
-     * This expected to only be called from command classes which are defined in dceditcommands.h
+    /**
+     * @brief movePage
+     *
+     * @param oldContainerBasedPathName
+     * @param newContainerBasedPathName
+     *
+     * Change the name / path for a container file.
+     * All cells, cell codes and connections are updated accordingly.
+     * This expected to be called from command classes which are defined in dceditcommands.h
+     *
+     * @return pointer to a page object for the new file path or NULL when this failed.
      */
-    bool                    removeCell(DCCell *cell);
+    DCVCPage*               movePage(const QString &oldContainerBasedPathName, const QString &newContainerBasedPathName);
+
+    /**
+     * @brief change the path information of a cell.
+     * @param cell
+     * @param pageNewContainerBasedPathName
+     *
+     * @note This will be called from DCVCCell::changePageBelonging().
+     * This shouldn't be directly called from other methods.
+     * @return
+     */
+    bool                    moveCell(DCCell*cell, const QString& pageNewContainerBasedPathName);
+
+    /**
+     * @brief change the path information of a cell code.
+     * @param cellcode
+     * @param pageNewContainerBasedPathName
+     *
+     * @note This will be called from DCVCCellCode::changePageBelonging().
+     * This shouldn't be directly called from other methods.
+     * @return
+     */
+    bool                    moveCellCodeClass(DCCellCode*cellcode, const QString& pageNewContainerBasedPathName);
+
+    bool                    renameCell(DCCell *cell, const QString& newName);
+
+    bool                    renameCellCodeClass(DCCellCode *cellcode, const QString& newName);
+
     //
     DCContent*              getContent() const { return d_content; }
     DCScene*                getScene() const { return d_scene; }
@@ -99,6 +148,7 @@ public:
     bool                    saveCustomScriptToWorkFile(TKCell *cell, std::string customScript);
     bool                    saveClassScriptToWorkFile(TKCellCode *cellCode, std::string code);
 
+    QString                 sysFilePathToContainerBasedPath(const QString& sysFilePath);
     QString                 readCustomScriptFromWorkFile(const DCCell *cell);
     QString                 readCellCodeScriptFromFile(const DCCellCode *cellcode);
 
index 3ad3522..49cf023 100644 (file)
@@ -29,6 +29,7 @@
 #include "dcaxonterminal.h"
 #include "dcvpagecomponent.h"
 #include "dcscene.h"
+#include "utils/dcutil.h"
 
 #include <QDomDocument>
 #include <QMap>
@@ -89,7 +90,7 @@ bool DCContainerSaver::saveForPage(const QString& containerRootPath, DCVCPage *p
         aCellCodeTag.setAttribute("parameter", "cellcode");
         if (cell->getCellCode() && cell->getCellCode() != d_container->getEmptyCellCodeClass())
         {
-            aCellCodeTag.setAttribute("href", QString::fromStdString(cell->getCellCode()->getName()));
+            aCellCodeTag.setAttribute("href", QString::fromStdString(cell->getCellCode()->getFQNName()));
         }
         else
         {
@@ -131,9 +132,7 @@ bool DCContainerSaver::saveForPage(const QString& containerRootPath, DCVCPage *p
     for (int i = 0; i < vcellcodeclasses->length(); i++)
     {
         DCCellCode *cellcodeclass = dynamic_cast<DCVCCellCode*>(vcellcodeclasses->at(i))->getOwnerCellCodeClass();
-        QString cellCodeClassName = QString::fromStdString(cellcodeclass->getName());
-        if (cellCodeClassName.indexOf("#") >= 0)
-            cellCodeClassName = cellCodeClassName.mid(cellCodeClassName.indexOf("#")+1);
+        QString cellCodeClassName = DCUtil::getNameFromFQNPath(QString::fromStdString(cellcodeclass->getFQNName()));
 
         QDomElement aCellCodeTag = doc.createElement("a");
         aCellCodeTag.setAttribute("define", "cellcode");
index 411596f..5c1134f 100644 (file)
@@ -478,6 +478,11 @@ void DCCreator::doCommandAddPage(const void *requester, const QString &container
     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);
@@ -488,9 +493,9 @@ void DCCreator::doCommandAddDirectory(const void *requester, const QString &sysF
     DCCommandUtil::postAddDirectoryCommand(requester, this, sysFilePath);
 }
 
-void DCCreator::doCommandRemoveDirectory(const void *requester, const QString &sysFilePath)
+void DCCreator::doCommandRenameDirectory(const void *requester, const QString &oldSysFilePath, const QString &newSysFilePath)
 {
-    DCCommandUtil::postRemoveDirectoryCommand(requester, this, sysFilePath);
+    DCCommandUtil::postRenameDirectoryCommand(requester, this, oldSysFilePath, newSysFilePath);
 }
 
 bool DCCreator::doCommandRenameDirectoryImmidiate(const void *requester, const QString &containerBasedPath, const QString &oldName, const QString &newName)
@@ -502,6 +507,11 @@ bool DCCreator::doCommandRenameDirectoryImmidiate(const void *requester, const Q
     return false;
 }
 
+void DCCreator::doCommandRemoveDirectory(const void *requester, const QString &sysFilePath)
+{
+    DCCommandUtil::postRemoveDirectoryCommand(requester, this, sysFilePath);
+}
+
 DCContainer* DCCreator::getCurrentContainer() const
 {
     if (d_vcontent)
index c531695..3d1b1a1 100644 (file)
@@ -110,9 +110,11 @@ public:
     void doCommandAddCell(const void *requester, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
     void doCommandRemoveCells(const void *requester, DCContainer *container, const QList<DCCell*> &cells);
     void doCommandAddPage(const void *requester, const QString& containerBasedPath);
+    void doCommandMovePage(const void *requester, const QString &oldContainerBasedPath, const QString &newContainerBasedPath);
     void doCommandRemovePage(const void *requester, DCVCPage *page);
 
     void doCommandAddDirectory(const void *requester, const QString& sysFilePath);
+    void doCommandRenameDirectory(const void *requester, const QString& oldSysFilePath, const QString& newSysFilePath);
     void doCommandRemoveDirectory(const void *requester, const QString& sysFilePath);
 
     bool doCommandRenameDirectoryImmidiate(const void *requester, const QString& containerBasedPath, const QString& oldName, const QString &newName);
index 7f99d19..648cddf 100644 (file)
 
 #include <QVBoxLayout>
 #include <QLabel>
+#include <QFileInfo>
 
-DCInputNewPageNameDialog::DCInputNewPageNameDialog(QWidget *parent) :
-    QDialog(parent), d_result("")
+DCInputNewPageNameDialog::DCInputNewPageNameDialog(const QString &sysDir, const QString &windowTitle, const QString &fileName, QWidget *parent)
+    : QDialog(parent), d_dir(sysDir), d_result("")
 {
-    d_inputField = new QLineEdit();
+    setWindowTitle(windowTitle);
+
+    d_inputField = new QLineEdit(fileName);
     QVBoxLayout *contentLayout = new QVBoxLayout;
     contentLayout->addWidget(new QLabel(tr("name")));
     QHBoxLayout *hlayout = new QHBoxLayout;
@@ -49,12 +52,13 @@ DCInputNewPageNameDialog::DCInputNewPageNameDialog(QWidget *parent) :
 
 void DCInputNewPageNameDialog::inputChanged()
 {
-    // TODO:
-    // Need to consider the case when the name has already existed.
-    //
     if (d_inputField->text().length() > 0)
     {
-        d_okButton->setEnabled(true);
+        QFileInfo fileInfo(d_dir + "/" + d_inputField->text() + ".xhtml");
+        if (!fileInfo.exists())
+            d_okButton->setEnabled(true);
+        else
+            d_okButton->setEnabled(false);
     }
     else
     {
index 0723108..ebf0e43 100644 (file)
@@ -27,13 +27,14 @@ class DCInputNewPageNameDialog : public QDialog
 {
     Q_OBJECT
 
+    QString     d_dir;
     QString     d_result;
     QLineEdit   *d_inputField;
     QPushButton *d_okButton;
     QPushButton *d_cancelButton;
 
 public:
-    explicit DCInputNewPageNameDialog(QWidget *parent = 0);
+    DCInputNewPageNameDialog(const QString& sysDir, const QString& windowTitle, const QString& fileName = "", QWidget *parent = 0);
     virtual ~DCInputNewPageNameDialog() {}
 
     QString getName() const { return d_result + ".xhtml"; }
index 638d7bd..3e9f14a 100644 (file)
@@ -21,7 +21,6 @@
 #define __INCLUDE_TKCELLCODE__
 
 #include <string>
-#include <vector>
 
 class TKReceptor;
 class TKContainer;
@@ -31,16 +30,16 @@ class TKCellCodeInstance;
 class TKCellCode
 {
 public:
-    TKCellCode(std::string theName, std::string theCellAPIName) : mName(theName), mCellAPIName(theCellAPIName) {}
+    TKCellCode(std::string theFQNName, std::string theCellAPIName) : mFQNName(theFQNName), mCellAPIName(theCellAPIName) {}
     virtual ~TKCellCode() {}
     
-    std::string getName() const { return mName; }
+    std::string getFQNName() const { return mFQNName; }
     std::string getCellAPIName() const { return mCellAPIName; }
 
        virtual TKCellCodeInstance* createCellCodeInstance(TKCell *owner, const void *data) = 0;
 
-private:
-    std::string mName;
+protected:
+    std::string mFQNName;
     std::string mCellAPIName;
 };
 
index 5d31d9e..af46ce5 100644 (file)
@@ -53,7 +53,7 @@ public:
     const TKCellMap* getCells() { return &mCells; }
     const TKCellCodeMap* getCellCodes() { return &mCellCodes; }
 
-    void        setContainerRootPath(std::string contentPath) { mContainerRootPath = contentPath; }
+    void        setContainerRootPath(std::string containerPath) { mContainerRootPath = containerPath; }
     std::string getContainerRootPath() { return mContainerRootPath; }
     bool        setDataStore(std::string storagePath);
     DNStorage*  getDataStore() { return mStorage; }
index 306440d..72579d4 100644 (file)
@@ -103,7 +103,7 @@ DCTreeViewWidget::DCTreeViewWidget(QWidget *parent, DCCreator *creator) :
     connect(d_creator, SIGNAL(destroyed(QObject*)), this, SLOT(creatorDestroyed()));
 
     connect(&d_fileSystemModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString)));
-
+    connect(&d_fileSystemModel, SIGNAL(rowsRemoved(const QModelIndex, int, int)), this, SLOT(rowsRemoved()));
     setContextMenuPolicy(Qt::CustomContextMenu);
     connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(doContextMenu(const QPoint&)));
     connect(d_creator, SIGNAL(commandExecuted(const QUndoCommand*)), this, SLOT(commandExecuted(const QUndoCommand*)));
@@ -159,9 +159,39 @@ bool DCTreeViewWidget::removeDirectory(const QString &path)
     if (s_treeViewWidget)
     {
         QModelIndex index = s_treeViewWidget->d_fileSystemModel.index(path);
-        if (index.isValid())
+        if (index.isValid() && s_treeViewWidget->d_fileSystemModel.fileInfo(index).isDir())
         {
             r = s_treeViewWidget->d_fileSystemModel.rmdir(index);
+            if (r)
+            {
+                //hack for prevening auto selection happing by removing row.
+                s_treeViewWidget->d_inSelectionChange = true;
+            }
+        }
+    }
+    else
+    {
+        Q_ASSERT(0);
+    }
+    return r;
+}
+
+//static
+bool DCTreeViewWidget::removeFile(const QString &path)
+{
+    bool r = false;
+
+    if (s_treeViewWidget)
+    {
+        QModelIndex index = s_treeViewWidget->d_fileSystemModel.index(path);
+        if (index.isValid() && s_treeViewWidget->d_fileSystemModel.fileInfo(index).isFile())
+        {
+            r = s_treeViewWidget->d_fileSystemModel.remove(index);
+            if (r)
+            {
+                //hack for prevening auto selection happing by removing row.
+                s_treeViewWidget->d_inSelectionChange = true;
+            }
         }
     }
     else
@@ -247,95 +277,112 @@ void DCTreeViewWidget::doContextMenu(const QPoint &pos)
 
     if (showMenu)
     {
-        QString containerPath;
-        QString containerBasedPath;
+        DCContainer *container = d_creator->getCurrentContainer();
 
-        if (index.isValid())
+        if (container)
         {
-            containerPath = QString::fromStdString(d_creator->getCurrentContainer()->getContainerRootPath());
-            containerBasedPath = "/" + QDir(containerPath).relativeFilePath(fileModel->filePath(index));
-        }
+            QString containerBasedPath;
 
-        QAction* selectedItem = menu.exec(globalPos);
-        if (selectedItem)
-        {
-            if (selectedItem == addDictionaryAction)
-            {
-                if (index.isValid())
-                    d_creator->doCommandAddDirectory(this, fileModel->filePath(index));
-            }
-            else if (selectedItem == removeDirectoryAction)
+            if (index.isValid())
             {
-                if (index.isValid())
-                    d_creator->doCommandRemoveDirectory(this, fileModel->filePath(index));
+                containerBasedPath = container->sysFilePathToContainerBasedPath(fileModel->filePath(index));
             }
-            else if (selectedItem == addPageAction)
+
+            QAction* selectedItem = menu.exec(globalPos);
+            if (selectedItem)
             {
-                if (index.isValid())
+                if (selectedItem == addDictionaryAction)
+                {
+                    if (index.isValid())
+                        d_creator->doCommandAddDirectory(this, fileModel->filePath(index));
+                }
+                else if (selectedItem == removeDirectoryAction)
                 {
-                    if (containerBasedPath.length() >= 1)
+                    if (index.isValid())
+                        d_creator->doCommandRemoveDirectory(this, fileModel->filePath(index));
+                }
+                else if (selectedItem == addPageAction)
+                {
+                    if (index.isValid())
                     {
-                        DCInputNewPageNameDialog dialog;
-                        if (dialog.exec())
+                        if (containerBasedPath.length() >= 1)
                         {
-                            QString pageName = dialog.getName();
-                            if (pageName.length() > 0)
+                            DCInputNewPageNameDialog dialog(fileModel->filePath(index), tr("Add new page"));
+                            if (dialog.exec())
                             {
-                                QString pathName = containerBasedPath;
-                                if (containerBasedPath.length()>1)
-                                    pathName.append("/");
-                                pathName.append(pageName);
-                                d_creator->doCommandAddPage(this, pathName);
+                                QString pageName = dialog.getName();
+                                if (pageName.length() > 0)
+                                {
+                                    QString pathName = containerBasedPath;
+                                    if (containerBasedPath.length()>1)
+                                        pathName.append("/");
+                                    pathName.append(pageName);
+                                    d_creator->doCommandAddPage(this, pathName);
+                                }
                             }
                         }
                     }
                 }
-            }
-            else if (selectedItem == renamePageAction)
-            {
-                //TODO
-                QMessageBox msgBox;
-                msgBox.setText("This command hasn't implemented yet");
-                msgBox.exec();
-            }
-            else if (selectedItem == removePageAction)
-            {
-                if (index.isValid())
+                else if (selectedItem == renamePageAction)
                 {
-                    bool doExecute = true;
-                    DCVCPage *page = d_scene->findPage(containerBasedPath.toStdString());
-                    if (page->getCells()->length() > 0 || page->getCellCodeClasses()->length() > 0)
+                    if (index.isValid())
                     {
-                        QMessageBox::StandardButton button = QMessageBox::warning(this,
-                                             tr("Remove file"),
-                                             tr("This Page has cells / cellcodes. Those cells / cell codes will be removed"),
-                                             QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel);
-
-                        doExecute = (button == QMessageBox::Ok);
+                        if (containerBasedPath.length() >= 1)
+                        {
+                            QFileInfo fileInfo = fileModel->filePath(index);
+                            QString oldName = fileInfo.fileName().left(fileInfo.fileName().length() - fileInfo.completeSuffix().length() - 1);
+                            DCInputNewPageNameDialog dialog(fileInfo.absolutePath(), tr("Rename"), oldName);
+                            if (dialog.exec())
+                            {
+                                QString pageName = dialog.getName();
+                                if (pageName.length() > 0)
+                                {
+                                    QString pathName = container->sysFilePathToContainerBasedPath(fileInfo.absolutePath() + "/" + pageName);
+                                    d_creator->doCommandMovePage(this, containerBasedPath, pathName);
+                                }
+                            }
+                        }
                     }
-                    if (doExecute)
+                }
+                else if (selectedItem == removePageAction)
+                {
+                    if (index.isValid())
                     {
-                        d_creator->doCommandRemovePage(this, page);
+                        bool doExecute = true;
+                        DCVCPage *page = d_scene->getPage(containerBasedPath.toStdString());
+                        if (page->getCells()->length() > 0 || page->getCellCodeClasses()->length() > 0)
+                        {
+                            QMessageBox::StandardButton button = QMessageBox::warning(this,
+                                                 tr("Remove file"),
+                                                 tr("This Page has cells / cellcodes. Those cells / cell codes will be removed"),
+                                                 QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel);
+
+                            doExecute = (button == QMessageBox::Ok);
+                        }
+                        if (doExecute)
+                        {
+                            d_creator->doCommandRemovePage(this, page);
+                        }
                     }
                 }
-            }
-            else if (selectedItem == addCellAction )
-            {
-                if (index.isValid())
+                else if (selectedItem == addCellAction )
                 {
-                    DCAddCellDialog dialog(d_creator->getCurrentContainer(), d_creator, containerBasedPath);
-                    dialog.exec();
+                    if (index.isValid())
+                    {
+                        DCAddCellDialog dialog(container, d_creator, containerBasedPath);
+                        dialog.exec();
+                    }
                 }
-            }
-            else  if (selectedItem == addCellCodeClassAction)
-            {
-                if (index.isValid())
+                else  if (selectedItem == addCellCodeClassAction)
                 {
-                    DCAddCellCodeClassDialog dialog(d_creator->getCurrentContainer(), d_creator, containerBasedPath);
-                    dialog.exec();
+                    if (index.isValid())
+                    {
+                        DCAddCellCodeClassDialog dialog(container, d_creator, containerBasedPath);
+                        dialog.exec();
+                    }
                 }
-            }
 
+            }
         }
     }
 }
@@ -393,6 +440,12 @@ void DCTreeViewWidget::rowsInserted(const QModelIndex &parent, int start, int en
     }
 }
 
+void DCTreeViewWidget::rowsRemoved()
+{
+    //hack for prevening auto selection happing by removing row.
+    d_inSelectionChange = false;
+}
+
 void DCTreeViewWidget::creatorDestroyed()
 {
     d_creator = NULL;
index c2333e6..47b88d7 100644 (file)
@@ -57,6 +57,7 @@ public:
 
     static bool addDirectory(const QString &path);
     static bool removeDirectory(const QString &path);
+    static bool removeFile(const QString &path);
     static void requestSelectionWhenRowAdded();
 
 protected:
@@ -70,6 +71,7 @@ private slots:
     void sceneChanged(const void *requester, DCScene*scene);
     void selectedPageChanged(const void *requester, const DCScene*scene);
     void creatorDestroyed();
+    void rowsRemoved();
 
     virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
 
index 7b55722..a5467cb 100644 (file)
@@ -113,7 +113,7 @@ void DCCommandUtil::postAddCellCommand(const void *requester, DCCreator *creator
 //static
 void DCCommandUtil::postRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
 {
-    postEvent(creator, new DCRemoveCellsCommand(requester, creator, container, cells));
+    postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cells));
 }
 
 //static
@@ -123,6 +123,12 @@ void DCCommandUtil::postAddPageCommand(const void *requester, DCCreator *creator
 }
 
 //static
+void DCCommandUtil::postMovePageCommand(const void *requester, DCCreator *creator, const QString &oldContainerBasedPath, const QString &newContainerBasedPath)
+{
+    postEvent(creator, new DCMovePageCommand(requester, creator, oldContainerBasedPath, newContainerBasedPath));
+}
+
+//static
 void DCCommandUtil::postRemovePageCommand(const void *requester, DCCreator *creator, DCVCPage *page)
 {
     postEvent(creator, new DCRemovePageCommand(requester, creator, page));
@@ -135,6 +141,12 @@ void DCCommandUtil::postAddDirectoryCommand(const void *requester, DCCreator *cr
 }
 
 //static
+void DCCommandUtil::postRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysOldFilePath, const QString &sysNewFilePath)
+{
+    postEvent(creator, new DCRenameDirectoryCommand(requester, creator, sysOldFilePath, sysNewFilePath));
+}
+
+//static
 void DCCommandUtil::postRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
 {
     postEvent(creator, new DCRemoveDirectoryCommand(requester, creator, sysFilePath));
index d35bcbb..863d9db 100644 (file)
@@ -52,9 +52,11 @@ struct DCCommandUtil
     static void postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
     static void postRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells);
     static void postAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPath);
+    static void postMovePageCommand(const void *requester, DCCreator *creator, const QString &oldContainerBasedPath, const QString& newContainerBasedPath);
     static void postRemovePageCommand(const void *requester, DCCreator *creator, DCVCPage *page);
 
     static void postAddDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysFilePath);
+    static void postRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysOldFilePath, const QString& sysNewFilePath);
     static void postRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysFilePath);
 };
 
index 39b1383..0fcdf15 100644 (file)
@@ -46,9 +46,9 @@ DCCell* DCComponentUtil::createCell(DCContainer *container, DCVCPage *page, std:
 }
 
 //static
-DCCellCode* DCComponentUtil::createCellCode(DCVCPage *page, std::string theName, std::string theCellAPIName)
+DCCellCode* DCComponentUtil::createCellCode(DCContainer *container, DCVCPage *page, std::string theName, std::string theCellAPIName)
 {
-    DCCellCode *cellcode = new DCCellCode(theName, theCellAPIName);
+    DCCellCode *cellcode = new DCCellCode(container, theName, theCellAPIName);
     DCVPageComponent *vcompo = new DCVCCellCode(cellcode, page);
     cellcode->bindComponent(vcompo);
     if (page)
index 3d15f71..1867040 100644 (file)
@@ -33,7 +33,7 @@ class DCContainer;
 struct DCComponentUtil
 {
     static DCCell*          createCell(DCContainer *container, DCVCPage *page, std::string location, std::string name, std::string type, bool canInterface);
-    static DCCellCode*      createCellCode(DCVCPage *page, std::string theName, std::string theCellAPIName);
+    static DCCellCode*      createCellCode(DCContainer *container, DCVCPage *page, std::string theName, std::string theCellAPIName);
     static DCAxon*          createAxon(DCCell *theOwner);
     static DCAxonTerminal*  createAxonTerminal(DCAxon *theOwner);
     static DCReceptor*      createReceptor(DCCell *theOwner);
index 893d2fa..62bf866 100644 (file)
@@ -18,6 +18,8 @@
 //
 #include "dcutil.h"
 
+#include "DNUtils.h"
+
 #include <QDir>
 #include <QFileInfoList>
 
@@ -43,3 +45,33 @@ void DCUtil::removeDirRecursive(QString path)
         }
     }
 }
+
+//static
+QString DCUtil::getFQNPath(const QString& containerBasedPath, const QString& name)
+{
+    return QString::fromStdString(getFQNString(containerBasedPath.toLocal8Bit().data(), name.toLocal8Bit().data()));
+}
+
+//static
+QString DCUtil::getFQNPath(std::string containerBasedPath, std::string name)
+{
+    return QString::fromStdString(getFQNString(containerBasedPath.c_str(), name.c_str()));
+}
+
+//static
+QString DCUtil::getNameFromFQNPath(const QString& fqnString)
+{
+    if (fqnString.indexOf("#") >= 0)
+        return fqnString.mid(fqnString.indexOf("#")+1);
+    else
+        return "";
+}
+
+//static
+QString DCUtil::getContainerBasedPathFromFQNPath(const QString& fqnPath)
+{
+    if (fqnPath.indexOf("#") >= 0)
+        return fqnPath.left(fqnPath.indexOf("#"));
+    else
+        return "";
+}
index 7dc8b2d..b6cdf3b 100644 (file)
 struct DCUtil
 {
     static void removeDirRecursive(QString path);
+    static QString getFQNPath(const QString& containerBasedPath, const QString& name);
+    static QString getFQNPath(std::string containerBasedPath, std::string name);
+    static QString getNameFromFQNPath(const QString& fqnString);
+    static QString getContainerBasedPathFromFQNPath(const QString& fqnPath);
+
 };
 
 #endif // DCUTIL_H
index d153f12..3641c97 100644 (file)
@@ -62,7 +62,27 @@ DCVCCell::~DCVCCell()
 
 void DCVCCell::changePageBelonging(DCVCPage *page)
 {
-    //TODO
+    if (page)
+    {
+        page->registerCell(this);
+    }
+    else
+    {
+        getPageBelonging()->unregisterCell(this);
+    }
+
+    DCContainer *container = dynamic_cast<DCContainer*> (d_owner->getContainer());
+    if (container)
+    {
+        if (getPageBelonging())
+        {
+            container->moveCell(getOwnerCell(), page->getLocationPath());
+        }
+        else
+        {
+            //TODO
+        }
+    }
 }
 
 void DCVCCell::prepareChildrenForDraw(bool isAnimationInterval)
@@ -199,7 +219,7 @@ void DCVCCell::renderOwnShape(bool isAnimationInterval, bool renderAsWireframe)
             QString label1;
             if (d_owner->getCellCode() && d_owner->getCellCode()!= d_emptyCellCode)
             {
-                label1 = QString::fromStdString(d_owner->getCellCode()->getName());
+                label1 = QString::fromStdString(d_owner->getCellCode()->getFQNName());
                 label1 = label1.mid(label1.lastIndexOf("#") + 1);
             }
             else
index 78a1b01..6dafe8e 100644 (file)
@@ -50,7 +50,15 @@ public:
     virtual DCCell*     getOwnerCell() const { return d_owner; }
     virtual bool        isResizingArea(float x, float y, float z) const;
 
+    /**
+     * @brief Change page this cell belongs.
+     * @param page
+     * @note DCVCPage will call this.
+     * Other classes shouldn't directly call this method.
+     * To move cell to other page, DCMoveCellCommand should be used.
+     */
     virtual void    changePageBelonging(DCVCPage *page);
+
     virtual void    prepareChildrenForDraw(bool isAnimationInterval);
     virtual void    drawChildren(bool isAnimationInterval);
     virtual void    drawChildrenForSelection(QList<DCVComponent*> *itemList);
index a9e330c..c9a6d0f 100644 (file)
@@ -19,6 +19,8 @@
 #include "dcvccellcode.h"
 
 #include "dcvcomponent.h"
+#include "dccellcode.h"
+#include "dccontainer.h"
 
 DCVCCellCode::DCVCCellCode(DCCellCode *owner, DCVCPage *page) : DCVPageComponent(page), d_owner(owner)
 {
@@ -26,5 +28,28 @@ DCVCCellCode::DCVCCellCode(DCCellCode *owner, DCVCPage *page) : DCVPageComponent
 
 void DCVCCellCode::changePageBelonging(DCVCPage *page)
 {
-    //TODO
+    if (getPageBelonging() != page)
+    {
+        if (page)
+        {
+            page->registerCellCodeClass(this);
+        }
+        else
+        {
+            getPageBelonging()->unregisterCellCodeClass(this);
+        }
+    }
+
+    DCContainer *container = d_owner->getContainer();
+    if (container)
+    {
+        if (getPageBelonging())
+        {
+            container->moveCellCodeClass(getOwnerCellCodeClass(), page->getLocationPath());
+        }
+        else
+        {
+            //TODO
+        }
+    }
 }
index 3bd2c08..72b7732 100644 (file)
@@ -33,6 +33,13 @@ public:
     virtual DCCell *    getOwnerCell() const { return NULL; }
     virtual bool        isResizingArea(float x, float y, float z) const { return false; }
 
+    /**
+     * @brief Change page this cell code belongs.
+     * @param page
+     * @note DCVCPage will call this.
+     * Other classes shouldn't directly call this method.
+     * To move cell to other page, DCMoveCellCodeClassCommand should be used.
+     */
     DCCellCode*     getOwnerCellCodeClass() const { return d_owner; }
     virtual void    changePageBelonging(DCVCPage *page);
     virtual void    prepareChildrenForDraw(bool isAnimationInterval) {}
index 6cd1a11..269ef27 100644 (file)
@@ -120,6 +120,27 @@ void DCVCPage::unregisterEditCursor()
     d_editCursor = NULL;
 }
 
+bool DCVCPage::moveComponentsTo(DCVCPage *newPage)
+{
+    QList<DCVPageComponent*> cells = d_cells;
+    for (int i = 0; i < cells.size(); i++)
+    {
+        cells.at(i)->changePageBelonging(newPage);
+    }
+
+    QList<DCVPageComponent*> cellCodes = d_cellCodeClasses;
+    for (int i = 0; i < cellCodes.size(); i++)
+    {
+        cellCodes.at(i)->changePageBelonging(newPage);
+    }
+
+    if (d_editCursor)
+    {
+        d_editCursor->changePageBelonging(newPage);
+    }
+    return true;
+}
+
 void DCVCPage::updateVisiblity(bool linkedCellVisible, bool linkedCellRenderFull, bool linkedCellSelectable, bool otherCellVisible, bool otherCellRenderFull, bool otherCellSelectable)
 {
     setVisible(linkedCellVisible || otherCellVisible ? DCV_VISIBLE_FULL : DCV_VISIBLE_NONE, linkedCellVisible || otherCellVisible ? DCV_VISIBLE_FULL : DCV_VISIBLE_NONE);
index b6c0efc..d34483a 100644 (file)
@@ -57,7 +57,7 @@ public:
     // They are called from DCVCCell.
     // Other classes shouldn't call this directly.
     // To change the page a cell belonging,
-    // DCVCCell::changePageBelonging() should be called instead.
+    // DCMoveCellCommand() should be used instead.
     void registerCell(DCVPageComponent *cell);
     void unregisterCell(DCVPageComponent *cell);
 
@@ -65,7 +65,7 @@ public:
     // They are called from DCVCCellCode.
     // Other classes shouldn't call this directly.
     // To change the page a cell code class belonging,
-    // DCVCCellCode::changePageBelonging() should be called instead.
+    // DCMoveCellCodeClassCommand should be used instead.
     void registerCellCodeClass(DCVPageComponent *cellCodeClass);
     void unregisterCellCodeClass(DCVPageComponent *cellCodeClass);
 
@@ -77,6 +77,19 @@ public:
     void registerEditCursor(DCVPageComponent *ecursor);
     void unregisterEditCursor();
 
+    /**
+     * @brief Move cells and cell codes belong to this page to newPage.
+     * @param newPage : the target page cells and cell codes are moving into.
+     *
+     * This will move cells, cell codes and connections belong to this page to the page passed in the parameter.
+     * This expected to be called from DCContainer.
+     * This shouldn't be called directly.
+     * To change the path / file name for a container file, DCMovePageCommand should be used.
+     *
+     * @return true for succuss, false for failure.
+     */
+    bool moveComponentsTo(DCVCPage *newPage);
+
     void updateVisiblity(bool linkedCellVisible, bool linkedCellRenderFull, bool linkedCellSelectable, bool otherCellVisible, bool otherCellRenderFull, bool otherCellSelectable);
 
     virtual void    prepareChildrenForDraw(bool isAnimationInterval);
index 0a72b34..2fca3a7 100644 (file)
@@ -70,7 +70,7 @@ void DCScene::initMode(DCVPersMode persMode, DCVEditMode editMode)
     emit modeInitialized();
 }
 
-DCVCPage* DCScene::findPage(const std::string &location)
+DCVCPage* DCScene::getPage(const std::string &location) const
 {
     DNLocker(getSceneLock());
 
index 2a4c6b8..4908934 100644 (file)
@@ -134,6 +134,7 @@ public:
     DCCell*                 getEditCellCodeCell() const { return d_editCellCodeCell; }
 
     const QMap<QString,DCVCPage*>* getPages() const { return &d_pages; }
+    DCVCPage*               getPage(const std::string& location) const;
     bool                    getIsPageExist(const std::string& location) const;
     QString                 getSceneSettingFilePathForPage(DCVCPage *page) const;
     QString                 getSceneSettingFilePathForPage(const QString& containerRootPath, DCVCPage *page) const;
@@ -160,8 +161,6 @@ public:
     bool doAnimation();
     void updateVisiblity();
 
-    DCVCPage* findPage(const std::string& location);
-
     DCVCPage* addPage(const std::string& location);
     bool removePage(DCVCPage *page);
 
index dfa777d..716ba7b 100644 (file)
@@ -191,7 +191,7 @@ void DCToolWindowCellCodeEditor::setData(DCContainer *container, DCCellCode *cel
             updateClassInformation();
             d_uiClassGroupBox->setVisible(true);
             titleString.append("CELL CODE : ");
-            titleString.append(QString::fromStdString(cellCodeClass->getName()));
+            titleString.append(QString::fromStdString(cellCodeClass->getFQNName()));
             titleString.append(" (");
             titleString.append(QString::fromStdString(cellCodeClass->getCellAPIName()));
             titleString.append(")");
@@ -259,7 +259,7 @@ void DCToolWindowCellCodeEditor::setData(DCContainer *container, DCCell *ownerCe
         updateClassInformation();
         d_uiClassGroupBox->setVisible(true);
         titleString.append("CELL CODE : ");
-        titleString.append(QString::fromStdString(d_cellCodeClass->getName()));
+        titleString.append(QString::fromStdString(d_cellCodeClass->getFQNName()));
         titleString.append(" (");
         titleString.append(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
         titleString.append(")");
@@ -283,7 +283,7 @@ void DCToolWindowCellCodeEditor::showClassScript()
     d_uiSwitchEditorButton->setText(tr("Switch to Custom Script"));
     if (d_cellCodeClass && d_cellCodeClass != d_container->getEmptyCellCodeClass() && d_container)
     {
-        d_editor->setPlainText(d_cellCodeClass->getOwnScript(d_container));
+        d_editor->setPlainText(d_cellCodeClass->getOwnScript());
         d_editor->setReadOnly(false);
     }
     else
@@ -314,7 +314,7 @@ void DCToolWindowCellCodeEditor::updateClassInformation()
 {
     if (d_cellCodeClass)
     {
-        d_uiClassName->setText(QString::fromStdString(d_cellCodeClass->getName()));
+        d_uiClassName->setText(QString::fromStdString(d_cellCodeClass->getFQNName()));
         d_uiClassType->setText(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
     }
     else
@@ -417,7 +417,7 @@ void DCToolWindowCellCodeEditor::saveScriptToFile()
     {
     case CELLCLASS_EDIT_MODE:
         if (d_cellCodeClass)
-            d_cellCodeClass->saveScript(d_container, d_editor->toPlainText());
+            d_cellCodeClass->saveScript(d_editor->toPlainText());
         break;
 
     case CUSTOMSCRIPT_EDIT_MODE:
index bea9b60..348777a 100644 (file)
@@ -120,7 +120,7 @@ void DCToolWindowCellEditor::setCell(DCCell *cell)
         title.append(QString::fromStdString(cell->getName()));
         if (cell->getCellCode() && cell->getCellCode() != getController()->getCurrentContainer()->getEmptyCellCodeClass())
         {
-            d_classButton->setText(QString::fromStdString(cell->getCellCode()->getName()));
+            d_classButton->setText(QString::fromStdString(cell->getCellCode()->getFQNName()));
         }
         else
         {