Permalink
Browse files

New template system and more refactoring

  • Loading branch information...
bmcdorman committed Oct 7, 2012
1 parent 01069b2 commit 3e499889e0ee7c1f9ebe8deffd50f283b6787687
Showing with 3,902 additions and 1,414 deletions.
  1. +22 −2 CMakeLists.txt
  2. +20 −0 include/c_highlighter.hpp
  3. +76 −0 include/code_editor.hpp
  4. +0 −56 include/dialogs/template_dialog.hpp
  5. +25 −0 include/interface/dummy_interface.hpp
  6. +35 −0 include/kar.hpp
  7. +18 −6 include/main_window.hpp
  8. +1 −0 include/menus/menus.hpp
  9. +53 −0 include/menus/template_pack_menu.hpp
  10. +4 −3 include/project/project.hpp
  11. +2 −2 include/project/project_manager.hpp
  12. +52 −0 include/project/project_model.hpp
  13. +8 −9 include/source_file.hpp
  14. +48 −0 include/syntax_highlighter.hpp
  15. +5 −1 include/tab.hpp
  16. +45 −0 include/template_dialog.hpp
  17. +33 −0 include/template_file.hpp
  18. +0 −72 include/template_format.hpp
  19. +32 −59 include/template_manager.hpp
  20. +47 −0 include/template_model.hpp
  21. +67 −0 include/template_pack.hpp
  22. +72 −0 include/template_tab.hpp
  23. +44 −0 include/unit.hpp
  24. +29 −0 include/widgets/icon_widget.hpp
  25. +5 −2 include/widgets/output_widget.hpp
  26. +0 −37 include/working_unit.hpp
  27. +1 −1 plugins/interfaces/CMakeLists.txt
  28. +3 −3 plugins/interfaces/cbc3/CMakeLists.txt
  29. +0 −28 plugins/interfaces/cbc3/Cbc3Interface.h
  30. +12 −13 plugins/interfaces/cbc3/{Cbc3Interface.cpp → kovan_interface.cpp}
  31. +28 −0 plugins/interfaces/cbc3/kovan_interface.hpp
  32. +2 −2 plugins/interfaces/computer/CMakeLists.txt
  33. +6 −6 plugins/interfaces/computer/{ComputerInterface.cpp → computer_interface.cpp}
  34. +5 −8 plugins/interfaces/computer/{ComputerInterface.h → computer_interface.hpp}
  35. +2 −2 plugins/interfaces/serial/CMakeLists.txt
  36. +0 −45 plugins/interfaces/shared/SerialDevice.h
  37. +0 −52 plugins/interfaces/shared/TcpSocketDevice.h
  38. 0 plugins/interfaces/shared/{Keys.h → keys.hpp}
  39. +21 −33 plugins/interfaces/shared/{SerialDevice.cpp → serial_device.cpp}
  40. +51 −0 plugins/interfaces/shared/serial_device.hpp
  41. +1 −1 plugins/interfaces/shared/{SerialIODevice.cpp → serial_io_device.cpp}
  42. 0 plugins/interfaces/shared/{SerialIODevice.h → serial_io_device.hpp}
  43. +27 −36 plugins/interfaces/shared/{TcpSocketDevice.cpp → tcp_socket_device.cpp}
  44. +57 −0 plugins/interfaces/shared/tcp_socket_device.hpp
  45. +1 −1 plugins/lexers/c/CMakeLists.txt
  46. +36 −11 plugins/lexers/c/{LexerC.cpp → lexer_c.cpp}
  47. +27 −24 plugins/lexers/c/{LexerC.h → lexer_c.hpp}
  48. +1 −1 plugins/lexers/cpp/CMakeLists.txt
  49. +35 −12 plugins/lexers/cpp/{LexerCPP.cpp → lexer_cpp.cpp}
  50. +26 −23 plugins/lexers/cpp/{LexerCPP.h → lexer_cpp.hpp}
  51. +1 −1 plugins/lexers/java/CMakeLists.txt
  52. +34 −10 plugins/lexers/java/{LexerJava.cpp → lexer_java.cpp}
  53. +26 −23 plugins/lexers/java/{LexerJava.h → lexer_java.hpp}
  54. +1 −1 plugins/lexers/javascript/CMakeLists.txt
  55. +0 −20 plugins/lexers/javascript/LexerJavaScript.cpp
  56. +42 −0 plugins/lexers/javascript/lexer_javascript.cpp
  57. +28 −25 plugins/lexers/javascript/{LexerJavaScript.h → lexer_javascript.hpp}
  58. +1 −1 plugins/lexers/python/CMakeLists.txt
  59. +34 −12 plugins/lexers/python/{LexerPython.cpp → lexer_python.cpp}
  60. +26 −23 plugins/lexers/python/{LexerPython.h → lexer_python.hpp}
  61. BIN rc/icon_set/icons/eye.png
  62. BIN rc/icon_set/icons/package.png
  63. +2 −0 rc/rc.qrc
  64. +1 −1 scripts/osx_install_names.sh
  65. +69 −0 src/c_highlighter.cpp
  66. +217 −0 src/code_editor.cpp
  67. +0 −192 src/dialogs/template_dialog.cpp
  68. +99 −0 src/interface/dummy_interface.cpp
  69. +97 −0 src/kar.cpp
  70. +5 −5 src/lexer/syntax_standards.cpp
  71. +4 −2 src/main.cpp
  72. +112 −33 src/main_window.cpp
  73. +12 −3 src/menus/file_operations_menu.cpp
  74. +30 −5 src/menus/menu_manager.cpp
  75. +1 −1 src/menus/source_file_menu.cpp
  76. +55 −0 src/menus/template_pack_menu.cpp
  77. +8 −5 src/project/project.cpp
  78. +215 −0 src/project/project_model.cpp
  79. +3 −2 src/resource_helper.cpp
  80. +125 −164 src/source_file.cpp
  81. +86 −0 src/syntax_highlighter.cpp
  82. +10 −0 src/tab.cpp
  83. +64 −0 src/template_dialog.cpp
  84. +48 −0 src/template_file.cpp
  85. +0 −97 src/template_format.cpp
  86. +28 −110 src/template_manager.cpp
  87. +237 −0 src/template_model.cpp
  88. +185 −0 src/template_pack.cpp
  89. +219 −0 src/template_tab.cpp
  90. +85 −0 src/unit.cpp
  91. +11 −7 src/web_tab.cpp
  92. +27 −0 src/widgets/icon_widget.cpp
  93. +129 −2 src/widgets/output_widget.cpp
  94. +0 −62 src/working_unit.cpp
  95. +11 −2 tests/CMakeLists.txt
  96. +0 −28 tests/CommandChainTest.cpp
  97. +0 −25 tests/OutputWidgetTest.cpp
  98. +26 −0 tests/code_editor_test.cpp
  99. +53 −0 tests/output_widget_test.cpp
  100. +25 −0 tests/project_model_test.cpp
  101. +48 −0 tests/template_test.cpp
  102. +3 −0 ui/MainWindow.ui
  103. +1 −1 ui/SourceFile.ui
  104. +141 −0 ui/template_dialog.ui
  105. +132 −0 ui/template_tab.ui
