* ./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...
This commit is contained in:
Jean-Paul Chaput 2010-03-23 12:54:50 +00:00
parent b50b492b69
commit d55da89955
5 changed files with 28 additions and 25 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -31,6 +31,7 @@
#include <QWidget>
#include <QTableView>
#include <QItemDelegate>
#include <QSortFilterProxyModel>
#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 );
}