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->setSectionResizeMode(i, QHeaderView::Interactive);
        }
        else if (ev->type() == QEvent::Hide)
        {
            QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
            for (int i = 0; i < hv->count(); ++i)
				hv->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
        }
        else if (ev->type() == QEvent::Resize)
        {
            QHeaderView *hv = qobject_cast<QHeaderView*>(obj);
            if (hv->sectionResizeMode(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
bool CFileListView::eventFilter(QObject* target, QEvent* event)
{
	QHeaderView * headerView = header();
	if (target == headerView && event && event->type() == QEvent::Resize && headerView->count() == NumberOfColumns)
	{
		auto resizeEvent = dynamic_cast<QResizeEvent*>(event);
		assert_and_return_r(resizeEvent, false);
		float oldHeaderWidth = 0.0f;
		for (int i = 0; i < headerView->count(); ++i)
			oldHeaderWidth += (float)headerView->sectionSize(i);

		const float newHeaderWidth = (float)resizeEvent->size().width();
		if (oldHeaderWidth <= 0.0f || newHeaderWidth <= 0.0f || oldHeaderWidth == newHeaderWidth)
			return false;

		std::vector<float> relativeColumnSizes(NumberOfColumns, 0.0f);
		for (int i = 0; i < headerView->count(); ++i)
			relativeColumnSizes[i] = headerView->sectionSize(i) / oldHeaderWidth;

		for (int i = 0; i < headerView->count(); ++i)
			headerView->resizeSection(i, (int)(newHeaderWidth * relativeColumnSizes[i] + 0.5f));

		return false;
	}

	return QTreeView::eventFilter(target, event);
}
示例#3
0
void DeploymentDataView::updateDeploymentDataModel()
{
    d->deploymentDataModel.setDeploymentData(d->target->deploymentData());
    QHeaderView *header = d->ui.deploymentDataView->header();
    header->setSectionResizeMode(0, QHeaderView::Interactive);
    header->setSectionResizeMode(1, QHeaderView::Interactive);
    d->ui.deploymentDataView->resizeColumnToContents(0);
    d->ui.deploymentDataView->resizeColumnToContents(1);
    if (header->sectionSize(0) + header->sectionSize(1)
            < d->ui.deploymentDataView->header()->width()) {
        d->ui.deploymentDataView->header()->setSectionResizeMode(1, QHeaderView::Stretch);
    }
}
void MusicVideoTableWidget::creatSearchedItems(const QString &songname,
                                               const QString &artistname,
                                               const QString &time)
{
    int count;
    setRowCount(count = m_downLoadManager->getSongIdIndex());
    QHeaderView *headerview = horizontalHeader();

    QTableWidgetItem *item = new QTableWidgetItem;
    item->setData(MUSIC_CHECK_ROLE, false);
    setItem(count - 1, 0, item);

                      item = new QTableWidgetItem;
    item->setText(QFontMetrics(font()).elidedText(songname, Qt::ElideRight,
                                                  headerview->sectionSize(1) - 5));
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    item->setToolTip(songname);
    setItem(count - 1, 1, item);

                      item = new QTableWidgetItem;
    item->setText(QFontMetrics(font()).elidedText(artistname, Qt::ElideRight,
                                                  headerview->sectionSize(2) - 5));
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    item->setToolTip(artistname);
    setItem(count - 1, 2, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(randToGetStrength()));
    setItem(count - 1, 3, item);

                      item = new QTableWidgetItem(time);
    item->setTextColor(QColor(50, 50, 50));
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count - 1, 4, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(QString::fromUtf8(":/share/showMV")));
    setItem(count - 1, 5, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(QString::fromUtf8(":/share/autionplay")));
    setItem(count - 1, 6, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(QString::fromUtf8(":/share/musicdownload")));
    setItem(count - 1, 7, item);
}
示例#5
0
// This is called by rclmain_w prior to exiting
void ResTable::saveColState()
{
    if (!m_ismainres)
	return;
    QSettings settings;
    settings.setValue("resTableSplitterSizes", splitter->saveState());

    QHeaderView *header = tableView->horizontalHeader();
    const vector<string>& vf = m_model->getFields();
    if (!header) {
	LOGERR(("ResTable::saveColState: no table header ??\n"));
	return;
    }

    // Remember the current column order. Walk in visual order and
    // create new list
    QStringList newfields;
    vector<int> newwidths;
    for (int vi = 0; vi < header->count(); vi++) {
	int li = header->logicalIndex(vi);
	if (li < 0 || li >= int(vf.size())) {
	    LOGERR(("saveColState: logical index beyond list size!\n"));
	    continue;
	}
	newfields.push_back(QString::fromUtf8(vf[li].c_str()));
	newwidths.push_back(header->sectionSize(li));
    }
    prefs.restableFields = newfields;
    prefs.restableColWidths = newwidths;
}
void QtPropertyEditor::drawRow(QPainter * painter, const QStyleOptionViewItem &option, const QModelIndex & index) const
{
	QColor gridColor = option.palette.color(QPalette::Normal, QPalette::Window);

	// draw horizontal bottom line
	painter->setPen(gridColor);
	painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());

	// adjust rect, so that grid line wont be overdrawn
	QStyleOptionViewItemV4 opt = option;
	opt.rect.adjust(0, 0, 0, -1);

	// draw row
	QTreeView::drawRow(painter, opt, index);

	// draw vertical line
	if(!(option.state & QStyle::State_Selected))
	{
		QHeaderView *hdr = header();
		if(NULL != hdr && hdr->count() > 1)
		{
			int sz = hdr->sectionSize(0);

			QPoint p1 = option.rect.topLeft();
			QPoint p2 = option.rect.bottomLeft();

			p1.setX(p1.x() + sz - 1);
			p2.setX(p2.x() + sz - 1);

			painter->setPen(gridColor);
			painter->drawLine(p1, p2);
		}
	}
}
示例#7
0
QRect QAccessibleTableHeaderCell::rect() const
{
    QHeaderView *header = 0;
    if (false) {
#ifndef QT_NO_TABLEVIEW
    } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
        if (orientation == Qt::Horizontal) {
            header = tv->horizontalHeader();
        } else {
            header = tv->verticalHeader();
        }
#endif
#ifndef QT_NO_TREEVIEW
    } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
        header = tv->header();
#endif
    }
    if (!header)
        return QRect();
    QPoint zero = header->mapToGlobal(QPoint(0, 0));
    int sectionSize = header->sectionSize(index);
    int sectionPos = header->sectionPosition(index);
    return orientation == Qt::Horizontal
            ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height())
            : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize);
}
示例#8
0
void CDlgStaying::FillTable( QStringList &lstData, QTableWidget *pTable, int nRows )
{
    int nIndex = pTable->columnCount( ) - 1;
    QHeaderView* pView = pTable->horizontalHeader( );
    pView->resizeSection( nIndex, pView->sectionSize( nIndex ) * 2 );

    CCommonFunction::FillTable( pTable, nRows, lstData );
}
示例#9
0
void AccountsTreeView::slotModelReset()
{
    hideColumns( m_leftview, QList<int>() << 3 << -1 );
    QHeaderView *v = m_leftview->header();
    kDebug(planDbg())<<v->sectionSize(2)<<v->sectionSizeHint(2)<<v->defaultSectionSize()<<v->minimumSectionSize();

    hideColumns( m_rightview, QList<int>() << 0 << 1 << 2 );
}
示例#10
0
CDlgMakeLicense::CDlgMakeLicense(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CDlgMakeLicense)
{
    ui->setupUi(this);
    CCommonFunction::ConnectCloseButton( ui->lblClose );
    ui->lblTitle->setText( windowTitle( ) );
    setWindowFlags( Qt::FramelessWindowHint );

    pProcess = new CProcessCpuid( ui->tableWidget, this );
    FillParkID( );
    connect( pProcess, SIGNAL( ParkIDChanged( QString& ) ), this, SLOT( ParkIDChanged( QString& ) ) );

    QHeaderView* pHeader = ui->tableWidget->horizontalHeader( );
    pHeader->resizeSection( 0, pHeader->sectionSize( 0 ) + 80 );
    pHeader->resizeSection( 1, pHeader->sectionSize( 1 ) + 20 );
    pHeader->resizeSection( 2, pHeader->sectionSize( 2 ) + 20 );
    pHeader->resizeSection( 3, pHeader->sectionSize( 3 ) + 20 );
    setStyleSheet( QString( "background-image:url(%1);" ).arg( statusTip( ) ) );
}
//-------------------------------------------------------------------------------------------------
void
BachFolderBrowserTreeView::saveColumns( IniConfig & ini, const BachFolderBrowserTreeView::ColumnStructEx columns [] )
{
	QHeaderView * hdr = header();
	for( int i=0; columns[i].name; i++ )
		ini.writeInt( columns[i].iniName + QString("Size"), hdr->sectionSize( i ) );
	for( int i=0; columns[i].name; i++ )
		ini.writeInt( columns[i].iniName + QString("Index"), hdr->visualIndex( i ) );
	for( int i=0; columns[i].name; i++ )
		ini.writeBool( columns[i].iniName + QString("Hidden"), hdr->isSectionHidden( i ) );
}
示例#12
0
CDlgGarageInGarage::CDlgGarageInGarage(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CDlgGarageInGarage)
{
    ui->setupUi(this);
    CCommonFunction::ConnectCloseButton( ui->lblClose );
    ui->lblTitle->setText( windowTitle( ) );
    setWindowFlags( Qt::FramelessWindowHint );

    QHeaderView* pHeader = ui->tabRecord->horizontalHeader( );
    int nIndex = 2;
    pHeader->resizeSection( nIndex, pHeader->sectionSize( nIndex ) * 2 );
}
void MusicVideoTableWidget::resizeWindow(float delta)
{
    QHeaderView *headerview = horizontalHeader();
    headerview->resizeSection(0, 30*delta);
    headerview->resizeSection(1, 210*delta);
    headerview->resizeSection(2, 136*delta);
    headerview->resizeSection(3, 30*delta);
    headerview->resizeSection(4, 55*delta);
    headerview->resizeSection(5, 24*delta);
    headerview->resizeSection(6, 24*delta);
    headerview->resizeSection(7, 24*delta);

    //resize row
    for(int i=0; i<rowCount(); ++i)
    {
        QTableWidgetItem *it = item(i, 1);
        it->setText(QFontMetrics(font()).elidedText(it->toolTip(), Qt::ElideRight,
                                                    headerview->sectionSize(1) - 5));
        it = item(i, 2);
        it->setText(QFontMetrics(font()).elidedText(it->toolTip(), Qt::ElideRight,
                                                    headerview->sectionSize(2) - 5));
    }
}
示例#14
0
void BreakpointWidget::showEvent(QShowEvent *)
{
    if (m_firstShow && m_debugController->breakpointModel()->rowCount() > 0) {
        for (int i = 0; i < m_breakpointsView->model()->columnCount(); ++i) {
            if(i == Breakpoint::LocationColumn){
                continue;
            }
            m_breakpointsView->resizeColumnToContents(i);
        }
        //for some reasons sometimes width can be very small about 200... But it doesn't matter as we use tooltip anyway.
        int width = m_breakpointsView->size().width();

        QHeaderView* header = m_breakpointsView->header();
        header->resizeSection(Breakpoint::LocationColumn, width > 400 ? width/2 : header->sectionSize(Breakpoint::LocationColumn)*2 );
        m_firstShow = false;
    }
}
示例#15
0
 void toggleColumnWidth(int logicalIndex)
 {
     QHeaderView *h = q->header();
     const int currentSize = h->sectionSize(logicalIndex);
     const int suggestedSize = suggestedColumnSize(logicalIndex);
     int targetSize = suggestedSize;
     // We switch to the size suggested by the contents, except
     // when we have that size already, in that case minimize.
     if (currentSize == suggestedSize) {
         QFontMetrics fm = q->fontMetrics();
         int headerSize = fm.width(q->model()->headerData(logicalIndex, Qt::Horizontal).toString());
         int minSize = 10 * fm.width(QLatin1Char('x'));
         targetSize = qMax(minSize, headerSize);
     }
     h->resizeSection(logicalIndex, targetSize);
     m_userHandled.remove(logicalIndex); // Reset.
     saveState();
 }
