From d55da89955c1fb6207dda545f547ccb6b37fce76 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Tue, 23 Mar 2010 12:54:50 +0000 Subject: [PATCH] * ./hurricane/src/viewer: - Bug: In NetlistWidget/NetlistModel, suppress the "forceRowHeight()" method which was terribly slowing down the table display. Instead uses the "setDefaultSectionSize()" of the vertical header to setup the row height (much more compact display). - Bug: In NetlistModel, strangely, although we have a "data()" and a "headerData()" method, the "data()" is also called for the headers potentially erasing any previous setting done with "headerData()". This was occuring for the fonts settings. Don't known if it is a bug or a feature of Qt... - Thoses changes has to be ported to the others widgets some times... --- hurricane/src/viewer/Graphics.cpp | 4 +-- hurricane/src/viewer/NetlistModel.cpp | 12 ++++++-- hurricane/src/viewer/NetlistWidget.cpp | 30 +++++++++---------- .../src/viewer/hurricane/viewer/Graphics.h | 2 +- .../viewer/hurricane/viewer/NetlistWidget.h | 5 +--- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/hurricane/src/viewer/Graphics.cpp b/hurricane/src/viewer/Graphics.cpp index 22b71f6c..6a3cfc3b 100644 --- a/hurricane/src/viewer/Graphics.cpp +++ b/hurricane/src/viewer/Graphics.cpp @@ -74,11 +74,11 @@ namespace Hurricane { } - const QFont Graphics::getFixedFont ( int weight, bool italic, bool underline ) + const QFont Graphics::getFixedFont ( int weight, bool italic, bool underline, int scale ) { const QFont defaultFont = QApplication::font (); - QFont fixedFont ( "Bitstream Vera Sans Mono", defaultFont.pointSize() ); + QFont fixedFont ( "Bitstream Vera Sans Mono", defaultFont.pointSize()+scale ); fixedFont.setWeight ( weight ); fixedFont.setItalic ( italic ); fixedFont.setUnderline ( underline ); diff --git a/hurricane/src/viewer/NetlistModel.cpp b/hurricane/src/viewer/NetlistModel.cpp index 0b1a0725..9641b5a8 100644 --- a/hurricane/src/viewer/NetlistModel.cpp +++ b/hurricane/src/viewer/NetlistModel.cpp @@ -63,10 +63,12 @@ namespace Hurricane { } if ( role == Qt::FontRole ) { + if ( index.row() == 0 ) return QVariant(); switch (index.column()) { case 0: return nameFont; default: return valueFont; } + return QVariant(); } if ( !index.isValid() ) return QVariant (); @@ -83,10 +85,14 @@ namespace Hurricane { , Qt::Orientation orientation , int role ) const { - if ( ( orientation == Qt::Vertical ) || (role != Qt::DisplayRole) ) - return QVariant(); + if ( orientation == Qt::Vertical ) return QVariant(); - if ( !_netlist ) { + static QFont headerFont = Graphics::getFixedFont ( QFont::Bold, false, false, +2 ); + + if ( role == Qt::FontRole ) return headerFont; + if ( role != Qt::DisplayRole ) return QVariant(); + + if ( not _netlist ) { if ( section == 0 ) return QVariant("Net"); return QVariant(); } diff --git a/hurricane/src/viewer/NetlistWidget.cpp b/hurricane/src/viewer/NetlistWidget.cpp index f9877760..9a023f2f 100644 --- a/hurricane/src/viewer/NetlistWidget.cpp +++ b/hurricane/src/viewer/NetlistWidget.cpp @@ -72,12 +72,11 @@ namespace Hurricane { _sortModel->setDynamicSortFilter ( true ); _sortModel->setFilterKeyColumn ( 0 ); - _view->setShowGrid(false); - _view->setAlternatingRowColors(true); - _view->setSelectionBehavior(QAbstractItemView::SelectRows); - _view->setSortingEnabled(true); - _view->setModel ( _sortModel ); - _view->horizontalHeader()->setStretchLastSection ( true ); + _view->setShowGrid ( false ); + _view->setAlternatingRowColors ( true ); + _view->setSelectionBehavior ( QAbstractItemView::SelectRows ); + _view->setSortingEnabled ( true ); + _view->setModel ( _sortModel ); QHeaderView* horizontalHeader = _view->horizontalHeader (); horizontalHeader->setStretchLastSection ( true ); @@ -85,6 +84,16 @@ namespace Hurricane { QHeaderView* verticalHeader = _view->verticalHeader (); verticalHeader->setVisible ( false ); + verticalHeader->setDefaultSectionSize ( _rowHeight ); + + // verticalHeader->setStyleSheet( "QHeaderView::section {" + // "padding-bottom: 0px;" + // "padding-top: 0px;" + // "padding-left: 0px;" + // "padding-right: 1px;" + // "margin: 0px;" + // "}" + // ); _filterPatternLineEdit = new QLineEdit(this); QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this); @@ -106,20 +115,12 @@ namespace Hurricane { , this , SLOT (textFilterChanged()) ); connect ( _view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)) , this , SLOT (updateSelecteds (const QItemSelection&,const QItemSelection&)) ); - connect ( _baseModel, SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); connect ( fitAction , SIGNAL(triggered ()), this, SLOT(fitToNet ()) ); resize(300, 300); } - void NetlistWidget::forceRowHeight () - { - for ( int rows=_sortModel->rowCount()-1; rows >= 0 ; rows-- ) - _view->setRowHeight ( rows, _rowHeight ); - } - - void NetlistWidget::goTo ( int delta ) { if ( delta == 0 ) return; @@ -187,7 +188,6 @@ namespace Hurricane { void NetlistWidget::textFilterChanged () { _sortModel->setFilterRegExp ( _filterPatternLineEdit->text() ); - forceRowHeight (); //updateSelecteds (); } diff --git a/hurricane/src/viewer/hurricane/viewer/Graphics.h b/hurricane/src/viewer/hurricane/viewer/Graphics.h index 075d8b95..67de7ea3 100644 --- a/hurricane/src/viewer/hurricane/viewer/Graphics.h +++ b/hurricane/src/viewer/hurricane/viewer/Graphics.h @@ -56,7 +56,7 @@ namespace Hurricane { // Accessors. static Graphics* getGraphics (); static bool isEnabled (); - static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false ); + static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 ); static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false ); static const Name& getGroup ( const Name& key ); static QColor getColor ( const Name& key, int darkening=100 ); diff --git a/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h b/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h index 78e38e73..5f185c44 100644 --- a/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/NetlistWidget.h @@ -31,6 +31,7 @@ #include #include +#include #include #include "hurricane/Commons.h" @@ -151,8 +152,6 @@ namespace Hurricane { void netSelected ( const Net* ); void netUnselected ( const Net* ); void netFitted ( const Net* ); - public slots: - void forceRowHeight (); private slots: void textFilterChanged (); void updateSelecteds ( const QItemSelection& , const QItemSelection& ); @@ -198,8 +197,6 @@ namespace Hurricane { setWindowTitle ( tr(windowTitle.c_str()) ); int rows = _sortModel->rowCount (); - for ( rows-- ; rows >= 0 ; rows-- ) - _view->setRowHeight ( rows, _rowHeight ); _view->selectRow ( 0 ); _view->resizeColumnToContents ( 0 ); }