* ./hurricane/src/hinspector :

- No more extra arguments in HInspectorWidget & RecordModel constructors.
       Valid values have to be sets through setRootRecord() & setSlot().
   - Key for forking sub-inspector is now *minus* 'o'.
This commit is contained in:
Jean-Paul Chaput 2008-06-19 16:51:11 +00:00
parent d17ecda179
commit 0066a1fa5e
5 changed files with 37 additions and 38 deletions

View File

@ -165,7 +165,8 @@ namespace Hurricane {
//cerr << "Inspector created." << endl; //cerr << "Inspector created." << endl;
if ( record ) { if ( record ) {
HInspectorWidget* inspector = new HInspectorWidget ( record ); HInspectorWidget* inspector = new HInspectorWidget ();
inspector->setRootRecord ( record );
inspector->show (); inspector->show ();
} else } else
cerr << "[ERROR] Attempt to run Inspector on NULL record." << endl; cerr << "[ERROR] Attempt to run Inspector on NULL record." << endl;

View File

@ -129,14 +129,13 @@ namespace Hurricane {
HInspectorWidget::HInspectorWidget ( Record* rootRecord, QWidget* parent ) HInspectorWidget::HInspectorWidget ( QWidget* parent )
: QWidget(parent) : QWidget(parent)
, _recordModel(NULL) , _recordModel(NULL)
, _sortModel(NULL) , _sortModel(NULL)
, _historyComboBox(NULL) , _historyComboBox(NULL)
, _slotsView(NULL) , _slotsView(NULL)
, _rowHeight(20) , _rowHeight(20)
, _rootRecord(rootRecord)
, _history() , _history()
{ {
setAttribute ( Qt::WA_DeleteOnClose ); setAttribute ( Qt::WA_DeleteOnClose );
@ -158,22 +157,6 @@ namespace Hurricane {
_historyComboBox = new QComboBox ( this ); _historyComboBox = new QComboBox ( this );
_history.setComboBox ( _historyComboBox ); _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); _filterPatternLineEdit = new QLineEdit(this);
QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this); QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this);
@ -187,7 +170,6 @@ namespace Hurricane {
setLayout ( inspectorLayout ); setLayout ( inspectorLayout );
connect ( _historyComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(historyChanged(int)) );
connect ( _filterPatternLineEdit, SIGNAL(textChanged(const QString &)) connect ( _filterPatternLineEdit, SIGNAL(textChanged(const QString &))
, this , SLOT(textFilterChanged()) , this , SLOT(textFilterChanged())
); );
@ -199,17 +181,33 @@ namespace Hurricane {
HInspectorWidget::~HInspectorWidget () HInspectorWidget::~HInspectorWidget ()
{ {
//cerr << "HInspectorWidget::~HInspectorWidget()" << endl; cerr << "HInspectorWidget::~HInspectorWidget()" << endl;
//cerr << "Records: " << Record::getAllocateds() << endl; cerr << "Records: " << Record::getAllocateds() << endl;
//cerr << "Slots: " << Slot::getAllocateds() << endl; cerr << "Slots: " << Slot::getAllocateds() << endl;
} }
void HInspectorWidget::setRootRecord ( Record* record ) void HInspectorWidget::setRootRecord ( Record* record )
{ {
_history.setRootRecord ( record ); _history.setRootRecord ( record );
_recordModel->setSlot ( _history.getSlot(), _history.getDepth() );
_slotsView->selectRow ( 0 ); if ( !_recordModel ) {
_recordModel = new RecordModel ( this );
_sortModel = new QSortFilterProxyModel ( this );
_sortModel->setSourceModel ( _recordModel );
_sortModel->setDynamicSortFilter ( true );
_sortModel->setFilterKeyColumn ( 1 );
_slotsView->setModel ( _sortModel );
_slotsView->horizontalHeader()->setStretchLastSection ( true );
_slotsView->resizeColumnToContents ( 0 );
// Only after creating the RecordModel can we connect the ComboBox.
connect ( _historyComboBox, SIGNAL(currentIndexChanged(int))
, this , SLOT(historyChanged(int)) );
}
setSlot ();
} }
@ -263,7 +261,7 @@ namespace Hurricane {
} }
} else if ( event->key() == Qt::Key_Left ) { } else if ( event->key() == Qt::Key_Left ) {
back (); back ();
} else if ( event->key() == Qt::Key_O ) { } else if ( event->key() == Qt::Key_o ) {
forkInspector ( _slotsView->currentIndex() ); forkInspector ( _slotsView->currentIndex() );
} else { } else {
event->ignore(); event->ignore();
@ -291,7 +289,8 @@ namespace Hurricane {
Record* record = slot->getDataRecord(); Record* record = slot->getDataRecord();
if ( record ) { if ( record ) {
HInspectorWidget* fork = new HInspectorWidget ( record ); HInspectorWidget* fork = new HInspectorWidget ();
fork->setRootRecord ( record );
fork->show (); fork->show ();
} }
} }

View File

@ -10,10 +10,10 @@
namespace Hurricane { namespace Hurricane {
RecordModel::RecordModel ( Slot* slot, QObject* parent ) RecordModel::RecordModel ( QObject* parent )
: QAbstractTableModel(parent) : QAbstractTableModel(parent)
, _slot(slot) , _slot(NULL)
, _record(slot->getDataRecord()) , _record(NULL)
, _depth(0) , _depth(0)
{ } { }
@ -35,9 +35,8 @@ namespace Hurricane {
emit layoutAboutToBeChanged (); emit layoutAboutToBeChanged ();
if ( _depth ) if ( _depth ) delete _record;
delete _record; if ( _slot ) delete _slot;
delete _slot;
_slot = slot; _slot = slot;
_record = record; _record = record;
@ -100,7 +99,8 @@ namespace Hurricane {
int RecordModel::rowCount ( const QModelIndex& parent ) const int RecordModel::rowCount ( const QModelIndex& parent ) const
{ {
return _record->_getSlotList().size();
return (_record) ? _record->_getSlotList().size() : 0;
} }

View File

@ -53,7 +53,7 @@ namespace Hurricane {
Q_OBJECT; Q_OBJECT;
public: public:
HInspectorWidget ( Record* rootRecord, QWidget* parent=NULL ); HInspectorWidget ( QWidget* parent=NULL );
~HInspectorWidget (); ~HInspectorWidget ();
void setRootRecord ( Record* record ); void setRootRecord ( Record* record );
private slots: private slots:
@ -75,7 +75,6 @@ namespace Hurricane {
QTableView* _slotsView; QTableView* _slotsView;
QLineEdit* _filterPatternLineEdit; QLineEdit* _filterPatternLineEdit;
int _rowHeight; int _rowHeight;
Record* _rootRecord;
History _history; History _history;
}; };

View File

@ -14,7 +14,7 @@ namespace Hurricane {
Q_OBJECT; Q_OBJECT;
public: public:
RecordModel ( Slot* slot, QObject* parent=NULL ); RecordModel ( QObject* parent=NULL );
~RecordModel (); ~RecordModel ();
bool setSlot ( Slot* slot, size_t depth ); bool setSlot ( Slot* slot, size_t depth );
int rowCount ( const QModelIndex& parent=QModelIndex() ) const; int rowCount ( const QModelIndex& parent=QModelIndex() ) const;