]> gitweb.hamatoma.de Git - reqt/commitdiff
start of recommand
authorhama <hama@siduction.net>
Tue, 9 Feb 2016 18:09:13 +0000 (19:09 +0100)
committerhama <hama@siduction.net>
Tue, 9 Feb 2016 18:09:13 +0000 (19:09 +0100)
13 files changed:
appl/rebackgui/mainwindow.cpp
appl/rebackgui/mainwindow.hpp
appl/rebackgui/rebackgui.pro
appl/recommand/CommandProcessor.cpp [new file with mode: 0644]
appl/recommand/CommandProcessor.hpp [new file with mode: 0644]
appl/recommand/main.cpp [new file with mode: 0644]
appl/recommand/mainwindow.cpp [new file with mode: 0644]
appl/recommand/mainwindow.hpp [new file with mode: 0644]
appl/recommand/mainwindow.ui [new file with mode: 0644]
appl/recommand/recommand.hpp [new file with mode: 0644]
appl/recommand/recommand.pro [new file with mode: 0644]
gui/ReGuiApplication.cpp
gui/ReGuiApplication.hpp

index b3bc904de2a74087d9cb83c301a1886ef46d2de9..1a2ff3c99030ce7382222d00921ca4200d0f6048 100644 (file)
@@ -517,35 +517,6 @@ void MainWindow::onUpdate(){
        saveState();
 }
 
-
-/**
- * Show a message.
- *
- * @param level                LOG_ERROR or LOG_INFO
- * @param message      the message to show
- * @return                     <code>false</code>: the message is an error message
- */
-bool MainWindow::say(ReLoggerLevel level, const QString& message)
-{
-       if (level == LOG_ERROR)
-               error(message);
-       else
-               log(message);
-       setStatusMessage(level, message);
-       return level >= LOG_INFO;
-}
-
-/**
-* Writes a text to the status line.
-*
-* @param error     <code>true</code>: the message is an error message
-* @param message   the text to set
-*/
-void MainWindow::setStatusMessage(bool error, const QString& message){
-   RE_UNUSED(error);
-  m_statusMessage->setText(message);
-}
-
 /**
  * Reads the history of the widget values and other parameters and set it.
  */
index 664e7ae2ae66de772c6cae2e2aa194f4d0152916..749ed758f6c1e46c5bf56773bdda403852c4cec3 100644 (file)
@@ -30,7 +30,6 @@ public:
    void expandFileList(const QString info);
    bool log(const QString& message);
    virtual bool say(ReLoggerLevel level, const QString& message);
-   void setStatusMessage(bool error, const QString& message);
    void startStop(bool isStart);
    void restoreState();
    void saveState();
index 8842e0c847f8ce0c54ad2236084a76e8fed4d4df..ca70619540199f881f77d2195e62c9bfa07d6a42 100644 (file)
@@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 TARGET = rebackgui
 TEMPLATE = app
-INCLUDEPATH = ../.. /usr/include/c++/4.9
+INCLUDEPATH = ../..
 
 SOURCES += main.cpp\
         ../../base/ReException.cpp \
@@ -50,5 +50,5 @@ FORMS    += mainwindow.ui \
 
 DISTFILES += \
        ReBackGui.html \
-    osconnect.pl
+       osconnect.pl
 
