}
+
+/*--------------------------------*/
+
+DCChangeCellCodeClassTypeCommand::DCChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode *cellCode, const QString& newType)
+ : DCCommand(requester, creator), d_cellCode(cellCode), d_type(newType)
+{
+
+}
+
+void DCChangeCellCodeClassTypeCommand::redo()
+{
+ bool r = false;
+ if (getContainer()->getIsScriptable(d_type))
+ {
+ d_cellCode->changeType(d_type);
+ }
+ setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+}
+
+void DCChangeCellCodeClassTypeCommand::undo()
+{
+
+}
+
+
/*--------------------------------*/
DCRemoveCellCodeClassCommand::DCRemoveCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCellCode *cellCode)
/*--------------------------------*/
+DCChangeCellTypeCommand::DCChangeCellTypeCommand(const void *requester, DCCreator *creator, DCCell* cell, const QString &newType)
+ : DCCommand(requester, creator), d_cell(cell), d_type(newType)
+{
+
+}
+
+void DCChangeCellTypeCommand::redo()
+{
+ bool r = false;
+ if (d_cell)
+ {
+ if (!getContainer()->getIsScriptable(d_type))
+ {
+ d_cell->setCellCode(getContainer()->getEmptyCellCodeClass(), NULL);
+ d_cell->saveCustomScript("");
+ }
+
+ if (d_cell->getIsCellCodeClassAssgined())
+ {
+ //TODO
+ }
+ else
+ {
+ d_cell->changeType(d_type);
+ r = true;
+ }
+ }
+ setCommandResult(r ? DCCommand::DCCOMMAND_SUCCEEDED : DCCommand::DCCOMMAND_FAILED);
+}
+
+void DCChangeCellTypeCommand::undo()
+{
+
+}
+
+/*--------------------------------*/
+
DCRenameCellCommand::DCRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newName)
: DCCommand(requester, creator), d_cell(cell), d_name(newName)
{
//------------------------------------------
+class DCChangeCellCodeClassTypeCommand : public DCCommand
+{
+ DCCellCode* d_cellCode;
+ QString d_type;
+
+public:
+ DCChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode* cellCode, const QString& newType);
+ virtual ~DCChangeCellCodeClassTypeCommand() {}
+ void undo();
+ void redo();
+};
+
+//------------------------------------------
+
class DCRemoveCellCodeClassCommand : public DCCommand
{
DCContainer *d_container;
//------------------------------------------
+class DCChangeCellTypeCommand : public DCCommand
+{
+ DCCell *d_cell;
+ QString d_type;
+
+public:
+ DCChangeCellTypeCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString& newType);
+ virtual ~DCChangeCellTypeCommand() {}
+ void undo();
+ void redo();
+};
+
+//------------------------------------------
+
class DCRenameCellCommand : public DCCommand
{
DCCell *d_cell;
return d_vComponent->getPageBelonging();
}
+bool DCCell::getIsCellCodeClassAssgined() const
+{
+ DCContainer *container = dynamic_cast<DCContainer*>(getContainer());
+
+ return d_cellCode && (container && d_cellCode != container->getEmptyCellCodeClass());
+}
+
DCAxon* DCCell::getAxon() const
{
return dynamic_cast<DCAxon*>(mAxon);
QString DCCell::getType() const
{
- return d_type;
+ DCContainer *container = dynamic_cast<DCContainer*>(getContainer());
+
+ if (d_cellCode && (container && d_cellCode != container->getEmptyCellCodeClass()))
+ {
+ return QString::fromStdString(d_cellCode->getCellAPIName());
+ }
+ else
+ {
+ return d_type;
+ }
}
float DCCell::getViewPageX() const
void DCCell::changeName(const QString &newName)
{
mName = newName.toStdString();
+ d_vComponent->updateShape();
}
void DCCell::changePath(const QString &newPath)
{
mLocation = newPath.toStdString();
+ d_vComponent->updateShape();
+}
+
+void DCCell::changeType(const QString &type)
+{
+ d_type = type;
+ d_vComponent->updateShape();
}
DCVPageComponent * getVComponent() const { return d_vComponent; }
DCVCPage* getPageBelonging() const;
DCCellCode* getCellCode() const { return d_cellCode; }
+ bool getIsCellCodeClassAssgined() const;
DCAxon* getAxon() const;
std::string getReceptorName(DCReceptor *receptor) const;
DCReceptor* getReceptor(const QString& receptorName);
*/
virtual DCReceptor* createReceptor(const QString &receptorName);
+ /**
+ * Change cell code type.
+ * change of cell's own type attribute only take effort when no cell code class is assined to this cell.
+ * In the case a cell code class is assiend to this cell, type of this cell rely on the cell code class's API type.
+ */
+ void changeType(const QString& type);
+
signals:
void cellCodeChanged();
mFQNName = fqnString.toStdString();
}
+void DCCellCode::changeType(const QString &newType)
+{
+ mCellAPIName = newType.toStdString();
+}
+
DCVCPage* getPageBelonging() const;
QString getOwnScript() const;
DCContainer* getContainer() const { return d_container; }
+
+ /**
+ * Change the API type of this cell.
+ *
+ */
+ void changeType(const QString& newType);
};
#endif // DCCELLCODE_H
return r ? newPage : NULL;
}
+
+
+QList<QString> DCContainer::getAvailableCellTypes() const
+{
+ QList<QString> list;
+
+ list.append(QString::fromStdString(TKContainer::CELLTYPE_JSBASIC));
+ list.append(QString::fromStdString(TKContainer::CELLTYPE_BASICSTORAGE));
+ list.append(QString::fromStdString(TKContainer::CELLTYPE_IN));
+ list.append(QString::fromStdString(TKContainer::CELLTYPE_OUT));
+
+ return list;
+}
+
+bool DCContainer::getIsScriptable(const QString& type) const
+{
+ std::string t = type.toStdString();
+
+ if (t == TKContainer::CELLTYPE_JSBASIC)
+ {
+ return true;
+ }
+ else if (t == TKContainer::CELLTYPE_BASICSTORAGE)
+ {
+ return true;
+ }
+ else if (t == TKContainer::CELLTYPE_IN)
+ {
+ return false;
+ }
+ else if (t == TKContainer::CELLTYPE_OUT)
+ {
+ return false;
+ }
+
+ return false;
+}
+
+
+bool DCContainer::getIsReceptorAvailable(const QString& type) const
+{
+ std::string t = type.toStdString();
+
+ if (t == TKContainer::CELLTYPE_JSBASIC)
+ {
+ return true;
+ }
+ else if (t == TKContainer::CELLTYPE_BASICSTORAGE)
+ {
+ return true;
+ }
+ else if (t == TKContainer::CELLTYPE_IN)
+ {
+ return false;
+ }
+ else if (t == TKContainer::CELLTYPE_OUT)
+ {
+ return true;
+ }
+
+ return false;
+}
+
QString readCustomScriptFromWorkFile(const DCCell *cell);
QString readCellCodeScriptFromFile(const DCCellCode *cellcode);
+
+ /***************************************************************************
+ * Cell type rules
+ **************************************************************************/
+
+ /**
+ * @brief return the avaiable cell types as the list of QString
+ * @return
+ */
+ QList<QString> getAvailableCellTypes() const;
+
+ /**
+ * @brief check if given cell type can have script
+ * @param type
+ * @return true if the given cell type can have script, false if no script avaiable for the cell type.
+ */
+ bool getIsScriptable(const QString& type) const;
+
+ /**
+ * @brief return if the cell type can accept receptors.
+ * The cell which inputs value from external can not receive value from internal cells.
+ * @param type
+ * @return
+ */
+ bool getIsReceptorAvailable(const QString& type) const;
+
};
#endif // DCCONTAINER_H
QDomElement aCellCodeTag = doc.createElement("a");
aCellCodeTag.setAttribute("parameter", "cellcode");
- if (cell->getCellCode() && cell->getCellCode() != d_container->getEmptyCellCodeClass())
+ if (cell->getIsCellCodeClassAssgined())
{
aCellCodeTag.setAttribute("href", QString::fromStdString(cell->getCellCode()->getFQNName()));
}
DCCommandUtil::postAddCellCodeClassCommand(requester, this, container, name, 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)
{
DCCommandUtil::postAddCellCommand(requester, this, container, containerBasedPath, name, type);
}
+void DCCreator::doCommandChangeCellType(const void *requester, DCCell *cell, const QString &newType)
+{
+ DCCommandUtil::postChangeCellTypeCommand(requester, this, cell, newType);
+}
+
void DCCreator::doCommandRemoveCells(const void *requester, DCContainer *container, const QList<DCCell*> &cells)
{
DCCommandUtil::postRemoveCellsCommand(requester, this, container, cells);
void doCommandUnassignCellCodeClassFromCell(const void *requester, DCCell *cell);
void doCommandAddCellCodeClass(const void *requester, DCContainer *container, const QString& name, const QString& type);
+ void doCommandChangeCellCodeClassType(const void *requester, DCCellCode *cellCode, const QString& newType);
void doCommandAddCell(const void *requester, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
+ void doCommandChangeCellType(const void *requester, DCCell *cell, const QString& newType);
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);
dialog/dcaddcelldialog.h \
utils/dcskeltoncreatorutil.h \
utils/dcutil.h \
- dccontainersaver.h
+ dccontainersaver.h \
+ visualizer/toolwindow/dccelltypecombobox.h \
+ visualizer/toolwindow/dccellcodetypecombobox.h
SOURCES = main.cpp \
mainwindow.cpp \
dialog/dcaddcelldialog.cpp \
utils/dcskeltoncreatorutil.cpp \
utils/dcutil.cpp \
- dccontainersaver.cpp
+ dccontainersaver.cpp \
+ visualizer/toolwindow/dccelltypecombobox.cpp \
+ visualizer/toolwindow/dccellcodetypecombobox.cpp
RESOURCES = denncoCreator.qrc
d_tableModel->setReadOnly(0,true);
d_comboBox = new QComboBox;
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_JSBASIC), QString::fromStdString(TKContainer::CELLTYPE_JSBASIC));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_BASICSTORAGE), QString::fromStdString(TKContainer::CELLTYPE_BASICSTORAGE));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_IN), QString::fromStdString(TKContainer::CELLTYPE_IN));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_OUT), QString::fromStdString(TKContainer::CELLTYPE_OUT));
+ d_comboBox->addItems(QStringList(d_container->getAvailableCellTypes()));
DCScene *scene = container->getScene();
const QMap<QString,DCVCPage*> *pages = scene->getPages();
d_tableModel->setReadOnly(0,true);
d_comboBox = new QComboBox;
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_JSBASIC), QString::fromStdString(TKContainer::CELLTYPE_JSBASIC));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_BASICSTORAGE), QString::fromStdString(TKContainer::CELLTYPE_BASICSTORAGE));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_IN), QString::fromStdString(TKContainer::CELLTYPE_IN));
- d_comboBox->addItem(QString::fromStdString(TKContainer::CELLTYPE_OUT), QString::fromStdString(TKContainer::CELLTYPE_OUT));
+ d_comboBox->addItems(QStringList(d_container->getAvailableCellTypes()));
DCScene *scene = container->getScene();
const QMap<QString,DCVCPage*> *pages = scene->getPages();
}
//static
+void DCCommandUtil::postChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode *cellCode, const QString &newType)
+{
+ postEvent(creator, new DCChangeCellCodeClassTypeCommand(requester, creator, cellCode, newType));
+}
+
+//static
void DCCommandUtil::postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &containerBasedPath, const QString &name, const QString &type)
{
postEvent(creator, new DCAddCellCommand(requester, creator, container, containerBasedPath, name, type));
}
//static
+void DCCommandUtil::postChangeCellTypeCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newType)
+{
+ postEvent(creator, new DCChangeCellTypeCommand(requester, creator, cell, newType));
+}
+
+//static
void DCCommandUtil::postRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
{
postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cells));
static void postUnassignCellCodeClassFromCellCommand(const void *requester, DCCreator *creator, DCCell *cell);
static void postAddCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString& name, const QString& type);
+ static void postChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode *cellCode, const QString& newType);
static void postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
+ static void postChangeCellTypeCommand(const void* requester, DCCreator *creator, DCCell *cell, const QString& newType);
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);
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Oct-15, 2012.
+//
+
+#include "dccellcodetypecombobox.h"
+
+#include "dccreator.h"
+#include "dccontainer.h"
+#include "dccellcode.h"
+
+DCCellCodeTypeComboBox::DCCellCodeTypeComboBox(DCCreator *creator, QWidget *parent) :
+ QComboBox(parent), d_creator(creator), d_cellCode(NULL)
+{
+ DCContainer *container = d_creator->getCurrentContainer();
+
+ QList<QString> list = creator->getCurrentContainer()->getAvailableCellTypes();
+ for (int i = 0; i < list.length(); i++)
+ {
+ if (container->getIsScriptable(list.at(i)))
+ {
+ addItem(list.at(i));
+ }
+ }
+ connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
+}
+
+DCCellCodeTypeComboBox::~DCCellCodeTypeComboBox()
+{
+
+}
+
+void DCCellCodeTypeComboBox::changeType(const QString &newType)
+{
+ for (int i = 0; i < count(); i++)
+ {
+ if (itemText(i) == newType)
+ {
+ setCurrentIndex(i);
+ break;
+ }
+ }
+}
+
+void DCCellCodeTypeComboBox::setEditingCellCode(DCCellCode *cellcode)
+{
+ d_cellCode = cellcode;
+ updateSelection();
+}
+
+void DCCellCodeTypeComboBox::updateSelection()
+{
+ if (d_cellCode)
+ {
+ changeType(QString::fromStdString(d_cellCode->getCellAPIName()));
+ }
+}
+
+void DCCellCodeTypeComboBox::slotCurrentIndexChanged(const QString &newType)
+{
+ if (QString::fromStdString(d_cellCode->getCellAPIName()) != newType)
+ {
+ d_creator->doCommandChangeCellCodeClassType(this, d_cellCode, newType);
+ emit typeChanged(newType);
+ }
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Oct-15, 2012.
+//
+
+#ifndef DCCELLCODETYPECOMBOBOX_H
+#define DCCELLCODETYPECOMBOBOX_H
+
+#include <QComboBox>
+
+class DCCreator;
+class DCCellCode;
+
+class DCCellCodeTypeComboBox : public QComboBox
+{
+ Q_OBJECT
+
+ DCCreator *d_creator;
+ DCCellCode *d_cellCode;
+
+ void changeType(const QString& newType);
+
+public:
+ DCCellCodeTypeComboBox(DCCreator *creator, QWidget *parent = 0);
+ virtual ~DCCellCodeTypeComboBox();
+
+ void setEditingCellCode(DCCellCode* cellcode);
+ void updateSelection();
+
+signals:
+ void typeChanged(const QString& newType);
+
+public slots:
+ void slotCurrentIndexChanged(const QString& newType);
+
+};
+
+#endif // DCCELLCODETYPECOMBOBOX_H
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Oct-15, 2012.
+//
+
+#include "dccelltypecombobox.h"
+
+#include "dccreator.h"
+#include "dccontainer.h"
+#include "dccell.h"
+
+DCCellTypeComboBox::DCCellTypeComboBox(DCCreator *creator, QWidget *parent) :
+ QComboBox(parent), d_creator(creator), d_cell(NULL)
+{
+ addItems(QStringList(creator->getCurrentContainer()->getAvailableCellTypes()));
+ connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
+}
+
+DCCellTypeComboBox::~DCCellTypeComboBox()
+{
+
+}
+
+void DCCellTypeComboBox::changeType(const QString &newType)
+{
+ for (int i = 0; i < count(); i++)
+ {
+ if (itemText(i) == newType)
+ {
+ setCurrentIndex(i);
+ break;
+ }
+ }
+}
+
+void DCCellTypeComboBox::setEditingCell(DCCell *cell)
+{
+ d_cell = cell;
+ updateSelection();
+}
+
+void DCCellTypeComboBox::updateSelection()
+{
+ if (d_cell)
+ {
+ changeType(d_cell->getType());
+ }
+}
+
+void DCCellTypeComboBox::slotCurrentIndexChanged(const QString &newType)
+{
+ DCContainer *container = d_creator->getCurrentContainer();
+
+ if (d_cell->getType() != newType)
+ {
+ bool isCurrentScriptable = container->getIsScriptable(d_cell->getType());
+ bool isNewScriptable = container->getIsScriptable(newType);
+ if (isCurrentScriptable && !isNewScriptable)
+ {
+ int r = QMessageBox::warning(NULL, tr("Change cell type"),
+ tr("This cell type doesn't support cell code scripts. All script attached to this cell will be removed when you change this type. Do you proceed?"),
+ QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
+ if (r == QMessageBox::Cancel)
+ {
+ changeType(d_cell->getType());
+ return;
+ }
+ }
+ d_creator->doCommandChangeCellType(this, d_cell, newType);
+ }
+ emit typeChanged(newType);
+}
--- /dev/null
+// Copyright (c) 2012 Dennco Project
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+//
+// Created by tkawata on Oct-15, 2012.
+//
+
+#ifndef DCCELLTYPECOMBOBOX_H
+#define DCCELLTYPECOMBOBOX_H
+
+#include <QComboBox>
+
+class DCCreator;
+class DCCell;
+
+class DCCellTypeComboBox : public QComboBox
+{
+ Q_OBJECT
+
+ DCCreator *d_creator;
+ DCCell *d_cell;
+
+ void changeType(const QString& newType);
+
+public:
+ DCCellTypeComboBox(DCCreator *creator, QWidget *parent = 0);
+ virtual ~DCCellTypeComboBox();
+
+ void setEditingCell(DCCell* cell);
+ void updateSelection();
+
+signals:
+ void typeChanged(const QString& newType);
+
+public slots:
+ void slotCurrentIndexChanged(const QString& newType);
+};
+
+#endif // DCCELLTYPECOMBOBOX_H
"QPlainTextEdit {background: black;} "
"QGroupBox { border: 1px solid gray; border-radius: 3px;} "
"QTableView { background: black;} "
- "QPushButton { background-color: rgb(128,128,128);} ";
+ "QPushButton { background-color: rgb(128,128,128);} "
+ "QComboBox { background-color: rgb(128,128,128); "
+ " border: 1px solid gray;"
+ " border-radius: 3px;"
+ " padding: 1px 18px 1px 3px;"
+ " }"
+ "QComboBox QAbstractItemView {"
+ " background: rgb(128,128,128);"
+ " color: white;"
+ " selection-background-color: rgb(128,128,255);"
+ "}";
DCToolWindowBase::DCToolWindowBase(const QString &windowTitle,DCCreator *creator)
: QDialog(0,Qt::CustomizeWindowHint | Qt::FramelessWindowHint), d_collapsed(false), d_creator(creator)
#include "dccreator.h"
#include "dceditablelabel.h"
#include "dceditabletreeview.h"
+#include "dccellcodetypecombobox.h"
+#include "dccelltypecombobox.h"
#include "utils/dcqtitemmodel.h"
#include "dialog/dcassigncellcodeclassdialog.h"
cellclassGroupBoxLayoutInnder1->addWidget(new QLabel(tr("type")), 1,0);
d_uiClassName = new DCEditableLabel(this, "");
- d_uiClassType = new DCEditableLabel(this, "");
+ d_uiClassType = new DCCellCodeTypeComboBox(creator, this);
d_uiClassUnsetButton = new QPushButton(tr("Unset class"));
d_uiClassUserList = new QTableView;
cellclassGroupBoxLayoutInnder1->addWidget(d_uiClassName, 0,1);
d_uiCellName = new DCEditableLabel(this, "");
d_uiCellPath = new DCEditableLabel(this, "");
- d_uiCellType = new DCEditableLabel(this, "");
+ d_uiCellType = new DCCellTypeComboBox(creator, this);
d_uiSwitchEditorButton = new QPushButton(tr("Open custom script"));
cellGroupBoxLayout->addWidget(d_uiCellName, 0,1);
cellGroupBoxLayout->addWidget(d_uiCellPath, 1,1);
connect(d_uiSwitchEditorButton, SIGNAL(clicked()), this, SLOT(switchEditor()));
connect(d_uiClassUnsetButton, SIGNAL(clicked()), this, SLOT(unsetCellCodeButtonClicked()));
connect(d_uiClassAssignButton, SIGNAL(clicked()), this, SLOT(assignCellCodeButtonClicked()));
+ connect(getController(), SIGNAL(commandExecuted(const QUndoCommand*)), this, SLOT(commandExecuted(const QUndoCommand*)));
}
DCToolWindowCellCodeEditor::~DCToolWindowCellCodeEditor()
{
d_receptors->disconnect(this);
d_axonTerminals->disconnect(this);
+ getController()->disconnect(this);
if (d_receptorItemModel)
d_receptorItemModel->deleteLater();
d_cellCodeClass = cellCodeClass;
d_ownerCell = ownerCell;
- QString titleString = "";
-
- bool cellCodeAvaiable = true;
-
- if (ownerCell)
- {
- titleString.append("CELL : ");
- titleString.append(QString::fromStdString(d_ownerCell->getName()));
- titleString.append(" ");
-
- updateCellInformation();
- d_uiCellGroupBox->setVisible(true);
-
- cellCodeAvaiable = d_container->isScriptableCell(ownerCell);
- }
- else
- {
- d_uiCellGroupBox->setVisible(false);
- }
+ d_uiClassType->setEditingCellCode(cellCodeClass);
+ d_uiCellType->setEditingCell(ownerCell);
+ updateInformation();
-
- if (cellCodeClass && cellCodeAvaiable)
- {
- if (d_container->getEmptyCellCodeClass() != cellCodeClass)
- {
- updateClassInformation();
- d_uiClassGroupBox->setVisible(true);
- titleString.append("CELL CODE : ");
- titleString.append(QString::fromStdString(cellCodeClass->getFQNName()));
- titleString.append(" (");
- titleString.append(QString::fromStdString(cellCodeClass->getCellAPIName()));
- titleString.append(")");
- d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(true);
- d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(false);
- d_uiClassGroupBox->adjustSize();
- }
- else
- {
- d_uiClassGroupBox->setVisible(true);
- d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(false);
- d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(true);
- d_uiClassGroupBox->adjustSize();
- }
- }
- else
- {
- d_uiClassGroupBox->setVisible(false);
- d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(false);
- d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(false);
- d_editor->setPlainText("");
- d_editor->setReadOnly(true);
- }
-
- setButtonedWindowTitle(titleString);
showClassScript();
}
d_cellCodeClass = ownerCell->getCellCode();
}
+ d_uiClassType->setEditingCellCode(d_cellCodeClass);
+ d_uiCellType->setEditingCell(d_ownerCell);
+ updateInformation();
- QString titleString = "";
-
- if (ownerCell)
- {
- titleString.append("CELL : ");
- titleString.append(QString::fromStdString(d_ownerCell->getName()));
- titleString.append(" ");
-
- updateCellInformation();
- d_uiCellGroupBox->setVisible(true);
- }
- else
- {
- d_uiCellGroupBox->setVisible(false);
- }
-
- if (d_cellCodeClass && d_cellCodeClass != d_container->getEmptyCellCodeClass())
- {
- updateClassInformation();
- d_uiClassGroupBox->setVisible(true);
- titleString.append("CELL CODE : ");
- titleString.append(QString::fromStdString(d_cellCodeClass->getFQNName()));
- titleString.append(" (");
- titleString.append(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
- titleString.append(")");
-
- }
- else
- {
- d_uiClassGroupBox->setVisible(false);
- d_editor->setPlainText("");
- d_editor->setReadOnly(true);
- }
-
- setButtonedWindowTitle(titleString);
showCustomScript();
}
d_mode = CELLCLASS_EDIT_MODE;
d_uiClassGroupBox->setVisible(true);
d_uiSwitchEditorButton->setText(tr("Switch to Custom Script"));
- if (d_cellCodeClass && d_cellCodeClass != d_container->getEmptyCellCodeClass() && d_container)
+ if (d_ownerCell->getIsCellCodeClassAssgined() && d_container)
{
d_editor->setPlainText(d_cellCodeClass->getOwnScript());
d_editor->setReadOnly(false);
}
}
-void DCToolWindowCellCodeEditor::updateClassInformation()
-{
- if (d_cellCodeClass)
- {
- d_uiClassName->setText(QString::fromStdString(d_cellCodeClass->getFQNName()));
- d_uiClassType->setText(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
- }
- else
- {
- d_uiClassName->setText("");
- d_uiClassType->setText("");
- }
-}
-
-void DCToolWindowCellCodeEditor::updateCellInformation()
+void DCToolWindowCellCodeEditor::updateInformation()
{
d_receptorItemModel->removeAllItems();
d_axonTerminalItemModel->removeAllItems();
+ //update cell information
if (d_ownerCell)
{
d_uiCellName->setText(QString::fromStdString(d_ownerCell->getName()));
d_uiCellPath->setText(QString::fromStdString(d_ownerCell->getLocation()));
- d_uiCellType->setText(d_ownerCell->getType());
+ d_uiCellType->updateSelection();
+ d_uiCellType->setEnabled(!d_ownerCell->getIsCellCodeClassAssgined());
d_receptorItemModel->insertString("receptors");
d_receptorItemModel->setReadOnly(0,true);
{
d_uiCellName->setText("");
d_uiCellPath->setText("");
- d_uiCellType->setText("");
+ d_uiCellType->updateSelection();
+ }
+
+ //update cell code information
+ if (d_cellCodeClass)
+ {
+ d_uiClassName->setText(QString::fromStdString(d_cellCodeClass->getFQNName()));
+ d_uiClassType->updateSelection();
+ }
+ else
+ {
+ d_uiClassName->setText("");
+ d_uiClassType->updateSelection();
+ }
+
+
+ // update title and tool visibility
+ QString titleString = "";
+ if (d_ownerCell)
+ {
+ titleString.append("CELL : ");
+ titleString.append(QString::fromStdString(d_ownerCell->getName()));
+ titleString.append(" ");
+
+ d_uiCellGroupBox->setVisible(true);
+ if (d_container->isScriptableCell(d_ownerCell))
+ {
+ if (d_ownerCell->getIsCellCodeClassAssgined())
+ {
+ titleString.append("CELL CODE : ");
+ titleString.append(QString::fromStdString(d_cellCodeClass->getFQNName()));
+ titleString.append(" (");
+ titleString.append(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
+ titleString.append(")");
+ d_uiClassGroupBox->setVisible(true);
+ d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(true);
+ d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(false);
+ d_uiClassGroupBox->adjustSize();
+ }
+ else
+ {
+ d_uiClassGroupBox->setVisible(true);
+ d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(false);
+ d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(true);
+ d_uiClassGroupBox->adjustSize();
+ }
+ }
+ else
+ {
+ d_uiClassGroupBox->setVisible(false);
+ d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(false);
+ d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(false);
+ }
}
+ else
+ {
+ titleString.append("CELL CODE : ");
+ titleString.append(QString::fromStdString(d_cellCodeClass->getFQNName()));
+ titleString.append(" (");
+ titleString.append(QString::fromStdString(d_cellCodeClass->getCellAPIName()));
+ titleString.append(")");
+ d_uiCellGroupBox->setVisible(false);
+ d_uiClassGroupBox->setVisible(true);
+ d_uiClassGroupBox->layout()->itemAt(0)->widget()->setVisible(true);
+ d_uiClassGroupBox->layout()->itemAt(1)->widget()->setVisible(false);
+ d_uiClassGroupBox->adjustSize();
+ }
+ setButtonedWindowTitle(titleString);
+
}
+
void DCToolWindowCellCodeEditor::switchEditor()
{
saveScriptToFile();
{
setData(d_container, d_ownerCell->getCellCode(), d_ownerCell);
}
+
+void DCToolWindowCellCodeEditor::commandExecuted(const QUndoCommand *executedCommand)
+{
+ if (getIsOnStage())
+ updateInformation();
+}
class DCEditableLabel;
class DCEditableTreeView;
class DCQtItemModel;
+class DCCellCodeTypeComboBox;
+class DCCellTypeComboBox;
class DCToolWindowCellCodeEditor : public DCToolWindowBase
{
private:
enum DCScriptEditMode { CELLCLASS_EDIT_MODE, CUSTOMSCRIPT_EDIT_MODE };
- DCScriptEditMode d_mode;
- DCContainer *d_container;
- DCCodeEditor *d_editor;
- DCCellCode *d_cellCodeClass;
- DCCell *d_ownerCell;
-
- QGroupBox *d_uiClassGroupBox;
- DCEditableLabel *d_uiClassName;
- DCEditableLabel *d_uiClassType;
- QTableView *d_uiClassUserList;
- QPushButton *d_uiClassUnsetButton;
- QPushButton *d_uiClassAssignButton;
-
- QGroupBox *d_uiCellGroupBox;
- DCEditableLabel *d_uiCellName;
- DCEditableLabel *d_uiCellPath;
- DCEditableLabel *d_uiCellType;
- DCEditableTreeView *d_receptors;
- DCQtItemModel *d_receptorItemModel;
- DCEditableTreeView *d_axonTerminals;
- DCQtItemModel *d_axonTerminalItemModel;
- QPushButton *d_uiSwitchEditorButton;
-
- QPushButton *d_uiCloseButton;
-
- void updateCellInformation();
- void updateClassInformation();
- void showClassScript();
- void showCustomScript();
+ DCScriptEditMode d_mode;
+ DCContainer *d_container;
+ DCCodeEditor *d_editor;
+ DCCellCode *d_cellCodeClass;
+ DCCell *d_ownerCell;
+
+ QGroupBox *d_uiClassGroupBox;
+ DCEditableLabel *d_uiClassName;
+ DCCellCodeTypeComboBox *d_uiClassType;
+ QTableView *d_uiClassUserList;
+ QPushButton *d_uiClassUnsetButton;
+ QPushButton *d_uiClassAssignButton;
+
+ QGroupBox *d_uiCellGroupBox;
+ DCEditableLabel *d_uiCellName;
+ DCEditableLabel *d_uiCellPath;
+ DCCellTypeComboBox *d_uiCellType;
+ DCEditableTreeView *d_receptors;
+ DCQtItemModel *d_receptorItemModel;
+ DCEditableTreeView *d_axonTerminals;
+ DCQtItemModel *d_axonTerminalItemModel;
+ QPushButton *d_uiSwitchEditorButton;
+
+ QPushButton *d_uiCloseButton;
+
+ void updateInformation();
+ void showClassScript();
+ void showCustomScript();
public:
DCToolWindowCellCodeEditor(DCCreator *creator);
void unsetCellCodeButtonClicked();
void assignCellCodeButtonClicked();
void classForCellChanged();
+ void commandExecuted(const QUndoCommand *executedCommand);
};
#include "dceditablelabel.h"
#include "dceditabletreeview.h"
+#include "dccelltypecombobox.h"
#include "dccell.h"
#include "dccreator.h"
#include "dcreceptor.h"
d_layout->addWidget(d_detailButton,6,0,1,2);
d_textPage = new DCEditableLabel(this, "");
- d_textType = new DCEditableLabel(this, "");
+ d_comboType = new DCCellTypeComboBox(creator, this);
d_layout->addWidget(d_textPage, 0,1);
- d_layout->addWidget(d_textType, 1,1);
+ d_layout->addWidget(d_comboType, 1,1);
d_classButton = new QPushButton("...");
- QPushButton *customScriptEditButton = new QPushButton(tr("edit..."));
+ d_customScriptButton = new QPushButton(tr("edit..."));
d_layout->addWidget(d_classButton, 2,1);
- d_layout->addWidget(customScriptEditButton, 3,1);
+ d_layout->addWidget(d_customScriptButton, 3,1);
d_receptors = new DCEditableTreeView(this);
d_receptors->setHeaderHidden(true);
connect(d_axonTerminals, SIGNAL(vscrollbarHidden()), this, SLOT(adjustTreeColumnWidth()));
connect(d_classButton, SIGNAL(clicked()), this, SLOT(slotCellCodeEditButtonPressed()));
- connect(customScriptEditButton, SIGNAL(clicked()), this, SLOT(slotCustomScriptEditButtonPressed()));
-
+ connect(d_customScriptButton, SIGNAL(clicked()), this, SLOT(slotCustomScriptEditButtonPressed()));
}
DCToolWindowCellEditor::~DCToolWindowCellEditor()
void DCToolWindowCellEditor::setCell(DCCell *cell)
{
+ if (d_cell)
+ d_cell->disconnect(this);
+
d_cell = cell;
QString title = "CELL:";
if (cell)
{
title.append(QString::fromStdString(cell->getName()));
- if (cell->getCellCode() && cell->getCellCode() != getController()->getCurrentContainer()->getEmptyCellCodeClass())
- {
- d_classButton->setText(QString::fromStdString(cell->getCellCode()->getFQNName()));
- }
- else
- {
- d_classButton->setText("...");
- }
connect(cell, SIGNAL(destroyed(QObject*)), this, SLOT(slotCellDestroyed()));
+ d_comboType->setEditingCell(cell);
}
setButtonedWindowTitle(title);
d_receptorItemModel->removeAllItems();
d_axonTerminalItemModel->removeAllItems();
- if (d_cell)
+ DCContainer *container = getController()->getCurrentContainer();
+
+ if (d_cell && container)
{
+ if (container->getIsScriptable(d_cell->getType()))
+ {
+ if (d_cell->getIsCellCodeClassAssgined())
+ {
+ d_classButton->setText(QString::fromStdString(d_cell->getCellCode()->getFQNName()));
+ }
+ else
+ {
+ d_classButton->setText("...");
+ }
+ d_classButton->setEnabled(true);
+
+ d_customScriptButton->setText("Edit...");
+ d_customScriptButton->setEnabled(true);
+ }
+ else
+ {
+ d_classButton->setText("N/A");
+ d_classButton->setEnabled(false);
+ d_customScriptButton->setText("N/A");
+ d_customScriptButton->setEnabled(false);
+ }
+
+ d_comboType->updateSelection();
+ d_comboType->setEnabled(!d_cell->getIsCellCodeClassAssgined());
+
d_textPage->setText(QString::fromStdString(d_cell->getLocation()));
- d_textType->setText(d_cell->getType());
d_receptorItemModel->insertString("receptors");
d_receptorItemModel->insertColumns(1,2);
class DCEditableTreeView;
class DCQtItemModel;
class DCEditableLabel;
+class DCCellTypeComboBox;
class DCToolWindowCellEditor : public DCToolWindowBase
{
private:
DCCell *d_cell;
DCEditableLabel *d_textPage;
- DCEditableLabel *d_textType;
+ DCCellTypeComboBox *d_comboType;
QPushButton *d_classButton;
+ QPushButton *d_customScriptButton;
QPushButton *d_detailButton;
DCEditableTreeView *d_receptors;
DCQtItemModel *d_receptorItemModel;