* ./hurricane/src/hurricane/DbU.{h,cpp} :
- Add forgotten converter function physicalToGrid(), physical units to founder grid units. * ./hurricane/src/hinspector : - Added history support, and ability to move through the history stack. - Fork support : by typing 'O' (capitalized 'o' letter) you can open a new inspector on the current record.
This commit is contained in:
parent
98ece39fab
commit
62d5b757fb
|
@ -17,188 +17,285 @@
|
||||||
#include "hurricane/Slot.h"
|
#include "hurricane/Slot.h"
|
||||||
|
|
||||||
|
|
||||||
HInspectorWidget::HInspectorWidget ( Record* rootRecord, QWidget* parent )
|
namespace Hurricane {
|
||||||
: QWidget(parent)
|
|
||||||
, _slotsHistory()
|
|
||||||
, _recordModel(NULL)
|
|
||||||
, _sortModel(NULL)
|
|
||||||
, _recordsHistoryComboBox(NULL)
|
|
||||||
, _slotsView(NULL)
|
|
||||||
, _rowHeight(20)
|
|
||||||
, _rootRecord(rootRecord)
|
|
||||||
{
|
|
||||||
setAttribute ( Qt::WA_DeleteOnClose );
|
|
||||||
|
|
||||||
_rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4;
|
|
||||||
|
|
||||||
//recordsHistoryComboBox = new QComboBox(this);
|
|
||||||
|
|
||||||
_slotsView = new QTableView(this);
|
|
||||||
_slotsView->setShowGrid(false);
|
|
||||||
_slotsView->setAlternatingRowColors(true);
|
|
||||||
_slotsView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
_slotsView->setSortingEnabled(true);
|
|
||||||
|
|
||||||
QHeaderView* horizontalHeader = _slotsView->horizontalHeader ();
|
|
||||||
horizontalHeader->setStretchLastSection ( true );
|
|
||||||
horizontalHeader->setMinimumSectionSize ( 200 );
|
|
||||||
|
|
||||||
QHeaderView* verticalHeader = _slotsView->verticalHeader ();
|
|
||||||
verticalHeader->setVisible ( false );
|
|
||||||
|
|
||||||
Slot* rootSlot = getSlot ( "TopLevelSlot", _rootRecord );
|
|
||||||
_slotsHistory.push_back ( rootSlot );
|
|
||||||
|
|
||||||
_recordModel = new RecordModel ( rootSlot->getClone(), this );
|
|
||||||
_sortModel = new QSortFilterProxyModel ( this );
|
|
||||||
_sortModel->setSourceModel ( _recordModel );
|
|
||||||
_sortModel->setDynamicSortFilter ( true );
|
|
||||||
_sortModel->setFilterKeyColumn ( 1 );
|
|
||||||
|
|
||||||
_slotsView->setModel ( _sortModel );
|
|
||||||
_slotsView->horizontalHeader()->setStretchLastSection ( true );
|
|
||||||
_slotsView->resizeColumnToContents ( 0 );
|
|
||||||
|
|
||||||
int rows = _sortModel->rowCount ();
|
|
||||||
for ( rows-- ; rows >= 0 ; rows-- )
|
|
||||||
_slotsView->setRowHeight ( rows, _rowHeight );
|
|
||||||
|
|
||||||
QGridLayout* inspectorLayout = new QGridLayout();
|
|
||||||
//inspectorLayout->addWidget(recordsHistoryComboBox, 0, 0, 1, 2);
|
|
||||||
inspectorLayout->addWidget(_slotsView, 1, 0, 1, 2);
|
|
||||||
|
|
||||||
_filterPatternLineEdit = new QLineEdit(this);
|
|
||||||
QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this);
|
|
||||||
filterPatternLabel->setBuddy(_filterPatternLineEdit);
|
|
||||||
|
|
||||||
inspectorLayout->addWidget(filterPatternLabel, 2, 0);
|
|
||||||
inspectorLayout->addWidget(_filterPatternLineEdit, 2, 1);
|
|
||||||
|
|
||||||
//QGroupBox* inspectorGroupBox = new QGroupBox(tr("Hurricane inspector"), this);
|
|
||||||
//inspectorGroupBox->setLayout(inspectorLayout);
|
|
||||||
|
|
||||||
//QVBoxLayout* mainLayout = new QVBoxLayout;
|
|
||||||
//mainLayout->addWidget(inspectorGroupBox);
|
|
||||||
//setLayout(mainLayout);
|
|
||||||
setLayout(inspectorLayout);
|
|
||||||
|
|
||||||
//connect(recordsHistoryComboBox, SIGNAL(currentIndexChanged(int)),
|
|
||||||
// this, SLOT(recordChanged(int)));
|
|
||||||
|
|
||||||
connect ( _filterPatternLineEdit
|
|
||||||
, SIGNAL(textChanged(const QString &))
|
|
||||||
, this
|
|
||||||
, SLOT(textFilterChanged())
|
|
||||||
);
|
|
||||||
|
|
||||||
setWindowTitle(tr("Inspector"));
|
|
||||||
resize(500, 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
HInspectorWidget::~HInspectorWidget ()
|
HInspectorWidget::History::History ()
|
||||||
{
|
: _depth(0)
|
||||||
//cerr << "HInspector::~HInspector() - " << hex << (void*)this << dec << endl;
|
, _slots()
|
||||||
clearHistory ();
|
, _comboBox(NULL)
|
||||||
|
{
|
||||||
//cerr << "Records: " << Record::getAllocateds() << endl;
|
|
||||||
//cerr << "Slots: " << Slot::getAllocateds() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::setRootRecord ( Record* record )
|
|
||||||
{
|
|
||||||
//recordsHistoryComboBox->clear();
|
|
||||||
clearHistory ();
|
|
||||||
|
|
||||||
_rootRecord = record;
|
|
||||||
Slot* rootSlot = getSlot("TopLevelRecord",record);
|
|
||||||
|
|
||||||
_slotsHistory.push_back ( rootSlot );
|
|
||||||
_recordModel->setSlot ( rootSlot->getClone(), _slotsHistory.size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::clearHistory ()
|
|
||||||
{
|
|
||||||
if ( !_slotsHistory.empty() ) {
|
|
||||||
if ( _slotsHistory.size() > 1 )
|
|
||||||
delete _slotsHistory[0]->getDataRecord();
|
|
||||||
|
|
||||||
for ( size_t i=0 ; i < _slotsHistory.size() ; i++ )
|
|
||||||
delete _slotsHistory[i];
|
|
||||||
|
|
||||||
_slotsHistory.clear ();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool HInspectorWidget::setSlot ( Slot* slot )
|
HInspectorWidget::History::~History ()
|
||||||
{
|
{
|
||||||
if ( !slot ) return false;
|
clear ( true );
|
||||||
|
|
||||||
bool change = true;
|
|
||||||
//cerr << "HInspector::setSlot() - " << hex << (void*)slot << dec << endl;
|
|
||||||
|
|
||||||
change = _recordModel->setSlot ( slot, _slotsHistory.size() );
|
|
||||||
|
|
||||||
int rows = _sortModel->rowCount ();
|
|
||||||
for ( rows-- ; rows >= 0 ; rows-- )
|
|
||||||
_slotsView->setRowHeight ( rows, _rowHeight );
|
|
||||||
|
|
||||||
//cerr << "Records: " << Record::getAllocateds() << endl;
|
|
||||||
//cerr << "Slots: " << Slot::getAllocateds() << endl;
|
|
||||||
|
|
||||||
return change;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::pushSlot ( Slot* slot )
|
|
||||||
{
|
|
||||||
//cerr << "pushSlot() - [clone of] " << hex << (void*)slot << dec << endl;
|
|
||||||
_slotsHistory.push_back ( slot->getClone() );
|
|
||||||
|
|
||||||
if ( !setSlot(slot->getClone()) ) {
|
|
||||||
//cerr << "pushSlot() cancelled" << endl;
|
|
||||||
delete _slotsHistory.back ();
|
|
||||||
_slotsHistory.pop_back ();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::popSlot ()
|
void HInspectorWidget::History::push ( Slot* slot )
|
||||||
{
|
{
|
||||||
if ( _slotsHistory.size() > 1 ) {
|
if ( _depth < _slots.size()-1 ) {
|
||||||
//cerr << "popSlot() - " << hex << (void*)_slotsHistory.back() << dec << endl;
|
while ( _depth < _slots.size()-1 ) pop ();
|
||||||
//cerr << "popSlot() - " << _slotsHistory.back()->getDataString() << endl;
|
|
||||||
|
|
||||||
delete _slotsHistory.back ();
|
|
||||||
_slotsHistory.pop_back ();
|
|
||||||
|
|
||||||
setSlot ( _slotsHistory.back()->getClone() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::keyPressEvent(QKeyEvent *event)
|
|
||||||
{
|
|
||||||
if ( event->matches(QKeySequence::MoveToNextChar) ) {
|
|
||||||
QModelIndex index = _slotsView->currentIndex();
|
|
||||||
if ( index.isValid() ) {
|
|
||||||
Slot* slot = _recordModel->getRecord()->getSlot(_sortModel->mapToSource(index).row());
|
|
||||||
|
|
||||||
if ( slot )
|
|
||||||
pushSlot ( slot );
|
|
||||||
}
|
}
|
||||||
} else if ( event->matches(QKeySequence::MoveToPreviousChar) ) {
|
|
||||||
popSlot ();
|
_depth++;
|
||||||
} else {
|
_slots.push_back ( slot->getClone() );
|
||||||
event->ignore();
|
_comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str()));
|
||||||
|
_comboBox->setCurrentIndex ( _depth );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HInspectorWidget::textFilterChanged ()
|
void HInspectorWidget::History::pop ()
|
||||||
{
|
{
|
||||||
_sortModel->setFilterRegExp ( _filterPatternLineEdit->text() );
|
if ( _slots.size() > 1 ) {
|
||||||
}
|
delete _slots.back ();
|
||||||
|
_slots.pop_back ();
|
||||||
|
_comboBox->removeItem ( _slots.size() );
|
||||||
|
if ( _depth == _slots.size() )
|
||||||
|
_comboBox->setCurrentIndex ( --_depth );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::History::back ()
|
||||||
|
{
|
||||||
|
if ( _depth == 0 ) return;
|
||||||
|
|
||||||
|
_comboBox->setCurrentIndex ( --_depth );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::History::goTo ( int depth )
|
||||||
|
{
|
||||||
|
if ( ( depth < 0 ) || ( depth >= (int)_slots.size() ) ) return;
|
||||||
|
|
||||||
|
_depth = depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t HInspectorWidget::History::getDepth () const
|
||||||
|
{
|
||||||
|
return _depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Slot* HInspectorWidget::History::getSlot () const
|
||||||
|
{
|
||||||
|
return _slots[_depth]->getClone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::History::clear ( bool inDelete )
|
||||||
|
{
|
||||||
|
if ( !_slots.empty() ) {
|
||||||
|
// Delete the rootRecord only if it'not the current viewed record.
|
||||||
|
if ( _depth != 0 ) {
|
||||||
|
delete _slots[0]->getDataRecord();
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( size_t i=0 ; i < _slots.size() ; i++ )
|
||||||
|
delete _slots[i];
|
||||||
|
|
||||||
|
_slots.clear ();
|
||||||
|
if ( !inDelete )
|
||||||
|
_comboBox->clear ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::History::setComboBox ( QComboBox* comboBox )
|
||||||
|
{
|
||||||
|
assert ( comboBox != NULL );
|
||||||
|
|
||||||
|
_comboBox = comboBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::History::setRootRecord ( Record* rootRecord )
|
||||||
|
{
|
||||||
|
assert ( _comboBox != NULL );
|
||||||
|
assert ( rootRecord != NULL );
|
||||||
|
|
||||||
|
clear ();
|
||||||
|
|
||||||
|
Slot* rootSlot = ::getSlot ( "<TopLevelSlot>", rootRecord );
|
||||||
|
_slots.push_back ( rootSlot );
|
||||||
|
_comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str()));
|
||||||
|
_depth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HInspectorWidget::HInspectorWidget ( Record* rootRecord, QWidget* parent )
|
||||||
|
: QWidget(parent)
|
||||||
|
, _recordModel(NULL)
|
||||||
|
, _sortModel(NULL)
|
||||||
|
, _historyComboBox(NULL)
|
||||||
|
, _slotsView(NULL)
|
||||||
|
, _rowHeight(20)
|
||||||
|
, _rootRecord(rootRecord)
|
||||||
|
, _history()
|
||||||
|
{
|
||||||
|
setAttribute ( Qt::WA_DeleteOnClose );
|
||||||
|
|
||||||
|
_rowHeight = QFontMetrics(Graphics::getFixedFont()).height() + 4;
|
||||||
|
|
||||||
|
_slotsView = new QTableView(this);
|
||||||
|
_slotsView->setShowGrid(false);
|
||||||
|
_slotsView->setAlternatingRowColors(true);
|
||||||
|
_slotsView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
_slotsView->setSortingEnabled(true);
|
||||||
|
|
||||||
|
QHeaderView* horizontalHeader = _slotsView->horizontalHeader ();
|
||||||
|
horizontalHeader->setStretchLastSection ( true );
|
||||||
|
horizontalHeader->setMinimumSectionSize ( 200 );
|
||||||
|
|
||||||
|
QHeaderView* verticalHeader = _slotsView->verticalHeader ();
|
||||||
|
verticalHeader->setVisible ( false );
|
||||||
|
|
||||||
|
_historyComboBox = new QComboBox ( this );
|
||||||
|
_history.setComboBox ( _historyComboBox );
|
||||||
|
_history.setRootRecord ( _rootRecord );
|
||||||
|
|
||||||
|
_recordModel = new RecordModel ( _history.getSlot(), this );
|
||||||
|
_sortModel = new QSortFilterProxyModel ( this );
|
||||||
|
_sortModel->setSourceModel ( _recordModel );
|
||||||
|
_sortModel->setDynamicSortFilter ( true );
|
||||||
|
_sortModel->setFilterKeyColumn ( 1 );
|
||||||
|
|
||||||
|
_slotsView->setModel ( _sortModel );
|
||||||
|
_slotsView->horizontalHeader()->setStretchLastSection ( true );
|
||||||
|
_slotsView->resizeColumnToContents ( 0 );
|
||||||
|
|
||||||
|
int rows = _sortModel->rowCount ();
|
||||||
|
for ( rows-- ; rows >= 0 ; rows-- )
|
||||||
|
_slotsView->setRowHeight ( rows, _rowHeight );
|
||||||
|
_slotsView->selectRow ( 0 );
|
||||||
|
|
||||||
|
_filterPatternLineEdit = new QLineEdit(this);
|
||||||
|
QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this);
|
||||||
|
filterPatternLabel->setBuddy(_filterPatternLineEdit);
|
||||||
|
|
||||||
|
QGridLayout* inspectorLayout = new QGridLayout();
|
||||||
|
inspectorLayout->addWidget(_historyComboBox , 0, 0, 1, 2);
|
||||||
|
inspectorLayout->addWidget(_slotsView , 1, 0, 1, 2);
|
||||||
|
inspectorLayout->addWidget(filterPatternLabel , 2, 0);
|
||||||
|
inspectorLayout->addWidget(_filterPatternLineEdit, 2, 1);
|
||||||
|
|
||||||
|
setLayout ( inspectorLayout );
|
||||||
|
|
||||||
|
connect ( _historyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(historyChanged(int)) );
|
||||||
|
connect ( _filterPatternLineEdit, SIGNAL(textChanged(const QString &))
|
||||||
|
, this , SLOT(textFilterChanged())
|
||||||
|
);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Inspector"));
|
||||||
|
resize(500, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HInspectorWidget::~HInspectorWidget ()
|
||||||
|
{
|
||||||
|
//cerr << "HInspectorWidget::~HInspectorWidget()" << endl;
|
||||||
|
//cerr << "Records: " << Record::getAllocateds() << endl;
|
||||||
|
//cerr << "Slots: " << Slot::getAllocateds() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::setRootRecord ( Record* record )
|
||||||
|
{
|
||||||
|
_history.setRootRecord ( record );
|
||||||
|
_recordModel->setSlot ( _history.getSlot(), _history.getDepth() );
|
||||||
|
_slotsView->selectRow ( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool HInspectorWidget::setSlot ()
|
||||||
|
{
|
||||||
|
bool change = true;
|
||||||
|
|
||||||
|
change = _recordModel->setSlot ( _history.getSlot(), _history.getDepth() );
|
||||||
|
if ( change ) {
|
||||||
|
int rows = _sortModel->rowCount ();
|
||||||
|
for ( rows-- ; rows >= 0 ; rows-- )
|
||||||
|
_slotsView->setRowHeight ( rows, _rowHeight );
|
||||||
|
_slotsView->selectRow ( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::pushSlot ( Slot* slot )
|
||||||
|
{
|
||||||
|
_history.push ( slot );
|
||||||
|
if ( !setSlot() )
|
||||||
|
_history.pop ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::popSlot ()
|
||||||
|
{
|
||||||
|
_history.pop ();
|
||||||
|
setSlot ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::back ()
|
||||||
|
{
|
||||||
|
_history.back ();
|
||||||
|
setSlot ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if ( event->key() == Qt::Key_Right ) {
|
||||||
|
QModelIndex index = _slotsView->currentIndex();
|
||||||
|
if ( index.isValid() ) {
|
||||||
|
Slot* slot = _recordModel->getRecord()->getSlot(_sortModel->mapToSource(index).row());
|
||||||
|
|
||||||
|
if ( slot )
|
||||||
|
pushSlot ( slot );
|
||||||
|
}
|
||||||
|
} else if ( event->key() == Qt::Key_Left ) {
|
||||||
|
back ();
|
||||||
|
} else if ( event->key() == Qt::Key_O ) {
|
||||||
|
forkInspector ( _slotsView->currentIndex() );
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::textFilterChanged ()
|
||||||
|
{
|
||||||
|
_sortModel->setFilterRegExp ( _filterPatternLineEdit->text() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::historyChanged ( int depth )
|
||||||
|
{
|
||||||
|
_history.goTo ( depth );
|
||||||
|
setSlot ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HInspectorWidget::forkInspector ( const QModelIndex& index )
|
||||||
|
{
|
||||||
|
if ( index.isValid() ) {
|
||||||
|
Slot* slot = _recordModel->getRecord()->getSlot(_sortModel->mapToSource(index).row());
|
||||||
|
Record* record = slot->getDataRecord();
|
||||||
|
|
||||||
|
if ( record ) {
|
||||||
|
HInspectorWidget* fork = new HInspectorWidget ( record );
|
||||||
|
fork->show ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
|
@ -7,106 +7,107 @@
|
||||||
#include "hurricane/inspector/RecordModel.h"
|
#include "hurricane/inspector/RecordModel.h"
|
||||||
|
|
||||||
|
|
||||||
RecordModel::RecordModel ( Slot* slot, QObject* parent )
|
namespace Hurricane {
|
||||||
: QAbstractTableModel(parent)
|
|
||||||
, _slot(slot)
|
|
||||||
, _record(slot->getDataRecord())
|
|
||||||
, _depth(1)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
RecordModel::~RecordModel ()
|
RecordModel::RecordModel ( Slot* slot, QObject* parent )
|
||||||
{
|
: QAbstractTableModel(parent)
|
||||||
//cerr << "RecordModel::~RecordModel()" << endl;
|
, _slot(slot)
|
||||||
|
, _record(slot->getDataRecord())
|
||||||
delete _record;
|
, _depth(0)
|
||||||
delete _slot;
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool RecordModel::setSlot ( Slot* slot, size_t depth )
|
RecordModel::~RecordModel ()
|
||||||
{
|
{
|
||||||
//cerr << "RecordModel::setSlot() " << _depth << " -> " << depth << endl;
|
delete _record;
|
||||||
//cerr << slot->getDataString() << endl;
|
delete _slot;
|
||||||
|
|
||||||
Record* record = slot->getDataRecord ();
|
|
||||||
if ( !record ) {
|
|
||||||
//cerr << "RecordModel::setSlot() - Cancelling, NULL record" << endl;
|
|
||||||
delete slot;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit layoutAboutToBeChanged ();
|
|
||||||
|
|
||||||
if ( _depth > 1 ) delete _record;
|
bool RecordModel::setSlot ( Slot* slot, size_t depth )
|
||||||
delete _slot;
|
{
|
||||||
|
Record* record = slot->getDataRecord ();
|
||||||
_slot = slot;
|
if ( !record ) {
|
||||||
_record = record;
|
delete slot;
|
||||||
_depth = depth;
|
return false;
|
||||||
|
|
||||||
emit layoutChanged ();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant RecordModel::data ( const QModelIndex& index, int role ) const
|
|
||||||
{
|
|
||||||
static QFont nameFont = Graphics::getFixedFont ( QFont::Bold );
|
|
||||||
static QFont valueFont = Graphics::getFixedFont ( QFont::Normal, true );
|
|
||||||
|
|
||||||
if ( !index.isValid() ) return QVariant ();
|
|
||||||
|
|
||||||
if ( role == Qt::SizeHintRole ) {
|
|
||||||
switch (index.column()) {
|
|
||||||
case 0: return 200;
|
|
||||||
case 1: return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit layoutAboutToBeChanged ();
|
||||||
|
|
||||||
|
if ( _depth )
|
||||||
|
delete _record;
|
||||||
|
delete _slot;
|
||||||
|
|
||||||
|
_slot = slot;
|
||||||
|
_record = record;
|
||||||
|
_depth = depth;
|
||||||
|
|
||||||
|
emit layoutChanged ();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( role == Qt::FontRole ) {
|
|
||||||
switch (index.column()) {
|
|
||||||
case 0: return nameFont;
|
|
||||||
case 1: return valueFont;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( role == Qt::DisplayRole ) {
|
QVariant RecordModel::data ( const QModelIndex& index, int role ) const
|
||||||
int row = index.row ();
|
{
|
||||||
Slot* slot = _record->getSlot ( row );
|
static QFont nameFont = Graphics::getFixedFont ( QFont::Bold );
|
||||||
if ( slot ) {
|
static QFont valueFont = Graphics::getFixedFont ( QFont::Normal, true );
|
||||||
switch ( index.column() ) {
|
|
||||||
case 0: return QVariant(slot->getName ().c_str());
|
if ( !index.isValid() ) return QVariant ();
|
||||||
case 1: return QVariant(slot->getDataString().c_str());
|
|
||||||
|
if ( role == Qt::SizeHintRole ) {
|
||||||
|
switch (index.column()) {
|
||||||
|
case 0: return 200;
|
||||||
|
case 1: return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ( role == Qt::FontRole ) {
|
||||||
|
switch (index.column()) {
|
||||||
|
case 0: return nameFont;
|
||||||
|
case 1: return valueFont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QVariant RecordModel::headerData ( int section
|
if ( role == Qt::DisplayRole ) {
|
||||||
, Qt::Orientation orientation
|
int row = index.row ();
|
||||||
, int role ) const
|
Slot* slot = _record->getSlot ( row );
|
||||||
{
|
if ( slot ) {
|
||||||
if ( ( orientation == Qt::Vertical ) || ( section > 1 ) || (role != Qt::DisplayRole) )
|
switch ( index.column() ) {
|
||||||
|
case 0: return QVariant(slot->getName ().c_str());
|
||||||
|
case 1: return QVariant(slot->getDataString().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
if ( section == 0 )
|
|
||||||
return QVariant ( tr("Object Attribute") );
|
|
||||||
|
|
||||||
return QVariant ( tr("Value") );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int RecordModel::rowCount ( const QModelIndex& parent ) const
|
QVariant RecordModel::headerData ( int section
|
||||||
{
|
, Qt::Orientation orientation
|
||||||
return _record->_getSlotList().size();
|
, int role ) const
|
||||||
}
|
{
|
||||||
|
if ( ( orientation == Qt::Vertical ) || ( section > 1 ) || (role != Qt::DisplayRole) )
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if ( section == 0 )
|
||||||
|
return QVariant ( tr("Object Attribute") );
|
||||||
|
|
||||||
|
return QVariant ( tr("Value") );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int RecordModel::columnCount ( const QModelIndex& parent ) const
|
int RecordModel::rowCount ( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
return 2;
|
return _record->_getSlotList().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RecordModel::columnCount ( const QModelIndex& parent ) const
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
|
@ -3,51 +3,84 @@
|
||||||
#define __HINSPECTOR_WIDGET_H__
|
#define __HINSPECTOR_WIDGET_H__
|
||||||
|
|
||||||
|
|
||||||
#include "hurricane/Commons.h"
|
|
||||||
|
|
||||||
using namespace Hurricane;
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "hurricane/Commons.h"
|
||||||
|
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
|
class QModelIndex;
|
||||||
class QTableView;
|
class QTableView;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QHeaderView;
|
class QHeaderView;
|
||||||
|
|
||||||
class RecordModel;
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
class HInspectorWidget : public QWidget {
|
class RecordModel;
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef vector<Slot*> SlotsVector;
|
|
||||||
|
|
||||||
public:
|
class HInspectorWidget : public QWidget {
|
||||||
HInspectorWidget ( Record* rootRecord, QWidget* parent=NULL );
|
|
||||||
~HInspectorWidget ();
|
|
||||||
void setRootRecord ( Record* record );
|
|
||||||
private slots:
|
|
||||||
void textFilterChanged ();
|
|
||||||
protected:
|
|
||||||
void keyPressEvent ( QKeyEvent * event );
|
|
||||||
private:
|
|
||||||
void clearHistory ();
|
|
||||||
void pushSlot ( Slot* slot );
|
|
||||||
void popSlot ();
|
|
||||||
bool setSlot ( Slot* slot );
|
|
||||||
|
|
||||||
private:
|
public:
|
||||||
SlotsVector _slotsHistory;
|
typedef vector<Slot*> SlotsVector;
|
||||||
RecordModel* _recordModel;
|
|
||||||
QSortFilterProxyModel* _sortModel;
|
private:
|
||||||
QComboBox* _recordsHistoryComboBox;
|
class History {
|
||||||
QTableView* _slotsView;
|
public:
|
||||||
QLineEdit* _filterPatternLineEdit;
|
History ();
|
||||||
int _rowHeight;
|
~History ();
|
||||||
Record* _rootRecord;
|
void push ( Slot* slot );
|
||||||
};
|
void pop ();
|
||||||
|
void back ();
|
||||||
|
void goTo ( int depth );
|
||||||
|
void clear ( bool inDelete=false );
|
||||||
|
void setComboBox ( QComboBox* comboBox );
|
||||||
|
void setRootRecord ( Record* rootRecord );
|
||||||
|
size_t getDepth () const;
|
||||||
|
Slot* getSlot () const;
|
||||||
|
private:
|
||||||
|
size_t _depth;
|
||||||
|
SlotsVector _slots;
|
||||||
|
QComboBox* _comboBox;
|
||||||
|
private:
|
||||||
|
History ( const History& );
|
||||||
|
History& operator= ( const History& );
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HInspectorWidget ( Record* rootRecord, QWidget* parent=NULL );
|
||||||
|
~HInspectorWidget ();
|
||||||
|
void setRootRecord ( Record* record );
|
||||||
|
private slots:
|
||||||
|
void textFilterChanged ();
|
||||||
|
void historyChanged ( int depth );
|
||||||
|
void forkInspector ( const QModelIndex& index );
|
||||||
|
protected:
|
||||||
|
void keyPressEvent ( QKeyEvent * event );
|
||||||
|
private:
|
||||||
|
void pushSlot ( Slot* slot );
|
||||||
|
void popSlot ();
|
||||||
|
void back ();
|
||||||
|
bool setSlot ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
RecordModel* _recordModel;
|
||||||
|
QSortFilterProxyModel* _sortModel;
|
||||||
|
QComboBox* _historyComboBox;
|
||||||
|
QTableView* _slotsView;
|
||||||
|
QLineEdit* _filterPatternLineEdit;
|
||||||
|
int _rowHeight;
|
||||||
|
Record* _rootRecord;
|
||||||
|
History _history;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
#endif // __HINSPECTOR_WIDGET_H__
|
#endif // __HINSPECTOR_WIDGET_H__
|
||||||
|
|
|
@ -6,34 +6,37 @@
|
||||||
|
|
||||||
#include "hurricane/Commons.h"
|
#include "hurricane/Commons.h"
|
||||||
|
|
||||||
using namespace Hurricane;
|
|
||||||
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
class RecordModel : public QAbstractTableModel {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
class RecordModel : public QAbstractTableModel {
|
public:
|
||||||
Q_OBJECT;
|
RecordModel ( Slot* slot, QObject* parent=NULL );
|
||||||
|
~RecordModel ();
|
||||||
|
bool setSlot ( Slot* slot, size_t depth );
|
||||||
|
int rowCount ( const QModelIndex& parent=QModelIndex() ) const;
|
||||||
|
int columnCount ( const QModelIndex& parent=QModelIndex() ) const;
|
||||||
|
QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const;
|
||||||
|
QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const;
|
||||||
|
inline Record* getRecord ();
|
||||||
|
inline Slot* getSlot ();
|
||||||
|
|
||||||
public:
|
private:
|
||||||
RecordModel ( Slot* slot, QObject* parent=NULL );
|
Slot* _slot;
|
||||||
~RecordModel ();
|
Record* _record;
|
||||||
bool setSlot ( Slot* slot, size_t depth );
|
size_t _depth;
|
||||||
int rowCount ( const QModelIndex& parent=QModelIndex() ) const;
|
};
|
||||||
int columnCount ( const QModelIndex& parent=QModelIndex() ) const;
|
|
||||||
QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const;
|
|
||||||
QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const;
|
|
||||||
inline Record* getRecord ();
|
|
||||||
inline Slot* getSlot ();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Slot* _slot;
|
|
||||||
Record* _record;
|
|
||||||
size_t _depth;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Inline Functions.
|
// Inline Functions.
|
||||||
inline Record* RecordModel::getRecord () { return _record; }
|
inline Record* RecordModel::getRecord () { return _record; }
|
||||||
inline Slot* RecordModel::getSlot () { return _slot; }
|
inline Slot* RecordModel::getSlot () { return _slot; }
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
#endif // __RECORD_MODEL_H__
|
#endif // __RECORD_MODEL_H__
|
||||||
|
|
|
@ -134,6 +134,12 @@ namespace Hurricane {
|
||||||
{ return _physicalsPerGrid; }
|
{ return _physicalsPerGrid; }
|
||||||
|
|
||||||
|
|
||||||
|
double DbU::physicalToGrid ( double physical, UnitPower p )
|
||||||
|
{
|
||||||
|
return ( physical * getUnitPower(p) ) / _physicalsPerGrid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DbU::setGridsPerLambda ( double gridsPerLambda )
|
void DbU::setGridsPerLambda ( double gridsPerLambda )
|
||||||
{
|
{
|
||||||
if ( ( rint(gridsPerLambda) != gridsPerLambda )
|
if ( ( rint(gridsPerLambda) != gridsPerLambda )
|
||||||
|
|
|
@ -67,6 +67,7 @@ namespace Hurricane {
|
||||||
static double getUnitPower ( UnitPower p );
|
static double getUnitPower ( UnitPower p );
|
||||||
static void setPhysicalsPerGrid ( double gridsPerLambda, UnitPower p );
|
static void setPhysicalsPerGrid ( double gridsPerLambda, UnitPower p );
|
||||||
static double getPhysicalsPerGrid ();
|
static double getPhysicalsPerGrid ();
|
||||||
|
static double physicalToGrid ( double physical, UnitPower p );
|
||||||
// Lamba Managment.
|
// Lamba Managment.
|
||||||
static void setGridsPerLambda ( double gridsPerLambda );
|
static void setGridsPerLambda ( double gridsPerLambda );
|
||||||
static double getGridsPerLambda ();
|
static double getGridsPerLambda ();
|
||||||
|
|
Loading…
Reference in New Issue