OSDN Git Service

[denncoCreator] Implemented dialog window to show engine's error messages for initial...
authortkawata <tkawata@users.sourceforge.jp>
Sun, 21 Oct 2012 13:55:57 +0000 (22:55 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Sun, 21 Oct 2012 13:55:57 +0000 (22:55 +0900)
Source/dcconsole.cpp [new file with mode: 0644]
Source/dcconsole.h [new file with mode: 0644]
Source/dccreator.cpp
Source/dccreator.h
Source/denncoCreator.pro

diff --git a/Source/dcconsole.cpp b/Source/dcconsole.cpp
new file mode 100644 (file)
index 0000000..a958b16
--- /dev/null
@@ -0,0 +1,61 @@
+//  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-21, 2012.
+//
+#include "dcconsole.h"
+
+DCConsole::DCConsole() : d_size(100)
+{
+}
+
+void DCConsole::vprintf(TKLog::MessageType type, const char *fmt, va_list ap)
+{
+    (type);
+    QString msg = QString().vsprintf(fmt,ap);
+
+    d_queue.append(msg);
+    while (d_queue.size() > d_size)
+    {
+        d_queue.dequeue();
+    }
+#ifdef DEBUG
+    qDebug() << msg << endl;
+#endif
+}
+
+QString DCConsole::getLog(int n) const
+{
+    if (n < 1)
+    {
+        n = d_queue.size();
+    }
+
+    QString message = "";
+    int p = d_queue.size() - n;
+    if (p < 0) p = 0;
+    for (int i = d_queue.size() - 1; i >= p; i--)
+    {
+        message.append(d_queue.at(i));
+        message.append("\n");
+    }
+    return message;
+}
+
+void DCConsole::clearLog()
+{
+    d_queue.clear();
+}
diff --git a/Source/dcconsole.h b/Source/dcconsole.h
new file mode 100644 (file)
index 0000000..2fa0002
--- /dev/null
@@ -0,0 +1,39 @@
+//  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-21, 2012.
+//
+#ifndef DCCONSOLE_H
+#define DCCONSOLE_H
+
+#include "TKConsole.h"
+
+#include <QQueue>
+#include <QString>
+
+class DCConsole : public TKConsole
+{
+    QQueue<QString> d_queue;
+    int             d_size;
+
+public:
+    DCConsole();
+    virtual void vprintf(TKLog::MessageType type, const char *fmt, va_list arg);
+    QString getLog(int n = 0) const;
+    void    clearLog();
+};
+
+#endif // DCCONSOLE_H
index e8c8ec9..25f47f0 100644 (file)
@@ -17,6 +17,8 @@
 //  Created by tkawata on Sep-30, 2012.
 //
 #include "TKLog.h"
+#include "DNGlobal.h"
+#include "dcconsole.h"
 
 #include "dccreator.h"
 
@@ -47,6 +49,9 @@ DCCreator::DCCreator(QMainWindow *mainwindow)
 {
     d_undoStack = new QUndoStack(this);
     d_cellCodeEditor = new DCToolWindowCellCodeEditor(this);
+
+    d_console = new DCConsole;
+    TKLog::setDestination(d_console);
 }
 
 DCCreator::~DCCreator()
@@ -55,6 +60,10 @@ DCCreator::~DCCreator()
     {
         delete d_vcontent;
     }
+    if (d_console)
+    {
+        delete d_console;
+    }
 }
 
 bool DCCreator::event(QEvent *event)
@@ -95,6 +104,8 @@ void DCCreator::initMode()
 
 bool DCCreator::loadContent(const QString &contentRoot)
 {
+    d_console->clearLog();
+
     d_contentRootPath = contentRoot;
     if (d_vcontent)
     {
@@ -132,6 +143,13 @@ bool DCCreator::loadContent(const QString &contentRoot)
     {
         d_scene = NULL;
         emit sceneChanged(this, NULL);
+
+        if (!dnGlobal()->isErrorStatusNormal())
+        {
+            QMessageBox msgBox(QMessageBox::Warning, QString::fromStdString(dnGlobal()->getMessage1()), QString::fromStdString(dnGlobal()->getMessage2()));
+            msgBox.setInformativeText(d_console->getLog(10));
+            msgBox.exec();
+        }
         return false;
     }
 }
index f49ba43..49f54ca 100644 (file)
@@ -31,6 +31,7 @@ class DCVComponent;
 class DCContainer;
 class DCCommand;
 class DCToolWindowCellCodeEditor;
+class DCConsole;
 
 #include <QtGUI>
 
@@ -49,6 +50,7 @@ private:
     QString             d_contentRootPath;
 
     QUndoStack          *d_undoStack;
+    DCConsole           *d_console;
 
     DCToolWindowCellCodeEditor  *d_cellCodeEditor;
 
index 2b9263a..7f735f6 100644 (file)
@@ -93,7 +93,8 @@ HEADERS       = mainwindow.h \
     visualizer/toolwindow/dccellcodetypecombobox.h \
     dialog/dcrenamecelldialog.h \
     uieditor/dcuieditor.h \
-    uieditor/dcuitexteditor.h
+    uieditor/dcuitexteditor.h \
+    dcconsole.h
 
 SOURCES       = main.cpp \
                 mainwindow.cpp \
@@ -181,7 +182,8 @@ SOURCES       = main.cpp \
     visualizer/toolwindow/dccellcodetypecombobox.cpp \
     dialog/dcrenamecelldialog.cpp \
     uieditor/dcuieditor.cpp \
-    uieditor/dcuitexteditor.cpp
+    uieditor/dcuitexteditor.cpp \
+    dcconsole.cpp
 
 RESOURCES     = denncoCreator.qrc