introducing hinspector widget

This commit is contained in:
Christophe Alexandre 2008-04-25 14:15:42 +00:00
parent a2d9ab4087
commit 4e645a28aa
32 changed files with 184 additions and 30 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,44 @@
#include <QVBoxLayout>
#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);
}

View File

@ -0,0 +1,27 @@
#ifndef HINSPECTORWIDGET_H
#define HINSPECTORWIDGET_H
#include "Commons.h"
using namespace Hurricane;
#include <QWidget>
#include <QTableView>
class RecordModel;
class HInspectorWidget : public QWidget {
Q_OBJECT
public:
typedef map<Record*, RecordModel*> RecordModels;
HInspectorWidget(QWidget* parent=0);
~HInspectorWidget();
void setRecord(Record* record);
private:
RecordModels recordModels;
QTableView* slotsTableView;
};
#endif // HINSPECTORWIDGET_H

View File

@ -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;
}

View File

@ -0,0 +1,21 @@
#ifndef RECORDMODEL_H
#define RECORDMODEL_H
#include <QAbstractTableModel>
#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

View File

@ -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 {

View File

@ -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

View File

@ -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)

View File

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 536 B

View File

Before

Width:  |  Height:  |  Size: 522 B

After

Width:  |  Height:  |  Size: 522 B

View File

Before

Width:  |  Height:  |  Size: 523 B

After

Width:  |  Height:  |  Size: 523 B

View File

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 605 B

View File

Before

Width:  |  Height:  |  Size: 923 B

After

Width:  |  Height:  |  Size: 923 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 394 B

View File

Before

Width:  |  Height:  |  Size: 850 B

After

Width:  |  Height:  |  Size: 850 B

View File

@ -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