--- /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 Dec-24/2012.
+//
+#include "dccellcodescripttreeviewwidget.h"
+
+#include "dccreator.h"
+#include "dccontainer.h"
+#include "dccellcode.h"
+#include "mainwindow.h"
+#include "dialog/dcaddcellcodeclassdialog.h"
+#include "utils/dcqtitemmodel.h"
+
+const static QString S_ScriptTreeStyle =
+ "QTreeView::branch:!has-children:adjoins-item {"
+ "border-image: url(:/docIcon.png) 0;"
+ "}";
+
+class ScriptTreeModelItem : public DCQtItemModelItem
+{
+ QVector<QVariant> mItemUserData;
+public:
+ ScriptTreeModelItem(const QVector<QVariant> &data, DCQtItemModelItem *parent)
+ : DCQtItemModelItem(data, parent), mItemUserData(data)
+ {
+ }
+
+ ScriptTreeModelItem(const QStringList &headers, DCQtItemModelItem *parent = 0)
+ : DCQtItemModelItem(headers, parent)
+ {
+ QVector<QVariant> rootData;
+ foreach (QString header, headers)
+ {
+ rootData << header;
+ }
+ mItemUserData = rootData;
+ }
+
+ virtual ~ScriptTreeModelItem()
+ {
+ }
+
+
+ QVariant userData(int column) const
+ {
+ return mItemUserData.value(column);
+ }
+
+ virtual bool insertChildren(int position, int count, int columns)
+ {
+ if (position < 0 || position > mChildItems.size())
+ return false;
+
+ for (int row = 0; row < count; ++row) {
+ QVector<QVariant> data(columns);
+ DCQtItemModelItem *item = new ScriptTreeModelItem(data, this);
+ mChildItems.insert(position, item);
+ }
+
+ return true;
+ }
+
+ virtual bool insertColumns(int position, int columns)
+ {
+ if (!DCQtItemModelItem::insertColumns(position, columns))
+ return false;
+
+ for (int column = 0; column < columns; ++column)
+ mItemUserData.insert(position, QVariant());
+
+ return true;
+ }
+
+ virtual bool removeColumns(int position, int columns)
+ {
+ if (!DCQtItemModelItem::removeColumns(position, columns))
+ return false;
+
+ for (int column = 0; column < columns; ++column)
+ mItemUserData.remove(position);
+
+ return true;
+ }
+
+ bool setUserData(int column, const QVariant &value)
+ {
+ if (column < 0 || column >= mItemUserData.size())
+ return false;
+
+ mItemUserData[column] = value;
+ return true;
+ }
+};
+
+class ScriptTreeModel : public DCQtItemModel
+{
+public:
+ ScriptTreeModel(const QStringList &headers, QObject *parent = 0)
+ : DCQtItemModel(headers, new ScriptTreeModelItem(headers), parent)
+ {}
+
+ virtual ~ScriptTreeModel()
+ {
+ }
+
+
+ virtual QVariant data(const QModelIndex &index, int role) const
+ {
+ if (!index.isValid())
+ return QVariant();
+
+ if (role == Qt::UserRole)
+ {
+ ScriptTreeModelItem *item = dynamic_cast<ScriptTreeModelItem*>(getItem(index));
+ if (item)
+ return item->userData(index.column());
+ }
+ else
+ {
+ return DCQtItemModel::data(index,role);
+ }
+
+ return QVariant();
+ }
+
+
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
+ {
+ bool result = false;
+ if (role == Qt::UserRole)
+ {
+ ScriptTreeModelItem *item = dynamic_cast<ScriptTreeModelItem*>(getItem(index));
+ if (item)
+ result = item->setUserData(index.column(), value);
+ }
+ else
+ {
+ return DCQtItemModel::setData(index,value,role);
+ }
+
+ if (result)
+ emit dataChanged(index, index);
+
+ return result;
+ }
+
+};
+
+
+DCCellCodeScriptTreeViewWidget::DCCellCodeScriptTreeViewWidget(QWidget *parent, DCCreator *creator) :
+ QTreeView(parent), d_creator(creator)
+{
+ QStringList headers;
+ headers << "Name";
+ d_model = new ScriptTreeModel(headers);
+
+ setIndentation(15);
+ setModel(d_model);
+ setStyleSheet(S_ScriptTreeStyle);
+
+ connect(d_creator, SIGNAL(contentRootPathChanged(const void*, QString)), this, SLOT(contentRootPathChanged(const void*, QString)));
+ connect(d_creator, SIGNAL(destroyed(QObject*)), this, SLOT(creatorDestroyed()));
+ connect(d_creator, SIGNAL(commandExecuted(const QUndoCommand*)), this, SLOT(commandExecuted(const QUndoCommand*)));
+
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),this, SLOT(doContextMenu(const QPoint&)));
+}
+
+DCCellCodeScriptTreeViewWidget::~DCCellCodeScriptTreeViewWidget()
+{
+ if (d_model)
+ d_model->deleteLater();
+}
+
+
+void DCCellCodeScriptTreeViewWidget::rebuildModel()
+{
+ if (!d_model)
+ return;
+
+ if (!d_creator || !d_creator->getCurrentContainer())
+ return;
+
+ d_model->removeAllItems();
+
+ QVector<QString> pathNames;
+ DCContainer *container = d_creator->getCurrentContainer();
+ const TKCellCodeMap* cellCodeScripts = container->getCellCodes();
+ TKCellCodeMap::const_iterator it = cellCodeScripts->begin();
+ while(it != cellCodeScripts->end())
+ {
+ pathNames.append(QString::fromStdString(it->first));
+ it++;
+ }
+ qSort(pathNames);
+
+ QVector<QString>::const_iterator sit = pathNames.begin();
+ while(sit != pathNames.end())
+ {
+ QStringList nodes = (*sit).split("/");
+
+ QModelIndex index;
+ if (nodes.length() < 1)
+ {
+ ++sit;
+ continue;
+ }
+
+ for (int i = 1; i < nodes.length() -1; i++)
+ {
+ QString n = nodes.at(i);
+ index = childNode(n, index);
+ }
+ QString ln = nodes.at(nodes.length()-1);
+ int p = ln.lastIndexOf("#");
+ if (p <= 0)
+ {
+ //invalid
+ ++sit;
+ continue;
+ }
+ QString fName = ln.left(p);
+ QString cName = ln.mid(p+1);
+ index = childNode(fName, index);
+ index = childNode(cName, index);
+ d_model->setData(index, QVariant(*sit), Qt::UserRole);
+ ++sit;
+ }
+ expandAll();
+}
+
+void DCCellCodeScriptTreeViewWidget::selectPath(const QString path)
+{
+ QStringList nodes = path.split("/");
+
+ QModelIndex index;
+ if (path.length() < 1)
+ {
+ return;
+ }
+
+ for (int i = 1; i < nodes.length() -1; i++)
+ {
+ QString n = nodes.at(i);
+ index = childNode(n, index, false);
+ if (!index.isValid())
+ break;
+ }
+
+ QString ln = nodes.at(nodes.length()-1);
+ int p = ln.lastIndexOf("#");
+ if (p>0)
+ {
+ QString fName = ln.left(p);
+ QString cName = ln.mid(p+1);
+
+ index = childNode(fName, index, false);
+ if (index.isValid())
+ {
+ index = childNode(cName, index, false);
+ selectionModel()->select(index, QItemSelectionModel::Select);
+ }
+ }
+}
+
+QModelIndex DCCellCodeScriptTreeViewWidget::childNode(const QString& nodeName, const QModelIndex& currentIndex, bool createWhenNotExist)
+{
+ QModelIndex childIndex;
+
+ for (int j = 0; j < d_model->rowCount(currentIndex); j++)
+ {
+ if (d_model->data(d_model->index(j,0,currentIndex), Qt::EditRole).toString() == nodeName)
+ {
+ childIndex = d_model->index(j,0,currentIndex);
+ break;
+ }
+ }
+ if (!childIndex.isValid() && createWhenNotExist)
+ {
+ int position = d_model->rowCount(currentIndex);;
+ d_model->insertRows(position,1,currentIndex);
+ childIndex = d_model->index(position,0,currentIndex);
+ d_model->setData(childIndex,QVariant(nodeName));
+ }
+ return childIndex;
+}
+
+void DCCellCodeScriptTreeViewWidget::contentRootPathChanged(const void *requester, QString rootPath)
+{
+ rebuildModel();
+}
+
+void DCCellCodeScriptTreeViewWidget::creatorDestroyed()
+{
+ d_creator = NULL;
+}
+
+void DCCellCodeScriptTreeViewWidget::commandExecuted(const QUndoCommand *)
+{
+ rebuildModel();
+}
+
+void DCCellCodeScriptTreeViewWidget::doContextMenu(const QPoint& pos)
+{
+ if (!d_creator || !d_creator->getCurrentContainer())
+ return;
+
+ QPoint globalPos = mapToGlobal(pos);
+
+ QMenu menu;
+
+ QAction *addCellCodeScriptAction = NULL;
+ QAction *removeCellCodeScriptAction = NULL;
+
+ QString path = "";
+ QModelIndex index;
+ QModelIndexList indexes = selectedIndexes();
+ addCellCodeScriptAction = menu.addAction(tr("Add cell code script..."));
+ if (indexes.length() > 0)
+ {
+ index = indexes.at(0);
+ QString pathName = d_model->data(index, Qt::UserRole).toString();
+ if (!pathName.isEmpty() && pathName.length() > 0)
+ {
+ removeCellCodeScriptAction = menu.addAction(tr("Remove..."));
+ path = pathName;
+ }
+ else
+ {
+ QModelIndex topIndex;
+ while (index != topIndex)
+ {
+ path.prepend(d_model->data(index, Qt::EditRole).toString());
+ index = index.parent();
+ path.prepend("/");
+
+ }
+ }
+ }
+
+ QAction* selectedItem = menu.exec(globalPos);
+ if (selectedItem == addCellCodeScriptAction)
+ {
+ int s = path.lastIndexOf("#");
+ if (s>0)
+ {
+ path = path.left(s);
+ }
+ DCAddCellCodeClassDialog dialog(d_creator, path);
+ dialog.exec();
+ QString addedPathName = dialog.getAddedCellCodeClassName();
+ if (!addedPathName.isEmpty() && addedPathName.length()>0)
+ {
+ selectPath(addedPathName);
+ }
+ }
+ else if (selectedItem == removeCellCodeScriptAction)
+ {
+ qDebug() << "Remove cell code script!!";
+ qDebug() << path;
+ DCContainer *container = d_creator->getCurrentContainer();
+ if (container)
+ {
+ DCCellCode *cellCode = dynamic_cast<DCCellCode*>(container->getCellCode(path.toStdString()));
+ if (cellCode)
+ {
+ QString msg = "Deleting Cell code script:\n" + path + "\nDo you want to continue?";
+ QMessageBox msgBox(QMessageBox::Warning, tr("Delete cell code script"), msg);
+ msgBox.setStandardButtons(QMessageBox::Cancel | QMessageBox::Yes);
+ int ret = msgBox.exec();
+ if (ret == QMessageBox::Yes)
+ {
+ d_creator->doCommandRemoveCellCode(this, container, cellCode);
+ }
+ }
+ }
+ }
+}
+
+void DCCellCodeScriptTreeViewWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ (void) event;
+
+ if (!d_creator || !d_creator->getCurrentContainer())
+ return;
+
+ QModelIndex index = currentIndex();
+ if (index.isValid())
+ {
+ QString pathName = d_model->data(index, Qt::UserRole).toString();
+
+ if (!pathName.isEmpty() && pathName.length()>0)
+ {
+ DCContainer *container = d_creator->getCurrentContainer();
+ if (container)
+ {
+ DCCellCode *cellCode = dynamic_cast<DCCellCode*>(container->getCellCode(pathName.toStdString()));
+ if (cellCode)
+ {
+ MainWindow::openExternalEditorFor(cellCode->getWorkFilePathForCellCodeScript());
+ }
+ }
+ }
+ }
+}
--- /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 Dec-24/2012.
+//
+#ifndef DCCELLCODESCRIPTTREEVIEWWIDGET_H
+#define DCCELLCODESCRIPTTREEVIEWWIDGET_H
+
+#include <QTreeView>
+#include <QWidget>
+#include <QUndoCommand>
+
+class DCCreator;
+class DCQtItemModel;
+
+class DCCellCodeScriptTreeViewWidget : public QTreeView
+{
+ Q_OBJECT
+ DCQtItemModel *d_model;
+ DCCreator *d_creator;
+
+ void rebuildModel();
+ QModelIndex childNode(const QString& nodeName, const QModelIndex& currentIndex, bool createWhenNotExist = true);
+ void selectPath(const QString path);
+
+public:
+ DCCellCodeScriptTreeViewWidget(QWidget *parent, DCCreator *creator);
+ ~DCCellCodeScriptTreeViewWidget();
+
+protected:
+ virtual void mouseDoubleClickEvent(QMouseEvent *event);
+
+signals:
+
+public slots:
+ void contentRootPathChanged(const void *requester, QString rootPath);
+ void creatorDestroyed();
+ void commandExecuted(const QUndoCommand*);
+ void doContextMenu(const QPoint&);
+};
+
+#endif // DCCELLCODESCRIPTTREEVIEWWIDGET_H
#include <QVBoxLayout>
#include <QLabel>
-#include "dccreator.h"
#include "dccontainer.h"
#include "dccodeeditor.h"
#include "dccell.h"
disconnect(d_cell, 0, this, 0);
}
this->disconnect();
-
- QList<QProcess*>::iterator it = d_processes.begin();
- while (it != d_processes.end())
- {
- delete (*it);
- it = d_processes.erase(it);
- }
}
//slot
}
else
{
- if (openExternalEditor(d_cell->getWorkFilePathForCustomScript()))
+ if (MainWindow::openExternalEditorFor(d_cell->getWorkFilePathForCustomScript()))
{
saveCustomScriptOnlyToFile(true);
d_customScriptExternalMode = true;
else
{
DCCellCode *cellCode = d_cell->getCellCode();
- if (openExternalEditor(cellCode->getWorkFilePathForCellCodeScript()))
+ if (MainWindow::openExternalEditorFor(cellCode->getWorkFilePathForCellCodeScript()))
{
saveCellCodeScriptOnlyToFile(true);
d_cellCodeScriptExternalMode = true;
}
}
-bool DCCellScriptsEditorPageWidget::openExternalEditor(const QString& path)
-{
- QString editorPath = MainWindow::readSettingsForExternalScriptEditorPath();
- if (editorPath.isEmpty() || editorPath.length() == 0)
- {
- DCCodeEditorExternalEditorSettingDialog dialog;
- dialog.exec();
- editorPath = MainWindow::readSettingsForExternalScriptEditorPath();
- }
- if (editorPath.isEmpty() || editorPath.length() == 0)
- return false;
-
- QString parameterOrg = MainWindow::readSettingsForExternalScriptEditorParameters();
- QString parameter = "";
- int i = 0;
- int j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
- while (j >= 0)
- {
- parameter += parameterOrg.mid(i, j-i);
- parameter += path;
- i = j + 2;
- if (i > parameterOrg.length())
- break;
- j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
- }
- if (i < parameterOrg.length())
- parameter += parameterOrg.mid(i);
-
- QList<QProcess*>::iterator it = d_processes.begin();
- while (it != d_processes.end())
- {
- if ((*it)->state() != QProcess::Running)
- {
- delete (*it);
- it = d_processes.erase(it);
- }
- else
- ++it;
- }
- QProcess *newProcess = new QProcess;
- newProcess->start("\"" + editorPath + "\" " + parameter);
-
- d_processes.append(newProcess);
-
- return true;
-}
-
bool DCCellScriptsEditorPageWidget::getIsModified() const
{
return d_modified;
#include <QWidget>
#include <QSplitter>
#include <QPushButton>
-#include <QProcess>
#include "dceditscriptfolder.h"
QPushButton *d_cellCodeScriptEditExternalButton;
bool d_customScriptExternalMode;
bool d_cellCodeScriptExternalMode;
- QList<QProcess*> d_processes;
bool loadCustomScript(bool forceReload = false);
bool loadCellCodeScript(bool forceReload = false);
bool loadScripts();
void updateModifiedStatus();
- bool openExternalEditor(const QString& path);
public:
DCCellScriptsEditorPageWidget(DCCell *targetCell, QWidget *parent = 0);
DCCommandUtil::postRemoveCellCommand(requester, this, container, cell);
}
+void DCCreator::doCommandRemoveCellCode(const void *requester, DCContainer *container, DCCellCode *cellCode)
+{
+ DCCommandUtil::postRemoveCellCodeCommand(requester, this, container, cellCode);
+}
+
void DCCreator::doCommandAddPage(const void *requester, const QString &containerBasedPath)
{
DCCommandUtil::postAddPageCommand(requester, this, containerBasedPath);
void doCommandRenameCell(const void *requester, DCCell *cell, const QString& newContainerBasedPath, const QString& newName);
void doCommandChangeCellType(const void *requester, DCCell *cell, const QString& newType);
void doCommandRemoveCell(const void *requester, DCContainer *container, DCCell* cell);
+ void doCommandRemoveCellCode(const void *requester, DCContainer *container, DCCellCode* cellCode);
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);
QT += core gui xml opengl sql webkit network
-INCLUDEPATH += engine/layer1 engine/layer2 visualizer visualizer/component visualizer/toolwindow visualizer/component/shape treeview codeeditor receptoreditor axoneditor axonterminaleditor
+INCLUDEPATH += engine/layer1 engine/layer2 visualizer visualizer/component visualizer/toolwindow visualizer/component/shape treeview codeeditor receptoreditor axoneditor axonterminaleditor cellcodescripttreeview
HEADERS = mainwindow.h \
visualizer/dcscene.h \
engine/versioninfo.h \
codeeditor/dceditscriptfolder.h \
codeeditor/dccodeeditorscriptmanager.h \
- dialog/dccodeeditorexternaleditorsettingdialog.h
+ dialog/dccodeeditorexternaleditorsettingdialog.h \
+ cellcodescripttreeview/dccellcodescripttreeviewwidget.h
SOURCES = main.cpp \
mainwindow.cpp \
dialog/dcmanagecellcodedialog.cpp \
codeeditor/dceditscriptfolder.cpp \
codeeditor/dccodeeditorscriptmanager.cpp \
- dialog/dccodeeditorexternaleditorsettingdialog.cpp
+ dialog/dccodeeditorexternaleditorsettingdialog.cpp \
+ cellcodescripttreeview/dccellcodescripttreeviewwidget.cpp
RESOURCES = denncoCreator.qrc
<file alias="pageIcon.png">images/page.png</file>
<file alias="folderIcon.png">images/folder.png</file>
<file>images/playbutton.png</file>
+ <file alias="docIcon.png">images/docIcon.png</file>
</qresource>
</RCC>
#include "dccontent.h"
#include "dcglvisualizerwidget.h"
#include "dctreeviewwidget.h"
+#include "dccellcodescripttreeviewwidget.h"
#include "TKConsole.h"
#include "utils/dcresources.h"
#include "utils/dcskeltoncreatorutil.h"
d_treeViewWidget = new DCTreeViewWidget(this, d_creator);
ui->treeViewDock->layout()->addWidget(d_treeViewWidget);
+ d_cellCodeScriptTreeViewWidget = new DCCellCodeScriptTreeViewWidget(this, d_creator);
+ ui->cellCodeScriptTreeViewDock->layout()->addWidget(d_cellCodeScriptTreeViewWidget);
+
DCCellScriptsEditorWindow::construct(d_creator);
setCurrentContent("");
setUnifiedTitleAndToolBarOnMac(true);
+
+ tabifyDockWidget(ui->dock2,ui->dock1);
}
MainWindow::~MainWindow()
DCManageCellCodeDialog dialog(d_creator, NULL, this);
dialog.exec();
}
+
+
+//static
+bool MainWindow::openExternalEditorFor(const QString &path)
+{
+ static QList<QProcess*> s_processes;
+ static QMutex s_mutex;
+
+ QMutexLocker locker(&s_mutex);
+
+ QString editorPath = readSettingsForExternalScriptEditorPath();
+ if (editorPath.isEmpty() || editorPath.length() == 0)
+ {
+ DCCodeEditorExternalEditorSettingDialog dialog;
+ dialog.exec();
+ editorPath = readSettingsForExternalScriptEditorPath();
+ }
+ if (editorPath.isEmpty() || editorPath.length() == 0)
+ return false;
+
+ QString parameterOrg = readSettingsForExternalScriptEditorParameters();
+ QString parameter = "";
+ int i = 0;
+ int j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
+ while (j >= 0)
+ {
+ parameter += parameterOrg.mid(i, j-i);
+ parameter += path;
+ i = j + 2;
+ if (i > parameterOrg.length())
+ break;
+ j = parameterOrg.indexOf(QRegExp("%F[ \t\"']|%F$"),i);
+ }
+ if (i < parameterOrg.length())
+ parameter += parameterOrg.mid(i);
+
+ QList<QProcess*>::iterator it = s_processes.begin();
+ while (it != s_processes.end())
+ {
+ if ((*it)->state() != QProcess::Running)
+ {
+ delete (*it);
+ it = s_processes.erase(it);
+ }
+ else
+ ++it;
+ }
+ QProcess *newProcess = new QProcess;
+ newProcess->start("\"" + editorPath + "\" " + parameter);
+
+ s_processes.append(newProcess);
+
+ return true;
+}
class DCCreator;
class DCGLVisualizerWidget;
class DCTreeViewWidget;
+class DCCellCodeScriptTreeViewWidget;
class MainWindow : public QMainWindow
{
static QString readSettingsForExternalScriptEditorParameters();
static void writeSettingsForExternalScriptEditorPath(const QString& arg);
static void writeSettingsForExternalScriptEditorParameters(const QString& arg);
+ static bool openExternalEditorFor(const QString& path);
protected:
void closeEvent(QCloseEvent *event);
Ui::MainWindow *ui;
- DCCreator *d_creator;
- DCGLVisualizerWidget *d_visualizerWidget;
- DCTreeViewWidget *d_treeViewWidget;
- QProcess d_player;
- QString d_IPCServerName;
- QStringList d_contentOpenHistory;
+ DCCreator *d_creator;
+ DCGLVisualizerWidget *d_visualizerWidget;
+ DCTreeViewWidget *d_treeViewWidget;
+ DCCellCodeScriptTreeViewWidget *d_cellCodeScriptTreeViewWidget;
+ QProcess d_player;
+ QString d_IPCServerName;
+ QStringList d_contentOpenHistory;
};
#endif // MAINWINDOW_H
<layout class="QHBoxLayout" name="horizontalLayout"/>
</widget>
</widget>
+ <widget class="QDockWidget" name="dock2">
+ <property name="features">
+ <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
+ </property>
+ <property name="windowTitle">
+ <string>Cell Code Scripts</string>
+ </property>
+ <attribute name="dockWidgetArea">
+ <number>1</number>
+ </attribute>
+ <widget class="QWidget" name="cellCodeScriptTreeViewDock">
+ <layout class="QHBoxLayout" name="horizontalLayout_2"/>
+ </widget>
+ </widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
}
//static
+void DCCommandUtil::postRemoveCellCodeCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCellCode* cellCode)
+{
+ postEvent(creator, new DCRemoveCellCodeClassCommand(requester, creator, container, cellCode));
+}
+
+//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 postRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString& newContainerBasedPath, const QString& newName);
static void postChangeCellTypeCommand(const void* requester, DCCreator *creator, DCCell *cell, const QString& newType);
static void postRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCell *cells);
+ static void postRemoveCellCodeCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCellCode *cells);
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);
{
}
+DCQtItemModelItem::DCQtItemModelItem(const QStringList &headers, DCQtItemModelItem *parent)
+ :mParentItem(parent)
+{
+ QVector<QVariant> rootData;
+ foreach (QString header, headers)
+ {
+ rootData << header;
+ }
+ mItemData = rootData;
+}
+
+
DCQtItemModelItem::~DCQtItemModelItem()
{
qDeleteAll(mChildItems);
-DCQtItemModel::DCQtItemModel(const QStringList &headers, QObject *parent)
+DCQtItemModel::DCQtItemModel(const QStringList &headers, DCQtItemModelItem *rootItem, QObject *parent)
: QAbstractItemModel(parent)
{
QVector<QVariant> rootData;
mReadOnlyAttrib.push_back(true);
}
- mRootItem = new DCQtItemModelItem(rootData);
+ if (rootItem)
+ mRootItem = rootItem;
+ else
+ mRootItem = new DCQtItemModelItem(rootData);
}
DCQtItemModel::~DCQtItemModel()
{
public:
DCQtItemModelItem(const QVector<QVariant> &data, DCQtItemModelItem *parent = 0);
+ DCQtItemModelItem(const QStringList &headers, DCQtItemModelItem *parent = 0);
virtual ~DCQtItemModelItem();
DCQtItemModelItem *child(int number);
int childCount() const;
int columnCount() const;
- QVariant data(int column) const;
- bool insertChildren(int position, int count, int columns);
- bool insertColumns(int position, int columns);
- DCQtItemModelItem *parent();
- bool removeChildren(int position, int count);
- bool removeColumns(int position, int columns);
+ virtual QVariant data(int column) const;
+ virtual bool insertChildren(int position, int count, int columns);
+ virtual bool insertColumns(int position, int columns);
+ virtual DCQtItemModelItem *parent();
+ virtual bool removeChildren(int position, int count);
+ virtual bool removeColumns(int position, int columns);
int childNumber() const;
- bool setData(int column, const QVariant &value);
+ virtual bool setData(int column, const QVariant &value);
-private:
+protected:
QList<DCQtItemModelItem*> mChildItems;
QVector<QVariant> mItemData;
DCQtItemModelItem *mParentItem;
{
Q_OBJECT
public:
- DCQtItemModel(const QStringList &headers, QObject *parent = 0);
+ DCQtItemModel(const QStringList &headers, DCQtItemModelItem *rootItem = 0, QObject *parent = 0);
virtual ~DCQtItemModel();
QVariant data(const QModelIndex &index, int role) const;