Пример #1
0
bool TreeWidgetColumnStretcher::eventFilter(QObject *obj, QEvent *ev)
{
    if (obj == parent()) {
        if (ev->type() == QEvent::Show) {
            QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
            for (int i = 0; i < hv->count(); ++i)
                hv->setResizeMode(i, QHeaderView::Interactive);
        } else if (ev->type() == QEvent::Hide) {
            QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
            for (int i = 0; i < hv->count(); ++i)
                hv->setResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
        } else if (ev->type() == QEvent::Resize) {
            QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
            if (hv->resizeMode(m_columnToStretch) == QHeaderView::Interactive) {
                QResizeEvent *re = static_cast<QResizeEvent*>(ev);
                int diff = re->size().width() - re->oldSize().width() ;
                hv->resizeSection(m_columnToStretch, qMax(32, hv->sectionSize(1) + diff));
            }
        }
    }
    return false;
}
Пример #2
0
//--------------------------------------------------------------------------------------
//! Update a table row for changed device info
//--------------------------------------------------------------------------------------
void tNDP2kDevicePage::rowChanged(int row, tNDP2kDevice* pDevice)
{
    QHeaderView* pHeaderView = m_pTableWidget->horizontalHeader();
    for(int i = 0; i < m_DisplayColumns.count(); i++)
    {
        if(m_DisplayColumns[i] == addressColumn)
        {
            m_pTableWidget->item(row, i)->setText(QString().sprintf("%03d", pDevice->Address()));
        }

        if(m_DisplayColumns[i] == modelIdColumn)
        {
            QString str = pDevice->ModelId();

            if( pDevice->Nickname() != NULL )
            {
                str += " " + pDevice->Nickname();
            }

            if(pDevice->N2kName().ManCode() == BEP_ID )
            {
                str += " [" + pDevice->BepCZoneDipswitch() + "]";
            }
            else if(pDevice->N2kName().DeviceInstance() != 0 && pDevice->N2kName().ManCode() != SIMRAD_ID )
            {
                str += " [" + pDevice->DeviceInstance() + "]";
            }

            tQReadLocker lock( pDevice->Locker() );
            if( pDevice->HasAdditionalInfo() )
            {
                str += " (" + pDevice->AdditionalInfo() + ")";
            }
            lock.unlock();

            m_pTableWidget->item(row, i)->setText(str);
        }


        if(m_DisplayColumns[i] == manufacturerColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->Manufacturer());
        }

        if(m_DisplayColumns[i] == nameColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->HexName());
        }

        if(m_DisplayColumns[i] == productCodeColumn)
        {
            m_pTableWidget->item(row, i)->setText(QString("%1").arg(pDevice->ProductCode()));
        }

        if(m_DisplayColumns[i] == SwVersionColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->SwVersion());
        }

        if(m_DisplayColumns[i] == classFunctionColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->ClassFunction());
        }

        if(m_DisplayColumns[i] == deviceInstanceColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->DeviceInstance());
        }

        if(m_DisplayColumns[i] == serialNumberColumn)
        {
            m_pTableWidget->item(row, i)->setText(pDevice->SerialNoOrThisDevice());
        }

        m_pTableWidget->item(row, i)->setTextAlignment( Qt::AlignVCenter );

        pHeaderView->setResizeMode( i, pHeaderView->resizeMode( i ) ); // resize to new contents
    }
}
Пример #3
0
int HeaderView::resizeMode(lua_State * L) // ( int logicalIndex ) const : ResizeMode 
{
    QHeaderView* obj = QtObject<QHeaderView>::check( L, 1);
	Util::push( L, obj->resizeMode( Util::toInt( L, 2) ) );
	return 1;
}