]> gitweb.hamatoma.de Git - reqt/commitdiff
StartPerspective
authorhama <hama@siduction.net>
Sat, 5 Sep 2015 00:03:01 +0000 (02:03 +0200)
committerhama <hama@siduction.net>
Sat, 5 Sep 2015 00:03:01 +0000 (02:03 +0200)
16 files changed:
appl/reide/mainwindow.cpp
appl/reide/mainwindow.ui
appl/reide/reide.hpp
appl/reide/reide.pro
appl/reide/startwidget.ui [new file with mode: 0644]
appl/reide/views/FileTreeView.cpp
appl/reide/views/FileTreeView.hpp
appl/reide/views/ProjectPerspective.cpp
appl/reide/views/StartPerspective.cpp [new file with mode: 0644]
appl/reide/views/StartPerspective.hpp [new file with mode: 0644]
appl/reide/views/StartView.cpp [new file with mode: 0644]
appl/reide/views/StartView.hpp [new file with mode: 0644]
appl/reide/views/startview.ui [new file with mode: 0644]
base/ReDiff.cpp [new file with mode: 0644]
base/ReDiff.hpp [new file with mode: 0644]
base/rebase.hpp

index 47fb26336f6cac6c6ef5f8190e33baf06d593fbd..b4a8188e937ab091e8f34ab37829cdf7cfc826bf 100644 (file)
@@ -41,17 +41,15 @@ MainWindow::MainWindow(const char* workspace, const char* project,
                        changeProject(proj);
        }
 
-       ui->setupUi(this);
-       ReEdit* edit = ui->widget;
-#if defined __linux__
-       m_file = new ReFile("/home/hm/editor.txt", false);
-#else
-       m_file = new ReFile("U:\\ws_cpp\\rplqt\\Doxyfile", false);
-#endif
-       edit->setLines(m_file);
-       edit->setCursorLine(0);
-       connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
-       open();
+       //ui->setupUi(this);
+       //ReEdit* edit = ui->widget;
+       //edit->setLines(m_file);
+       //edit->setCursorLine(0);
+       //connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
+       Perspective* mainPerspective = new StartPerspective(this);
+       m_perspectives.addPerspective(mainPerspective);
+       m_perspectives.changePerspective(mainPerspective->name());
+       //open();
 }
 
 MainWindow::~MainWindow() {
@@ -99,9 +97,9 @@ void MainWindow::changeWorkspace(const QString& path) {
 void MainWindow::openFile(const QString& name) {
        m_file = new ReFile(name, false);
 
-       ReEdit* edit = ui->widget;
-       edit->setLines(m_file);
-       edit->setCursorLine(0);
+       //ReEdit* edit = ui->widget;
+       //edit->setLines(m_file);
+       //edit->setCursorLine(0);
        int maxEntries = m_workspace->intValue("history.max_files");
        m_workspace->addHistoryEntry(Workspace::KEY_HISTORY_FILES, name, ';',
            maxEntries);
index cad587b3197a6881be7671945ed2c97af2dc1fcb..efd52e1335fa85c563e20f0ed836f9680173c3df 100644 (file)
    <string>MainWindow</string>
   </property>
   <widget class="QWidget" name="centralWidget">
-   <layout class="QVBoxLayout" name="verticalLayout">
-    <item>
-     <widget class="ReEdit" name="widget" native="true"/>
-    </item>
-   </layout>
+   <layout class="QVBoxLayout" name="verticalLayout"/>
   </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
@@ -26,7 +22,7 @@
      <x>0</x>
      <y>0</y>
      <width>803</width>
-     <height>23</height>
+     <height>35</height>
     </rect>
    </property>
   </widget>
   </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
-  <customwidget>
-   <class>ReEdit</class>
-   <extends>QWidget</extends>
-   <header>gui/regui.hpp</header>
-   <container>1</container>
-  </customwidget>
- </customwidgets>
  <resources>
   <include location="editor.qrc"/>
  </resources>
index 182bf48c9debf53df43d8a8dddaca29727526158..bacca585d4b6bea045e8119e3aadf1bb87a737ee 100644 (file)
 #include "views/View.hpp"
 #include "views/EditorView.hpp"
 #include "views/FileTreeView.hpp"
+#include "views/StartView.hpp"
 #include "views/Perspective.hpp"
 #include "views/ProjectPerspective.hpp"
+#include "views/StartPerspective.hpp"
 #include "workspace.hpp"
 #include "project.hpp"
 #include "mainwindow.hpp"
index a8b0bc2ac79e300ae3c6e7c19acc1e737757bc98..b1691246888b17b45e68a904b165fe8d70385a9f 100644 (file)
@@ -24,16 +24,19 @@ SOURCES += \
        ../../base/ReQStringUtils.cpp \
        ../../base/ReFileUtils.cpp \
        ../../base/ReException.cpp \
+       ../../base/ReDiff.cpp \
        projectselection.cpp \
        workspace.cpp \
        project.cpp \
+       filesearch.cpp \
        views/View.cpp \
        views/FileTreeView.cpp \
        views/EditorView.cpp \
        views/Perspective.cpp \
        views/ProjectPerspective.cpp \
-       main.cpp \
-    filesearch.cpp
+       views/StartPerspective.cpp \
+       views/StartView.cpp \
+       main.cpp
 
 
 HEADERS  += mainwindow.hpp \
@@ -46,13 +49,15 @@ HEADERS  += mainwindow.hpp \
        projectselection.hpp \
        workspace.hpp \
        project.hpp \
-       storage.hpp \
        reide.hpp \
-    filesearch.hpp
+       filesearch.hpp \
+       views/StartView.hpp
 
 FORMS    += mainwindow.ui \
        projectselection.ui \
-    filesearch.ui
+       filesearch.ui \
+       startwidget.ui \
+       views/startview.ui
 
 RESOURCES += \
         editor.qrc
diff --git a/appl/reide/startwidget.ui b/appl/reide/startwidget.ui
new file mode 100644 (file)
index 0000000..5aa9469
--- /dev/null
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>startWidget</class>
+ <widget class="QWidget" name="startWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>861</width>
+    <height>445</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Start</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <widget class="QTextBrowser" name="textBrowser">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>125</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>16777215</width>
+       <height>125</height>
+      </size>
+     </property>
+     <property name="html">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Create a new file&lt;/span&gt;:&lt;br /&gt;     Insert a filename and click on &amp;quot;Create&amp;quot;. Use the 2nd &amp;quot;...&amp;quot; to choose the parent directory.&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Create a new project&lt;/span&gt;: &lt;br /&gt;        Insert a directory name  and click on &amp;quot;Create&amp;quot; &lt;/p&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="maximumSize">
+      <size>
+       <width>16777215</width>
+       <height>75</height>
+      </size>
+     </property>
+     <property name="title">
+      <string>Open/create file/project:</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_4">
+      <item>
+       <widget class="QLineEdit" name="lineEditOpen">
+        <property name="toolTip">
+         <string>Name of the file/project directory to open</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonOpen">
+        <property name="toolTip">
+         <string>Opens the file/project (Control-O)</string>
+        </property>
+        <property name="text">
+         <string>Open</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+O</string>
+        </property>
+        <property name="autoDefault">
+         <bool>false</bool>
+        </property>
+        <property name="default">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="toolButtonSelectFile">
+        <property name="toolTip">
+         <string>Selects a file wit a file open dialog box (Control-Shift-F)</string>
+        </property>
+        <property name="text">
+         <string>...</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+Shift+F</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="toolButtonSelectProject">
+        <property name="toolTip">
+         <string>Select a project directory with a directory open box (Control-Shift-P)</string>
+        </property>
+        <property name="text">
+         <string>...</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+Shift+P</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonCreate">
+        <property name="text">
+         <string>Create</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+N</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="handleWidth">
+      <number>3</number>
+     </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>Last opened files:</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="QLineEdit" name="lineEditFilterLastFile">
+           <property name="toolTip">
+            <string>Filter for last opened files.
+Use wildcards: '*' (any string) and '?' (any character)</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="tableWidgetFiles">
+         <property name="mouseTracking">
+          <bool>true</bool>
+         </property>
+         <property name="editTriggers">
+          <set>QAbstractItemView::NoEditTriggers</set>
+         </property>
+         <property name="columnCount">
+          <number>3</number>
+         </property>
+         <attribute name="horizontalHeaderMinimumSectionSize">
+          <number>1</number>
+         </attribute>
+         <attribute name="horizontalHeaderStretchLastSection">
+          <bool>true</bool>
+         </attribute>
+         <column>
+          <property name="text">
+           <string>File</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Modified</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Directory</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_5"/>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="layoutWidget_2">
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <item>
+          <widget class="QLabel" name="label_2">
+           <property name="text">
+            <string>Last opened projects:</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="QLineEdit" name="lineEditFilterLastProjects">
+           <property name="toolTip">
+            <string>Filter for last opened projects.
+Use wildcards: '*' (any string) and '?' (any character)</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="tableWidgetProjects">
+         <property name="mouseTracking">
+          <bool>true</bool>
+         </property>
+         <property name="columnCount">
+          <number>2</number>
+         </property>
+         <attribute name="horizontalHeaderStretchLastSection">
+          <bool>true</bool>
+         </attribute>
+         <attribute name="verticalHeaderStretchLastSection">
+          <bool>false</bool>
+         </attribute>
+         <column>
+          <property name="text">
+           <string>Name</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Parent</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_7"/>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 9a81961bf94835d2af50a1b3e50cf46aa14d971f..90388d53e84ea829ba91e5f0a4ea478f489a1a3d 100644 (file)
 /**
  * Constructor.
  *
- * @param name                 the name of the view
+ * @param directory            the base directory of the tree
  * @param mainWindow   the parent (main window)
  */
-FileTreeView::FileTreeView(MainWindow* mainWindow) :
-           View("FileTreeView", mainWindow) {
+FileTreeView::FileTreeView(const QString& directory, MainWindow* mainWindow) :
+           View("FileTreeView", mainWindow),
+           m_fileTree(new ReFileTree(directory, mainWindow->logger())) {
 }
index 15901428b4b381822e465b5ac22126b0a869fcbd..239a9bf24933c1567b9230916327d2c29d8cfb76 100644 (file)
@@ -19,7 +19,7 @@
  */
 class FileTreeView: public View {
 public:
-       FileTreeView(MainWindow* mainWindow);
+       FileTreeView(const QString& directory, MainWindow* mainWindow);
 public:
        /** Returns the view specific widget.
         * @return the view specific widget
index 60d911f75b449989238dcf34afb5a611edfc4ca0..c8216ee91e1e0d69cf6c17d8491d052c65abe827 100644 (file)
  */
 ProjectPerspective::ProjectPerspective(MainWindow* mainWindow) :
            Perspective("ProjectPerspective", mainWindow) {
+       setDefaultViews();
 }
 
 void ProjectPerspective::setDefaultViews() {
-       append(new EditorView(m_mainWindow), Qt::NoDockWidgetArea);
-       append(new FileTreeView(m_mainWindow), Qt::LeftDockWidgetArea);
+       if (m_views.size() == 0) {
+               append(new EditorView(m_mainWindow), Qt::NoDockWidgetArea);
+               append(new FileTreeView(QDir::homePath(), m_mainWindow),
+                   Qt::LeftDockWidgetArea);
+       }
 }
diff --git a/appl/reide/views/StartPerspective.cpp b/appl/reide/views/StartPerspective.cpp
new file mode 100644 (file)
index 0000000..9aab7a0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * project.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 "reide.hpp"
+
+/**
+ * Constructor.
+ *
+ * @param mainWindow   the parent (main window)
+ */
+StartPerspective::StartPerspective(MainWindow* mainWindow) :
+               Perspective("StartPerspective", mainWindow) {
+       setDefaultViews();
+}
+
+void StartPerspective::setDefaultViews() {
+       if (m_views.size() == 0){
+               append(new StartView(m_mainWindow), Qt::NoDockWidgetArea);
+       }
+}
diff --git a/appl/reide/views/StartPerspective.hpp b/appl/reide/views/StartPerspective.hpp
new file mode 100644 (file)
index 0000000..269aec9
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * project.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 StartPerspective_HPP
+#define StartPerspective_HPP
+
+/**
+ * Manages the aspects of a standard project.
+ */
+class StartPerspective: public Perspective {
+public:
+       StartPerspective(MainWindow* mainWindow);
+public:
+       virtual void setDefaultViews();
+};
+
+#endif // StartPerspective_HPP
diff --git a/appl/reide/views/StartView.cpp b/appl/reide/views/StartView.cpp
new file mode 100644 (file)
index 0000000..756941a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 "reide.hpp"
+#include "ui_startview.h"
+
+/**
+ * Constructor.
+ *
+ * @param mainWindow   the main window, the parent
+ */
+StartView::StartView(MainWindow* mainWindow) :
+           QWidget(mainWindow),
+           View("StartView", mainWindow),
+           ui(new Ui::StartView) {
+       ui->setupUi(this);
+}
+
+/**
+ * Destructor.
+ */
+StartView::~StartView() {
+       delete ui;
+}
+
+/**
+ * Returns the view specific widget.
+ *
+ * @return     the view specific widget
+ */
+QWidget*StartView::widget() {
+       return NULL; // ui->startWidget
+}
diff --git a/appl/reide/views/StartView.hpp b/appl/reide/views/StartView.hpp
new file mode 100644 (file)
index 0000000..2cc7fac
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 STARTVIEW_HPP
+#define STARTVIEW_HPP
+
+#include <QWidget>
+#include "View.hpp"
+namespace Ui {
+class StartView;
+}
+class View;
+/**
+ * Form to open/create a file/project.
+ *
+ * A view is a widget displayed as a dock in the window displaying a perspective.
+ */
+class StartView: public QWidget, public View {
+       Q_OBJECT
+
+public:
+       explicit StartView(MainWindow* mainWindow);
+       ~StartView();
+public:
+       virtual QWidget* widget();
+
+private:
+       Ui::StartView *ui;
+};
+
+#endif // STARTVIEW_HPP
diff --git a/appl/reide/views/startview.ui b/appl/reide/views/startview.ui
new file mode 100644 (file)
index 0000000..b45fbfe
--- /dev/null
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StartView</class>
+ <widget class="QWidget" name="startView">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>981</width>
+    <height>595</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <widget class="QTextBrowser" name="textBrowser">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>125</height>
+      </size>
+     </property>
+     <property name="maximumSize">
+      <size>
+       <width>16777215</width>
+       <height>125</height>
+      </size>
+     </property>
+     <property name="html">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Create a new file&lt;/span&gt;:&lt;br /&gt;     Insert a filename and click on &amp;quot;Create&amp;quot;. Use the 2nd &amp;quot;...&amp;quot; to choose the parent directory.&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Create a new project&lt;/span&gt;: &lt;br /&gt;        Insert a directory name  and click on &amp;quot;Create&amp;quot; &lt;/p&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="maximumSize">
+      <size>
+       <width>16777215</width>
+       <height>75</height>
+      </size>
+     </property>
+     <property name="title">
+      <string>Open/create file/project:</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_4">
+      <item>
+       <widget class="QLineEdit" name="lineEditOpen">
+        <property name="toolTip">
+         <string>Name of the file/project directory to open</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonOpen">
+        <property name="toolTip">
+         <string>Opens the file/project (Control-O)</string>
+        </property>
+        <property name="text">
+         <string>Open</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+O</string>
+        </property>
+        <property name="autoDefault">
+         <bool>false</bool>
+        </property>
+        <property name="default">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="toolButtonSelectFile">
+        <property name="toolTip">
+         <string>Selects a file wit a file open dialog box (Control-Shift-F)</string>
+        </property>
+        <property name="text">
+         <string>...</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+Shift+F</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="toolButtonSelectProject">
+        <property name="toolTip">
+         <string>Select a project directory with a directory open box (Control-Shift-P)</string>
+        </property>
+        <property name="text">
+         <string>...</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+Shift+P</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="pushButtonCreate">
+        <property name="text">
+         <string>Create</string>
+        </property>
+        <property name="shortcut">
+         <string>Ctrl+N</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="handleWidth">
+      <number>3</number>
+     </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>Last opened files:</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="QLineEdit" name="lineEditFilterLastFile">
+           <property name="toolTip">
+            <string>Filter for last opened files.
+Use wildcards: '*' (any string) and '?' (any character)</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="tableWidgetFiles">
+         <property name="mouseTracking">
+          <bool>true</bool>
+         </property>
+         <property name="editTriggers">
+          <set>QAbstractItemView::NoEditTriggers</set>
+         </property>
+         <property name="columnCount">
+          <number>3</number>
+         </property>
+         <attribute name="horizontalHeaderMinimumSectionSize">
+          <number>1</number>
+         </attribute>
+         <attribute name="horizontalHeaderStretchLastSection">
+          <bool>true</bool>
+         </attribute>
+         <column>
+          <property name="text">
+           <string>File</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Modified</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Directory</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_5"/>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="layoutWidget_2">
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <item>
+          <widget class="QLabel" name="label_2">
+           <property name="text">
+            <string>Last opened projects:</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="QLineEdit" name="lineEditFilterLastProjects">
+           <property name="toolTip">
+            <string>Filter for last opened projects.
+Use wildcards: '*' (any string) and '?' (any character)</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <widget class="QTableWidget" name="tableWidgetProjects">
+         <property name="mouseTracking">
+          <bool>true</bool>
+         </property>
+         <property name="columnCount">
+          <number>2</number>
+         </property>
+         <attribute name="horizontalHeaderStretchLastSection">
+          <bool>true</bool>
+         </attribute>
+         <attribute name="verticalHeaderStretchLastSection">
+          <bool>false</bool>
+         </attribute>
+         <column>
+          <property name="text">
+           <string>Name</string>
+          </property>
+         </column>
+         <column>
+          <property name="text">
+           <string>Parent</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_7"/>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/base/ReDiff.cpp b/base/ReDiff.cpp
new file mode 100644 (file)
index 0000000..e14af2c
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * ReFile.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"
+
+
+/**
+ * Constructor.
+ *
+ * @param list1        first line list
+ * @param list2 2nd line list
+ */
+ReDiff::ReDiff(const QStringList& list1, const QStringList& list2) :
+       m_list1(list1), m_list2(list2){
+
+}
+
+ReCommonSlice ReDiff::longestMatchingSlice(int from1, int to1, int from2, int to2){
+       ReCommonSlice rc;
+       rc.m_from1 = from1;
+       rc.m_from2 = from2;
+       rc.m_count = 0;
+
+       int nMax = max(to1 - from1, to2 - from2);
+       int* runs = new int[nMax];
+       int* runs2 = new int[nMax];
+       memset(runs, 0, nMax * sizeof runs[0]);
+       for (int ix1 = from1; ix1 < to1; ix1++){
+               memset(runs2, 0, nMax * sizeof runs[0]);
+               for (int ix2 = from2; ix2 < to2; ix2++){
+                       if (m_list1.at(ix1) == m_list2.at(ix2)){
+                               int count = runs2[ix2] = runs[ix2 - 1] + 1;
+                               if (count > rc.m_count){
+                                       rc.m_from1 = ix1 - count + 1;
+                                       rc.m_from2 = ix2 - count + 1;
+                                       rc.m_count = count;
+                               }
+                       }
+               }
+               runs = runs2;
+       }
+       delete runs;
+       delete runs2;
+       return rc;
+}
+
+/**
+ * Calculates the difference lists.
+ */
+void ReDiff::build()
+{
+       /*
+        * def longest_matching_slice(a, a0, a1, b, b0, b1):
+       sa, sb, n = a0, b0, 0
+
+       runs = {}
+       for i in range(a0, a1):
+               new_runs = {}
+               for j in range(b0, b1):
+                       if a[i] == b[j]:
+                               k = new_runs[j] = runs.get(j-1, 0) + 1
+                               if k > n:
+                                       sa, sb, n = i-k+1, j-k+1, k
+               runs = new_runs
+
+       assert a[sa:sa+n] == b[sb:sb+n]
+       return sa, sb, n
+
+        */
+}
diff --git a/base/ReDiff.hpp b/base/ReDiff.hpp
new file mode 100644 (file)
index 0000000..edf057b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ReFile.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 REDIFF_HPP
+#define REDIFF_HPP
+
+
+class ReCommonSlice {
+public:
+       //@ first common line in list1
+       int m_from1;
+       //@ first common line in list2
+       int m_from2;
+       int m_count;
+};
+
+class ReDiff {
+public:
+       ReDiff(const QStringList& list1, const QStringList& list2);
+       ~ReDiff();
+public:
+       void build();
+protected:
+       ReCommonSlice longestMatchingSlice(int from1, int to1, int from2, int to2);
+protected:
+       const QStringList& m_list1;
+       const QStringList& m_list2;
+
+       QList<ReCommonSlice> m_slices;
+};
+
+#endif // REDIFF_HPP
index 599a5b1c24c74992763b098b9161fa35b516c927..d79125f272178033c9b128c8a7dd278a563b45c5 100644 (file)
@@ -102,6 +102,7 @@ inline int roundInt(double value) {
 #include "base/ReLineSource.hpp"
 #include "base/ReFileUtils.hpp"
 #include "base/ReFile.hpp"
+#include "base/ReDiff.hpp"
 #include "base/ReTest.hpp"
 
 #endif // REBASE_HPP