Browse Source

misc

cl-refactor
yann300 10 years ago
parent
commit
d97c0b5141
  1. 2
      mix/CMakeLists.txt
  2. 16
      mix/CodeEditorExtensionMan.cpp
  3. 9
      mix/CodeEditorExtensionMan.h
  4. 11
      mix/ConstantCompilation.cpp
  5. 6
      mix/ConstantCompilation.h
  6. 1
      mix/Feature.cpp
  7. 1
      mix/Feature.h

2
mix/CMakeLists.txt

@ -10,7 +10,7 @@ elseif ("${TARGET_PLATFORM}" STREQUAL "w64")
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp)
include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets)
elseif (UNIX) elseif (UNIX)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake" /opt/Qt5.3.2/5.3/gcc_64/lib/cmake/Qt5Declarative) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake")
endif () endif ()
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)

16
mix/CodeEditorExtensionMan.cpp

@ -38,6 +38,13 @@ CodeEditorExtensionManager::CodeEditorExtensionManager()
{ {
} }
CodeEditorExtensionManager::~CodeEditorExtensionManager()
{
for (int k = 0; k < m_features.length(); k++){
delete m_features.at(k);
}
}
void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor) void CodeEditorExtensionManager::loadEditor(QQuickItem* _editor)
{ {
if (!_editor) if (!_editor)
@ -61,10 +68,11 @@ void CodeEditorExtensionManager::initExtensions()
{ {
try{ try{
//only one for now //only one for now
ConstantCompilation* compil = new ConstantCompilation(m_doc); ConstantCompilation* m_constantCompilation = new ConstantCompilation(m_doc);
if (compil->tabUrl() != "") if (m_constantCompilation->tabUrl() != "")
compil->addContentOn(m_tabView); m_constantCompilation->addContentOn(m_tabView);
compil->start(); m_constantCompilation->start();
m_features.append(m_constantCompilation);
} }
catch (dev::Exception const& exception){ catch (dev::Exception const& exception){
qDebug() << "unable to load extensions: "; qDebug() << "unable to load extensions: ";

9
mix/CodeEditorExtensionMan.h

@ -20,11 +20,12 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#ifndef CODEEDITOREXTENSIONMANAGER_H #ifndef CODEEDITOREXTENSIONMAN_H
#define CODEEDITOREXTENSIONMANAGER_H #define CODEEDITOREXTENSIONMAN_H
#include <QQuickItem> #include <QQuickItem>
#include <QTextDocument> #include <QTextDocument>
#include <QVector>
#include "Feature.h" #include "Feature.h"
class CodeEditorExtensionManager : public QObject class CodeEditorExtensionManager : public QObject
@ -36,15 +37,17 @@ class CodeEditorExtensionManager : public QObject
public: public:
CodeEditorExtensionManager(); CodeEditorExtensionManager();
~CodeEditorExtensionManager();
void initExtensions(); void initExtensions();
void setEditor(QQuickItem*); void setEditor(QQuickItem*);
void setTabView(QQuickItem*); void setTabView(QQuickItem*);
private: private:
QQuickItem* m_editor; QQuickItem* m_editor;
QVector<Feature*> m_features;
QQuickItem* m_tabView; QQuickItem* m_tabView;
QTextDocument* m_doc; QTextDocument* m_doc;
void loadEditor(QQuickItem*); void loadEditor(QQuickItem*);
}; };
#endif // CODEEDITOREXTENSIONMANAGER_H #endif // CODEEDITOREXTENSIONMAN_H

11
mix/ConstantCompilation.cpp

@ -40,18 +40,19 @@ ConstantCompilation::ConstantCompilation(QTextDocument* _doc)
m_editor = _doc; m_editor = _doc;
} }
QString ConstantCompilation::tabUrl(){ QString ConstantCompilation::tabUrl()
{
return QStringLiteral("qrc:/qml/BasicContent.qml"); return QStringLiteral("qrc:/qml/BasicContent.qml");
} }
void ConstantCompilation::start() QString ConstantCompilation::title()
{ {
connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile())); return "compiler";
} }
QString ConstantCompilation::title() void ConstantCompilation::start()
{ {
return "compiler"; connect(m_editor, SIGNAL(contentsChange(int,int,int)), this, SLOT(compile()));
} }
void ConstantCompilation::compile() void ConstantCompilation::compile()

6
mix/ConstantCompilation.h

@ -32,9 +32,9 @@ class ConstantCompilation : public Feature
public: public:
ConstantCompilation(QTextDocument* doc); ConstantCompilation(QTextDocument* doc);
void start(); void start() override;
QString title(); QString title() override;
QString tabUrl(); QString tabUrl() override;
private: private:
QTextDocument* m_editor; QTextDocument* m_editor;

1
mix/Feature.cpp

@ -47,7 +47,6 @@ void Feature::addContentOn(QObject* tabView) {
Q_ARG(QVariant, QVariant::fromValue(component))); Q_ARG(QVariant, QVariant::fromValue(component)));
m_view = qvariant_cast<QObject*>(returnValue); m_view = qvariant_cast<QObject*>(returnValue);
} }
catch (dev::Exception const& exception){ catch (dev::Exception const& exception){
qDebug() << exception.what(); qDebug() << exception.what();

1
mix/Feature.h

@ -34,6 +34,7 @@ public:
Feature(); Feature();
virtual QString tabUrl() { return ""; } virtual QString tabUrl() { return ""; }
virtual QString title() { return ""; } virtual QString title() { return ""; }
virtual void start() {}
void addContentOn(QObject* tabView); void addContentOn(QObject* tabView);
protected: protected:

Loading…
Cancel
Save