View
@@ -36,7 +36,7 @@ SET(QT_USE_PHONON TRUE)
INCLUDE(${QT_USE_FILE})
-FILE(GLOB INCLUDES ${INCLUDE}/*.h
+FILE(GLOB INCLUDES ${INCLUDE}/*.hpp
${INCLUDE}/lexer/*
${INCLUDE}/dialogs/*
${INCLUDE}/widgets/*
@@ -80,7 +80,7 @@ ADD_LIBRARY(kisside STATIC ${KISS_SRCS_CXX})
SET(EXECUTABLE_OUTPUT_PATH ${KISS_SOURCE_DIR}/deploy)
SET(LIBRARY_OUTPUT_PATH ${KISS_SOURCE_DIR}/lib)
-TARGET_LINK_LIBRARIES(KISS ${QT_LIBRARIES} qscintilla2 pcompiler tinyarchive z)
+TARGET_LINK_LIBRARIES(KISS ${QT_LIBRARIES} qscintilla2 pcompiler)
IF(APPLE)
ADD_CUSTOM_TARGET(MacDeployQt ALL
@@ -106,6 +106,26 @@ ELSE(APPLE)
install(DIRECTORY ${RC}/templates DESTINATION ${KISS_SOURCE_DIR}/deploy)
ENDIF(APPLE)
+IF(APPLE)
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
+ADD_CUSTOM_TARGET(kiss_osx_install_names ALL
+ COMMAND ${OSX_INSTALL_NAMES_SCRIPT} ${EXECUTABLE_OUTPUT_PATH}/KISS.app/Contents/MacOS/KISS
+ QtCore.framework/Versions/4/QtCore
+ QtScript.framework/Versions/4/QtScript
+ QtDBus.framework/Versions/4/QtDBus
+ QtGui.framework/Versions/4/QtGui
+ QtNetwork.framework/Versions/4/QtNetwork
+ QtXml.framework/Versions/4/QtXml
+ QtXmlPatterns.framework/Versions/4/QtXmlPatterns
+ QtSvg.framework/Versions/4/QtSvg
+ QtSql.framework/Versions/4/QtSql
+ QtWebKit.framework/Versions/4/QtWebKit
+ phonon.framework/Versions/4/phonon
+ QtDeclarative.framework/Versions/4/QtDeclarative
+ WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
+ DEPENDS KISS Info.plist MacDeployQt)
+ENDIF(APPLE)
+
# Accessory Programs
LINK_DIRECTORIES(${KISS_SOURCE_DIR}/lib)
View
@@ -0,0 +1,20 @@
+#ifndef _C_HIGHLIGHTER_HPP_
+#define _C_HIGHLIGHTER_HPP_
+
+#include "syntax_highlighter.hpp"
+
+#include <QHash>
+
+class QTextDocument;
+
+namespace Kiss
+{
+ class CHighlighter : public SyntaxHighlighter
+ {
+ Q_OBJECT
+ public:
+ CHighlighter(QTextDocument *parent = 0);
+ };
+}
+
+#endif
View
@@ -0,0 +1,76 @@
+#ifndef _CODE_EDITOR_HPP_
+#define _CODE_EDITOR_HPP_
+
+#include <QMap>
+#include <QWidget>
+#include <QPlainTextEdit>
+
+namespace Kiss
+{
+ namespace Widget
+ {
+ class CodeEditor;
+
+ class CodeEditorMargin : public QWidget
+ {
+ public:
+ CodeEditorMargin(CodeEditor *editor);
+ QSize sizeHint() const;
+
+ protected:
+ void paintEvent(QPaintEvent *event);
+
+ private:
+ CodeEditor *m_editor;
+ };
+
+ class MarginIndicator
+ {
+ public:
+ MarginIndicator(const QColor& color);
+ const QColor& color() const;
+
+ static const MarginIndicator& none();
+ private:
+ QColor m_color;
+
+ static MarginIndicator s_none;
+ };
+
+ class CodeEditor : public QPlainTextEdit
+ {
+ Q_OBJECT
+ public:
+ CodeEditor(QWidget *parent = 0);
+
+ void setEditorFont(const QFont& font);
+ QFont editorFont() const;
+ QFont marginFont() const;
+
+ void setMarginIndicator(const int& line, const MarginIndicator& indicator);
+ void clearIndicators();
+
+ quint16 marginSize() const;
+
+ friend class CodeEditorMargin;
+ protected:
+ void marginPaintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *e);
+ void scrollContentsBy(int dx, int dy);
+
+ void keyPressEvent(QKeyEvent *e);
+
+ private slots:
+ void highlightCurrentLine();
+ void updateMarginArea(const QRect& rect, const int& dy);
+ void updateMarginSize();
+
+ private:
+ QFont m_marginFont;
+ CodeEditorMargin *m_margin;
+ QMap<int, MarginIndicator> m_indicators;
+ };
+ }
+}
+
+#endif
@@ -1,56 +0,0 @@
-/**************************************************************************
- * Copyright 2007-2012 KISS Institute for Practical Robotics *
- * *
- * This file is part of KISS (Kipr's Instructional Software System). *
- * *
- * KISS is free software: you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation, either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * KISS is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with KISS. Check the LICENSE file in the project root. *
- * If not, see <http://www.gnu.org/licenses/>. *
- **************************************************************************/
-
-#ifndef __TEMPLATEDIALOG_H__
-#define __TEMPLATEDIALOG_H__
-
-#include "ui_TemplateDialog.h"
-#include <QDialog>
-#include <QFile>
-
-class TemplateDialog : public QDialog, private Ui::TemplateDialog
-{
- Q_OBJECT
-public:
- TemplateDialog(QWidget* parent = 0);
-
- int exec();
-
- // Returns to the path of the target file for the selected target
-
- QString selectedTypeName() const;
- QString templateFile() const;
- QByteArray templateData() const;
-
-private slots:
- void on_ui_types_currentItemChanged(QListWidgetItem* current, QListWidgetItem* prev);
- void on_ui_templates_itemDoubleClicked(QTreeWidgetItem* current);
-
- void on_ui_templates_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem*);
- void on_ui_remove_clicked();
- void on_ui_install_clicked();
-
-private:
- void addTemplates(const QString& target, QTreeWidgetItem* parentItem, const QString& parent);
- void addUserTemplates(const QString& target);
- void addPackTemplates(const QString& pack);
-};
-
-#endif
@@ -0,0 +1,25 @@
+#ifndef _DUMMY_INTERFACE_HPP_
+#define _DUMMY_INTERFACE_HPP_
+
+#include "interface.hpp"
+
+#include <QObject>
+
+namespace Kiss
+{
+ namespace Target
+ {
+ class DummyInterface : public QObject, public Interface
+ {
+ Q_OBJECT
+ Q_INTERFACES(Kiss::Target::Interface)
+ public:
+ DummyInterface();
+
+ virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
+ virtual void invalidateResponder();
+ };
+ }
+}
+
+#endif
View
@@ -0,0 +1,35 @@
+#ifndef _KAR_HPP_
+#define _KAR_HPP_
+
+#include <QString>
+#include <QMap>
+#include <QStringList>
+#include <QByteArray>
+
+namespace Kiss
+{
+ class Kar
+ {
+ public:
+ bool addFile(const QString& name, const QByteArray& data);
+ void setFile(const QString& name, const QByteArray& data);
+ bool removeFile(const QString& name);
+ bool hasFile(const QString& name);
+ bool rename(const QString& name, const QString& newName);
+
+ QByteArray data(const QString& name) const;
+ QStringList files() const;
+
+ static Kar *create();
+ static Kar *load(const QString& path);
+ bool save(const QString& path);
+
+ private:
+ Kar();
+ Kar(const QMap<QString, QByteArray>& data);
+
+ QMap<QString, QByteArray> m_data;
+ };
+}
+
+#endif
View
@@ -28,6 +28,7 @@
#include "menu_manager.hpp"
#include "project_manager.hpp"
+#include "project_model.hpp"
#include "main_window_menu.hpp"
#include <Qsci/qscilexercpp.h>
@@ -42,6 +43,11 @@ class QListWidgetItem;
namespace Kiss
{
+ namespace Template
+ {
+ class Manager;
+ }
+
namespace Widget
{
class SourceFile;
@@ -67,9 +73,9 @@ namespace Kiss
bool openFile(const QString& filePath);
bool memoryOpen(const QByteArray& ba, const QString& assocPath);
bool openProject(const QString& filePath);
- bool newProject(const QString& filePath);
+ bool newProject(const QString& folderPath);
- void initMenus(Tab* tab);
+ void initMenus(Tab *tab);
void initMenus();
@@ -142,10 +148,13 @@ namespace Kiss
Menu::Manager *menuManager();
Menu::Menuable* menuable(const QString& name);
- QList<Menu::Menuable*> menuablesExcept(const QStringList& name);
+ QList<Menu::Menuable*> menuablesExcept(const QStringList& names);
+ void deactivateMenuablesExcept(const QStringList& names);
QList<Menu::Menuable*> menuables();
void activateMenuable(const QString& name, QObject *on);
QStringList standardMenus() const;
+
+ Template::Manager *templateManager() const;
void restart();
@@ -158,6 +167,8 @@ namespace Kiss
friend class Menu::MainWindowMenu;
public slots:
+ void importTemplatePack();
+ void newTemplatePack();
Project::Project *newProject();
void newFile();
void open();
@@ -198,19 +209,20 @@ namespace Kiss
void projectClicked(const QModelIndex& index);
void projectFileClicked(const QModelIndex& index);
- void projectOpened(Project::Project *project);
- void projectClosed(Project::Project *project);
+ void projectOpened(Kiss::Project::Project *project);
+ void projectClosed(Kiss::Project::Project *project);
private:
Tab *m_currentTab;
EditorSettingsDialog m_editorSettingsDialog;
ThemeSettingsDialog m_themeSettingsDialog;
QMap<QWidget *, Tab *> m_lookup;
Menu::Manager m_menuManager;
+ Template::Manager *m_templateManager;
Project::Manager m_projectManager;
QList<Menu::Menuable *> m_menuables;
- // ProjectsModel m_projectsModel;
+ Project::Model m_projectsModel;
void addLookup(Tab *tab);
void removeLookup(QWidget* widget);
View
@@ -24,6 +24,7 @@
#include "menu_manager.hpp"
#include "target_menu.hpp"
#include "source_file_menu.hpp"
+#include "template_pack_menu.hpp"
#include "web_tab_menu.hpp"
#include "main_window_menu.hpp"
#include "developer_menu.hpp"
Oops, something went wrong.

0 comments on commit 3e49988

Please sign in to comment.