示例#16
0
    Q_SLOT void resizeColumns() // Needs moc, see BaseTreeView::setModel
    {
        QHeaderView *h = q->header();
        QTC_ASSERT(h, return);

        if (m_settings && !m_settingsKey.isEmpty()) {
            for (int i = 0, n = h->count(); i != n; ++i) {
                int targetSize;
                if (m_userHandled.contains(i))
                    targetSize = m_userHandled.value(i);
                else
                    targetSize = suggestedColumnSize(i);
                const int currentSize = h->sectionSize(i);
                if (targetSize > 0 && targetSize != currentSize)
                    h->resizeSection(i, targetSize);
            }
        }
    }
示例#17
0
void PreferenceDialog::chooseFont()
{
    bool ok;
    QFont font;
    QLabel *label = NULL;

    if (sender() == ui->chooseViewerFont) {
        font = ui->viewerSample->font();
    }
    else if (sender() == ui->chooseBoxFont) {
        font = ui->sampleEdit->font();
    }
    else if (sender() == ui->chooseViewFont) {
        font = m_model.font();
    }

    font = QFontDialog::getFont(&ok, font, this);

    if (sender() == ui->chooseViewerFont) {
        ui->viewerSample->setFont(font);
        label = ui->viewerFont;
    }
    else if (sender() == ui->chooseBoxFont) {
        ui->sampleEdit->setFont(font);
        label = ui->boxFont;
    }
    else if (sender() == ui->chooseViewFont) {
        QHeaderView *header = ui->sampleTable->verticalHeader();
        header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5);
        ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5);
        ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2);
        m_model.setFont(font);
        m_model.update();
        label = ui->viewFont;
    }
    label->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));

}
示例#18
0
void SensorWidget::paintEvent(QPaintEvent* event)
{
  painter.begin(this);
  painter.setFont(font);
  painter.setBrush(altBrush);
  painter.setPen(fontPen);
  fillBackground = false;

  paintRect = painter.window();
  paintRectField0 = QRect(headerView->sectionViewportPosition(0) + textOffset, 0, headerView->sectionSize(0) - textOffset * 2, lineSpacing);
  paintRectField1 = QRect(headerView->sectionViewportPosition(1) + textOffset, 0, headerView->sectionSize(1) - textOffset * 2, lineSpacing);
  {
    SYNC_WITH(sensorView.console);
    paintInertialSensorData();
    newSection();
    paintSystemSensorData();
    newSection();
    paintFsrSensorData();
    newSection();
    paintKeyStates();
  }
  painter.end();
  setMinimumHeight(paintRectField1.top());
}
示例#19
0
void PreferenceDialog::loadAppearance(QSettings &settings, bool import)
{
    QPalette palette;
    QColor color;
    QFont font;

    //>>>> アドレスボックス
    palette = QPalette();
    // 背景色
    color = settings.value(IniKey_BoxColorBg).value<QColor>();
    palette.setColor(QPalette::Base, color);
    // 文字色
    color = settings.value(IniKey_BoxColorFg).value<QColor>();
    palette.setColor(QPalette::Text, color);
    // フォント
    font = settings.value(IniKey_BoxFont).value<QFont>();
    ui->boxFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
    // サンプル表示
    ui->sampleEdit->setPalette(palette);
    ui->sampleEdit->setFont(font);

    //>>>> ファイルビュー
    // 背景色
    color = settings.value(IniKey_ViewColorBgMark).value<QColor>();
    m_colorMap["clrBgMark"] = color;
    color = settings.value(IniKey_ViewColorBgNormal).value<QColor>();
    m_colorMap["clrBgNormal"] = color;
    // 文字色
    color = settings.value(IniKey_ViewColorFgHidden).value<QColor>();
    m_colorMap["clrFgHidden"] = color;
    color = settings.value(IniKey_ViewColorFgMark).value<QColor>();
    m_colorMap["clrFgMark"] = color;
    color = settings.value(IniKey_ViewColorFgNormal).value<QColor>();
    m_colorMap["clrFgNormal"] = color;
    color = settings.value(IniKey_ViewColorFgReadonly).value<QColor>();
    m_colorMap["clrFgReadonly"] = color;
    color = settings.value(IniKey_ViewColorFgSystem).value<QColor>();
    m_colorMap["clrFgSystem"] = color;
    // フォント
    font = settings.value(IniKey_ViewFont).value<QFont>();
    ui->viewFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
    // サンプル表示
    QHeaderView *header = ui->sampleTable->verticalHeader();
    header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5);
    ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5);
    ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2);
    m_model.setFont(font);
    m_model.update();

    //>>>> テキストビューア
    // 文字色と背景色
    if (settings.value(IniKey_ViewerInherit).toBool()) {
        ui->viewerInherit->setChecked(true);
        color = settings.value(IniKey_ViewColorBgNormal).value<QColor>();
        palette.setColor(QPalette::Base, color);
        color = settings.value(IniKey_ViewColorFgNormal).value<QColor>();
        palette.setColor(QPalette::Text, color);
    }
    else if (!import){
        ui->viewerInherit->setChecked(false);
        color = settings.value(IniKey_ViewerColorBg).value<QColor>();
        palette.setColor(QPalette::Base, color);
        color = settings.value(IniKey_ViewerColorFg).value<QColor>();
        palette.setColor(QPalette::Text, color);
    }
    ui->viewerSample->setPalette(palette);
    // フォント
    if (!import) {
        font = settings.value(IniKey_ViewerFont).value<QFont>();
        ui->viewerFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
        ui->viewerSample->setFont(font);
    }
}
示例#20
0
int HeaderView::sectionSize(lua_State * L) // ( int logicalIndex ) const : int
{	
    QHeaderView* obj = QtObject<QHeaderView>::check( L, 1);
	Util::push( L, obj->sectionSize( Util::toInt( L, 2) ) );
	return 1;
}
void MusicCloudSharedSongTableWidget::receiveDataFinshed(const QNDataItems &items)
{
    clear();
    int count = items.count();
    if(count == 0)
    {
        emit updateLabelMessage(tr("List Is Empty!"));
        createUploadFileWidget();
        return;
    }

    delete m_openFileWidget;
    m_openFileWidget = nullptr;

    setRowCount(count);
    QHeaderView *headerview = horizontalHeader();
    for(int i=0; i<count; ++i)
    {
        QNDataItem dataItem = items[i];
        QTableWidgetItem *item = new QTableWidgetItem;
        item->setData(MUSIC_DATAS_ROLE, QVariant::fromValue<QNDataItem>(dataItem));
        setItem(i, 0, item);

                          item = new QTableWidgetItem;
        item->setToolTip(dataItem.m_name);
        item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
        item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
        item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        setItem(i, 1, item);

                          item = new QTableWidgetItem;
        item->setToolTip(MusicUtils::Number::size2Label(dataItem.m_size));
        item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 5));
        item->setTextColor(QColor(MusicUIObject::MColorStyle12_S));
        item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
        setItem(i, 2, item);

        ///insert server datas into caches
        MusicUploadData data;
        data.m_path = dataItem.m_name.trimmed();
        data.m_name = data.m_path;
        data.m_state = MusicUploadData::Successed;
        if(!m_waitedFiles.contains(data))
        {
            m_waitedFiles << data;
        }
    }

    m_currentUploadIndex = m_waitedFiles.count();
    emit updateLabelMessage(tr("List Update Finished!"));
}
void MusicLrcSearchTableWidget::createSearchedItem(const MusicSearchedItem &songItem)
{
    int count = rowCount();
    setRowCount(count + 1);

    QHeaderView *headerview = horizontalHeader();
    QTableWidgetItem *item = new QTableWidgetItem;
    item->setData(MUSIC_CHECK_ROLE, false);
    setItem(count, 0, item);

                      item = new QTableWidgetItem;
    item->setToolTip(songItem.m_songName);
    item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(1) - 20));
    item->setTextColor(QColor(100, 100, 100));
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count, 1, item);

                      item = new QTableWidgetItem;
    item->setToolTip(songItem.m_singerName);
    item->setText(MusicUtils::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerview->sectionSize(2) - 20));
    item->setTextColor(QColor(100, 100, 100));
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count, 2, item);

                      item = new QTableWidgetItem(songItem.m_time);
    item->setTextColor(QColor(100, 100, 100));
    item->setTextAlignment(Qt::AlignCenter);
    setItem(count, 3, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(randToGetStrength()));
    setItem(count, 4, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(":/tiny/lb_server_type"));
    item->setToolTip(songItem.m_type);
    setItem(count, 5, item);

                      item = new QTableWidgetItem;
    item->setIcon(QIcon(":/contextMenu/btn_download"));
    setItem(count, 6, item);
}