diff --git a/appl/recommand/CommandProcessor.cpp b/appl/recommand/CommandProcessor.cpp
new file mode 100644 (file)
index 0000000..c43ab27
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+
+/**
+ * Constructor.
+ *
+ * @param mainWindow   the GUI object
+ */
+CommandProcessor::CommandProcessor(MainWindow* mainWindow) :
+       m_mainWindow(mainWindow)
+{
+
+}
+
+void CommandProcessor::interpret(const QString& text)
+{
+
+}
diff --git a/appl/recommand/CommandProcessor.hpp b/appl/recommand/CommandProcessor.hpp
new file mode 100644 (file)
index 0000000..223466a
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef COMMANDPROCESSOR_HPP
+#define COMMANDPROCESSOR_HPP
+
+class MainWindow;
+
+class CommandProcessor
+{
+public:
+       CommandProcessor(MainWindow* mainWindow);
+public:
+       void interpret(const QString& text);
+protected:
+       MainWindow* m_mainWindow;
+};
+
+#endif // COMMANDPROCESSOR_HPP
diff --git a/appl/recommand/main.cpp b/appl/recommand/main.cpp
new file mode 100644 (file)
index 0000000..344f0aa
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+#include <QApplication>
+char** g_argv;
+int main(int argc, char *argv[]){
+   g_argv = argv;
+   QString homeDir = argc > 1 ? argv[1] : "";
+   QApplication a(argc, argv);
+   MainWindow w(homeDir);
+       w.show();
+       return a.exec();
+}
diff --git a/appl/recommand/mainwindow.cpp b/appl/recommand/mainwindow.cpp
new file mode 100644 (file)
index 0000000..68e990e
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+
+MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
+       ReGuiApplication("recommand", homeDir, 2, 100100100, parent),
+       ReGuiValidator(),
+       ui(new Ui::MainWindow),
+       m_processor(NULL)
+{
+       ui->setupUi(this);
+       initializeGuiElements();
+       connect(ui->pushButtonRun, SIGNAL(clicked()), this, SLOT(onRun()));
+       connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(onClear()));
+}
+
+MainWindow::~MainWindow()
+{
+       delete ui;
+}
+
+
+/**
+ * Clears the result field.
+ */
+void MainWindow::onClear()
+{
+       ui->textEditResult->clear();
+}
+
+/**
+ * Set GUI elements from the queue when the GUI timer is triggered.
+ */
+void MainWindow::onGuiTimerUpdate()
+{
+       int count = m_guiQueue.count();
+       while(count-- > 0){
+               m_mutexGuiQueue.lock();
+               ReGuiQueueItem item = m_guiQueue.popFront();
+               m_mutexGuiQueue.unlock();
+               if (item.m_type == ReGuiQueueItem::Undef)
+                       break;
+               if (! item.apply()){
+                       switch (item.m_type){
+                       case ReGuiQueueItem::ReadyMessage:
+                               say(LOG_INFO, item.m_value);
+                               break;
+                       case ReGuiQueueItem::LogMessage:
+                               say(LOG_INFO, item.m_value);
+                               break;
+                       case ReGuiQueueItem::LogError:
+                               say(LOG_ERROR, item.m_value);
+                               break;
+                       case ReGuiQueueItem::StatusLine:
+                               setStatusMessage(LOG_INFO, item.m_value);
+                               break;
+                       default:
+                               say(LOG_ERROR, "unknown item type: " + QString::number(item.m_type)
+                                       + " " + item.m_value);
+                               break;
+                       }
+               }
+       }
+}
+
+/**
+ * Executes the current commands.
+ */
+void MainWindow::onRun()
+{
+
+}
+
+/**
+ * Writes a message.
+ *
+ * @param level                mode of the message, e.g. LOG_ERROR
+ * @param message      the message
+ * @return                     <code>false</code>level is error or warning
+ */
+bool MainWindow::say(ReLoggerLevel level, const QString& message){
+       QString edit = ui->textEditResult->toPlainText();
+       QString msg;
+       switch(level){
+       case LOG_WARNING:
+               msg = "+++ ";
+               break;
+       case LOG_ERROR:
+               msg = "*** ";
+               break;
+       default:
+               break;
+       }
+
+       if (! edit.endsWith("\n")){
+               msg += "\n";
+       }
+       msg += message;
+       edit += msg;
+       ui->textEditResult->setText(edit);
+       return level >= LOG_INFO;
+}
+
diff --git a/appl/recommand/mainwindow.hpp b/appl/recommand/mainwindow.hpp
new file mode 100644 (file)
index 0000000..056d867
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef RECOMMAND_HPP
+#include "recommand.hpp"
+#endif
+#ifndef MAINWINDOW_HPP
+#define MAINWINDOW_HPP
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public ReGuiApplication, public ReGuiValidator
+{
+       Q_OBJECT
+
+public:
+       explicit MainWindow(const QString& homeDir, QWidget *parent = 0);
+       virtual ~MainWindow();
+
+public:
+       virtual void onGuiTimerUpdate();
+       void onRun();
+       void onClear();
+       virtual bool say(ReLoggerLevel level, const QString& message);
+
+private:
+       Ui::MainWindow *ui;
+       CommandProcessor* m_processor;
+};
+
+#endif // MAINWINDOW_HPP
diff --git a/appl/recommand/mainwindow.ui b/appl/recommand/mainwindow.ui
new file mode 100644 (file)
index 0000000..fe5a83c
--- /dev/null
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>977</width>
+    <height>624</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QVBoxLayout" name="verticalLayout_3">
+    <item>
+     <widget class="QSplitter" name="splitter">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <widget class="QWidget" name="layoutWidget">
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <item>
+           <widget class="QLabel" name="label">
+            <property name="text">
+             <string>Write command, try &quot;help;&quot;</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonRun">
+            <property name="minimumSize">
+             <size>
+              <width>125</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Run</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonSave">
+            <property name="text">
+             <string>Save</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <widget class="QTextEdit" name="textEditPad"/>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="layoutWidget">
+       <layout class="QVBoxLayout" name="verticalLayout_2">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <widget class="QLabel" name="label_2">
+            <property name="text">
+             <string>Result:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_2">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonClear">
+            <property name="text">
+             <string>Clear</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <widget class="QTextEdit" name="textEditResult"/>
+        </item>
+       </layout>
+      </widget>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>977</width>
+     <height>26</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+  <widget class="QToolBar" name="toolBar">
+   <property name="windowTitle">
+    <string>toolBar</string>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/appl/recommand/recommand.hpp b/appl/recommand/recommand.hpp
new file mode 100644 (file)
index 0000000..7ca2a86
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef RECOMMAND_HPP
+#define RECOMMAND_HPP
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "CommandProcessor.hpp"
+#include "mainwindow.hpp"
+#include "ui_mainwindow.h"
+#endif // RECOMMAND_HPP
diff --git a/appl/recommand/recommand.pro b/appl/recommand/recommand.pro
new file mode 100644 (file)
index 0000000..21da3bb
--- /dev/null
@@ -0,0 +1,37 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-02-09T13:02:50
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = recommand
+TEMPLATE = app
+INCLUDEPATH = ../..
+
+
+SOURCES += main.cpp\
+        ../../base/ReException.cpp \
+        ../../base/ReConfig.cpp \
+        ../../base/ReQStringUtils.cpp \
+        ../../base/ReFileUtils.cpp \
+        ../../base/ReMatcher.cpp \
+        ../../base/ReLogger.cpp \
+        ../../base/ReRandomizer.cpp \
+        ../../base/ReStringUtils.cpp \
+        ../../gui/ReStateStorage.cpp \
+        ../../gui/ReGuiApplication.cpp \
+        ../../gui/ReGuiValidator.cpp \
+        ../../gui/ReGuiQueue.cpp \
+       ../../gui/ReGuiUtils.cpp \
+               mainwindow.cpp \
+       CommandProcessor.cpp
+
+HEADERS  += mainwindow.hpp \
+       CommandProcessor.hpp \
+    recommand.hpp
+
+FORMS    += mainwindow.ui
index f80c676fb947009a26263350e30c7b7a50c2938b..4b38ab05163e7dd9d0562f66b9574e84f6467b77 100644 (file)
@@ -40,7 +40,7 @@ ReGuiApplication::ReGuiApplication(const char* applicationName,
        m_guiQueue(),
        m_guiTimer(new QTimer(this)),
        m_statusMessage(new QLabel(tr("Welcome!"))),
-    m_mutexGuiQueue()
+       m_mutexGuiQueue()
 {
        m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + applicationName,
                                                                   maxLogSize, maxLogFiles);
@@ -187,3 +187,23 @@ void ReGuiApplication::externalLog(const QString& message){
        m_mutexGuiQueue.unlock();
 }
 
+/**
+* Writes a text to the status line.
+*
+* @param level     level of the messge: LOG_INFO, LOG_ERROR...
+* @param message   the text to set
+*/
+void ReGuiApplication::setStatusMessage(ReLoggerLevel level, const QString& message){
+   switch(level){
+   case LOG_ERROR:
+          m_statusMessage->setText("! " + message);
+          break;
+   case LOG_WARNING:
+          m_statusMessage->setText("+ " + message);
+          break;
+       default:
+          m_statusMessage->setText(message);
+          break;
+   }
+}
+
index 2b90c39c95802a8175f96cacfc07e2fc06666758..55323195a1162f9d3e754e76ba6389778a274409 100644 (file)
@@ -37,6 +37,7 @@ public:
        ReLogger* logger();
 public:
        static QString buildHomeDir(QString homeDirBase, const QString& node);
+       void setStatusMessage(ReLoggerLevel level, const QString& message);
 protected:
        void initializeGuiElements();
 protected slots: