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() {
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);
<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">
<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>
#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"
../../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 \
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
--- /dev/null
+<?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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Create a new file</span>:<br /> Insert a filename and click on &quot;Create&quot;. Use the 2nd &quot;...&quot; to choose the parent directory.</p>
+<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Create a new project</span>: <br /> Insert a directory name and click on &quot;Create&quot; </p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></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>
/**
* 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())) {
}
*/
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
*/
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);
+ }
}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+<?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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Create a new file</span>:<br /> Insert a filename and click on &quot;Create&quot;. Use the 2nd &quot;...&quot; to choose the parent directory.</p>
+<p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Create a new project</span>: <br /> Insert a directory name and click on &quot;Create&quot; </p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></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>
--- /dev/null
+/*
+ * 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
+
+ */
+}
--- /dev/null
+/*
+ * 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
#include "base/ReLineSource.hpp"
#include "base/ReFileUtils.hpp"
#include "base/ReFile.hpp"
+#include "base/ReDiff.hpp"
#include "base/ReTest.hpp"
#endif // REBASE_HPP