diff --git a/hurricane/cmake_modules/FindHURRICANE.cmake b/hurricane/cmake_modules/FindHURRICANE.cmake index 49be51ba..ea9293ab 100644 --- a/hurricane/cmake_modules/FindHURRICANE.cmake +++ b/hurricane/cmake_modules/FindHURRICANE.cmake @@ -38,7 +38,7 @@ IF(UNIX) ) FIND_PATH(HURRICANE_VIEWER_INCLUDE_PATH - NAMES CellViewer.h + NAMES CellViewer.h HInspectorWidget.h PATHS ${HURRICANE_DIR_SEARCH} PATH_SUFFIXES include/hurricane # Help the user find it if we cannot. @@ -46,7 +46,15 @@ IF(UNIX) ) FIND_LIBRARY(HURRICANE_VIEWER_LIBRARY_PATH - NAMES hurricaneviewer + NAMES hviewer + PATHS ${HURRICANE_DIR_SEARCH} + PATH_SUFFIXES lib + # Help the user find it if we cannot. + DOC "The ${HURRICANE_INCLUDE_PATH_DESCRIPTION}" + ) + + FIND_LIBRARY(HURRICANE_INSPECTOR_LIBRARY_PATH + NAMES hinspector PATHS ${HURRICANE_DIR_SEARCH} PATH_SUFFIXES lib # Help the user find it if we cannot. @@ -81,6 +89,10 @@ IF(UNIX) ENDIF(HURRICANE_VIEWER_LIBRARY_PATH) ENDIF(HURRICANE_VIEWER_INCLUDE_PATH) + IF (HURRICANE_INSPECTOR_LIBRARY_PATH) + SET(HURRICANE_GRAPHICAL_LIBRARIES ${HURRICANE_GRAPHICAL_LIBRARIES} ${HURRICANE_INSPECTOR_LIBRARY_PATH}) + ENDIF(HURRICANE_INSPECTOR_LIBRARY_PATH) + IF(HURRICANE_FOUND) IF(NOT HURRICANE_FIND_QUIETLY) MESSAGE(STATUS "Found HURRICANE : ${HURRICANE_LIBRARIES}") @@ -96,6 +108,7 @@ IF(UNIX) HURRICANE_LIBRARY_PATH HURRICANE_GRAPHICAL_INCLUDE_PATH HURRICANE_GRAPHICAL_LIBRARY_PATH + HURRICANE_INSPECTOR_LIBRARY_PATH ) ENDIF(UNIX) diff --git a/hurricane/src/CMakeLists.txt b/hurricane/src/CMakeLists.txt index c73a1e03..b25d9854 100644 --- a/hurricane/src/CMakeLists.txt +++ b/hurricane/src/CMakeLists.txt @@ -1,3 +1,4 @@ -ADD_SUBDIRECTORY(hurricane) -ADD_SUBDIRECTORY(viewer) -ADD_SUBDIRECTORY(pyext) +add_subdirectory(hurricane) +add_subdirectory(hinspector) +add_subdirectory(hviewer) +add_subdirectory(pyext) diff --git a/hurricane/src/hinspector/CMakeLists.txt b/hurricane/src/hinspector/CMakeLists.txt new file mode 100644 index 00000000..05bdd344 --- /dev/null +++ b/hurricane/src/hinspector/CMakeLists.txt @@ -0,0 +1,14 @@ +include(${QT_USE_FILE}) + +include_directories(${HURRICANE_SOURCE_DIR}/src/hurricane) + +set(mocincludes RecordModel.h HInspectorWidget.h) +set(cpps RecordModel.cpp HInspectorWidget.cpp) + +QT4_WRAP_CPP(MOC_SRCS ${mocincludes}) + +add_library(hinspector SHARED ${cpps} ${MOC_SRCS}) +target_link_libraries(hinspector ${QT_LIBRARIES} hurricane) + +install(FILES HInspectorWidget.h DESTINATION /include/hurricane) +install(TARGETS hinspector DESTINATION /lib) diff --git a/hurricane/src/hinspector/HInspectorWidget.cpp b/hurricane/src/hinspector/HInspectorWidget.cpp new file mode 100644 index 00000000..b785cc50 --- /dev/null +++ b/hurricane/src/hinspector/HInspectorWidget.cpp @@ -0,0 +1,44 @@ +#include + +#include "RecordModel.h" +#include "HInspectorWidget.h" + +HInspectorWidget::HInspectorWidget(QWidget* parent): + QWidget(parent), + recordModels(), + slotsTableView(NULL) +{ + + slotsTableView = new QTableView; + slotsTableView->setAlternatingRowColors(true); + slotsTableView->setSelectionBehavior(QAbstractItemView::SelectRows); + + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(slotsTableView); + setLayout(mainLayout); + + setWindowTitle(tr("Inspector")); + resize(1000, 500); +} + +HInspectorWidget::~HInspectorWidget() { + for (RecordModels::iterator rmit = recordModels.begin(); + rmit != recordModels.end(); + ++rmit) { + delete rmit->second; + } +} + +void HInspectorWidget::setRecord(Record* record) { + RecordModel* recordModel = NULL; + + RecordModels::iterator rmit = recordModels.find(record); + if (rmit != recordModels.end()) { + recordModel = rmit->second; + } else { + recordModel = new RecordModel(record); + recordModels[record] = recordModel; + } + slotsTableView->setModel(recordModel); +} diff --git a/hurricane/src/hinspector/HInspectorWidget.h b/hurricane/src/hinspector/HInspectorWidget.h new file mode 100644 index 00000000..cdcab180 --- /dev/null +++ b/hurricane/src/hinspector/HInspectorWidget.h @@ -0,0 +1,27 @@ +#ifndef HINSPECTORWIDGET_H +#define HINSPECTORWIDGET_H + +#include "Commons.h" +using namespace Hurricane; + +#include +#include + +class RecordModel; + +class HInspectorWidget : public QWidget { + Q_OBJECT + + public: + typedef map RecordModels; + HInspectorWidget(QWidget* parent=0); + ~HInspectorWidget(); + void setRecord(Record* record); + + private: + RecordModels recordModels; + QTableView* slotsTableView; +}; + + +#endif // HINSPECTORWIDGET_H diff --git a/hurricane/src/hinspector/RecordModel.cpp b/hurricane/src/hinspector/RecordModel.cpp new file mode 100644 index 00000000..9d00619f --- /dev/null +++ b/hurricane/src/hinspector/RecordModel.cpp @@ -0,0 +1,34 @@ +#include "RecordModel.h" + +RecordModel::RecordModel(Record* r, QObject* parent): + QAbstractTableModel(parent), + record(r) +{} + +QVariant RecordModel::data(const QModelIndex &index, int role) const { + if (!index.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole) + return QVariant(); + + unsigned row = index.row(); + Slot* slot = record->getSlot(row); + if (slot) { + switch (index.column()) { + case 0: + return QVariant(getString(slot->getName()).c_str()); + case 1: + return QVariant(slot->getDataString().c_str()); + } + } + return QVariant(); +} + +int RecordModel::rowCount(const QModelIndex &parent) const { + return record->_getSlotList().size(); +} + +int RecordModel::columnCount(const QModelIndex &parent) const { + return 2; +} diff --git a/hurricane/src/hinspector/RecordModel.h b/hurricane/src/hinspector/RecordModel.h new file mode 100644 index 00000000..7261708e --- /dev/null +++ b/hurricane/src/hinspector/RecordModel.h @@ -0,0 +1,21 @@ +#ifndef RECORDMODEL_H +#define RECORDMODEL_H + +#include + +#include "Commons.h" +using namespace Hurricane; + +class RecordModel : public QAbstractTableModel { + Q_OBJECT + + public: + RecordModel(Record* record, QObject* parent=0); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + private: + Record* record; +}; + +#endif // RECORDMODEL_H diff --git a/hurricane/src/hurricane/Record.h b/hurricane/src/hurricane/Record.h index 7a58f667..1f86d1cd 100644 --- a/hurricane/src/hurricane/Record.h +++ b/hurricane/src/hurricane/Record.h @@ -26,13 +26,13 @@ -# ifndef __RECORD__ -# define __RECORD__ +#ifndef __RECORD__ +#define __RECORD__ -# ifndef __HURRICANE_COMMONS__ -# error "Record.h musn't be included alone, please uses Commons.h." -# endif +#ifndef __HURRICANE_COMMONS__ +#error "Record.h musn't be included alone, please uses Commons.h." +#endif namespace Hurricane { diff --git a/hurricane/src/hurricane/Slot.h b/hurricane/src/hurricane/Slot.h index eb4e4521..e3e4e1cb 100644 --- a/hurricane/src/hurricane/Slot.h +++ b/hurricane/src/hurricane/Slot.h @@ -25,13 +25,13 @@ -# ifndef __HURRICANE_SLOT__ -# define __HURRICANE_SLOT__ +#ifndef __HURRICANE_SLOT__ +#define __HURRICANE_SLOT__ -# ifndef __HURRICANE_COMMONS__ -# error "Slot.h musn't be included alone, please uses Commons.h." -# endif +#ifndef __HURRICANE_COMMONS__ +#error "Slot.h musn't be included alone, please uses Commons.h." +#endif diff --git a/hurricane/src/viewer/CMakeLists.txt b/hurricane/src/hviewer/CMakeLists.txt similarity index 72% rename from hurricane/src/viewer/CMakeLists.txt rename to hurricane/src/hviewer/CMakeLists.txt index 1e40abee..4b4a8171 100644 --- a/hurricane/src/viewer/CMakeLists.txt +++ b/hurricane/src/hviewer/CMakeLists.txt @@ -10,8 +10,8 @@ set(cpps ScreenUtilities.cpp DisplayStyle.cpp ScreenLayer.cpp LayersList.cpp Cel QT4_WRAP_CPP(MOC_SRCS ${mocincludes}) QT4_ADD_RESOURCES(RCC_SRCS CellViewer.qrc) -add_library(hurricaneviewer SHARED ${cpps} ${MOC_SRCS} ${RCC_SRCS}) -target_link_libraries(hurricaneviewer ${QT_LIBRARIES} hurricane) +add_library(hviewer SHARED ${cpps} ${MOC_SRCS} ${RCC_SRCS}) +target_link_libraries(hviewer ${QT_LIBRARIES} hurricane) install(FILES ${exports} DESTINATION /include/hurricane) -install(TARGETS hurricaneviewer DESTINATION /lib) +install(TARGETS hviewer DESTINATION /lib) diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp similarity index 100% rename from hurricane/src/viewer/CellViewer.cpp rename to hurricane/src/hviewer/CellViewer.cpp diff --git a/hurricane/src/viewer/CellViewer.h b/hurricane/src/hviewer/CellViewer.h similarity index 100% rename from hurricane/src/viewer/CellViewer.h rename to hurricane/src/hviewer/CellViewer.h diff --git a/hurricane/src/viewer/CellViewer.qrc b/hurricane/src/hviewer/CellViewer.qrc similarity index 100% rename from hurricane/src/viewer/CellViewer.qrc rename to hurricane/src/hviewer/CellViewer.qrc diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/hviewer/CellWidget.cpp similarity index 100% rename from hurricane/src/viewer/CellWidget.cpp rename to hurricane/src/hviewer/CellWidget.cpp diff --git a/hurricane/src/viewer/CellWidget.h b/hurricane/src/hviewer/CellWidget.h similarity index 100% rename from hurricane/src/viewer/CellWidget.h rename to hurricane/src/hviewer/CellWidget.h diff --git a/hurricane/src/viewer/DisplayStyle.cpp b/hurricane/src/hviewer/DisplayStyle.cpp similarity index 100% rename from hurricane/src/viewer/DisplayStyle.cpp rename to hurricane/src/hviewer/DisplayStyle.cpp diff --git a/hurricane/src/viewer/DisplayStyle.h b/hurricane/src/hviewer/DisplayStyle.h similarity index 100% rename from hurricane/src/viewer/DisplayStyle.h rename to hurricane/src/hviewer/DisplayStyle.h diff --git a/hurricane/src/viewer/LayersList.cpp b/hurricane/src/hviewer/LayersList.cpp similarity index 100% rename from hurricane/src/viewer/LayersList.cpp rename to hurricane/src/hviewer/LayersList.cpp diff --git a/hurricane/src/viewer/LayersList.h b/hurricane/src/hviewer/LayersList.h similarity index 100% rename from hurricane/src/viewer/LayersList.h rename to hurricane/src/hviewer/LayersList.h diff --git a/hurricane/src/viewer/ScreenLayer.cpp b/hurricane/src/hviewer/ScreenLayer.cpp similarity index 100% rename from hurricane/src/viewer/ScreenLayer.cpp rename to hurricane/src/hviewer/ScreenLayer.cpp diff --git a/hurricane/src/viewer/ScreenLayer.h b/hurricane/src/hviewer/ScreenLayer.h similarity index 100% rename from hurricane/src/viewer/ScreenLayer.h rename to hurricane/src/hviewer/ScreenLayer.h diff --git a/hurricane/src/viewer/ScreenUtilities.cpp b/hurricane/src/hviewer/ScreenUtilities.cpp similarity index 100% rename from hurricane/src/viewer/ScreenUtilities.cpp rename to hurricane/src/hviewer/ScreenUtilities.cpp diff --git a/hurricane/src/viewer/ScreenUtilities.h b/hurricane/src/hviewer/ScreenUtilities.h similarity index 100% rename from hurricane/src/viewer/ScreenUtilities.h rename to hurricane/src/hviewer/ScreenUtilities.h diff --git a/hurricane/src/viewer/images/gtk-go-down.png b/hurricane/src/hviewer/images/gtk-go-down.png similarity index 100% rename from hurricane/src/viewer/images/gtk-go-down.png rename to hurricane/src/hviewer/images/gtk-go-down.png diff --git a/hurricane/src/viewer/images/gtk-go-forward-ltr.png b/hurricane/src/hviewer/images/gtk-go-forward-ltr.png similarity index 100% rename from hurricane/src/viewer/images/gtk-go-forward-ltr.png rename to hurricane/src/hviewer/images/gtk-go-forward-ltr.png diff --git a/hurricane/src/viewer/images/gtk-go-forward-rtl.png b/hurricane/src/hviewer/images/gtk-go-forward-rtl.png similarity index 100% rename from hurricane/src/viewer/images/gtk-go-forward-rtl.png rename to hurricane/src/hviewer/images/gtk-go-forward-rtl.png diff --git a/hurricane/src/viewer/images/gtk-go-up.png b/hurricane/src/hviewer/images/gtk-go-up.png similarity index 100% rename from hurricane/src/viewer/images/gtk-go-up.png rename to hurricane/src/hviewer/images/gtk-go-up.png diff --git a/hurricane/src/viewer/images/palette_hide_all.png b/hurricane/src/hviewer/images/palette_hide_all.png similarity index 100% rename from hurricane/src/viewer/images/palette_hide_all.png rename to hurricane/src/hviewer/images/palette_hide_all.png diff --git a/hurricane/src/viewer/images/palette_show_all.png b/hurricane/src/hviewer/images/palette_show_all.png similarity index 100% rename from hurricane/src/viewer/images/palette_show_all.png rename to hurricane/src/hviewer/images/palette_show_all.png diff --git a/hurricane/src/viewer/images/stock_open.png b/hurricane/src/hviewer/images/stock_open.png similarity index 100% rename from hurricane/src/viewer/images/stock_open.png rename to hurricane/src/hviewer/images/stock_open.png diff --git a/hurricane/src/viewer/images/stock_save.png b/hurricane/src/hviewer/images/stock_save.png similarity index 100% rename from hurricane/src/viewer/images/stock_save.png rename to hurricane/src/hviewer/images/stock_save.png diff --git a/hurricane/src/pyext/PyInstanceLocator.h b/hurricane/src/pyext/PyInstanceLocator.h index 215a34f5..e471aa4f 100644 --- a/hurricane/src/pyext/PyInstanceLocator.h +++ b/hurricane/src/pyext/PyInstanceLocator.h @@ -53,14 +53,14 @@ -# ifndef __PYINSTANCELOCATOR__ -# define __PYINSTANCELOCATOR__ +#ifndef __PYINSTANCELOCATOR__ +#define __PYINSTANCELOCATOR__ -# include "PyHurricane.h" +#include "PyHurricane.h" -# include "Locator.h" -# include "Instance.h" +#include "Locator.h" +#include "Instance.h" namespace Isobar { @@ -83,15 +83,15 @@ extern "C" { // ------------------------------------------------------------------- // Functions & Types exported to "PyHurricane.ccp". - extern PyTypeObject PyTypeInstanceLocator; - extern PyMethodDef PyInstanceLocator_Methods[]; + extern PyTypeObject PyTypeInstanceLocator; + extern PyMethodDef PyInstanceLocator_Methods[]; - extern void PyInstanceLocator_LinkPyType (); + extern void PyInstanceLocator_LinkPyType (); -# define IsPyInstanceLocator(v) ( (v)->ob_type == &PyTypeInstanceLocator ) -# define PYINSTANCELOCATOR(v) ( (PyInstanceLocator*)(v) ) -# define PYINSTANCELOCATOR_O(v) ( PYINSTANCELOCATOR(v)->_object ) +#define IsPyInstanceLocator(v) ( (v)->ob_type == &PyTypeInstanceLocator ) +#define PYINSTANCELOCATOR(v) ( (PyInstanceLocator*)(v) ) +#define PYINSTANCELOCATOR_O(v) ( PYINSTANCELOCATOR(v)->_object ) } // End of extern "C". @@ -104,4 +104,4 @@ extern "C" { -# endif +#endif