Beispiel #1
0
void CandidateWindow::adjustCandidateWindowSize()
{
#if defined(ENABLE_DEBUG)
    qDebug( "adjustCandidateWindowSize()" );
#endif
    int width = 0;
    int height = 0;
    QListViewItem *item = cList->firstChild();
    if ( item )
        height = item->height() * ( cList->childCount() + 1 );

    // 2004-08-02 Kazuki Ohta <*****@*****.**>
    // FIXME!:
    //    There may be more proper way. Now width is adjusted by indeterminal 3 spaces.
    //    Using QWidget::adjustSize() seems not to work properly...
    unsigned int maxCharIndex = 0, maxCharCount = 0;
    for ( int i = 0; i < cList->childCount(); i++ )
    {
        if ( maxCharCount < cList->itemAtIndex( i ) ->text( 1 ).length() )
        {
            maxCharIndex = i;
            maxCharCount = cList->itemAtIndex( i ) ->text( 1 ).length();
        }
    }
    QFontMetrics fm( cList->font() );
    width = fm.width( cList->itemAtIndex( maxCharIndex ) ->text( 0 ) + "   " + cList->itemAtIndex( maxCharIndex ) ->text( 1 ) );
    if ( width < MIN_CAND_WIDTH )
        width = MIN_CAND_WIDTH;

    resize( width, height );
}
QListViewItem * ListViewDnd::itemAt( QPoint pos )
{
    QListView * src = (QListView *) this->src;
    int headerHeight = (int)(src->header()->height());
    pos.ry() -= headerHeight;
    QListViewItem * result = src->itemAt( pos );

    if ( result && ( pos.ry() < (src->itemPos(result) + result->height()/2) ) )
	result = result->itemAbove();

    // Wind back if has parent, and we're in flat mode
    while ( result && result->parent() && (dMode & Flat) )
	result = result->parent();

    // Wind back if has parent, and we're in flat mode
    while ( result && !result->isVisible() && result->parent() )
	result = result->parent();

    if ( !result && src->firstChild() && (pos.y() > src->itemRect(src->firstChild()).bottom()) ) {
	result = src->lastItem();
	if ( !result->isVisible() )
	    // Handle special case where last item is actually hidden
	    result = result->itemAbove();
    }

    return result;
}
Beispiel #3
0
/******************************************************************************
*  Find the height of one list item.
*/
int EventListViewBase::itemHeight()
{
    EventListViewItemBase* item = firstChild();
    if (!item)
    {
        // The list is empty, so create a temporary item to find its height
        QListViewItem* item = new QListViewItem(this, QString::null);
        int height = item->height();
        delete item;
        return height;
    }
    else
        return item->height();
}
Beispiel #4
0
void CostTypeView::refresh()
{
    clear();
    setColumnWidth(1, 50);
    setColumnWidth(2, 50);

    if (!_data || !_activeItem) return;
    switch(_activeItem->type()) {
    case TraceCost::Object:
    case TraceCost::Class:
    case TraceCost::File:
    case TraceCost::FunctionCycle:
    case TraceCost::Function:
	break;
    default:
	return;
    }
    TraceCostItem* c = (TraceCostItem*) _activeItem;

    TraceCostType* ct =0 ;
    QListViewItem* item = 0;
    QString sumStr, pureStr;
    QListViewItem* costItem=0;

    TraceCostMapping* m = _data->mapping();
    for (int i=m->virtualCount()-1;i>=0;i--) {
	ct = m->virtualType(i);
	if (!ct) continue;
	item = new CostTypeItem(this, c, ct, _groupType);
	if (ct == _costType) costItem = item;
    }
    for (int i=m->realCount()-1;i>=0;i--) {
	ct = m->realType(i);
	item = new CostTypeItem(this, c, ct, _groupType);
	if (ct == _costType) costItem = item;
    }

    if (costItem) {
	setSelected(costItem, true);
	ensureItemVisible(costItem);
    }

    if (item) setMinimumHeight(3*item->height());
}
Beispiel #5
0
void UserView::paintEmptyArea(QPainter *p, const QRect &r)
{
    if ((r.width() == 0) || (r.height() == 0))
        return;
    QPixmap bg(r.width(), r.height());
    QPainter pp(&bg);
    pp.fillRect(QRect(0, 0, r.width(), r.height()), colorGroup().base());
    PaintView pv;
    pv.p        = &pp;
    pv.pos      = viewport()->mapToParent(r.topLeft());
    pv.size	= r.size();
    pv.win      = this;
    pv.isStatic = false;
    pv.height   = r.height();
    pv.margin   = 0;
    QListViewItem *item = firstChild();
    if (item)
        pv.height = item->height();
    Event e(EventPaintView, &pv);
    e.process();
    pp.end();
    p->drawPixmap(r.topLeft(), bg);
    setStaticBackground(pv.isStatic);
}