]> gitweb.hamatoma.de Git - reqt/commitdiff
ReFileSystem
authorhama <hama@siduction.net>
Mon, 14 Sep 2015 22:20:52 +0000 (00:20 +0200)
committerhama <hama@siduction.net>
Mon, 14 Sep 2015 22:20:52 +0000 (00:20 +0200)
14 files changed:
appl/reide/mainwindow.cpp
appl/reide/mainwindow.hpp
appl/reide/reide.pro
appl/reidos/idosmain.cpp [new file with mode: 0644]
appl/reidos/idosmain.hpp [new file with mode: 0644]
appl/reidos/idosmain.ui [new file with mode: 0644]
appl/reidos/main.cpp [new file with mode: 0644]
appl/reidos/reidos.pro [new file with mode: 0644]
base/rebase.hpp
gui/ReSettings.cpp
gui/ReSettings.hpp
os/ReFileSystem.cpp [new file with mode: 0644]
os/ReFileSystem.hpp [new file with mode: 0644]
os/reos.hpp

index 0d8aca259581d6ac23ef01689a2a19fd6b169287..9ec5186f310b900cb253d31bd65e372a2390ba47 100644 (file)
@@ -20,7 +20,8 @@ MainWindow::MainWindow(const char* workspace, const char* project,
                m_logger(logger),
                m_perspectives(this),
                m_timerRuns(false),
-               m_timer(this){
+               m_timer(this),
+       m_delayedStorage(NULL){
        setLayout(new QVBoxLayout);
        if (workspace == NULL)
                workspace = QDir::homePath().toUtf8();
@@ -52,6 +53,7 @@ MainWindow::MainWindow(const char* workspace, const char* project,
        m_perspectives.addPerspective(mainPerspective);
        m_perspectives.change(mainPerspective->name());
        m_perspectives.addPerspective(new ProjectPerspective(proj, this));
+       m_delayedStorage = new ReDelayedStorage(m_workspace->historyFile())
 }
 
 /**
@@ -61,13 +63,10 @@ MainWindow::MainWindow(const char* workspace, const char* project,
  */
 void MainWindow::geometryChanged(int value){
        ReUseParameter(value);
-       if (! m_timer.isActive()){
-               m_timer.start(5000);
-       }
+       m_delayedStorage->storeWindow(this);
 }
 
 void MainWindow::timeout(){
-       ReSettings
 }
 
 /**
index 2254719180e4f02ba5d5b8275c2eb4f4adbf5031..3a3c43ab6d8345b950adaf54bb9b51cdce1c9b82 100644 (file)
@@ -34,12 +34,15 @@ public:
 public slots:
        void open();
        void geometryChanged(int value);
+protected slots:
+       void timeout();
 private:
        Workspace* m_workspace;
        ReLogger* m_logger;
        PerspectiveList m_perspectives;
        bool m_timerRuns;
        QTimer m_timer;
+       ReDelayedStorage* m_delayedStorage;
 };
 
 #endif // MAINWINDOW_HPP
index b1691246888b17b45e68a904b165fe8d70385a9f..2c280340ff2bf35bb6f55292c1ce3bed185df2ea 100644 (file)
@@ -10,7 +10,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
 TARGET = ReEditor
 TEMPLATE = app
-
+PRECOMPILED_HEADER = base/rebase.hpp
 INCLUDEPATH += ../..
 
 SOURCES += \
@@ -43,6 +43,8 @@ HEADERS  += mainwindow.hpp \
         ../../base/rebase.hpp \
         ../../gui/regui.hpp \
         ../../gui/ReEdit.hpp \
+        ../../gui/ReStateStorage.hpp \
+        ../../gui/ReSettings.hpp \
        ../../base/ReStringUtils.hpp \
        ../../base/ReQStringUtils.hpp \
        ../../base/ReException.hpp \
diff --git a/appl/reidos/idosmain.cpp b/appl/reidos/idosmain.cpp
new file mode 100644 (file)
index 0000000..e2a4e6e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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 "idosmain.hpp"
+#include "ui_idosmain.h"
+
+IDosMain::IDosMain(QWidget *parent) :
+       QMainWindow(parent),
+       ui(new Ui::IDosMain)
+{
+       ui->setupUi(this);
+}
+
+IDosMain::~IDosMain()
+{
+       delete ui;
+}
diff --git a/appl/reidos/idosmain.hpp b/appl/reidos/idosmain.hpp
new file mode 100644 (file)
index 0000000..769371f
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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 IDOSMAIN_HPP
+#define IDOSMAIN_HPP
+
+#include <QMainWindow>
+
+namespace Ui {
+class IDosMain;
+}
+
+class IDosMain : public QMainWindow
+{
+       Q_OBJECT
+
+public:
+       explicit IDosMain(QWidget *parent = 0);
+       ~IDosMain();
+
+private:
+       Ui::IDosMain *ui;
+};
+
+#endif // IDOSMAIN_HPP
diff --git a/appl/reidos/idosmain.ui b/appl/reidos/idosmain.ui
new file mode 100644 (file)
index 0000000..6054c6c
--- /dev/null
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>IDosMain</class>
+ <widget class="QMainWindow" name="IDosMain">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>787</width>
+    <height>590</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>IDosMain</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="">
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <item>
+           <widget class="QComboBox" name="comboBoxPathTop">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonHistoryTop">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonUpTop">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonRootTop">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <widget class="QTableWidget" name="tableWidgetTop">
+          <attribute name="horizontalHeaderStretchLastSection">
+           <bool>true</bool>
+          </attribute>
+          <column>
+           <property name="text">
+            <string>Type</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Size</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Modified</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Attributes</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Name</string>
+           </property>
+          </column>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="layoutWidget">
+       <layout class="QVBoxLayout" name="verticalLayout_2">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <widget class="QComboBox" name="comboBoxPathBottom">
+            <property name="editable">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonHistoryBottom">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonUpBottom">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QToolButton" name="toolButtonRootBottom">
+            <property name="text">
+             <string>...</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <widget class="QTableWidget" name="tableWidgetTop_2">
+          <attribute name="horizontalHeaderStretchLastSection">
+           <bool>true</bool>
+          </attribute>
+          <column>
+           <property name="text">
+            <string>Type</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Size</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Modified</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Attributes</string>
+           </property>
+          </column>
+          <column>
+           <property name="text">
+            <string>Name</string>
+           </property>
+          </column>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>787</width>
+     <height>35</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>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/appl/reidos/main.cpp b/appl/reidos/main.cpp
new file mode 100644 (file)
index 0000000..83d2a71
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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 "idosmain.hpp"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+       QApplication a(argc, argv);
+       IDosMain w;
+       w.show();
+
+       return a.exec();
+}
diff --git a/appl/reidos/reidos.pro b/appl/reidos/reidos.pro
new file mode 100644 (file)
index 0000000..15e7855
--- /dev/null
@@ -0,0 +1,41 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2015-09-14T18:00:57
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = reidos
+TEMPLATE = app
+
+INCLUDEPATH += . ../..
+
+SOURCES += main.cpp\
+        ../../gui/ReEdit.cpp \
+        ../../gui/ReStateStorage.cpp \
+        ../../gui/ReSettings.cpp \
+        ../../gui/ReFileTree.cpp \
+        ../../base/ReFile.cpp \
+        ../../os/ReFileSystem.cpp \
+       ../../base/ReLogger.cpp \
+       ../../base/ReQStringUtils.cpp \
+       ../../base/ReFileUtils.cpp \
+       ../../base/ReException.cpp \
+       idosmain.cpp \
+       main.cpp
+
+HEADERS  +=  ../../base/rebase.hpp \
+        ../../gui/regui.hpp \
+        ../../gui/ReEdit.hpp \
+        ../../gui/ReStateStorage.hpp \
+        ../../gui/ReSettings.hpp \
+       ../../base/ReStringUtils.hpp \
+       ../../base/ReQStringUtils.hpp \
+       ../../base/ReException.hpp \
+       ../../os/reos.hpp \
+       idosmain.hpp
+
+FORMS    += idosmain.ui
index d79125f272178033c9b128c8a7dd278a563b45c5..4894bf12b5beaa50a1c011dbc542e7f1bf3bb68d 100644 (file)
 #include <QTranslator>
 #include <QDateTime>
 #include <QDir>
+#include <QTimer>
+#include <QWidget>
+#include <QMainWindow>
+#include <QComboBox>
+#include <QComboBox>
+
 typedef unsigned char uint8_t;
 #if !defined __linux__
 typedef qint64 int64_t;
index db352a636a563246b70a419516742d8de2e1d367..c8a10e16ec495e42f44de5a5f55278df620577b0 100644 (file)
@@ -206,6 +206,15 @@ void ReSettings::changeValue(const char* name, const QString& value) {
                property->m_value = value;
 }
 
+/**
+ * Returns the name of the history file.
+ * @return     the full name of the history file
+ */
+const QString& ReSettings::fileHistory() const
+{
+       return m_fileHistory;
+}
+
 /**
  * Returns a history item as a list.
  *
@@ -396,30 +405,23 @@ void ReSettings::writeSettings() {
  *
  * @param delay        time between first change of setting and storage in seconds
  */
-ReDelayedStorage::ReDelayedStorage(const QString& file, int delay) :
+ReDelayedStorage::ReDelayedStorage(const QString& file, ReLogger* logger,
+                                                                  int delay) :
        m_timer(NULL),
        m_list(),
        m_delay(delay),
-       m_file(file){
+       m_file(file),
+       m_logger(logger){
        m_timer.setSingleShot(true);
-       QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
+       connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
 }
 
 /**
- * Tests whether a given widget is in the internal list.
- *
- * @param widget       the widget to search
- * @return                     <code>true</code>: the widget is in the list
+ * Destructor.
  */
-bool ReDelayedStorage::contains(const QWidget* widget){
-       QList<ObjInfo*>::const_iterator;
-       bool rc = false;
-       for (it = m_list.cbegin(); ! rc && it != m_list.cend(); ++it){
-               ObjInfo* info = *it;
-               if (info->m_widget == widget)
-                       rc = true;
-       }
-       return rc;
+ReDelayedStorage::~ReDelayedStorage()
+{
+
 }
 
 /**
@@ -429,7 +431,7 @@ bool ReDelayedStorage::contains(const QWidget* widget){
  * @return                     -1: not found<br>
  *                                     otherwise: the index in <code>m_list</code>
  */
-QWidget*ReDelayedStorage::indexOf(const QWidget* widget)
+int ReDelayedStorage::indexOf(const QWidget* widget) const
 {
        int rc = -1;
        for (int ix = 0; rc < 0 && ix < m_list.size(); ix++)
@@ -443,16 +445,16 @@ QWidget*ReDelayedStorage::indexOf(const QWidget* widget)
  *
  * @param window       the window to store
  */
-void ReDelayedStorage::storeWindow(QMainWindow* window)
+void ReDelayedStorage::storeWindow(const QMainWindow* window)
 {
        int ix = indexOf(window);
        if (ix < 0){
                ObjInfo* info = new ObjInfo;
                info->m_type = OT_WINDOW;
-               info->m_widget = widget;
+               info->m_widget = window;
                m_list.append(info);
                if (! m_timer.isActive()){
-                       timer.start(m_delay*1000);
+                       m_timer.start(m_delay*1000);
                }
        }
 }
@@ -462,7 +464,7 @@ void ReDelayedStorage::storeWindow(QMainWindow* window)
  */
 void ReDelayedStorage::timeout()
 {
-       ReStateStorage storage(m_file);
+       ReStateStorage storage(m_file, m_logger);
        storage.initForRead();
        for (int ix = 0; ix < m_list.size(); ix++){
                ObjInfo* info = m_list.at(ix);
index 9e1efa0ef53461871d3f76b01122ab2319b35922..526e50d03b0023ca115950c5e12564db9f01a9b5 100644 (file)
 
 #ifndef STORAGE_HPP
 #define STORAGE_HPP
-#include <QTimer>
+#ifndef REBASE_HPP
+#include "base/rebase.hpp"
+#endif
+
 enum RePropertyType {
        PT_UNDEF,
        PT_INT,
@@ -35,8 +38,9 @@ public:
        RePropertyType m_type;
        const char* m_limits;
 };
-
-class ReDelayedStorage{
+class ReLogger;
+class QMainWindow;
+class ReDelayedStorage : protected QObject{
        Q_OBJECT
        enum ObjType {
                OT_UNDEF,
@@ -47,18 +51,20 @@ class ReDelayedStorage{
                const QWidget* m_widget;
        } ObjInfo;
 public:
-       ReDelayedStorage(const QString& file, int delay = 5);
+       ReDelayedStorage(const QString& file, ReLogger* m_logger, int delay = 5);
+       virtual ~ReDelayedStorage();
 public:
        void storeWindow(const QMainWindow* window);
 public:
        void timeout();
 private:
-       int indexOf(const QWidget* widget);
+       int indexOf(const QWidget* widget) const;
 private:
        QTimer m_timer;
        QList<ObjInfo*> m_list;
        int m_delay;
        QString m_file;
+       ReLogger* m_logger;
 };
 
 class ReSettings {
@@ -72,6 +78,7 @@ public:
                int maxEntries);
        bool boolValue(const char* name);
        void changeValue(const char* name, const QString& value);
+       const QString& fileHistory() const;
        QStringList& historyAsList(const char* key, QStringList& list,
                const char* form = NULL);
        void insertProperty(ReProperty* property);
@@ -83,6 +90,7 @@ public:
        QString topOfHistory(const char* key, const QString& defaultValue = "");
        void writeSettings();
 
+
 protected:
        QString m_prefix;
        QString m_path;
diff --git a/os/ReFileSystem.cpp b/os/ReFileSystem.cpp
new file mode 100644 (file)
index 0000000..2d9e14b
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * ReTraverser.cpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+
+#include "base/rebase.hpp"
+#include "os/reos.hpp"
+
+
+/**
+ * Constructor.
+ *
+ * @param name the name of the filesystem
+ */
+ReFileSystem::ReFileSystem(const QString& name) :
+       m_name(name), m_writeable(false)
+{
+
+}
+
+/**
+ * Destructor.
+ */
+ReFileSystem::~ReFileSystem()
+{
+
+}
+
+bool ReFileSystem::getWriteable() const
+{
+       return m_writeable;
+}
+
+void ReFileSystem::setWriteable(bool writeable)
+{
+       m_writeable = writeable;
+}
+
+/**
+ * Constructor.
+ */
+ReLinuxFS::ReLinuxFS(const QString& basePath) :
+       m_path(basePath),
+       m_currentPath(basePath),
+       m_dir(basePath)
+{
+
+}
+
+/**
+ * Changes the current directory of the filesystem.
+ *
+ * @param path the new current directory
+ * @return             0: success<br>
+ *                             EC_PATH_NOT_FOUND       directory does not exist<br>
+ *                             EC_NOT_ACCESSIBLE       parent not readable
+ */
+ReFileSystem::ErrorCode ReLinuxFS::setDirectory(const QString& path)
+{
+       ErrorCode rc = m_dir.setCurrent(path) ? EC_SUCCESS : EC_PATH_NOT_FOUND;
+       m_currentPath = m_dir.absolutePath();
+       return rc;
+}
+
+/**
+ * Returns the name of the current directory.
+ *
+ * @return     the name of the current directory
+ */
+const QString&ReLinuxFS::directory() const
+{
+       return m_currentDir;
+}
+
+/**
+ * Returns a list of the file infos of the current directory.
+ *
+ * @param patterns     only files matching these patterns will be in the result.
+ *                                     Can contain wildcard '*' (for any string)
+ * @return                     a list of the files matching the patterns
+ */
+QList<ReFileMetaData*> ReLinuxFS::listInfos(const QString& pattern)
+{
+       QList<ReFileMetaData*> rc;
+       m_dir.setNameFilters(patterns);
+       QFileInfoList list = m_dir.entryInfoList();
+       QFileInfoList::const_iterator it;
+       for (it = list.cbegin(); it != list.cend(); it++){
+               const QFileInfo& info = *it;
+               ReFileMetaData* meta = new ReFileMetaData(info.fileName());
+
+       }
+}
+
diff --git a/os/ReFileSystem.hpp b/os/ReFileSystem.hpp
new file mode 100644 (file)
index 0000000..4f7a51e
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * ReFileSystem.hpp
+ *
+ * License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * You also can use this license: http://www.wtfpl.net
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef OS_REFILESYSTEM_HPP_
+#define OS_REFILESYSTEM_HPP_
+
+class ReFileMetaData {
+public:
+       FileMetaData(const QString& node);
+       virtual ~FileMetaData();
+public:
+       QString m_node;
+       QDateTime m_modified;
+       QDateTime m_created;
+       int16_t m_owner;
+       int16_t m_group;
+       mode_t m_mode;
+};
+
+class ReFileSystem {
+       enum ErrorCode {
+               EC_SUCCESS,
+               EC_PATH_NOT_FOUND,
+               EC_NOT_ACCESSIBLE,
+       };
+
+public:
+       ReFileSystem(const QString& name);
+       virtual ~ReFileSystem();
+public:
+       /** Changes the current directory of the filesystem.
+        * @param path  the new current directory
+        * @return      0: success<br>
+        *                      EC_PATH_NOT_FOUND       directory does not exist<br>
+        *                      EC_NOT_ACCESSIBLE       parent not readable
+        */
+       virtual ErrorCode setDirectory(const QString& path) = 0;
+       /** Returns the name of the current directory.
+        * @return      the name of the current directory
+        */
+       virtual const QString& directory() const = 0;
+       /** Returns a list of the file infos of the current directory.
+        * @param patterns      only files matching these patterns will be in the result
+        *                                      Can contain wildcard '*' (for any string)
+        * @return                      a list of the files matching the patterns
+        */
+       virtual QList<ReFileMetaData*> listInfos(const QStringList& patterns) = 0;
+public:
+       bool getWriteable() const;
+       void setWriteable(bool writeable);
+
+protected:
+       QString m_name;
+       QString m_directory;
+       bool m_writeable;
+};
+
+class ReLinuxFS : public ReFileSystem {
+public:
+       ReLinuxFS(const QString& basePath);
+       virtual ~ReLinuxFS();
+       // ReFileSystem interface
+public:
+       ErrorCode setDirectory(const QString& path);
+       const QString& directory() const;
+       QList<ReFileMetaData*> listInfos(const QStringList& patterns);
+protected:
+       QString m_basePath;
+       QString m_currentPath;
+       QDir m_dir;
+};
+
+#endif /* OS_REFILESYSTEM_HPP_ */
index 5cbb3962bab9bcfa306338e63f64004030551dc0..f4b0fe6119cd2cf0c6b06dac4550ae2d89a08bd8 100644 (file)
@@ -44,5 +44,6 @@ inline bool operator >(const ReFileTime_t& time1, const ReFileTime_t& time2) {
 #include "os/ReDirTools.hpp"
 #include "net/renet.hpp"
 #include "os/ReRemoteDir.hpp"
+#include "os/ReFileSystem.hpp"
 
 #endif /* OS_REOS_HPP_ */