* ./hurricane/src/hviewer :

- Bug : InspectorWidget was using Record from Occurrences in the SelectionWidget.
        but those Occurences were created on the fly by the CellWidget/Selectors.
        So, whenever the selection changes the Occurrence may diseapear leaving a
        bad Record in the InspectorWidget (core dump).
          Now, the TabInspector keep a copy of the Inspected occurrence, so it
        can go through any selection change.
          In addition, the InspectorWidget could be passed Occurrence that it keeps
        local copy along with Record*.
    - New Feature : internal, first step toward an extensible ControllerWidget :
        now all Tab are derived classes of ControllerTab.
This commit is contained in:
Jean-Paul Chaput 2008-11-27 15:09:04 +00:00
parent 9c4d322de1
commit e5f5ce3592
6 changed files with 288 additions and 133 deletions

View File

@ -76,6 +76,91 @@ namespace Hurricane {
{ }
// -------------------------------------------------------------------
// Class : "Hurricane::TabGraphics".
TabGraphics::TabGraphics ( QWidget* parent )
: ControllerTab(parent)
, _graphics (new GraphicsWidget())
{
_graphics->setObjectName ( "controller.tabGraphics.graphics" );
QVBoxLayout* wLayout = new QVBoxLayout ();
wLayout->setContentsMargins ( 0, 0, 0, 0 );
wLayout->addWidget ( _graphics );
setLayout ( wLayout );
}
void TabGraphics::setCellWidget ( CellWidget* cellWidget )
{
if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) {
connect ( _graphics, SIGNAL(styleChanged()), getCellWidget(), SLOT(redraw()) );
}
}
}
// -------------------------------------------------------------------
// Class : "Hurricane::TabDisplayFilter".
TabDisplayFilter::TabDisplayFilter ( QWidget* parent )
: ControllerTab (parent)
, _displayFilter(new DisplayFilterWidget())
{
_displayFilter->setObjectName ( "controller.tabDisplayFilter.graphics" );
QVBoxLayout* wLayout = new QVBoxLayout ();
wLayout->setContentsMargins ( 0, 0, 0, 0 );
wLayout->addWidget ( _displayFilter );
setLayout ( wLayout );
}
void TabDisplayFilter::setCellWidget ( CellWidget* cellWidget )
{
if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget );
_displayFilter->setCellWidget ( cellWidget );
}
}
// -------------------------------------------------------------------
// Class : "Hurricane::TabPalette".
TabPalette::TabPalette ( QWidget* parent )
: ControllerTab(parent)
, _palette (new PaletteWidget())
{
_palette->setObjectName ( "controller.tabPalette.palette" );
QVBoxLayout* wLayout = new QVBoxLayout ();
wLayout->setContentsMargins ( 0, 0, 0, 0 );
wLayout->addWidget ( _palette );
setLayout ( wLayout );
}
void TabPalette::setCellWidget ( CellWidget* cellWidget )
{
if ( getCellWidget() )
getCellWidget()->detachFromPalette ();
if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) {
getCellWidget()->bindToPalette ( _palette );
}
}
}
// -------------------------------------------------------------------
// Class : "Hurricane::TabNetlist".
@ -132,7 +217,7 @@ namespace Hurricane {
void TabNetlist::setCellWidget ( CellWidget* cellWidget )
{
if ( getCellWidget() != cellWidget ) {
setCellWidget ( cellWidget );
ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) {
connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)) , this , SLOT(setCell(Cell*)) );
connect ( _netlistBrowser, SIGNAL(netSelected(const Net*)), getCellWidget(), SLOT(select(const Net*)) );
@ -159,8 +244,7 @@ namespace Hurricane {
TabSelection::TabSelection ( QWidget* parent )
: QWidget (parent)
, _cellWidget(NULL)
: ControllerTab(parent)
, _selection (new SelectionWidget())
{
_selection->setObjectName ( "controller.tabSelection.selection" );
@ -180,25 +264,25 @@ namespace Hurricane {
void TabSelection::setCellWidget ( CellWidget* cellWidget )
{
if ( _cellWidget != cellWidget ) {
_cellWidget = cellWidget;
if ( _cellWidget ) {
connect ( _cellWidget , SIGNAL(cellChanged(Cell*))
if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget ( cellWidget );
if ( getCellWidget() ) {
connect ( getCellWidget() , SIGNAL(cellChanged(Cell*))
, this , SLOT(setCell(Cell*)) );
connect ( _cellWidget , SIGNAL(selectionChanged(const set<Selector*>&,Cell*))
connect ( getCellWidget(), SIGNAL(selectionChanged(const set<Selector*>&,Cell*))
, _selection , SLOT (setSelection (const set<Selector*>&,Cell*)) );
connect ( _selection , SIGNAL(occurrenceToggled(Occurrence,bool))
, _cellWidget , SLOT (toggleSelect (Occurrence,bool)) );
connect ( _cellWidget , SIGNAL(occurrenceToggled(Occurrence))
, getCellWidget(), SLOT (toggleSelect (Occurrence,bool)) );
connect ( getCellWidget(), SIGNAL(occurrenceToggled(Occurrence))
, _selection , SLOT (toggleSelection (Occurrence)) );
connect ( _selection , SIGNAL(cumulativeToggled (bool))
, _cellWidget , SLOT (setCumulativeSelection(bool)) );
, getCellWidget(), SLOT (setCumulativeSelection(bool)) );
connect ( _selection , SIGNAL(showSelectionToggled(bool))
, _cellWidget , SLOT (setShowSelection (bool)) );
connect ( _cellWidget , SIGNAL(showSelectionToggled(bool))
, getCellWidget(), SLOT (setShowSelection (bool)) );
connect ( getCellWidget(), SIGNAL(showSelectionToggled(bool))
, _selection , SLOT (setShowSelection (bool)) );
connect ( _selection , SIGNAL(selectionCleared())
, _cellWidget , SLOT (unselectAll ()) );
, getCellWidget(), SLOT (unselectAll ()) );
}
}
}
@ -222,8 +306,8 @@ namespace Hurricane {
void TabSelection::cellPostModificate ()
{
//updateTab ();
if ( _cellWidget && _cellWidget->getCell() )
_selection->setSelection ( _cellWidget->getSelectorSet(), _cellWidget->getCell() );
if ( getCellWidget() && getCellWidget()->getCell() )
_selection->setSelection ( getCellWidget()->getSelectorSet(), getCellWidget()->getCell() );
else
_selection->setSelection ( set<Selector*>() );
}
@ -234,12 +318,11 @@ namespace Hurricane {
TabInspector::TabInspector ( QWidget* parent )
: QWidget (parent)
, _cellWidget (NULL)
: ControllerTab (parent)
, _inspectorWidget (new InspectorWidget())
, _bookmarks (new QComboBox())
, _selectionRecord (NULL)
, _updateFromSelection(false)
, _selectionOccurrence()
, _updateFromSelection(true)
{
_inspectorWidget->setObjectName ( "controller.tabInspector.inspectorWidget" );
@ -281,10 +364,10 @@ namespace Hurricane {
void TabInspector::setCellWidget ( CellWidget* cellWidget )
{
if ( _cellWidget != cellWidget ) {
_cellWidget = cellWidget;
if ( _cellWidget ) {
connect ( _cellWidget, SIGNAL(cellChanged(Cell*)), this, SLOT(setCell(Cell*)) );
if ( getCellWidget() != cellWidget ) {
ControllerTab::setCellWidget( cellWidget );
if ( getCellWidget() ) {
connect ( getCellWidget(), SIGNAL(cellChanged(Cell*)), this, SLOT(setCell(Cell*)) );
}
}
}
@ -296,12 +379,12 @@ namespace Hurricane {
case 0: _inspectorWidget->setRootRecord ( NULL ); break;
case 1: _inspectorWidget->setRootRecord ( getRecord(DataBase::getDB()) ); break;
case 2:
if ( _cellWidget && _cellWidget->getCell() )
_inspectorWidget->setRootRecord ( getRecord(_cellWidget->getCell()) );
if ( getCellWidget() && getCellWidget()->getCell() )
_inspectorWidget->setRootRecord ( getRecord(getCellWidget()->getCell()) );
break;
case 3:
if ( _cellWidget && _cellWidget->getCell() )
_inspectorWidget->setRootRecord ( _selectionRecord );
if ( getCellWidget() && getCellWidget()->getCell() )
_inspectorWidget->setRootRecord ( getRecord(_selectionOccurrence) );
break;
}
}
@ -309,22 +392,23 @@ namespace Hurricane {
void TabInspector::updateTab ()
{
if ( _updateFromSelection && (_bookmarks->currentIndex() == 3) )
_inspectorWidget->setRootRecord ( _selectionRecord );
if ( _updateFromSelection && (_bookmarks->currentIndex() == 3) ) {
_inspectorWidget->setRootRecord ( getRecord(_selectionOccurrence) );
}
_updateFromSelection = false;
}
void TabInspector::setSelectionRecord ( Record* record )
void TabInspector::setSelectionOccurrence ( Occurrence& occurrence )
{
_updateFromSelection = true;
_selectionRecord = record;
_selectionOccurrence = occurrence;
}
void TabInspector::cellPreModificate ()
{
_selectionRecord = NULL;
_selectionOccurrence = Occurrence();
if ( _bookmarks->currentIndex() > 1 )
_inspectorWidget->setRootRecord ( NULL );
}
@ -332,8 +416,8 @@ namespace Hurricane {
void TabInspector::cellPostModificate ()
{
if ( ( _bookmarks->currentIndex() == 2 ) && _cellWidget && _cellWidget->getCell() )
_inspectorWidget->setRootRecord ( getRecord(_cellWidget->getCell()) );
if ( ( _bookmarks->currentIndex() == 2 ) && getCellWidget() && getCellWidget()->getCell() )
_inspectorWidget->setRootRecord ( getRecord(getCellWidget()->getCell()) );
}
@ -344,9 +428,9 @@ namespace Hurricane {
ControllerWidget::ControllerWidget ( QWidget* parent )
: QTabWidget (parent)
, _cellWidget (NULL)
, _graphics (new GraphicsWidget())
, _palette (new PaletteWidget())
, _displayFilter(new DisplayFilterWidget())
, _tabGraphics (new TabGraphics())
, _tabPalette (new TabPalette())
, _tabDisplayFilter(new TabDisplayFilter())
, _tabNetlist (new TabNetlist())
, _tabSelection (new TabSelection())
, _tabInspector (new TabInspector())
@ -357,16 +441,16 @@ namespace Hurricane {
//connect ( _netlistBrowser, SIGNAL(destroyed()), this, SLOT(netlistBrowserDestroyed()) );
_graphics ->setObjectName ( "controller.graphics" );
_palette ->setObjectName ( "controller.palette" );
_displayFilter->setObjectName ( "controller.displayFilter" );
_tabGraphics ->setObjectName ( "controller.graphics" );
_tabPalette ->setObjectName ( "controller.palette" );
_tabDisplayFilter->setObjectName ( "controller.displayFilter" );
_tabNetlist ->setObjectName ( "controller.tabNetlist" );
_tabSelection ->setObjectName ( "controller.tabSelection" );
_tabInspector ->setObjectName ( "controller.tabInspector" );
addTab ( _graphics , "Look" );
addTab ( _displayFilter , "Filter" );
addTab ( _palette , "Layers&&Gos" );
addTab ( _tabGraphics , "Look" );
addTab ( _tabDisplayFilter , "Filter" );
addTab ( _tabPalette , "Layers&&Gos" );
addTab ( _tabNetlist , "Netlist" );
addTab ( _tabSelection , "Selection" );
addTab ( _tabInspector , "Inspector" );
@ -374,30 +458,23 @@ namespace Hurricane {
connect ( this, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)) );
//connect ( _tabNetlist->getNetlistBrowser(), SIGNAL(netSelected(const Net*))
// , _tabSelection , SLOT(setUpdateFromNetlist(const Net*)) );
connect ( _tabSelection->getSelection() , SIGNAL(inspect(Record*))
, _tabInspector , SLOT(setSelectionRecord(Record*)) );
connect ( _tabSelection->getSelection() , SIGNAL(inspect(Occurrence&))
, _tabInspector , SLOT(setSelectionOccurrence(Occurrence&)) );
resize ( 540, 540 );
}
void ControllerWidget::setCellWidget ( CellWidget* widget )
void ControllerWidget::setCellWidget ( CellWidget* cellWidget )
{
if ( _cellWidget )
_cellWidget->detachFromPalette ();
_cellWidget = widget;
_cellWidget = cellWidget;
if ( _cellWidget ) {
_displayFilter->setCellWidget ( _cellWidget );
_tabNetlist ->setCellWidget ( _cellWidget );
_tabSelection ->setCellWidget ( _cellWidget );
_tabInspector ->setCellWidget ( _cellWidget );
_cellWidget ->bindToPalette ( _palette );
for ( int i=0 ; i<count() ; ++i )
(static_cast<ControllerTab*>(widget(i)))->setCellWidget ( _cellWidget );
connect ( _graphics , SIGNAL(styleChanged()) , _cellWidget, SLOT(redraw()) );
connect ( _cellWidget, SIGNAL(cellChanged(Cell*)) , this , SLOT(cellChanged(Cell*)) );
connect ( _cellWidget, SIGNAL(cellPreModificated()) , this , SLOT(cellPreModificate()) );
connect ( _cellWidget, SIGNAL(cellPostModificated()), this , SLOT(cellPostModificate()) );
connect ( _cellWidget, SIGNAL(cellChanged(Cell*)) , this, SLOT(cellChanged(Cell*)) );
connect ( _cellWidget, SIGNAL(cellPreModificated()) , this, SLOT(cellPreModificate()) );
connect ( _cellWidget, SIGNAL(cellPostModificated()), this, SLOT(cellPostModificate()) );
}
}
@ -408,26 +485,21 @@ namespace Hurricane {
void ControllerWidget::updateTab ( int index )
{
switch ( index ) {
case 4: _tabSelection->updateTab (); break;
case 5: _tabInspector->updateTab (); break;
}
(static_cast<ControllerTab*>(widget(index)))->updateTab ();
}
void ControllerWidget::cellPreModificate ()
{
_tabInspector ->cellPreModificate ();
_tabSelection ->cellPreModificate ();
_tabNetlist ->cellPreModificate ();
for ( int i=0 ; i<count() ; ++i )
(static_cast<ControllerTab*>(widget(i)))->cellPreModificate ();
}
void ControllerWidget::cellPostModificate ()
{
_tabNetlist ->cellPostModificate ();
_tabSelection ->cellPostModificate ();
_tabInspector ->cellPostModificate ();
for ( int i=0 ; i<count() ; ++i )
(static_cast<ControllerTab*>(widget(i)))->cellPostModificate ();
}

View File

@ -165,6 +165,7 @@ namespace Hurricane {
, _view(NULL)
, _rowHeight(20)
, _history()
, _rootOccurrence()
{
setAttribute ( Qt::WA_DeleteOnClose );
setAttribute ( Qt::WA_QuitOnClose, false );
@ -223,9 +224,24 @@ namespace Hurricane {
}
void InspectorWidget::setRootOccurrence ( Occurrence& occurrence )
{
_rootOccurrence = occurrence;
_setRootRecord ( getRecord(occurrence) );
}
void InspectorWidget::setRootRecord ( Record* record )
{
_rootOccurrence = Occurrence();
_setRootRecord ( record );
}
void InspectorWidget::_setRootRecord ( Record* record )
{
_history.setRootRecord ( record );
if ( !record ) _rootOccurrence = Occurrence ();
if ( !_baseModel ) {
_baseModel = new RecordModel ( this );

View File

@ -198,6 +198,8 @@ namespace Hurricane {
_view->selectRow ( 0 );
_view->resizeColumnToContents ( 0 );
//if ( !_cumulative->isChecked() ) emit inspect ( NULL );
}
@ -211,8 +213,9 @@ namespace Hurricane {
{
if ( index.isValid() ) {
Occurrence occurrence = _baseModel->getOccurrence ( _sortModel->mapToSource(index).row() );
emit inspect ( getRecord(occurrence) );
}
emit inspect ( occurrence );
} else
emit inspect ( NULL );
}

View File

@ -31,6 +31,8 @@
class QCheckBox;
class QComboBox;
#include "hurricane/Occurrence.h"
namespace Hurricane {
@ -72,6 +74,69 @@ namespace Hurricane {
inline CellWidget* ControllerTab::getCellWidget () { return _cellWidget; }
// -------------------------------------------------------------------
// Class : "Hurricane::TabGraphics".
class TabGraphics : public ControllerTab {
Q_OBJECT;
public:
TabGraphics ( QWidget* parent=NULL );
inline GraphicsWidget* getGraphics ();
public slots:
void setCellWidget ( CellWidget* );
protected:
GraphicsWidget* _graphics;
};
inline GraphicsWidget* TabGraphics::getGraphics () { return _graphics; }
// -------------------------------------------------------------------
// Class : "Hurricane::TabDisplayFilter".
class TabDisplayFilter : public ControllerTab {
Q_OBJECT;
public:
TabDisplayFilter ( QWidget* parent=NULL );
inline DisplayFilterWidget* getDisplayFilter ();
public slots:
virtual void setCellWidget ( CellWidget* );
protected:
DisplayFilterWidget* _displayFilter;
};
inline DisplayFilterWidget* TabDisplayFilter::getDisplayFilter () { return _displayFilter; }
// -------------------------------------------------------------------
// Class : "Hurricane::TabPalette".
class TabPalette : public ControllerTab {
Q_OBJECT;
public:
TabPalette ( QWidget* parent=NULL );
inline PaletteWidget* getPalette ();
public slots:
virtual void setCellWidget ( CellWidget* );
protected:
PaletteWidget* _palette;
};
inline PaletteWidget* TabPalette::getPalette () { return _palette; }
// -------------------------------------------------------------------
// Class : "Hurricane::TabNetlist".
@ -104,28 +169,25 @@ namespace Hurricane {
// Class : "Hurricane::TabSelection".
class TabSelection : public QWidget {
class TabSelection : public ControllerTab {
Q_OBJECT;
public:
TabSelection ( QWidget* parent=NULL );
inline CellWidget* getCellWidget ();
inline SelectionWidget* getSelection ();
void updateTab ();
void cellPreModificate ();
void cellPostModificate ();
virtual void updateTab ();
virtual void cellPreModificate ();
virtual void cellPostModificate ();
public slots:
void setCell ( Cell* );
void setCellWidget ( CellWidget* );
virtual void setCell ( Cell* );
virtual void setCellWidget ( CellWidget* );
protected:
CellWidget* _cellWidget;
SelectionWidget* _selection;
bool _selectionChanged;
};
inline CellWidget* TabSelection::getCellWidget () { return _cellWidget; }
inline SelectionWidget* TabSelection::getSelection () { return _selection; }
@ -133,33 +195,30 @@ namespace Hurricane {
// Class : "Hurricane::TabInspector".
class TabInspector : public QWidget {
class TabInspector : public ControllerTab {
Q_OBJECT;
public:
TabInspector ( QWidget* parent=NULL );
inline CellWidget* getCellWidget ();
inline InspectorWidget* getInspectorWidget ();
inline QComboBox* getBookmarks ();
void updateTab ();
void cellPreModificate ();
void cellPostModificate ();
virtual void updateTab ();
virtual void cellPreModificate ();
virtual void cellPostModificate ();
public slots:
void setCell ( Cell* );
void setCellWidget ( CellWidget* );
void setSelectionRecord ( Record* );
void bookmarkChanged ( int index );
virtual void setCell ( Cell* );
virtual void setCellWidget ( CellWidget* );
virtual void setSelectionOccurrence ( Occurrence& );
virtual void bookmarkChanged ( int index );
protected:
CellWidget* _cellWidget;
InspectorWidget* _inspectorWidget;
QComboBox* _bookmarks;
Record* _selectionRecord;
Occurrence _selectionOccurrence;
bool _updateFromSelection;
};
inline CellWidget* TabInspector::getCellWidget () { return _cellWidget; }
inline InspectorWidget* TabInspector::getInspectorWidget () { return _inspectorWidget; }
inline QComboBox* TabInspector::getBookmarks () { return _bookmarks; }
@ -189,9 +248,9 @@ namespace Hurricane {
protected:
CellWidget* _cellWidget;
GraphicsWidget* _graphics;
PaletteWidget* _palette;
DisplayFilterWidget* _displayFilter;
TabGraphics* _tabGraphics;
TabPalette* _tabPalette;
TabDisplayFilter* _tabDisplayFilter;
TabNetlist* _tabNetlist;
TabSelection* _tabSelection;
TabInspector* _tabInspector;
@ -199,9 +258,9 @@ namespace Hurricane {
inline CellWidget* ControllerWidget::getCellWidget () { return _cellWidget; }
inline GraphicsWidget* ControllerWidget::getGraphics () { return _graphics; }
inline PaletteWidget* ControllerWidget::getPalette () { return _palette; }
inline DisplayFilterWidget* ControllerWidget::getDisplayFilter () { return _displayFilter; }
inline GraphicsWidget* ControllerWidget::getGraphics () { return _tabGraphics->getGraphics(); }
inline PaletteWidget* ControllerWidget::getPalette () { return _tabPalette->getPalette(); }
inline DisplayFilterWidget* ControllerWidget::getDisplayFilter () { return _tabDisplayFilter->getDisplayFilter(); }
inline NetlistWidget* ControllerWidget::getNetlistBrowser () { return _tabNetlist->getNetlistBrowser(); }
inline SelectionWidget* ControllerWidget::getSelection () { return _tabSelection->getSelection(); }
inline InspectorWidget* ControllerWidget::getInspectorWidget () { return _tabInspector->getInspectorWidget(); }

View File

@ -30,6 +30,7 @@
#include <QWidget>
#include "hurricane/Commons.h"
#include "hurricane/Occurrence.h"
class QSortFilterProxyModel;
@ -79,16 +80,18 @@ namespace Hurricane {
public:
InspectorWidget ( QWidget* parent=NULL );
~InspectorWidget ();
void setRootRecord ( Record* record );
void setRootRecord ( Record* );
void setRootOccurrence ( Occurrence& );
private slots:
void forceRowHeight ();
void textFilterChanged ();
void historyChanged ( int depth );
void forkInspector ( const QModelIndex& index );
void forkInspector ( const QModelIndex& );
protected:
void keyPressEvent ( QKeyEvent * event );
void keyPressEvent ( QKeyEvent* );
private:
void pushSlot ( Slot* slot );
void _setRootRecord ( Record* );
void pushSlot ( Slot* );
void popSlot ();
void back ();
bool setSlot ();
@ -101,6 +104,7 @@ namespace Hurricane {
QLineEdit* _filterPatternLineEdit;
int _rowHeight;
History _history;
Occurrence _rootOccurrence;
};

View File

@ -66,6 +66,7 @@ namespace Hurricane {
void showSelectionToggled ( bool );
void selectionCleared ();
void inspect ( Record* );
void inspect ( Occurrence& );
public slots:
void setShowSelection ( bool );
void selectCurrent ( const QModelIndex& current, const QModelIndex& );