"<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n"
"</html>\n" ;
-DCAddPageCommand::DCAddPageCommand(const void *requester, DCCreator *creator, const QString &contentBasedPath)
- : DCCommand(requester, creator), d_path(contentBasedPath)
+DCAddPageCommand::DCAddPageCommand(const void *requester, DCCreator *creator, const QString &containerBasedPath)
+ : DCCommand(requester, creator), d_path(containerBasedPath)
{
}
{
QString d_path;
public:
- DCAddPageCommand(const void *requester, DCCreator *creator, const QString& contentBasedPathName);
+ DCAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPathName);
virtual ~DCAddPageCommand() {}
void undo();
void redo();
#include "DNFileList.h"
#include "DNDirectory.h"
+#include "utils/dcutil.h"
#include <QMutexLocker>
#include <QDir>
void DCContainer::beganBuildContainer()
{
- removeDirRecursive(d_workDirRoot);
+ DCUtil::removeDirRecursive(d_workDirRoot);
}
void DCContainer::endedBuildContainer()
return out;
}
-void DCContainer::removeDirRecursive(QString path)
-{
- QDir dir(path);
-
- QFileInfoList list = dir.entryInfoList(QDir::NoDot | QDir::NoDotDot | QDir::AllEntries);
-
- for (int i = 0; i < list.length(); i++)
- {
- QFileInfo info = list.at(i);
- if (info.isDir())
- {
- removeDirRecursive(info.absoluteFilePath());
- info.dir().rmdir(info.absoluteFilePath());
- }
- else
- {
- QFile file(info.absoluteFilePath());
- file.remove();
- }
- }
-}
class DCContainer : public TKContainer
{
- void removeDirRecursive(QString path);
-
DCContent *d_content;
DCScene *d_scene;
DCCommandUtil::postAddCellCodeClassCommand(requester, this, container, name, type);
}
-void DCCreator::doCommandAddCell(const void *requester, DCContainer *container, const QString& contentBasedPath, const QString& name, const QString& type)
+void DCCreator::doCommandAddCell(const void *requester, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type)
{
- DCCommandUtil::postAddCellCommand(requester, this, container, contentBasedPath, name, type);
+ DCCommandUtil::postAddCellCommand(requester, this, container, containerBasedPath, name, type);
}
-void DCCreator::doCommandAddPage(const void *requester, const QString &contentBasedPath)
+void DCCreator::doCommandAddPage(const void *requester, const QString &containerBasedPath)
{
- DCCommandUtil::postAddPageCommand(requester, this, contentBasedPath);
+ DCCommandUtil::postAddPageCommand(requester, this, containerBasedPath);
}
void DCCreator::doCommandAddDirectory(const void *requester, const QString &sysFilePath)
DCCommandUtil::postRemoveDirectoryCommand(requester, this, sysFilePath);
}
-bool DCCreator::doCommandRenameDirectoryImmidiate(const void *requester, const QString &contentBasedPath, const QString &oldName, const QString &newName)
+bool DCCreator::doCommandRenameDirectoryImmidiate(const void *requester, const QString &containerBasedPath, const QString &oldName, const QString &newName)
{
//TODO
QMessageBox msgBox;
void doCommandUnsetCellCodeClass(const void *requester, DCCell *cell);
void doCommandAddCellCodeClass(const void *requester, DCContainer *container, const QString& name, const QString& type);
- void doCommandAddCell(const void *requester, DCContainer *container, const QString& contentBasedPath, const QString& name, const QString& type);
- void doCommandAddPage(const void *requester, const QString& contentBasedPath);
+ void doCommandAddCell(const void *requester, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
+ void doCommandAddPage(const void *requester, const QString& containerBasedPath);
void doCommandAddDirectory(const void *requester, const QString& sysFilePath);
void doCommandRemoveDirectory(const void *requester, const QString& sysFilePath);
- bool doCommandRenameDirectoryImmidiate(const void *requester, const QString& contentBasedPath, const QString& oldName, const QString &newName);
+ bool doCommandRenameDirectoryImmidiate(const void *requester, const QString& containerBasedPath, const QString& oldName, const QString &newName);
private slots:
void slotSceneSelectedPageChanged(const void *requester);
dialog/dcaddcellcodeclassdialog.h \
dialog/dcsinglecolumntableview.h \
dialog/dcinputnewpagenamedialog.h \
- dialog/dcaddcelldialog.h
+ dialog/dcaddcelldialog.h \
+ utils/dcskeltoncreatorutil.h \
+ utils/dcutil.h
SOURCES = main.cpp \
mainwindow.cpp \
dialog/dcaddcellcodeclassdialog.cpp \
dialog/dcsinglecolumntableview.cpp \
dialog/dcinputnewpagenamedialog.cpp \
- dialog/dcaddcelldialog.cpp
+ dialog/dcaddcelldialog.cpp \
+ utils/dcskeltoncreatorutil.cpp \
+ utils/dcutil.cpp
RESOURCES = denncoCreator.qrc
#include "dctreeviewwidget.h"
#include "TKConsole.h"
#include "utils/dcresources.h"
+#include "utils/dcskeltoncreatorutil.h"
#include <QCloseEvent>
#include <QFileDialog>
event->ignore();
}
}
-//! [4]
-//! [5]
void MainWindow::newFile()
-//! [5] //! [6]
{
- if (maybeSave()) {
-// textEdit->clear();
- setCurrentContent("");
+ QString dirName = QFileDialog::getSaveFileName(this, tr("Create new content"));
+ if (!dirName.isEmpty() && DCSkeltonCreatorUtil::createNewContent(dirName))
+ {
+ loadContent(dirName);
}
}
-//! [6]
-//! [7]
void MainWindow::open()
-//! [7] //! [8]
{
if (maybeSave()) {
- QString dirName = QFileDialog::getExistingDirectory(this);
+ QString dirName = QFileDialog::getExistingDirectory(this, tr("Open a content"));
if (!dirName.isEmpty())
loadContent(dirName);
}
bool r = false;
while (index.isValid())
{
- if (index.parent().isValid()
- && model->fileName(index.parent()) == "Container"
- && index.parent().parent().isValid()
- && index.parent().parent() == model->index(model->rootPath()))
+ if (model->fileName(index) == "Container"
+ && index.parent().isValid()
+ && index.parent() == model->index(model->rootPath()))
{
r = true;
}
if (QFileInfo(oldFilePath).isDir() && IsIndexUnderContainer(this, index))
{
QString contentPath = QString::fromStdString(d_creator->getCurrentContainer()->getContentPath());
- QString contentBasedPath = "/" + QDir(contentPath).relativeFilePath(baseDirPath);
- if (d_creator->doCommandRenameDirectoryImmidiate(this, contentBasedPath, oldFileName, value.toString()))
+ QString containerBasedPath = "/" + QDir(contentPath).relativeFilePath(baseDirPath);
+ if (d_creator->doCommandRenameDirectoryImmidiate(this, containerBasedPath, oldFileName, value.toString()))
{
r = QFileSystemModel::setData(index, value, role);
if (!r)
if (showMenu)
{
QString contentPath;
- QString contentBasedPath;
+ QString containerBasedPath;
if (index.isValid())
{
contentPath = QString::fromStdString(d_creator->getCurrentContainer()->getContentPath());
- contentBasedPath = "/" + QDir(contentPath).relativeFilePath(fileModel->filePath(index));
+ containerBasedPath = "/" + QDir(contentPath).relativeFilePath(fileModel->filePath(index));
}
QAction* selectedItem = menu.exec(globalPos);
{
if (index.isValid())
{
- if (contentBasedPath.length() > 1)
+ if (containerBasedPath.length() >= 1)
{
DCInputNewPageNameDialog dialog;
if (dialog.exec())
QString pageName = dialog.getName();
if (pageName.length() > 0)
{
- QString pathName = contentBasedPath + "/" + pageName;
+ QString pathName = containerBasedPath;
+ if (containerBasedPath.length()>1)
+ pathName.append("/");
+ pathName.append(pageName);
d_creator->doCommandAddPage(this, pathName);
}
}
{
if (index.isValid())
{
- DCAddCellDialog dialog(d_creator->getCurrentContainer(), d_creator, contentBasedPath);
+ DCAddCellDialog dialog(d_creator->getCurrentContainer(), d_creator, containerBasedPath);
dialog.exec();
}
}
{
if (index.isValid())
{
- DCAddCellCodeClassDialog dialog(d_creator->getCurrentContainer(), d_creator, contentBasedPath);
+ DCAddCellCodeClassDialog dialog(d_creator->getCurrentContainer(), d_creator, containerBasedPath);
dialog.exec();
}
}
}
//static
-void DCCommandUtil::postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &contentBasedPath, const QString &name, const QString &type)
+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, contentBasedPath, name, type));
+ postEvent(creator, new DCAddCellCommand(requester, creator, container, containerBasedPath, name, type));
}
//static
-void DCCommandUtil::postAddPageCommand(const void *requester, DCCreator *creator, const QString& contentBasedPath)
+void DCCommandUtil::postAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPath)
{
- postEvent(creator, new DCAddPageCommand(requester, creator, contentBasedPath));
+ postEvent(creator, new DCAddPageCommand(requester, creator, containerBasedPath));
}
//static
static void postUnsetCellCodeClassCommand(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 postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString& contentBasedPath, const QString& name, const QString& type);
- static void postAddPageCommand(const void *requester, DCCreator *creator, const QString& contentBasedPath);
+ static void postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString& containerBasedPath, const QString& name, const QString& type);
+ static void postAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPath);
static void postAddDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysFilePath);
static void postRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString& sysFilePath);
--- /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-1, 2012.
+//
+#include "dcskeltoncreatorutil.h"
+
+#include "utils/dcutil.h"
+
+#include <QFile>
+#include <QTextStream>
+
+static QString SKELTON_PROPERTY_XML =
+ "<dennco>\n"
+ "<TickIntervalSec>1.0</TickIntervalSec>\n"
+ "<UIPath>/ui/index.html</UIPath>\n"
+ "<EnableHTTPServer>no</EnableHTTPServer>\n"
+ "<EnableSerialServer>no</EnableSerialServer>\n"
+ "</dennco>";
+
+static QString SKELTON_UI_TOP =
+ "<html>\n"
+ "<head>\n"
+ "<title></title>\n"
+ "<script type=\"text/javascript\">\n"
+ "var timerId = setInterval(\"updateOutput()\", 500);\n"
+ "function updateOutput()\n"
+ "{\n"
+ " //function for getting updated data from cells\n"
+ "}\n"
+ "\n"
+ "function stopTimer()\n"
+ "{\n"
+ " clearInterval(timerId);\n"
+ "}\n"
+ "</script>\n"
+ "</head>\n"
+ "<body onunload=\"stopTimer()\">\n"
+ "</body>\n"
+ "</html>\n";
+
+//static
+bool DCSkeltonCreatorUtil::createNewContent(const QString &contentRootPath)
+{
+ if (QFileInfo(contentRootPath).exists())
+ {
+ QMessageBox msgBox;
+ msgBox.setText(tr("ERROR! The file already exist"));
+ return false;
+ }
+
+ QDir dir;
+ if (!dir.mkdir(contentRootPath))
+ {
+ QMessageBox msgBox;
+ msgBox.setText(tr("ERROR! Failed to create a directory"));
+ return false;
+ }
+
+ QString conteinerRoot = contentRootPath + "/Container";
+ if (!dir.mkdir(conteinerRoot))
+ {
+ QMessageBox msgBox;
+ msgBox.setText(tr("ERROR! Failed to create a directory"));
+ DCUtil::removeDirRecursive(contentRootPath);
+ return false;
+ }
+
+ QFile propertyFile(contentRootPath + "/property.xml");
+ propertyFile.open(QIODevice::WriteOnly);
+ QTextStream out(&propertyFile);
+ out << SKELTON_PROPERTY_XML;
+ propertyFile.close();
+
+ QString uiRoot = contentRootPath + "/ui";
+ if (!dir.mkdir(uiRoot))
+ {
+ QMessageBox msgBox;
+ msgBox.setText(tr("ERROR! Failed to create a directory"));
+ DCUtil::removeDirRecursive(contentRootPath);
+ return false;
+ }
+
+
+ QFile uiTopPage(uiRoot + "/index.html");
+ uiTopPage.open(QIODevice::WriteOnly);
+ QTextStream out2(&uiTopPage);
+ out2 << SKELTON_UI_TOP;
+ uiTopPage.close();
+
+ return true;
+}
+
--- /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-1, 2012.
+//
+#ifndef DCSKELTONCREATORUTIL_H
+#define DCSKELTONCREATORUTIL_H
+
+#include <QtGui>
+
+class DCSkeltonCreatorUtil : public QObject
+{
+public:
+ static bool createNewContent(const QString& contentRootPath);
+
+};
+
+#endif // DCSKELTONCREATORUTIL_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-1, 2012.
+//
+#include "dcutil.h"
+
+#include <QDir>
+#include <QFileInfoList>
+
+//static
+void DCUtil::removeDirRecursive(QString path)
+{
+ QDir dir(path);
+
+ QFileInfoList list = dir.entryInfoList(QDir::NoDot | QDir::NoDotDot | QDir::AllEntries);
+
+ for (int i = 0; i < list.length(); i++)
+ {
+ QFileInfo info = list.at(i);
+ if (info.isDir())
+ {
+ removeDirRecursive(info.absoluteFilePath());
+ info.dir().rmdir(info.absoluteFilePath());
+ }
+ else
+ {
+ QFile file(info.absoluteFilePath());
+ file.remove();
+ }
+ }
+}
--- /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-1, 2012.
+//
+#ifndef DCUTIL_H
+#define DCUTIL_H
+
+#include <QString>
+
+struct DCUtil
+{
+ static void removeDirRecursive(QString path);
+};
+
+#endif // DCUTIL_H