From: hama Date: Sun, 30 Aug 2015 18:32:04 +0000 (+0200) Subject: reditor renamed to reide X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=b4ba072f48eb8f07d9fab9de7cc04c738c8fbb00;p=reqt reditor renamed to reide --- diff --git a/appl/reditor/editor.qrc b/appl/reditor/editor.qrc deleted file mode 100644 index 3ec8152..0000000 --- a/appl/reditor/editor.qrc +++ /dev/null @@ -1,26 +0,0 @@ - - - icons/action_go.png - icons/action_paste.png - icons/arrow_turn_left.png - icons/bullet_go.png - icons/cog_edit.png - icons/database_save.png - icons/disk.png - icons/door_in.png - icons/eye.png - icons/folder_find.png - icons/folder_go.png - icons/folder_magnify.png - icons/folder.png - icons/layout_add.png - icons/paste_plain.png - icons/resultset_next.png - icons/sitemap_color.png - icons/table.png - icons/tables.png - icons/wand.png - icons/wrench.png - icons/folder_page.png - - diff --git a/appl/reditor/icons/action_go.png b/appl/reditor/icons/action_go.png deleted file mode 100755 index ef5bfc3..0000000 Binary files a/appl/reditor/icons/action_go.png and /dev/null differ diff --git a/appl/reditor/icons/action_paste.png b/appl/reditor/icons/action_paste.png deleted file mode 100755 index 60f7841..0000000 Binary files a/appl/reditor/icons/action_paste.png and /dev/null differ diff --git a/appl/reditor/icons/arrow_turn_left.png b/appl/reditor/icons/arrow_turn_left.png deleted file mode 100644 index a3d6c9e..0000000 Binary files a/appl/reditor/icons/arrow_turn_left.png and /dev/null differ diff --git a/appl/reditor/icons/bullet_go.png b/appl/reditor/icons/bullet_go.png deleted file mode 100644 index bc4faa7..0000000 Binary files a/appl/reditor/icons/bullet_go.png and /dev/null differ diff --git a/appl/reditor/icons/cog_edit.png b/appl/reditor/icons/cog_edit.png deleted file mode 100644 index 47b75a4..0000000 Binary files a/appl/reditor/icons/cog_edit.png and /dev/null differ diff --git a/appl/reditor/icons/database_save.png b/appl/reditor/icons/database_save.png deleted file mode 100644 index 44c06dd..0000000 Binary files a/appl/reditor/icons/database_save.png and /dev/null differ diff --git a/appl/reditor/icons/disk.png b/appl/reditor/icons/disk.png deleted file mode 100644 index 99d532e..0000000 Binary files a/appl/reditor/icons/disk.png and /dev/null differ diff --git a/appl/reditor/icons/door_in.png b/appl/reditor/icons/door_in.png deleted file mode 100644 index 41676a0..0000000 Binary files a/appl/reditor/icons/door_in.png and /dev/null differ diff --git a/appl/reditor/icons/eye.png b/appl/reditor/icons/eye.png deleted file mode 100644 index 564a1a9..0000000 Binary files a/appl/reditor/icons/eye.png and /dev/null differ diff --git a/appl/reditor/icons/folder.png b/appl/reditor/icons/folder.png deleted file mode 100644 index 784e8fa..0000000 Binary files a/appl/reditor/icons/folder.png and /dev/null differ diff --git a/appl/reditor/icons/folder_find.png b/appl/reditor/icons/folder_find.png deleted file mode 100644 index c64e2ee..0000000 Binary files a/appl/reditor/icons/folder_find.png and /dev/null differ diff --git a/appl/reditor/icons/folder_go.png b/appl/reditor/icons/folder_go.png deleted file mode 100644 index 34a736f..0000000 Binary files a/appl/reditor/icons/folder_go.png and /dev/null differ diff --git a/appl/reditor/icons/folder_magnify.png b/appl/reditor/icons/folder_magnify.png deleted file mode 100644 index 0a3e798..0000000 Binary files a/appl/reditor/icons/folder_magnify.png and /dev/null differ diff --git a/appl/reditor/icons/folder_page.png b/appl/reditor/icons/folder_page.png deleted file mode 100644 index 1ef6e11..0000000 Binary files a/appl/reditor/icons/folder_page.png and /dev/null differ diff --git a/appl/reditor/icons/layout_add.png b/appl/reditor/icons/layout_add.png deleted file mode 100644 index 6203722..0000000 Binary files a/appl/reditor/icons/layout_add.png and /dev/null differ diff --git a/appl/reditor/icons/paste_plain.png b/appl/reditor/icons/paste_plain.png deleted file mode 100644 index c0490eb..0000000 Binary files a/appl/reditor/icons/paste_plain.png and /dev/null differ diff --git a/appl/reditor/icons/resultset_next.png b/appl/reditor/icons/resultset_next.png deleted file mode 100644 index e252606..0000000 Binary files a/appl/reditor/icons/resultset_next.png and /dev/null differ diff --git a/appl/reditor/icons/sitemap_color.png b/appl/reditor/icons/sitemap_color.png deleted file mode 100644 index c64582b..0000000 Binary files a/appl/reditor/icons/sitemap_color.png and /dev/null differ diff --git a/appl/reditor/icons/table.png b/appl/reditor/icons/table.png deleted file mode 100755 index 6f794bc..0000000 Binary files a/appl/reditor/icons/table.png and /dev/null differ diff --git a/appl/reditor/icons/tables.png b/appl/reditor/icons/tables.png deleted file mode 100755 index e88ceb5..0000000 Binary files a/appl/reditor/icons/tables.png and /dev/null differ diff --git a/appl/reditor/icons/wand.png b/appl/reditor/icons/wand.png deleted file mode 100644 index 44ccbf8..0000000 Binary files a/appl/reditor/icons/wand.png and /dev/null differ diff --git a/appl/reditor/icons/wrench.png b/appl/reditor/icons/wrench.png deleted file mode 100644 index 5c8213f..0000000 Binary files a/appl/reditor/icons/wrench.png and /dev/null differ diff --git a/appl/reditor/main.cpp b/appl/reditor/main.cpp deleted file mode 100644 index e11e665..0000000 --- a/appl/reditor/main.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * main.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 "reditor.hpp" -#include - -int main(int argc, char *argv[]) { - const char* workspace = NULL; - const char* project = NULL; - for (int ix = 1; ix < argc; ix++) { - if (argv[ix][0] == '-') { - if (strcmp(argv[ix], "-w") == 0 && ix < argc - 1) { - workspace = argv[++ix]; - } else if (strncmp(argv[ix], "--workspace=", 12) == 0) { - workspace = argv[ix] + 12; - } else if (strcmp(argv[ix], "-p") == 0 && ix < argc - 1) { - project = argv[++ix]; - } else if (strncmp(argv[ix], "--project=", 10) == 0) { - workspace = argv[ix] + 10; - } - } - } - QApplication a(argc, argv); - ReLogger logger; - ReDebugAppender appender; - appender.setAutoDelete(false); - logger.addAppender(&appender); - MainWindow w(workspace, project, &logger); - logger.log(LOG_INFO, 1, "start"); - w.show(); - - return a.exec(); -} diff --git a/appl/reditor/mainwindow.cpp b/appl/reditor/mainwindow.cpp deleted file mode 100644 index 17e4bda..0000000 --- a/appl/reditor/mainwindow.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * mainwindow.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 "reditor.hpp" -#include "ui_mainwindow.h" -#include - -MainWindow::MainWindow(const char* workspace, const char* project, - ReLogger* logger, QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow), - m_project(NULL), - m_workspace(NULL), - m_logger(logger), - m_fileTree(NULL), - m_dockProjectTree(NULL) { - if (workspace == NULL) - workspace = QDir::homePath().toUtf8(); - changeWorkspace(workspace == NULL ? QDir::homePath() : workspace); - - QString proj(project == NULL ? "" : project); - if (project == NULL) { - QStringList lastProjects; - m_workspace->historyAsList("projects", lastProjects); - int ix = 0; - while (proj.isEmpty() && ix < lastProjects.size()) { - QFileInfo dir(lastProjects.at(ix)); - if (dir.isDir() && dir.isWritable()) - proj = lastProjects.at(ix); - } - if (!proj.isEmpty()) - 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(); -} - -MainWindow::~MainWindow() { - delete ui; -} - -/** - * Change the current project. - * - * @param path the directory containing the project data - */ -void MainWindow::changeProject(QString path) { - delete m_project; - if (path.endsWith(OS_SEPARATOR_STR)) - path.remove(path.size() - 1, 1); - m_project = new Project(path, this); - int maxEntries = m_workspace->intValue("history.max_projects"); - m_workspace->addHistoryEntry(Workspace::KEY_HISTORY_PROJECTS, path, ';', - maxEntries); - if (m_fileTree == NULL) { - m_fileTree = new ReFileTree(path, m_logger, this); - m_dockProjectTree = new QDockWidget("", this); - m_dockProjectTree->setWidget(m_fileTree); - addDockWidget(Qt::LeftDockWidgetArea, m_dockProjectTree); - } - m_fileTree->setPath(path); - m_dockProjectTree->setWindowTitle( - tr("Project") + " " + ReQStringUtils::nodeOf(path)); - -} - -/** - * Change the workspace. - * - * @param path the directory containing the workspace data - */ -void MainWindow::changeWorkspace(const QString& path) { - delete m_workspace; - m_workspace = new Workspace(path, m_logger); -} - -/** - * Calls the file selection dialog. - */ -void MainWindow::openFile(const QString& name) { - m_file = new ReFile(name, false); - - 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); -} - -/** - * Closes the current project. - */ -void MainWindow::closeProject() { - delete m_project; - m_project = NULL; -} - -/** - * Shows the "open project/file dialog". - */ -void MainWindow::open() { - ProjectSelection dialog(this); - dialog.exec(); -} -ReLogger* MainWindow::logger() const { - return m_logger; -} - -/** - * Returns the current workspace. - * - * @return the current workspace - */ -Project* MainWindow::project() const { - return m_project; -} - -Workspace* MainWindow::workspace() const { - return m_workspace; -} - diff --git a/appl/reditor/mainwindow.hpp b/appl/reditor/mainwindow.hpp deleted file mode 100644 index d80c6f9..0000000 --- a/appl/reditor/mainwindow.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * mainwindow.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 MAINWINDOW_HPP -#define MAINWINDOW_HPP - -#include -#ifndef REBASE_HPP -#include "reditor.hpp" -#endif -namespace Ui { -class MainWindow; -} - -class MainWindow: public QMainWindow { - Q_OBJECT - -public: - explicit MainWindow(const char* workspace, const char* project, - ReLogger* logger, QWidget *parent = 0); - ~MainWindow(); - void changeProject(QString path); - void changeWorkspace(const QString& path); - void closeProject(); - void openFile(const QString& name); - Project* project() const; - Workspace* workspace() const; - ReLogger* logger() const; - -public slots: - void open(); -private: - Ui::MainWindow *ui; - ReFile* m_file; - Project* m_project; - Workspace* m_workspace; - ReLogger* m_logger; - ReFileTree* m_fileTree; - QDockWidget* m_dockProjectTree; -}; - -#endif // MAINWINDOW_HPP diff --git a/appl/reditor/mainwindow.ui b/appl/reditor/mainwindow.ui deleted file mode 100644 index cad587b..0000000 --- a/appl/reditor/mainwindow.ui +++ /dev/null @@ -1,99 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 803 - 642 - - - - MainWindow - - - - - - - - - - - - 0 - 0 - 803 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - :/main/icons/table.png:/main/icons/table.png - - - Open - - - Open a file - - - Ctrl+O - - - - - - :/main/icons/disk.png:/main/icons/disk.png - - - Save - - - Save the file - - - Ctrl+S - - - - - - - ReEdit - QWidget -
gui/regui.hpp
- 1 -
-
- - - - -
diff --git a/appl/reditor/project.cpp b/appl/reditor/project.cpp deleted file mode 100644 index ffda4ee..0000000 --- a/appl/reditor/project.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 "reditor.hpp" - -const char* Project::KEY_HISTORY_OPEN_FILES = "openFiles"; -/** - * Constructor. - * - * @param path the directory containing the configuration - * @param logger the logger - */ -Project::Project(const QString& path, MainWindow* mainWindow) : - ReSettings(path, ".reditor.proj", mainWindow->logger()), - m_mainWindow(mainWindow) { - QString filename = topOfHistory(KEY_HISTORY_OPEN_FILES); - QFileInfo info(filename); - if (!filename.isEmpty() && info.exists() && !info.isDir()) { - m_mainWindow->openFile(filename); - } -} - -/** - * Opens a file in the project directory. - * - * @param filename the filename relative to the project directory - */ -void Project::openFile(const QString& filename) { - QString full = m_path + OS_SEPARATOR_STR + filename; - addHistoryEntry(KEY_HISTORY_OPEN_FILES, filename, ';', 1); - m_mainWindow->openFile(full); -} - diff --git a/appl/reditor/project.hpp b/appl/reditor/project.hpp deleted file mode 100644 index dc0b267..0000000 --- a/appl/reditor/project.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 PROJECT_HPP -#define PROJECT_HPP - -class MainWindow; - -class Project: public ReSettings { -public: - static const char* KEY_HISTORY_OPEN_FILES; -public: - Project(const QString& path, MainWindow* mainWindow); -public: - void openFile(const QString& filename); - -private: - MainWindow* m_mainWindow; -}; - -#endif // PROJECT_HPP diff --git a/appl/reditor/projectselection.cpp b/appl/reditor/projectselection.cpp deleted file mode 100644 index 1d7fd72..0000000 --- a/appl/reditor/projectselection.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * projectselection.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 "reditor.hpp" -#include "ui_projectselection.h" -#include -#include - -/** - * Constructor. - * - * @param parent NULL or the parent - * @param mainWindow the main window - */ -ProjectSelection::ProjectSelection(MainWindow* mainWindow, QWidget *parent) : - QDialog(parent), - ui(new Ui::ProjectSelection), - m_mainWindow(mainWindow) { - ui->setupUi(this); - connect(ui->toolButtonSelectFile, SIGNAL(clicked()), this, - SLOT(selectFile())); - connect(ui->toolButtonSelectProject, SIGNAL(clicked()), this, - SLOT(selectDir())); - connect(ui->pushButtonOpen, SIGNAL(clicked()), this, SLOT(open())); - connect(ui->lineEditFilterLastFile, SIGNAL(textChanged(QString)), this, - SLOT(textChangedFilterFiles(QString))); - connect(ui->tableWidgetFiles, SIGNAL(cellEntered(int,int)), this, - SLOT(cellEnteredFiles(int, int))); - connect(ui->tableWidgetProjects, SIGNAL(cellEntered(int,int)), this, - SLOT(cellEnteredProjects(int, int))); - Workspace* workspace = mainWindow->workspace(); - buildTableInfo(workspace, Workspace::KEY_HISTORY_FILES, true, m_files); - buildTableInfo(workspace, Workspace::KEY_HISTORY_PROJECTS, false, - m_projects); - buildTable("", m_files, ui->tableWidgetFiles); - buildTable("", m_projects, ui->tableWidgetProjects); -} - -/** - * Destructor. - */ -ProjectSelection::~ProjectSelection() { - delete ui; -} -/** - * Handles the event cellEntered for the last opened files. - * - * @param row the row of the entered cell - * @param col the column of the entered cell - */ -void ProjectSelection::cellEnteredFiles(int row, int col) { - ReUseParameter(col); - QString file = fileOfTable(ui->tableWidgetFiles, row); - ui->lineEditOpen->setText(file); -} - -/** - * Handles the event cellEntered for the last opened projects. - * - * @param row the row of the entered cell - * @param col the column of the entered cell - */ -void ProjectSelection::cellEnteredProjects(int row, int col) { - ReUseParameter(col); - QString file = fileOfTable(ui->tableWidgetProjects, row); - ui->lineEditOpen->setText(file); -} - -/** - * Builds the table from the table using a filter expression. - * - * @param filter a filter expression with wildcards '*' - * @param lines the full table info - * @param table OUT: will be filled with all lines matching the filter - */ -void ProjectSelection::buildTable(const QString& filter, - const QStringList& lines, QTableWidget* table) { - QStringList::const_iterator it; - int rowCount = 0; - ReMatcher matcher(filter, Qt::CaseInsensitive, true); - for (it = lines.cbegin(); it != lines.cend(); ++it) { - if (matcher.matches(*it)) - rowCount++; - } - table->setRowCount(rowCount); - int row = -1; - for (it = lines.cbegin(); it != lines.cend(); ++it) { - if (matcher.matches(*it)) { - row++; - QStringList cols = it->split('\t'); - for (int col = 0; col < cols.size(); col++) { - QTableWidgetItem* item = table->item(row, col); - if (item != NULL) - item->setText(cols.at(col)); - else { - item = new QTableWidgetItem(cols.at(col)); - table->setItem(row, col, item); - } - } - } - } -} - -/** - * Build the info for a table (last opened files or last opened projects). - * - * Note: the table shows a filtered part of this info. - * - * @param settings the history container - * @param key the name of the history entry - * @param withDate the file's name is part of the info - * @param tableContent OUT: the list containing the table info - */ -void ProjectSelection::buildTableInfo(ReSettings* settings, const char* key, - bool withDate, QStringList& tableContent) { - QStringList files; - settings->historyAsList(key, files); - QStringList::const_iterator it; - for (it = files.cbegin(); it != files.cend(); ++it) { - QFileInfo file(*it); - if (file.exists()) { - QString info = file.baseName(); - if (withDate) - info.append("\t").append( - file.lastModified().toString("yyyy.mm.dd/HH:MM:SS")); - info.append("\t").append(file.path()); - tableContent.append(info); - } - } -} - -/** - * Shows an error message. - * - * @param message message to show - */ -void ProjectSelection::error(const QString& message) { - QMessageBox dialog(QMessageBox::Critical, "Error", message, - QMessageBox::Close); - dialog.exec(); -} - -/** - * Extracts the full filename of a given table. - * - * The node is the first column, the path the last. - * - * @param table the table from which the filename is taken - * @param row the row where the filename is - * @return the full name of the file in the given row - */ -QString ProjectSelection::fileOfTable(QTableWidget* table, int row) { - int colPath = table->columnCount() - 1; - QString file = table->item(row, colPath)->text() + OS_SEPARATOR_STR - + table->item(row, 0)->text(); - return file; -} -/** - * Opens a file or a directory (project directory). - */ -void ProjectSelection::open() { - QString name = ui->lineEditOpen->text(); - if (name.isEmpty()) - error("missing filename/project directory"); - else { - QFileInfo file(name); - if (!file.exists()) - error("does not exists: " + name); - else { - if (file.isDir()) - m_mainWindow->changeProject(name); - else - m_mainWindow->openFile(name); - close(); - } - } -} - -/** - * Selects a directory (project directory) with an open dialog. - */ -void ProjectSelection::selectDir() { - QString name = ui->lineEditOpen->text(); - if (name.isEmpty() && m_mainWindow->project() != NULL) - name = m_mainWindow->project()->path(); - name = QFileDialog::getExistingDirectory(this, - tr("Select Project Directory"), name); - if (!name.isEmpty()) { - ui->lineEditOpen->setText(name); - open(); - } -} - -/** - * Selects a file with a file open dialog. - */ -void ProjectSelection::selectFile() { - QString name = ui->lineEditOpen->text(); - name = QFileDialog::getOpenFileName(this, tr("Select File"), name); - if (!name.isEmpty()) { - ui->lineEditOpen->setText(name); - open(); - } -} - -/** - * Handles the filter text change for a given table. - * - * @param text the filter text - * @param table the table which will be filled - * @param lines the full (unfiltered) table info - */ -void ProjectSelection::textChanged(const QString& text, QTableWidget* table, - const QStringList& lines) { - buildTable(text, lines, table); - if (table->rowCount() > 0) { - QString file = fileOfTable(table, 0); - ui->lineEditOpen->setText(file); - } -} - -/** - * Handles the event "text changed" of the last opened files. - * - * @param text the new text - */ -void ProjectSelection::textChangedFilterFiles(const QString& text) { - textChanged(text, ui->tableWidgetFiles, m_files); -} - -/** - * Handles the event "text changed" of the last opened projects. - * - * @param text the new text - */ -void ProjectSelection::textChangedFilterProjects(const QString& text) { - textChanged(text, ui->tableWidgetProjects, m_projects); -} diff --git a/appl/reditor/projectselection.hpp b/appl/reditor/projectselection.hpp deleted file mode 100644 index ea17c30..0000000 --- a/appl/reditor/projectselection.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * projectselection.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 PROJECTSELECTION_HPP -#define PROJECTSELECTION_HPP -#include "reditor.hpp" -#include -#include -namespace Ui { -class ProjectSelection; -} -class MainWindow; -class ProjectSelection: public QDialog { - Q_OBJECT - -public: - explicit ProjectSelection(MainWindow* mainWindow, QWidget *parent = 0); - ~ProjectSelection(); - -public slots: - void open(); - void selectDir(); - void selectFile(); -protected: - void buildTable(const QString& filter, const QStringList& lines, - QTableWidget* table); - void buildTableInfo(ReSettings* settings, const char* key, bool withDate, - QStringList& tableContent); - QString fileOfTable(QTableWidget* table, int row); - void textChanged(const QString& text, QTableWidget* table, - const QStringList& lines);protected slots: - void cellEnteredFiles(int row, int col); - void cellEnteredProjects(int row, int col); - void textChangedFilterFiles(const QString& text); - void textChangedFilterProjects(const QString& text); -private: - void error(const QString& message); -private: - Ui::ProjectSelection *ui; - MainWindow* m_mainWindow; - QStringList m_files; - QStringList m_projects; -}; - -#endif // PROJECTSELECTION_HPP diff --git a/appl/reditor/projectselection.ui b/appl/reditor/projectselection.ui deleted file mode 100644 index 8b24b07..0000000 --- a/appl/reditor/projectselection.ui +++ /dev/null @@ -1,227 +0,0 @@ - - - ProjectSelection - - - - 0 - 0 - 1034 - 703 - - - - Dialog - - - - - - - 16777215 - 75 - - - - Open new file/project: - - - - - - Name of the file/project directory to open - - - - - - - Opens the file/project (Control-O) - - - Open - - - - - - - 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 - - - - - - - - - - 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/reditor/reditor.hpp b/appl/reditor/reditor.hpp deleted file mode 100644 index e606072..0000000 --- a/appl/reditor/reditor.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * reditor.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 REDITOR_HPP -#define REDITOR_HPP -#include -#include "base/rebase.hpp" -#include "gui/regui.hpp" -#include "workspace.hpp" -#include "project.hpp" -#include "mainwindow.hpp" -#include "projectselection.hpp" -#endif // REDITOR_HPP - diff --git a/appl/reditor/reditor.pro b/appl/reditor/reditor.pro deleted file mode 100644 index a47db11..0000000 --- a/appl/reditor/reditor.pro +++ /dev/null @@ -1,50 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2015-06-03T20:56:48 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = ReEditor -TEMPLATE = app - -INCLUDEPATH += ../.. - -SOURCES += \ - ../../gui/ReEdit.cpp \ - ../../gui/ReStateStorage.cpp \ - ../../gui/ReSettings.cpp \ - ../../base/ReFile.cpp \ - ../../gui/ReFileTree.cpp \ - mainwindow.cpp \ - ../../base/ReLogger.cpp \ - ../../base/ReQStringUtils.cpp \ - ../../base/ReFileUtils.cpp \ - ../../base/ReException.cpp \ - projectselection.cpp \ - workspace.cpp \ - project.cpp \ - main.cpp - - -HEADERS += mainwindow.hpp \ - ../../base/rebase.hpp \ - ../../gui/regui.hpp \ - ../../gui/ReEdit.hpp \ - ../../base/ReStringUtils.hpp \ - ../../base/ReQStringUtils.hpp \ - ../../base/ReException.hpp \ - projectselection.hpp \ - workspace.hpp \ - project.hpp \ - reditor.hpp \ - storage.hpp - -FORMS += mainwindow.ui \ - projectselection.ui - -RESOURCES += \ - editor.qrc diff --git a/appl/reditor/workspace.cpp b/appl/reditor/workspace.cpp deleted file mode 100644 index 809c011..0000000 --- a/appl/reditor/workspace.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * workspace.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 "reditor.hpp" - -const char* Workspace::KEY_HISTORY_FILES = "files"; -const char* Workspace::KEY_HISTORY_PROJECTS = "projecs"; - -/** - * Constructor. - * - * @param path the directory containing the configuration - * @param logger the logger - */ -Workspace::Workspace(const QString& path, ReLogger* logger) : - ReSettings(path, ".reditor.ws", logger) { - insertProperty( - new ReProperty("editor.tabwidth", QObject::tr("Tabulator width"), - QObject::tr("Maximal length of the gap displaying a tabulator"), - "4", PT_INT, "[1,16]")); - insertProperty( - new ReProperty("history.max_projects", - QObject::tr("Maximal project entries"), - QObject::tr( - "Maximal number of projects in the 'last opened projects'"), - "20", PT_INT, "[1,100]")); - insertProperty( - new ReProperty("history.max_files", QObject::tr("Maximal file entries"), - QObject::tr("Maximal number of files in the 'last opened files'"), - "20", PT_INT, "[1,100]")); -} - diff --git a/appl/reditor/workspace.hpp b/appl/reditor/workspace.hpp deleted file mode 100644 index 8776fed..0000000 --- a/appl/reditor/workspace.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * workspace.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 WORKSPACE_HPP -#define WORKSPACE_HPP - -class Workspace: public ReSettings { -public: - static const char* KEY_HISTORY_FILES; - static const char* KEY_HISTORY_PROJECTS; -public: - Workspace(const QString& path, ReLogger* logger); -}; - -#endif // WORKSPACE_HPP diff --git a/appl/reide/editor.qrc b/appl/reide/editor.qrc new file mode 100644 index 0000000..3ec8152 --- /dev/null +++ b/appl/reide/editor.qrc @@ -0,0 +1,26 @@ + + + icons/action_go.png + icons/action_paste.png + icons/arrow_turn_left.png + icons/bullet_go.png + icons/cog_edit.png + icons/database_save.png + icons/disk.png + icons/door_in.png + icons/eye.png + icons/folder_find.png + icons/folder_go.png + icons/folder_magnify.png + icons/folder.png + icons/layout_add.png + icons/paste_plain.png + icons/resultset_next.png + icons/sitemap_color.png + icons/table.png + icons/tables.png + icons/wand.png + icons/wrench.png + icons/folder_page.png + + diff --git a/appl/reide/icons/action_go.png b/appl/reide/icons/action_go.png new file mode 100755 index 0000000..ef5bfc3 Binary files /dev/null and b/appl/reide/icons/action_go.png differ diff --git a/appl/reide/icons/action_paste.png b/appl/reide/icons/action_paste.png new file mode 100755 index 0000000..60f7841 Binary files /dev/null and b/appl/reide/icons/action_paste.png differ diff --git a/appl/reide/icons/arrow_turn_left.png b/appl/reide/icons/arrow_turn_left.png new file mode 100644 index 0000000..a3d6c9e Binary files /dev/null and b/appl/reide/icons/arrow_turn_left.png differ diff --git a/appl/reide/icons/bullet_go.png b/appl/reide/icons/bullet_go.png new file mode 100644 index 0000000..bc4faa7 Binary files /dev/null and b/appl/reide/icons/bullet_go.png differ diff --git a/appl/reide/icons/cog_edit.png b/appl/reide/icons/cog_edit.png new file mode 100644 index 0000000..47b75a4 Binary files /dev/null and b/appl/reide/icons/cog_edit.png differ diff --git a/appl/reide/icons/database_save.png b/appl/reide/icons/database_save.png new file mode 100644 index 0000000..44c06dd Binary files /dev/null and b/appl/reide/icons/database_save.png differ diff --git a/appl/reide/icons/disk.png b/appl/reide/icons/disk.png new file mode 100644 index 0000000..99d532e Binary files /dev/null and b/appl/reide/icons/disk.png differ diff --git a/appl/reide/icons/door_in.png b/appl/reide/icons/door_in.png new file mode 100644 index 0000000..41676a0 Binary files /dev/null and b/appl/reide/icons/door_in.png differ diff --git a/appl/reide/icons/eye.png b/appl/reide/icons/eye.png new file mode 100644 index 0000000..564a1a9 Binary files /dev/null and b/appl/reide/icons/eye.png differ diff --git a/appl/reide/icons/folder.png b/appl/reide/icons/folder.png new file mode 100644 index 0000000..784e8fa Binary files /dev/null and b/appl/reide/icons/folder.png differ diff --git a/appl/reide/icons/folder_find.png b/appl/reide/icons/folder_find.png new file mode 100644 index 0000000..c64e2ee Binary files /dev/null and b/appl/reide/icons/folder_find.png differ diff --git a/appl/reide/icons/folder_go.png b/appl/reide/icons/folder_go.png new file mode 100644 index 0000000..34a736f Binary files /dev/null and b/appl/reide/icons/folder_go.png differ diff --git a/appl/reide/icons/folder_magnify.png b/appl/reide/icons/folder_magnify.png new file mode 100644 index 0000000..0a3e798 Binary files /dev/null and b/appl/reide/icons/folder_magnify.png differ diff --git a/appl/reide/icons/folder_page.png b/appl/reide/icons/folder_page.png new file mode 100644 index 0000000..1ef6e11 Binary files /dev/null and b/appl/reide/icons/folder_page.png differ diff --git a/appl/reide/icons/layout_add.png b/appl/reide/icons/layout_add.png new file mode 100644 index 0000000..6203722 Binary files /dev/null and b/appl/reide/icons/layout_add.png differ diff --git a/appl/reide/icons/paste_plain.png b/appl/reide/icons/paste_plain.png new file mode 100644 index 0000000..c0490eb Binary files /dev/null and b/appl/reide/icons/paste_plain.png differ diff --git a/appl/reide/icons/resultset_next.png b/appl/reide/icons/resultset_next.png new file mode 100644 index 0000000..e252606 Binary files /dev/null and b/appl/reide/icons/resultset_next.png differ diff --git a/appl/reide/icons/sitemap_color.png b/appl/reide/icons/sitemap_color.png new file mode 100644 index 0000000..c64582b Binary files /dev/null and b/appl/reide/icons/sitemap_color.png differ diff --git a/appl/reide/icons/table.png b/appl/reide/icons/table.png new file mode 100755 index 0000000..6f794bc Binary files /dev/null and b/appl/reide/icons/table.png differ diff --git a/appl/reide/icons/tables.png b/appl/reide/icons/tables.png new file mode 100755 index 0000000..e88ceb5 Binary files /dev/null and b/appl/reide/icons/tables.png differ diff --git a/appl/reide/icons/wand.png b/appl/reide/icons/wand.png new file mode 100644 index 0000000..44ccbf8 Binary files /dev/null and b/appl/reide/icons/wand.png differ diff --git a/appl/reide/icons/wrench.png b/appl/reide/icons/wrench.png new file mode 100644 index 0000000..5c8213f Binary files /dev/null and b/appl/reide/icons/wrench.png differ diff --git a/appl/reide/main.cpp b/appl/reide/main.cpp new file mode 100644 index 0000000..e11e665 --- /dev/null +++ b/appl/reide/main.cpp @@ -0,0 +1,40 @@ +/* + * main.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 "reditor.hpp" +#include + +int main(int argc, char *argv[]) { + const char* workspace = NULL; + const char* project = NULL; + for (int ix = 1; ix < argc; ix++) { + if (argv[ix][0] == '-') { + if (strcmp(argv[ix], "-w") == 0 && ix < argc - 1) { + workspace = argv[++ix]; + } else if (strncmp(argv[ix], "--workspace=", 12) == 0) { + workspace = argv[ix] + 12; + } else if (strcmp(argv[ix], "-p") == 0 && ix < argc - 1) { + project = argv[++ix]; + } else if (strncmp(argv[ix], "--project=", 10) == 0) { + workspace = argv[ix] + 10; + } + } + } + QApplication a(argc, argv); + ReLogger logger; + ReDebugAppender appender; + appender.setAutoDelete(false); + logger.addAppender(&appender); + MainWindow w(workspace, project, &logger); + logger.log(LOG_INFO, 1, "start"); + w.show(); + + return a.exec(); +} diff --git a/appl/reide/mainwindow.cpp b/appl/reide/mainwindow.cpp new file mode 100644 index 0000000..17e4bda --- /dev/null +++ b/appl/reide/mainwindow.cpp @@ -0,0 +1,140 @@ +/* + * mainwindow.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 "reditor.hpp" +#include "ui_mainwindow.h" +#include + +MainWindow::MainWindow(const char* workspace, const char* project, + ReLogger* logger, QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow), + m_project(NULL), + m_workspace(NULL), + m_logger(logger), + m_fileTree(NULL), + m_dockProjectTree(NULL) { + if (workspace == NULL) + workspace = QDir::homePath().toUtf8(); + changeWorkspace(workspace == NULL ? QDir::homePath() : workspace); + + QString proj(project == NULL ? "" : project); + if (project == NULL) { + QStringList lastProjects; + m_workspace->historyAsList("projects", lastProjects); + int ix = 0; + while (proj.isEmpty() && ix < lastProjects.size()) { + QFileInfo dir(lastProjects.at(ix)); + if (dir.isDir() && dir.isWritable()) + proj = lastProjects.at(ix); + } + if (!proj.isEmpty()) + 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(); +} + +MainWindow::~MainWindow() { + delete ui; +} + +/** + * Change the current project. + * + * @param path the directory containing the project data + */ +void MainWindow::changeProject(QString path) { + delete m_project; + if (path.endsWith(OS_SEPARATOR_STR)) + path.remove(path.size() - 1, 1); + m_project = new Project(path, this); + int maxEntries = m_workspace->intValue("history.max_projects"); + m_workspace->addHistoryEntry(Workspace::KEY_HISTORY_PROJECTS, path, ';', + maxEntries); + if (m_fileTree == NULL) { + m_fileTree = new ReFileTree(path, m_logger, this); + m_dockProjectTree = new QDockWidget("", this); + m_dockProjectTree->setWidget(m_fileTree); + addDockWidget(Qt::LeftDockWidgetArea, m_dockProjectTree); + } + m_fileTree->setPath(path); + m_dockProjectTree->setWindowTitle( + tr("Project") + " " + ReQStringUtils::nodeOf(path)); + +} + +/** + * Change the workspace. + * + * @param path the directory containing the workspace data + */ +void MainWindow::changeWorkspace(const QString& path) { + delete m_workspace; + m_workspace = new Workspace(path, m_logger); +} + +/** + * Calls the file selection dialog. + */ +void MainWindow::openFile(const QString& name) { + m_file = new ReFile(name, false); + + 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); +} + +/** + * Closes the current project. + */ +void MainWindow::closeProject() { + delete m_project; + m_project = NULL; +} + +/** + * Shows the "open project/file dialog". + */ +void MainWindow::open() { + ProjectSelection dialog(this); + dialog.exec(); +} +ReLogger* MainWindow::logger() const { + return m_logger; +} + +/** + * Returns the current workspace. + * + * @return the current workspace + */ +Project* MainWindow::project() const { + return m_project; +} + +Workspace* MainWindow::workspace() const { + return m_workspace; +} + diff --git a/appl/reide/mainwindow.hpp b/appl/reide/mainwindow.hpp new file mode 100644 index 0000000..d80c6f9 --- /dev/null +++ b/appl/reide/mainwindow.hpp @@ -0,0 +1,50 @@ +/* + * mainwindow.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 MAINWINDOW_HPP +#define MAINWINDOW_HPP + +#include +#ifndef REBASE_HPP +#include "reditor.hpp" +#endif +namespace Ui { +class MainWindow; +} + +class MainWindow: public QMainWindow { + Q_OBJECT + +public: + explicit MainWindow(const char* workspace, const char* project, + ReLogger* logger, QWidget *parent = 0); + ~MainWindow(); + void changeProject(QString path); + void changeWorkspace(const QString& path); + void closeProject(); + void openFile(const QString& name); + Project* project() const; + Workspace* workspace() const; + ReLogger* logger() const; + +public slots: + void open(); +private: + Ui::MainWindow *ui; + ReFile* m_file; + Project* m_project; + Workspace* m_workspace; + ReLogger* m_logger; + ReFileTree* m_fileTree; + QDockWidget* m_dockProjectTree; +}; + +#endif // MAINWINDOW_HPP diff --git a/appl/reide/mainwindow.ui b/appl/reide/mainwindow.ui new file mode 100644 index 0000000..cad587b --- /dev/null +++ b/appl/reide/mainwindow.ui @@ -0,0 +1,99 @@ + + + MainWindow + + + + 0 + 0 + 803 + 642 + + + + MainWindow + + + + + + + + + + + + 0 + 0 + 803 + 23 + + + + + + TopToolBarArea + + + false + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + :/main/icons/table.png:/main/icons/table.png + + + Open + + + Open a file + + + Ctrl+O + + + + + + :/main/icons/disk.png:/main/icons/disk.png + + + Save + + + Save the file + + + Ctrl+S + + + + + + + ReEdit + QWidget +
gui/regui.hpp
+ 1 +
+
+ + + + +
diff --git a/appl/reide/project.cpp b/appl/reide/project.cpp new file mode 100644 index 0000000..ffda4ee --- /dev/null +++ b/appl/reide/project.cpp @@ -0,0 +1,41 @@ +/* + * 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 "reditor.hpp" + +const char* Project::KEY_HISTORY_OPEN_FILES = "openFiles"; +/** + * Constructor. + * + * @param path the directory containing the configuration + * @param logger the logger + */ +Project::Project(const QString& path, MainWindow* mainWindow) : + ReSettings(path, ".reditor.proj", mainWindow->logger()), + m_mainWindow(mainWindow) { + QString filename = topOfHistory(KEY_HISTORY_OPEN_FILES); + QFileInfo info(filename); + if (!filename.isEmpty() && info.exists() && !info.isDir()) { + m_mainWindow->openFile(filename); + } +} + +/** + * Opens a file in the project directory. + * + * @param filename the filename relative to the project directory + */ +void Project::openFile(const QString& filename) { + QString full = m_path + OS_SEPARATOR_STR + filename; + addHistoryEntry(KEY_HISTORY_OPEN_FILES, filename, ';', 1); + m_mainWindow->openFile(full); +} + diff --git a/appl/reide/project.hpp b/appl/reide/project.hpp new file mode 100644 index 0000000..dc0b267 --- /dev/null +++ b/appl/reide/project.hpp @@ -0,0 +1,29 @@ +/* + * 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 PROJECT_HPP +#define PROJECT_HPP + +class MainWindow; + +class Project: public ReSettings { +public: + static const char* KEY_HISTORY_OPEN_FILES; +public: + Project(const QString& path, MainWindow* mainWindow); +public: + void openFile(const QString& filename); + +private: + MainWindow* m_mainWindow; +}; + +#endif // PROJECT_HPP diff --git a/appl/reide/projectselection.cpp b/appl/reide/projectselection.cpp new file mode 100644 index 0000000..1d7fd72 --- /dev/null +++ b/appl/reide/projectselection.cpp @@ -0,0 +1,246 @@ +/* + * projectselection.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 "reditor.hpp" +#include "ui_projectselection.h" +#include +#include + +/** + * Constructor. + * + * @param parent NULL or the parent + * @param mainWindow the main window + */ +ProjectSelection::ProjectSelection(MainWindow* mainWindow, QWidget *parent) : + QDialog(parent), + ui(new Ui::ProjectSelection), + m_mainWindow(mainWindow) { + ui->setupUi(this); + connect(ui->toolButtonSelectFile, SIGNAL(clicked()), this, + SLOT(selectFile())); + connect(ui->toolButtonSelectProject, SIGNAL(clicked()), this, + SLOT(selectDir())); + connect(ui->pushButtonOpen, SIGNAL(clicked()), this, SLOT(open())); + connect(ui->lineEditFilterLastFile, SIGNAL(textChanged(QString)), this, + SLOT(textChangedFilterFiles(QString))); + connect(ui->tableWidgetFiles, SIGNAL(cellEntered(int,int)), this, + SLOT(cellEnteredFiles(int, int))); + connect(ui->tableWidgetProjects, SIGNAL(cellEntered(int,int)), this, + SLOT(cellEnteredProjects(int, int))); + Workspace* workspace = mainWindow->workspace(); + buildTableInfo(workspace, Workspace::KEY_HISTORY_FILES, true, m_files); + buildTableInfo(workspace, Workspace::KEY_HISTORY_PROJECTS, false, + m_projects); + buildTable("", m_files, ui->tableWidgetFiles); + buildTable("", m_projects, ui->tableWidgetProjects); +} + +/** + * Destructor. + */ +ProjectSelection::~ProjectSelection() { + delete ui; +} +/** + * Handles the event cellEntered for the last opened files. + * + * @param row the row of the entered cell + * @param col the column of the entered cell + */ +void ProjectSelection::cellEnteredFiles(int row, int col) { + ReUseParameter(col); + QString file = fileOfTable(ui->tableWidgetFiles, row); + ui->lineEditOpen->setText(file); +} + +/** + * Handles the event cellEntered for the last opened projects. + * + * @param row the row of the entered cell + * @param col the column of the entered cell + */ +void ProjectSelection::cellEnteredProjects(int row, int col) { + ReUseParameter(col); + QString file = fileOfTable(ui->tableWidgetProjects, row); + ui->lineEditOpen->setText(file); +} + +/** + * Builds the table from the table using a filter expression. + * + * @param filter a filter expression with wildcards '*' + * @param lines the full table info + * @param table OUT: will be filled with all lines matching the filter + */ +void ProjectSelection::buildTable(const QString& filter, + const QStringList& lines, QTableWidget* table) { + QStringList::const_iterator it; + int rowCount = 0; + ReMatcher matcher(filter, Qt::CaseInsensitive, true); + for (it = lines.cbegin(); it != lines.cend(); ++it) { + if (matcher.matches(*it)) + rowCount++; + } + table->setRowCount(rowCount); + int row = -1; + for (it = lines.cbegin(); it != lines.cend(); ++it) { + if (matcher.matches(*it)) { + row++; + QStringList cols = it->split('\t'); + for (int col = 0; col < cols.size(); col++) { + QTableWidgetItem* item = table->item(row, col); + if (item != NULL) + item->setText(cols.at(col)); + else { + item = new QTableWidgetItem(cols.at(col)); + table->setItem(row, col, item); + } + } + } + } +} + +/** + * Build the info for a table (last opened files or last opened projects). + * + * Note: the table shows a filtered part of this info. + * + * @param settings the history container + * @param key the name of the history entry + * @param withDate the file's name is part of the info + * @param tableContent OUT: the list containing the table info + */ +void ProjectSelection::buildTableInfo(ReSettings* settings, const char* key, + bool withDate, QStringList& tableContent) { + QStringList files; + settings->historyAsList(key, files); + QStringList::const_iterator it; + for (it = files.cbegin(); it != files.cend(); ++it) { + QFileInfo file(*it); + if (file.exists()) { + QString info = file.baseName(); + if (withDate) + info.append("\t").append( + file.lastModified().toString("yyyy.mm.dd/HH:MM:SS")); + info.append("\t").append(file.path()); + tableContent.append(info); + } + } +} + +/** + * Shows an error message. + * + * @param message message to show + */ +void ProjectSelection::error(const QString& message) { + QMessageBox dialog(QMessageBox::Critical, "Error", message, + QMessageBox::Close); + dialog.exec(); +} + +/** + * Extracts the full filename of a given table. + * + * The node is the first column, the path the last. + * + * @param table the table from which the filename is taken + * @param row the row where the filename is + * @return the full name of the file in the given row + */ +QString ProjectSelection::fileOfTable(QTableWidget* table, int row) { + int colPath = table->columnCount() - 1; + QString file = table->item(row, colPath)->text() + OS_SEPARATOR_STR + + table->item(row, 0)->text(); + return file; +} +/** + * Opens a file or a directory (project directory). + */ +void ProjectSelection::open() { + QString name = ui->lineEditOpen->text(); + if (name.isEmpty()) + error("missing filename/project directory"); + else { + QFileInfo file(name); + if (!file.exists()) + error("does not exists: " + name); + else { + if (file.isDir()) + m_mainWindow->changeProject(name); + else + m_mainWindow->openFile(name); + close(); + } + } +} + +/** + * Selects a directory (project directory) with an open dialog. + */ +void ProjectSelection::selectDir() { + QString name = ui->lineEditOpen->text(); + if (name.isEmpty() && m_mainWindow->project() != NULL) + name = m_mainWindow->project()->path(); + name = QFileDialog::getExistingDirectory(this, + tr("Select Project Directory"), name); + if (!name.isEmpty()) { + ui->lineEditOpen->setText(name); + open(); + } +} + +/** + * Selects a file with a file open dialog. + */ +void ProjectSelection::selectFile() { + QString name = ui->lineEditOpen->text(); + name = QFileDialog::getOpenFileName(this, tr("Select File"), name); + if (!name.isEmpty()) { + ui->lineEditOpen->setText(name); + open(); + } +} + +/** + * Handles the filter text change for a given table. + * + * @param text the filter text + * @param table the table which will be filled + * @param lines the full (unfiltered) table info + */ +void ProjectSelection::textChanged(const QString& text, QTableWidget* table, + const QStringList& lines) { + buildTable(text, lines, table); + if (table->rowCount() > 0) { + QString file = fileOfTable(table, 0); + ui->lineEditOpen->setText(file); + } +} + +/** + * Handles the event "text changed" of the last opened files. + * + * @param text the new text + */ +void ProjectSelection::textChangedFilterFiles(const QString& text) { + textChanged(text, ui->tableWidgetFiles, m_files); +} + +/** + * Handles the event "text changed" of the last opened projects. + * + * @param text the new text + */ +void ProjectSelection::textChangedFilterProjects(const QString& text) { + textChanged(text, ui->tableWidgetProjects, m_projects); +} diff --git a/appl/reide/projectselection.hpp b/appl/reide/projectselection.hpp new file mode 100644 index 0000000..ea17c30 --- /dev/null +++ b/appl/reide/projectselection.hpp @@ -0,0 +1,53 @@ +/* + * projectselection.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 PROJECTSELECTION_HPP +#define PROJECTSELECTION_HPP +#include "reditor.hpp" +#include +#include +namespace Ui { +class ProjectSelection; +} +class MainWindow; +class ProjectSelection: public QDialog { + Q_OBJECT + +public: + explicit ProjectSelection(MainWindow* mainWindow, QWidget *parent = 0); + ~ProjectSelection(); + +public slots: + void open(); + void selectDir(); + void selectFile(); +protected: + void buildTable(const QString& filter, const QStringList& lines, + QTableWidget* table); + void buildTableInfo(ReSettings* settings, const char* key, bool withDate, + QStringList& tableContent); + QString fileOfTable(QTableWidget* table, int row); + void textChanged(const QString& text, QTableWidget* table, + const QStringList& lines);protected slots: + void cellEnteredFiles(int row, int col); + void cellEnteredProjects(int row, int col); + void textChangedFilterFiles(const QString& text); + void textChangedFilterProjects(const QString& text); +private: + void error(const QString& message); +private: + Ui::ProjectSelection *ui; + MainWindow* m_mainWindow; + QStringList m_files; + QStringList m_projects; +}; + +#endif // PROJECTSELECTION_HPP diff --git a/appl/reide/projectselection.ui b/appl/reide/projectselection.ui new file mode 100644 index 0000000..8b24b07 --- /dev/null +++ b/appl/reide/projectselection.ui @@ -0,0 +1,227 @@ + + + ProjectSelection + + + + 0 + 0 + 1034 + 703 + + + + Dialog + + + + + + + 16777215 + 75 + + + + Open new file/project: + + + + + + Name of the file/project directory to open + + + + + + + Opens the file/project (Control-O) + + + Open + + + + + + + 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 + + + + + + + + + + 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/reditor.hpp b/appl/reide/reditor.hpp new file mode 100644 index 0000000..e606072 --- /dev/null +++ b/appl/reide/reditor.hpp @@ -0,0 +1,22 @@ +/* + * reditor.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 REDITOR_HPP +#define REDITOR_HPP +#include +#include "base/rebase.hpp" +#include "gui/regui.hpp" +#include "workspace.hpp" +#include "project.hpp" +#include "mainwindow.hpp" +#include "projectselection.hpp" +#endif // REDITOR_HPP + diff --git a/appl/reide/reide.pro b/appl/reide/reide.pro new file mode 100644 index 0000000..a47db11 --- /dev/null +++ b/appl/reide/reide.pro @@ -0,0 +1,50 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-06-03T20:56:48 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = ReEditor +TEMPLATE = app + +INCLUDEPATH += ../.. + +SOURCES += \ + ../../gui/ReEdit.cpp \ + ../../gui/ReStateStorage.cpp \ + ../../gui/ReSettings.cpp \ + ../../base/ReFile.cpp \ + ../../gui/ReFileTree.cpp \ + mainwindow.cpp \ + ../../base/ReLogger.cpp \ + ../../base/ReQStringUtils.cpp \ + ../../base/ReFileUtils.cpp \ + ../../base/ReException.cpp \ + projectselection.cpp \ + workspace.cpp \ + project.cpp \ + main.cpp + + +HEADERS += mainwindow.hpp \ + ../../base/rebase.hpp \ + ../../gui/regui.hpp \ + ../../gui/ReEdit.hpp \ + ../../base/ReStringUtils.hpp \ + ../../base/ReQStringUtils.hpp \ + ../../base/ReException.hpp \ + projectselection.hpp \ + workspace.hpp \ + project.hpp \ + reditor.hpp \ + storage.hpp + +FORMS += mainwindow.ui \ + projectselection.ui + +RESOURCES += \ + editor.qrc diff --git a/appl/reide/workspace.cpp b/appl/reide/workspace.cpp new file mode 100644 index 0000000..809c011 --- /dev/null +++ b/appl/reide/workspace.cpp @@ -0,0 +1,40 @@ +/* + * workspace.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 "reditor.hpp" + +const char* Workspace::KEY_HISTORY_FILES = "files"; +const char* Workspace::KEY_HISTORY_PROJECTS = "projecs"; + +/** + * Constructor. + * + * @param path the directory containing the configuration + * @param logger the logger + */ +Workspace::Workspace(const QString& path, ReLogger* logger) : + ReSettings(path, ".reditor.ws", logger) { + insertProperty( + new ReProperty("editor.tabwidth", QObject::tr("Tabulator width"), + QObject::tr("Maximal length of the gap displaying a tabulator"), + "4", PT_INT, "[1,16]")); + insertProperty( + new ReProperty("history.max_projects", + QObject::tr("Maximal project entries"), + QObject::tr( + "Maximal number of projects in the 'last opened projects'"), + "20", PT_INT, "[1,100]")); + insertProperty( + new ReProperty("history.max_files", QObject::tr("Maximal file entries"), + QObject::tr("Maximal number of files in the 'last opened files'"), + "20", PT_INT, "[1,100]")); +} + diff --git a/appl/reide/workspace.hpp b/appl/reide/workspace.hpp new file mode 100644 index 0000000..8776fed --- /dev/null +++ b/appl/reide/workspace.hpp @@ -0,0 +1,23 @@ +/* + * workspace.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 WORKSPACE_HPP +#define WORKSPACE_HPP + +class Workspace: public ReSettings { +public: + static const char* KEY_HISTORY_FILES; + static const char* KEY_HISTORY_PROJECTS; +public: + Workspace(const QString& path, ReLogger* logger); +}; + +#endif // WORKSPACE_HPP