* You also can use this license: http://www.wtfpl.net
* The latest sources: https://github.com/republib
*/
-#include "reditor.hpp"
+#include "reide.hpp"
#include <QApplication>
int main(int argc, char *argv[]) {
* The latest sources: https://github.com/republib
*/
-#include "reditor.hpp"
+#include "reide.hpp"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QMainWindow>
#ifndef REBASE_HPP
-#include "reditor.hpp"
+#include "reide.hpp"
#endif
namespace Ui {
class MainWindow;
* The latest sources: https://github.com/republib
*/
-#include "reditor.hpp"
+#include "reide.hpp"
const char* Project::KEY_HISTORY_OPEN_FILES = "openFiles";
/**
* The latest sources: https://github.com/republib
*/
-#include "reditor.hpp"
+#include "reide.hpp"
#include "ui_projectselection.h"
#include <QFileDialog>
#include <QMessageBox>
#ifndef PROJECTSELECTION_HPP
#define PROJECTSELECTION_HPP
-#include "reditor.hpp"
+#include "reide.hpp"
#include <QDialog>
#include <QTableWidget>
namespace Ui {
+++ /dev/null
-/*
- * 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 <QDockWidget>
-#include "base/rebase.hpp"
-#include "gui/regui.hpp"
-#include "workspace.hpp"
-#include "project.hpp"
-#include "mainwindow.hpp"
-#include "projectselection.hpp"
-#endif // REDITOR_HPP
-
--- /dev/null
+/*
+ * 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 REIDE_HPP
+#define REIDE_HPP
+#include <QDockWidget>
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "views/View.hpp"
+#include "views/EditorView.hpp"
+#include "views/FileTreeView.hpp"
+#include "views/Perspective.hpp"
+#include "views/ProjectPerspective.hpp"
+#include "workspace.hpp"
+#include "project.hpp"
+#include "mainwindow.hpp"
+#include "projectselection.hpp"
+#endif // REIDE_HPP
+
projectselection.cpp \
workspace.cpp \
project.cpp \
+ views/View.cpp \
+ views/FileTreeView.cpp \
+ views/EditorView.cpp \
+ views/Perspective.cpp \
+ views/ProjectPerspective.cpp \
main.cpp
projectselection.hpp \
workspace.hpp \
project.hpp \
- reditor.hpp \
- storage.hpp
+ storage.hpp \
+ reide.hpp
FORMS += mainwindow.ui \
projectselection.ui
--- /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)
+ */
+EditorView::EditorView(MainWindow* mainWindow) :
+ View("EditorView", mainWindow),
+ m_edit(new ReEdit(NULL)) {
+}
+
+/**
+ * Destructor.
+ */
+EditorView::~EditorView() {
+ delete m_edit;
+ m_edit = NULL;
+}
+
--- /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 EDITORVIEW_HPP
+#define EDITORVIEW_HPP
+
+class MainWindow;
+
+/**
+ * Abstract base class of the views.
+ *
+ * A view is a widget displayed as a dock in the window displaying a perspective.
+ */
+class EditorView: public View {
+public:
+ EditorView(MainWindow* mainWindow);
+ ~EditorView();
+public:
+ virtual QWidget* widget() {
+ return m_edit;
+ }
+ ;
+protected:
+ ReEdit* m_edit;
+};
+
+#endif // EDITORVIEW_HPP
--- /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 name the name of the view
+ * @param mainWindow the parent (main window)
+ */
+FileTreeView::FileTreeView(MainWindow* mainWindow) :
+ View("FileTreeView", mainWindow) {
+}
--- /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 FILETREEVIEW_HPP
+#define FILETREEVIEW_HPP
+
+/**
+ * Base class of the views.
+ *
+ * A view is a widget displayed as a dock in the window displaying a perspective.
+ */
+class FileTreeView: public View {
+public:
+ FileTreeView(MainWindow* mainWindow);
+public:
+ /** Returns the view specific widget.
+ * @return the view specific widget
+ */
+ virtual QWidget* widget() {
+ return m_fileTree;
+ }
+protected:
+ ReFileTree* m_fileTree;
+};
+
+#endif // FILETREEVIEW_HPP
--- /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 name the name of the perspective
+ * @param mainWindow the parent (main window)
+ */
+Perspective::Perspective(const char* name, MainWindow* mainWindow) :
+ m_name(name),
+ m_mainWindow(mainWindow) {
+}
+
+/**
+ * Destructor.
+ */
+Perspective::~Perspective() {
+ for (int ix = 0; ix < m_views.size(); ix++)
+ delete m_views.at(ix);
+ m_views.clear();
+}
+
+/**
+ * Sets the views as docks in the main window.
+ */
+void Perspective::activate() {
+ // the first view is the central widget, not a dock
+ m_mainWindow->setCentralWidget(m_views.at(0)->m_view->widget());
+ for (int ix = 1; ix < m_views.size(); ix++) {
+ ViewInfo* info = m_views.at(ix);
+ m_mainWindow->addDockWidget(info->m_position, info->m_dockWidget);
+ }
+}
+
+/**
+ * Appends a view to the view list.
+ *
+ * @param view the view to append
+ * @param position the positon of the dock
+ */
+void Perspective::append(View* view, Qt::DockWidgetArea position) {
+ ViewInfo* info = new ViewInfo();
+ info->m_position = position;
+ info->m_view = view;
+ info->m_dockWidget = new QDockWidget(m_mainWindow);
+ info->m_dockWidget->setWidget(view->widget());
+ m_views.append(info);
+}
+
+/**
+ * Removes the views (as docks) from the main window.
+ */
+void Perspective::deactivate() {
+ // the first view is the central widget, not a dock
+ for (int ix = 1; ix < m_views.size(); ix++) {
+ ViewInfo* info = m_views.at(ix);
+ m_mainWindow->removeDockWidget(info->m_dockWidget);
+ }
+}
+
+/**
+ * Constructor.
+ */
+PerspectiveList::PerspectiveList(MainWindow* mainWindow) :
+ m_current(NULL),
+ m_map(),
+ m_mainWindow(mainWindow) {
+}
+
+/**
+ * Adds a perspective to the collection.
+ *
+ * @param perspective the perspective to add
+ */
+void PerspectiveList::addPerspective(Perspective* perspective) {
+ m_map.insert(perspective->name(), perspective);
+}
+
+/**
+ * Deactivates the current perspective and activates another.
+ *
+ * @param perspective name of the new active perspective
+ */
+void PerspectiveList::changePerspective(const QByteArray& perspective) {
+ if (m_current != NULL)
+ m_current->deactivate();
+ m_current = m_map.value(perspective);
+ if (m_current != NULL)
+ m_current->activate();
+}
--- /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 PERSPECTIVE_HPP
+#define PERSPECTIVE_HPP
+
+class MainWindow;
+
+class ViewInfo {
+public:
+ View* m_view;
+ Qt::DockWidgetArea m_position;
+ QDockWidget* m_dockWidget;
+};
+
+/**
+ * Abstract base class for perspectives.
+ *
+ * A perspective is a collection of views displayed as docks of a window.
+ */
+class Perspective {
+public:
+ Perspective(const char* name, MainWindow* mainWindow);
+ ~Perspective();
+public:
+ void activate();
+ void append(View* view, Qt::DockWidgetArea location);
+ /** Returns the perspective's name.
+ * @return the name
+ */
+ const QByteArray& name() const {
+ return m_name;
+ }
+ /**
+ * Prepares the <code>m_map</code> with the views.
+ */
+ virtual void setDefaultViews() = 0;
+ void deactivate();
+
+protected:
+ QByteArray m_name;
+ MainWindow* m_mainWindow;
+ QList<ViewInfo*> m_views;
+};
+
+/**
+ * Manages a collection of <code>Perspective</code>s.
+ */
+class PerspectiveList {
+public:
+ PerspectiveList(MainWindow* mainWindow);
+public:
+ void addPerspective(Perspective* perspective);
+ void changePerspective(const QByteArray& perspective);
+private:
+ Perspective* m_current;
+ QMap<QByteArray, Perspective*> m_map;
+ MainWindow* m_mainWindow;
+};
+
+#endif // PERSPECTIVE_HPP
--- /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)
+ */
+ProjectPerspective::ProjectPerspective(MainWindow* mainWindow) :
+ Perspective("ProjectPerspective", mainWindow) {
+}
+
+void ProjectPerspective::setDefaultViews() {
+ append(new EditorView(m_mainWindow), Qt::NoDockWidgetArea);
+ append(new FileTreeView(m_mainWindow), Qt::LeftDockWidgetArea);
+}
--- /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 PROJECTPERSPECTIVE_HPP
+#define PROJECTPERSPECTIVE_HPP
+
+/**
+ * Manages the aspects of a standard project.
+ */
+class ProjectPerspective: public Perspective {
+public:
+ ProjectPerspective(MainWindow* mainWindow);
+public:
+ virtual void setDefaultViews();
+};
+
+#endif // PROJECTPERSPECTIVE_HPP
--- /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 name the name of the view
+ * @param mainWindow the parent (main window)
+ */
+View::View(const char* name, MainWindow* mainWindow) :
+ m_name(name),
+ m_mainWindow(mainWindow) {
+}
--- /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 VIEW_HPP
+#define VIEW_HPP
+
+class MainWindow;
+
+/**
+ * Base class of the views.
+ *
+ * A view is a widget displayed as a dock in the window displaying a perspective.
+ */
+class View {
+public:
+ View(const char* name, MainWindow* mainWindow);
+public:
+ /** Returns the view's name.
+ * @return the name
+ */
+ const QByteArray& name() const {
+ return m_name;
+ }
+ /**
+ * Returns the view specific widget.
+ * @return the view specific widget
+ */
+ virtual QWidget* widget() = 0;
+
+protected:
+ QByteArray m_name;
+ MainWindow* m_mainWindow;
+};
+
+#endif // VIEW_HPP
* The latest sources: https://github.com/republib
*/
-#include "reditor.hpp"
+#include "reide.hpp"
const char* Workspace::KEY_HISTORY_FILES = "files";
const char* Workspace::KEY_HISTORY_PROJECTS = "projecs";