Example #1
0
void GameList::LoadInterfaceLayout()
{
    auto header = tree_view->header();
    header->restoreState(UISettings::values.gamelist_header_state);

    item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
}
Example #2
0
void GameList::LoadInterfaceLayout() {
    auto header = tree_view->header();
    if (!header->restoreState(UISettings::values.gamelist_header_state)) {
        // We are using the name column to display icons and titles
        // so make it as large as possible as default.
        header->resizeSection(COLUMN_NAME, header->width());
    }

    item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
}
Example #3
0
void RotatedHeader::paintSection(QPainter *p, const QRect &rect, int idx) const {
	if (!rect.isValid() || idx == 0) 
		return QHeaderView::paintSection(p, rect, idx);

	QColor bg = model()->headerData(idx, Qt::Horizontal, Qt::BackgroundColorRole).value<QColor>();
	if (m_spacer_indexes.contains(idx)) {
		p->save();
		p->fillRect(rect, QBrush(bg));
		p->restore();
		return;
	}

	QStyleOptionHeader opt;
	opt.rect = rect;
	opt.orientation = Qt::Horizontal;
	opt.section = idx;
	opt.sortIndicator = QStyleOptionHeader::None;
	
	QStyle::State state = QStyle::State_None;
	if (isEnabled())
		state |= QStyle::State_Enabled;
	if (window()->isActiveWindow())
		state |= QStyle::State_Active;
	if (rect.contains(m_p))
		state |= QStyle::State_MouseOver;
	if (sortIndicatorSection() == idx) {
		//state |= QStyle::State_Sunken;
		if (sortIndicatorOrder() == Qt::AscendingOrder) {
			opt.sortIndicator = QStyleOptionHeader::SortDown;
		} else {
			opt.sortIndicator = QStyleOptionHeader::SortUp;
		}
	}
    if (m_hovered_column == idx) {
        state |= QStyle::State_MouseOver;
    }

	opt.state = state;
	style()->drawControl(QStyle::CE_HeaderSection, &opt, p);
	
    QBrush brush = QBrush(bg);
	if (m_shade_column_headers) {
		QLinearGradient g(rect.topLeft(), rect.bottomLeft());
		g.setColorAt(0.25, QColor(255, 255, 255, 10));
		g.setColorAt(1.0, bg);
        brush = QBrush(g);
	}
    if (idx > 0)
        p->fillRect(rect.adjusted(1,8,-1,-2), brush);

	if (sortIndicatorSection() == idx) {
		opt.rect = QRect(opt.rect.x() + opt.rect.width()/2 - 5, opt.rect.y(), 10, 8);
		style()->drawPrimitive(QStyle::PE_IndicatorHeaderArrow, &opt, p);
	}

	/* Draw a border around header if column has guides applied
	DwarfModelProxy *prox = static_cast<DwarfModelProxy*>(model());
	DwarfModel *dm = prox->get_dwarf_model();
	int col = dm->selected_col();
	if (dm->selected_col() == idx) {
		p->save();
		p->setPen(Qt::red);
		p->setBrush(Qt::NoBrush);
		p->drawRect(rect);
		p->restore();
	}
	*/
    
	QString data = this->model()->headerData(idx, Qt::Horizontal).toString();
	p->save();
	p->setPen(Qt::black);
	p->setRenderHint(QPainter::Antialiasing);
	p->translate(rect.x(), rect.y());
	p->rotate(90);
	p->setFont(QFont("Verdana", 8));
	p->drawText(14, -4, data);
	p->restore();
}
Example #4
0
void FileListHeader::sectionDoubleClickedSlot(int logicalIndex)
{
	setSortIndicator(logicalIndex, sortIndicatorOrder() == Qt::AscendingOrder ? Qt::DescendingOrder : Qt::AscendingOrder);
}