From: hama Date: Sat, 5 Sep 2015 00:03:01 +0000 (+0200) Subject: StartPerspective X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=bfe897949f9453c8c4d100493d03305b980df95c;p=reqt StartPerspective --- diff --git a/appl/reide/mainwindow.cpp b/appl/reide/mainwindow.cpp index 47fb263..b4a8188 100644 --- a/appl/reide/mainwindow.cpp +++ b/appl/reide/mainwindow.cpp @@ -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); diff --git a/appl/reide/mainwindow.ui b/appl/reide/mainwindow.ui index cad587b..efd52e1 100644 --- a/appl/reide/mainwindow.ui +++ b/appl/reide/mainwindow.ui @@ -14,11 +14,7 @@ MainWindow - - - - - + @@ -26,7 +22,7 @@ 0 0 803 - 23 + 35 @@ -84,14 +80,6 @@ - - - ReEdit - QWidget -
gui/regui.hpp
- 1 -
-
diff --git a/appl/reide/reide.hpp b/appl/reide/reide.hpp index 182bf48..bacca58 100644 --- a/appl/reide/reide.hpp +++ b/appl/reide/reide.hpp @@ -17,8 +17,10 @@ #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" diff --git a/appl/reide/reide.pro b/appl/reide/reide.pro index a8b0bc2..b169124 100644 --- a/appl/reide/reide.pro +++ b/appl/reide/reide.pro @@ -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 index 0000000..5aa9469 --- /dev/null +++ b/appl/reide/startwidget.ui @@ -0,0 +1,274 @@ + + + startWidget + + + + 0 + 0 + 861 + 445 + + + + Start + + + + + + false + + + + 0 + 125 + + + + + 16777215 + 125 + + + + <!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> + + + + + + + + 16777215 + 75 + + + + Open/create file/project: + + + + + + Name of the file/project directory to open + + + + + + + Opens the file/project (Control-O) + + + Open + + + Ctrl+O + + + false + + + true + + + + + + + Selects a file wit a file open dialog box (Control-Shift-F) + + + ... + + + Ctrl+Shift+F + + + + + + + Select a project directory with a directory open box (Control-Shift-P) + + + ... + + + Ctrl+Shift+P + + + + + + + Create + + + Ctrl+N + + + + + + + + + + Qt::Horizontal + + + 3 + + + + + + + + + Last opened files: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Filter for last opened files. +Use wildcards: '*' (any string) and '?' (any character) + + + + + + + + + true + + + QAbstractItemView::NoEditTriggers + + + 3 + + + 1 + + + true + + + + File + + + + + Modified + + + + + Directory + + + + + + + + + + + + + + + + + Last opened projects: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Filter for last opened projects. +Use wildcards: '*' (any string) and '?' (any character) + + + + + + + + + true + + + 2 + + + true + + + false + + + + Name + + + + + Parent + + + + + + + + + + + + + + + + diff --git a/appl/reide/views/FileTreeView.cpp b/appl/reide/views/FileTreeView.cpp index 9a81961..90388d5 100644 --- a/appl/reide/views/FileTreeView.cpp +++ b/appl/reide/views/FileTreeView.cpp @@ -14,9 +14,10 @@ /** * 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())) { } diff --git a/appl/reide/views/FileTreeView.hpp b/appl/reide/views/FileTreeView.hpp index 1590142..239a9bf 100644 --- a/appl/reide/views/FileTreeView.hpp +++ b/appl/reide/views/FileTreeView.hpp @@ -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 diff --git a/appl/reide/views/ProjectPerspective.cpp b/appl/reide/views/ProjectPerspective.cpp index 60d911f..c8216ee 100644 --- a/appl/reide/views/ProjectPerspective.cpp +++ b/appl/reide/views/ProjectPerspective.cpp @@ -18,9 +18,13 @@ */ 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 index 0000000..9aab7a0 --- /dev/null +++ b/appl/reide/views/StartPerspective.cpp @@ -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 index 0000000..269aec9 --- /dev/null +++ b/appl/reide/views/StartPerspective.hpp @@ -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 index 0000000..756941a --- /dev/null +++ b/appl/reide/views/StartView.cpp @@ -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 index 0000000..2cc7fac --- /dev/null +++ b/appl/reide/views/StartView.hpp @@ -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 +#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 index 0000000..b45fbfe --- /dev/null +++ b/appl/reide/views/startview.ui @@ -0,0 +1,274 @@ + + + StartView + + + + 0 + 0 + 981 + 595 + + + + Form + + + + + + false + + + + 0 + 125 + + + + + 16777215 + 125 + + + + <!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> + + + + + + + + 16777215 + 75 + + + + Open/create file/project: + + + + + + Name of the file/project directory to open + + + + + + + Opens the file/project (Control-O) + + + Open + + + Ctrl+O + + + false + + + true + + + + + + + Selects a file wit a file open dialog box (Control-Shift-F) + + + ... + + + Ctrl+Shift+F + + + + + + + Select a project directory with a directory open box (Control-Shift-P) + + + ... + + + Ctrl+Shift+P + + + + + + + Create + + + Ctrl+N + + + + + + + + + + Qt::Horizontal + + + 3 + + + + + + + + + Last opened files: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Filter for last opened files. +Use wildcards: '*' (any string) and '?' (any character) + + + + + + + + + true + + + QAbstractItemView::NoEditTriggers + + + 3 + + + 1 + + + true + + + + File + + + + + Modified + + + + + Directory + + + + + + + + + + + + + + + + + Last opened projects: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Filter for last opened projects. +Use wildcards: '*' (any string) and '?' (any character) + + + + + + + + + true + + + 2 + + + true + + + false + + + + Name + + + + + Parent + + + + + + + + + + + + + + + + diff --git a/base/ReDiff.cpp b/base/ReDiff.cpp new file mode 100644 index 0000000..e14af2c --- /dev/null +++ b/base/ReDiff.cpp @@ -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 index 0000000..edf057b --- /dev/null +++ b/base/ReDiff.hpp @@ -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 m_slices; +}; + +#endif // REDIFF_HPP diff --git a/base/rebase.hpp b/base/rebase.hpp index 599a5b1..d79125f 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -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