Ejemplo n.º 1
0
QwtDoubleRect VectorCurve::boundingRect() const
{
QwtDoubleRect rect = QwtPlotCurve::boundingRect();
QwtDoubleRect vrect = vectorEnd->boundingRect();

if (d_style == XYXY){
	rect.setTop(QMIN((double)rect.top(), (double)vrect.top()));
	rect.setBottom(QMAX((double)rect.bottom(), (double)vrect.bottom()));
	rect.setLeft(QMIN((double)rect.left(), (double)vrect.left()));
	rect.setRight(QMAX((double)rect.right(), (double)vrect.right()));
} else {
	const double angle = vectorEnd->x(0);
	double mag = vectorEnd->y(0);
	switch(d_position)
		{
		case Tail:
			rect.setTop(QMIN((double)rect.top(), (double)(rect.top()+mag*sin(angle))));
			rect.setBottom(QMAX((double)rect.bottom(), (double)(rect.bottom()+mag*sin(angle))));
			rect.setLeft(QMIN((double)rect.left(), (double)(rect.left()+mag*cos(angle))));
			rect.setRight(QMAX((double)rect.right(), (double)(rect.right()+mag*cos(angle))));
		break;

		case Middle:
			{
			mag *= 0.5;
			rect.setTop(QMIN((double)rect.top(), (double)(rect.top() - fabs(mag*sin(angle)))));
			rect.setBottom(QMAX((double)rect.bottom(), (double)(rect.bottom() + fabs(mag*sin(angle)))));
			rect.setLeft(QMIN((double)rect.left(), (double)(rect.left() - fabs(mag*cos(angle)))));
			rect.setRight(QMAX((double)rect.right(), (double)(rect.right() + fabs(mag*cos(angle)))));
			}
		break;

		case Head:
			rect.setTop(QMIN((double)rect.top(), (double)(rect.top() - mag*sin(angle))));
			rect.setBottom(QMAX((double)rect.bottom(), (double)(rect.bottom() - mag*sin(angle))));
			rect.setLeft(QMIN((double)rect.left(), (double)(rect.left() - mag*cos(angle))));
			rect.setRight(QMAX((double)rect.right(), (double)(rect.right() - mag*cos(angle))));
		break;
		}
	}
return rect;
}
Ejemplo n.º 2
0
/** Executes the simulation of this component */
void FloatMax::calculate()
{
	FloatXIn1Out::calculate();

	QPtrListIterator<ConnectorBase> it(*getInputConnectorPack()->getConnList());
	
	// Hint: Gate has min 2 inputs !!! No check is required.
	double result = ((ConnectorFloatIn*)it.current())->getInput();
	++it;
		
	while (it.current())		
	{
		result = QMAX(result, ((ConnectorFloatIn*)it.current())->getInput());
		++it;
	}
		
	setValue(result);
}
Ejemplo n.º 3
0
QSize KWQFileButton::sizeForCharacterWidth(int characters) const
{
    ASSERT(characters > 0);

    GtkWidget *w;
    GtkRequisition req, req2;

    // get the size from input
    w = getGtkEntryWidget();    
    gtk_entry_set_width_chars( GTK_ENTRY(w), characters );        
    gtk_widget_size_request( w, &req );

    // get the size from button
    w = getGtkButtonWidget();
    gtk_widget_size_request( w, &req2 );    
   
    return QSize( req.width + req2.width + 10, QMAX(req.height, req2.height) );
}
Ejemplo n.º 4
0
void Matrix::initImage(const QImage& image)
{
    initGlobals();
	d_view_type = ImageView;

    d_matrix_model = new MatrixModel(image, this);
    initImageView();

	int w = image.width();
	int h = image.height();
	if (w <= 500 && h <= 400){
		int size = QMAX(w, h);
        imageLabel->resize(size, size);
    } else
		imageLabel->resize(500, 500);

	displayImage(image);
}
Ejemplo n.º 5
0
void KateFileListItem::paintCell(QPainter *painter, const QColorGroup &cg, int column, int width, int align)
{
    KateFileList *fl = (KateFileList *)listView();
    if(!fl)
        return;

    if(column == 0)
    {
        QColorGroup cgNew = cg;

        // replace the base color with a different shading if necessary...
        if(fl->shadingEnabled() && m_viewhistpos > 1)
        {
            QColor b(cg.base());

            QColor shade = fl->viewShade();
            QColor eshade = fl->editShade();
            int hc = fl->histCount();
            // If this file is in the edit history, blend in the eshade
            // color. The blend is weighted by the position in the editing history
            if(fl->shadingEnabled() && m_edithistpos > 0)
            {
                int ec = fl->editHistCount();
                int v = hc - m_viewhistpos;
                int e = ec - m_edithistpos + 1;
                e = e * e;
                int n = QMAX(v + e, 1);
                shade.setRgb(((shade.red() * v) + (eshade.red() * e)) / n, ((shade.green() * v) + (eshade.green() * e)) / n,
                             ((shade.blue() * v) + (eshade.blue() * e)) / n);
            }
            // blend in the shade color.
            // max transperancy < .5, latest is most colored.
            float t = (0.5 / hc) * (hc - m_viewhistpos + 1);
            b.setRgb((int)((b.red() * (1 - t)) + (shade.red() * t)), (int)((b.green() * (1 - t)) + (shade.green() * t)),
                     (int)((b.blue() * (1 - t)) + (shade.blue() * t)));

            cgNew.setColor(QColorGroup::Base, b);
        }

        QListViewItem::paintCell(painter, cgNew, column, width, align);
    }
    else
        QListViewItem::paintCell(painter, cg, column, width, align);
}
Ejemplo n.º 6
0
/*!
  Draw a needle looking like a ray
*/
void QwtDialSimpleNeedle::drawRayNeedle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, int width, double direction, 
    bool hasKnob)
{
    if ( width <= 0 )
        width = 5;

    direction *= M_PI / 180.0;

    painter->save();

    const QPoint p1(center.x() + 1, center.y() + 2);
    const QPoint p2 = qwtPolar2Pos(p1, length, direction);

    if ( width == 1 )
    {
        painter->setPen(QPen(cg.mid(), 1));
        painter->drawLine(p1, p2);
    }
    else
    {
        QPointArray pa(4);
        pa.setPoint(0, qwtPolar2Pos(p1, width / 2, direction + M_PI_2));
        pa.setPoint(1, qwtPolar2Pos(p2, width / 2, direction + M_PI_2));
        pa.setPoint(2, qwtPolar2Pos(p2, width / 2, direction - M_PI_2));
        pa.setPoint(3, qwtPolar2Pos(p1, width / 2, direction - M_PI_2));

        painter->setPen(Qt::NoPen);
        painter->setBrush(cg.brush(QColorGroup::Mid));
        painter->drawPolygon(pa);
    }
    if ( hasKnob )
    {
        int knobWidth = QMAX(qRound(width * 0.7), 5);
        if ( knobWidth % 2 == 0 )
            knobWidth++;

        drawKnob(painter, center, knobWidth, 
            cg.brush(QColorGroup::Base), FALSE);
    }

    painter->restore();
}
Ejemplo n.º 7
0
bool KDialog::avoidArea( QWidget *w, const QRect& area, int screen )
{
  if ( !w )
    return false;
  QRect fg = w->frameGeometry();
  if ( !fg.intersects( area ) )
    return true; // nothing to do.

  QRect scr = screenRect( w, screen );
  QRect avoid( area ); // let's add some margin
  avoid.moveBy( -5, -5 );
  avoid.rRight() += 10;
  avoid.rBottom() += 10;

  if ( QMAX( fg.top(), avoid.top() ) <= QMIN( fg.bottom(), avoid.bottom() ) )
  {
    // We need to move the widget up or down
    int spaceAbove = QMAX(0, avoid.top() - scr.top());
    int spaceBelow = QMAX(0, scr.bottom() - avoid.bottom());
    if ( spaceAbove > spaceBelow ) // where's the biggest side?
      if ( fg.height() <= spaceAbove ) // big enough?
        fg.setY( avoid.top() - fg.height() );
      else
        return false;
    else
      if ( fg.height() <= spaceBelow ) // big enough?
        fg.setY( avoid.bottom() );
      else
        return false;
  }

  if ( QMAX( fg.left(), avoid.left() ) <= QMIN( fg.right(), avoid.right() ) )
  {
    // We need to move the widget left or right
    int spaceLeft = QMAX(0, avoid.left() - scr.left());
    int spaceRight = QMAX(0, scr.right() - avoid.right());
    if ( spaceLeft > spaceRight ) // where's the biggest side?
      if ( fg.width() <= spaceLeft ) // big enough?
        fg.setX( avoid.left() - fg.width() );
      else
        return false;
    else
      if ( fg.width() <= spaceRight ) // big enough?
        fg.setX( avoid.right() );
      else
        return false;
  }
  //kdDebug() << "Moving window to " << fg.x() << "," << fg.y() << endl;
  w->move(fg.x(), fg.y());
  return true;
}
Ejemplo n.º 8
0
void ScheduleDialog::initCanvas()
{
    DrawProperties p;

    p.canvas = canvas;
    p.nameWidth = 0;        // name labels are on other canvas
    p.x = WIDGET_SPACING;
    p.y = 0;
    p.width = canvas->width();
    p.height = canvas->height();

    // calculate pix per ns (find block with highest clock to draw it
    // BLOCKS_PER_CANVAS times.
    unsigned int max_clock = 0;
    QValueList<BlockNode*>::Iterator it;
    for (it = blocks_.begin(); it != blocks_.end(); ++it) {
        max_clock = QMAX(max_clock, (*it)->clock());
    }
    p.pixPerNs = (max_clock > 0)
        ? (double)p.width / (max_clock * BLOCKS_PER_CANVAS)
        : 1.0;

    drawRuler(&p);
    for (it = blocks_.begin(); it != blocks_.end(); ++it) {
        drawTimings(&p, *it);
    }

    // create highlighter
    highlightCanvasRectangle = new QCanvasRectangle(canvas);
    highlightCanvasRectangle->setSize(canvas->width(),
                                      BOX_HEIGHT + BOX_YSPACING);
    highlightCanvasRectangle->setBrush(QBrush(qApp->palette().active().highlight()));
    highlightCanvasRectangle->setPen(QPen(white));
    highlightCanvasRectangle->move(0, RULER_HEIGHT - BOX_YSPACING / 2);
    highlightCanvasRectangle->setZ(0);
    highlightCanvasRectangle->show();

    connect(timingTable, SIGNAL(currentChanged(int, int)),
            this, SLOT(updateHighlighter(int, int)));

    canvas->update();
    labelCanvas->update();
}
Ejemplo n.º 9
0
void fitDialog::activateCurve(int index)
{
    QwtPlotCurve *c = graph->curve(index);
    if (!c)
        return;

    if (graph->selectorsEnabled() && graph->selectedCurveID() == graph->curveKey(index))
    {
        double start = graph->selectedXStartValue();
        double end = graph->selectedXEndValue();
        boxFrom->setText(QString::number(QMIN(start, end), 'g', 15));
        boxTo->setText(QString::number(QMAX(start, end), 'g', 15));
    }
    else
    {
        boxFrom->setText(QString::number(c->minXValue(), 'g', 15));
        boxTo->setText(QString::number(c->maxXValue(), 'g', 15));
    }
};
Ejemplo n.º 10
0
void KasLoadItem::paint( QPainter *p )
{
    double val = valuesOne.last();
    double maxValue = 1.0;
    double scaleVal = QMAX( val, valuesFive.last() );

    if ( scaleVal >= maxValue )
	maxValue = 2.0;
    if ( scaleVal >= maxValue )
	maxValue = 5.0;
    if ( scaleVal >= maxValue )
	maxValue = 10.0;
    if ( scaleVal >= maxValue )
	maxValue = 20.0;
    if ( scaleVal >= maxValue )
	maxValue = 50.0;
    if ( scaleVal >= maxValue )
	maxValue = 100.0;

    double dh = extent()-16;
    dh = dh / maxValue;

    int h = (int) floor( dh * val );
    int w = extent()-4;
    h = (h > 0) ? h : 1;
    w = (w > 0) ? w : 1;

    KasItem::paint( p );

    QColor light = kasbar()->colorGroup().highlight();
    QColor dark = light.dark();

    KPixmap pix;
    pix.resize( w, h );
    KPixmapEffect::gradient( pix, light, dark, KPixmapEffect::DiagonalGradient );
    p->drawPixmap( 2, extent()-2-h, pix );

    p->setPen( kasbar()->colorGroup().mid() );
    for ( double pos = 0.2 ; pos < 1.0 ; pos += 0.2 ) {
	int ypos = (int) floor((extent()-2) - (dh*maxValue*pos));
	p->drawLine( 2, ypos, extent()-3, ypos );
    }
}
Ejemplo n.º 11
0
void AddAppletDialog::resizeAppletView()
{
    int w, h;
    QScrollView *v = m_mainWidget->appletScrollView;
    
    if (m_closing)
        return;
    
    for (int i = 0; i < 3; i++)
    {
        m_appletBox->layout()->activate();
        w = v->visibleWidth();
        h = m_appletBox->layout()->minimumSize().height();
        v->resizeContents(w, QMAX(h, v->visibleHeight()));
        if (w == m_appletBox->width() && h == m_appletBox->height())
        break;
        m_appletBox->resize(w, h);
        v->updateScrollBars();
    }
}
Ejemplo n.º 12
0
int K3bDeviceBranchViewItem::widthHint() const
{
  QFont f( listView()->font() );
  if ( m_bCurrent ) {
      f.setBold( true );
  }
  int w = QFontMetrics(f).width( text(0).left( text(0).find('\n') ) );

  f.setItalic( true );
  f.setBold( false );
  f.setPointSize( f.pointSize() - 2 );
  w = QMAX( w, QFontMetrics(f).width( text(0).mid( text(0).find('\n')+1 ) ) );

  w++; // see paintCell

  if( pixmap(0) )
    w += pixmap(0)->width() + 5;

  return w;
}
Ejemplo n.º 13
0
int NADDirectSource::frameCount(const QString& field) const {
  if (!_valid) {
    return 0;
  }

  if (field.isEmpty() || _fieldList.contains(field)) {
    int maxLen = 0;
    for (QStringList::ConstIterator i = _fieldList.begin(); i != _fieldList.end(); ++i) {
//      assert(!(*i).isEmpty());
      QSize sz = _conn->range(*i);
      maxLen = QMAX(sz.height() - sz.width() + 1, maxLen);
    }
    kstdDebug() << "NAD::frameCount(" << field << ") = maxLen = " << maxLen << endl;
    return maxLen;
  }

  QSize sz = _conn->range(field);
  kstdDebug() << "NAD::frameCount(" << field << ") = " << sz.height() - sz.width() + 1 << endl;
  return sz.height() - sz.width() + 1;
}
Ejemplo n.º 14
0
void QCompletionEdit::placeListBox()
{
    if ( listbox->count() == 0 ) {
	popup->close();
	return;
    }

    popup->resize( QMAX( listbox->sizeHint().width() + listbox->verticalScrollBar()->width() + 4, width() ),
		   listbox->sizeHint().height() + listbox->horizontalScrollBar()->height() + 4 );

    QPoint p( mapToGlobal( QPoint( 0, 0 ) ) );
    if ( p.y() + height() + popup->height() <= QApplication::desktop()->height() )
	popup->move( p.x(), p.y() + height() );
    else
	popup->move( p.x(), p.y() - listbox->height() );
    popup->show();
    listbox->setCurrentItem( 0 );
    listbox->setSelected( 0, TRUE );
    setFocus();
}
Ejemplo n.º 15
0
void QSplitter::getRange( int id, int *min, int *max )
{
    int minB = 0;	//before
    int maxB = 0;
    int minA = 0;
    int maxA = 0;	//after
    int n = data->list.count();
    if ( id < 0 || id >= n )
	return;
    int i;
    for ( i = 0; i < id; i++ ) {
	QSplitterLayoutStruct *s = data->list.at(i);
	if ( s->wid->isHidden() ) {
	    //ignore
	} else if ( s->isSplitter ) {
	    minB += s->sizer;
	    maxB += s->sizer;
	} else {
	    minB += pick( minSize(s->wid) );
	    maxB += pick( s->wid->maximumSize() );
	}
    }
    for ( i = id; i < n; i++ ) {
	QSplitterLayoutStruct *s = data->list.at(i);
	if ( s->wid->isHidden() ) {
	    //ignore
	} else 	if ( s->isSplitter ) {
	    minA += s->sizer;
	    maxA += s->sizer;
	} else {
	    minA += pick( minSize(s->wid) );
	    maxA += pick( s->wid->maximumSize() );
	}
    }
    QRect r = contentsRect();
    if ( min )
	*min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
    if ( max )
	*max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );

}
Ejemplo n.º 16
0
int QFontMetrics::charWidth( const QString &str, int pos ) const
{
    if ( pos < 0 || pos > (int)str.length() )
	return 0;

    const QChar &ch = str.unicode()[ pos ];
    if ( ch.unicode() < QFontEngineData::widthCacheSize &&
	 d->engineData && d->engineData->widthCache[ ch.unicode() ] )
	return (d->engineData->widthCache[ ch.unicode() ]*d->engineData->engine->scale)>>8;

    QFont::Script script;
    SCRIPT_FOR_CHAR( script, ch );

    int width;

    if ( script >= QFont::Arabic && script <= QFont::Khmer ) {
	// complex script shaping. Have to do some hard work
	int from = QMAX( 0,  pos - 8 );
	int to = QMIN( (int)str.length(), pos + 8 );
	QConstString cstr( str.unicode()+from, to-from);
	QTextEngine layout( cstr.string(), d );
	layout.itemize( QTextEngine::WidthOnly );
	width = layout.width( pos-from, 1 );
    } else if ( ::category( ch ) == QChar::Mark_NonSpacing || qIsZeroWidthChar(ch.unicode())) {
        width = 0;
    } else {
	QFontEngine *engine = d->engineForScript( script );
#ifdef QT_CHECK_STATE
	Q_ASSERT( engine != 0 );
#endif // QT_CHECK_STATE

	glyph_t glyphs[8];
	advance_t advances[8];
	int nglyphs = 7;
	engine->stringToCMap( &ch, 1, glyphs, advances, &nglyphs, FALSE );
	width = advances[0];
    }
    if ( ch.unicode() < QFontEngineData::widthCacheSize && width > 0 && width < 0x100 )
	d->engineData->widthCache[ ch.unicode() ] = width;
    return width;
}
Ejemplo n.º 17
0
int Filter::curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd)
{
    if (!c)
        return 0;

    int n = c->dataSize();
    int i_start = 0, i_end = n;

	if (c->x(0) < c->x(n-1)){
    	for (int i = 0; i < n; i++){
  	   	 if (c->x(i) >= start){
  	    	  i_start = i;
          	break;
        	}
		}
    	for (int i = n-1; i >= 0; i--){
  	    	if (c->x(i) <= end){
  	      		i_end = i;
          		break;
        	}
		}
	} else {
    	for (int i = 0; i < n; i++){
  	   	 if (c->x(i) <= end){
  	    	  i_start = i;
          	break;
        	}
		}
    	for (int i = n-1; i >= 0; i--){
  	    	if (c->x(i) >= start){
  	      		i_end = i;
          		break;
        	}
		}
	}

	*iStart = QMIN(i_start, i_end);
	*iEnd = QMAX(i_start, i_end);
    n = abs(i_end - i_start) + 1;
    return n;
}
Ejemplo n.º 18
0
void SetTabFret::stringChanged(int n)
{
    if (oldst == n)
		return;

	if (defaultByString[n - 1] != 0)
		for (int i = 0; i < n; i++)
			tuner[i]->setValue(lib_tuning[defaultByString[n - 1]].shift[i]);

    if (oldst < n) {       // Need to add
		for (int i = oldst; i < n; i++)
			tuner[i]->show();
    } else {             // Need to delete
		for (int i = n; i < oldst; i++)
			tuner[i]->hide();
    }
    oldst = n;

    setMinimumSize(QMAX(330, 20 + RADTUNER_W * n), 90+RADTUNER_H);
    reposTuners();
}
Ejemplo n.º 19
0
/*!
  Draw a compass needle 
*/
void QwtCompassMagnetNeedle::drawThinNeedle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, double direction) 
{
    const int colorOffset = 10;
    const int width = QMAX(qRound(length / 6.0), 3);

    painter->save();

    const QPoint arrowCenter(center.x() + 1, center.y() + 1);

    drawPointer(painter, cg.brush(QColorGroup::Dark), colorOffset, 
        arrowCenter, length, width, direction);
    drawPointer(painter, cg.brush(QColorGroup::Light), -colorOffset, 
        arrowCenter, length, width, direction + 180.0);
    
    drawKnob(painter, arrowCenter, width, 
        cg.brush(QColorGroup::Base), TRUE);

    painter->restore();
}
Ejemplo n.º 20
0
void GeometryTip::setGeometry(const QRect &geom)
{
    int w = geom.width();
    int h = geom.height();

    if(sizeHints)
    {
        if(sizeHints->flags & PResizeInc)
        {
            w = (w - sizeHints->base_width) / sizeHints->width_inc;
            h = (h - sizeHints->base_height) / sizeHints->height_inc;
        }
    }

    h = QMAX(h, 0); // in case of isShade() and PBaseSize
    QString pos;
    pos.sprintf("%+d,%+d<br>(<b>%d&nbsp;x&nbsp;%d</b>)", geom.x(), geom.y(), w, h);
    setText(pos);
    adjustSize();
    move(geom.x() + ((geom.width() - width()) / 2), geom.y() + ((geom.height() - height()) / 2));
}
Ejemplo n.º 21
0
/*!
  Draw a compass needle 
*/
void QwtCompassMagnetNeedle::drawPointer(
    QPainter *painter, const QBrush &brush,
    int colorOffset, const QPoint &center, int length, 
    int width, double direction)
{
    painter->save();

    const int peak = QMAX(qRound(length / 10.0), 5);

    const int knobWidth = width + 8;
    QRect knobRect(0, 0, knobWidth, knobWidth);
    knobRect.moveCenter(center);

    QPointArray pa(5);

    pa.setPoint(0, qwtDegree2Pos(center, width / 2, direction + 90.0));
    pa.setPoint(1, center);
    pa.setPoint(2, qwtDegree2Pos(pa.point(1), length - peak, direction));
    pa.setPoint(3, qwtDegree2Pos(center, length, direction));
    pa.setPoint(4, qwtDegree2Pos(pa.point(0), length - peak, direction));

    painter->setPen(Qt::NoPen);

    QBrush darkBrush = brush;
    darkBrush.setColor(darkBrush.color().dark(100 + colorOffset));
    painter->setBrush(darkBrush);
    painter->drawPolygon(pa);
    painter->drawPie(knobRect, qRound(direction * 16), 90 * 16);

    pa.setPoint(0, qwtDegree2Pos(center, width / 2, direction - 90.0));
    pa.setPoint(4, qwtDegree2Pos(pa.point(0), length - peak, direction));

    QBrush lightBrush = brush;
    lightBrush.setColor(lightBrush.color().dark(100 - colorOffset));
    painter->setBrush(lightBrush);
    painter->drawPolygon(pa);
    painter->drawPie(knobRect, qRound(direction * 16), -90 * 16);

    painter->restore();
}
Ejemplo n.º 22
0
int QWidgetStack::addWidget( QWidget * w, int id )
{
    static int nseq_no = -2;
    static int pseq_no = 0;

    if ( !w || w == invisible )
	return -1;

    // prevent duplicates
    removeWidget( w );

    if ( id >= 0 && dict->find( id ) )
	id = -2;
    if ( id < -1 )
	id = nseq_no--;
    else if ( id == -1 )
	id = pseq_no++;
    else
	pseq_no = QMAX(pseq_no, id + 1);
	// use id >= 0 as-is

    dict->insert( id, w );

    // preserve existing focus
    QWidget * f = w->focusWidget();
    while( f && f != w )
	f = f->parentWidget();
    if ( f ) {
	if ( !focusWidgets )
	    focusWidgets = new QPtrDict<QWidget>( 17 );
	focusWidgets->replace( w, w->focusWidget() );
    }

    w->hide();
    if ( w->parent() != this )
	w->reparent( this, contentsRect().topLeft(), FALSE );
    w->setGeometry( contentsRect() );
    updateGeometry();
    return id;
}
Ejemplo n.º 23
0
int KST::vectorToFile(KstVectorPtr v, QFile *f) {
  KstApp *app = KstApp::inst();
#define BSIZE 128
  char buf[BSIZE];

  v->readLock();

  int vSize = v->length();
  double *value = v->value();
  register int modval;
  QString saving = i18n("Saving vector %1").arg(v->tagName());

  modval = QMAX(vSize/100, 100);

  QString ltxt = "; " + v->tagName() + '\n';
  f->writeBlock(ltxt.ascii(), ltxt.length());
  ltxt.fill('-');
  ltxt[0] = ';';
  ltxt[1] = ' ';
  ltxt[ltxt.length() - 1] = '\n';
  f->writeBlock(ltxt.ascii(), ltxt.length());

  app->slotUpdateProgress(vSize, 0, QString::null);

  for (int i = 0; i < vSize; i++) {
    int l = snprintf(buf, BSIZE, "%.15g\n", value[i]);
    f->writeBlock(buf, l);
    if (i % modval == 0) {
      app->slotUpdateProgress(vSize, i, saving);
    }
  }

  v->readUnlock();

  app->slotUpdateProgress(0, 0, QString::null);

#undef BSIZE
  return 0;
}
Ejemplo n.º 24
0
void QLineEdit::cursorLeft( bool mark, int steps )
{
    if ( steps < 0 ) {
	cursorRight( mark, -steps );
	return;
    }
    if ( cursorPos > 0 || (!mark && hasMarkedText()) ) {
	cursorPos -= steps;
	if ( cursorPos < 0 )
	    cursorPos = 0;
	cursorOn = FALSE;
	blinkSlot();
	int minP = QMIN( minMark(), cursorPos );
	int maxP = QMAX( maxMark(), cursorPos );
	if ( mark )
	    newMark( cursorPos );
	else
	    markAnchor = markDrag = cursorPos;
	d->pmDirty = TRUE;
	repaintArea( minP, maxP );
    }
}
Ejemplo n.º 25
0
QSize
MenuItem::minimumSizeHint() const
{
	// Make the cell at least as high the pixmap or two lines of text one 
	// is being the smaller description + the 2 pixel offsets at top and bottom
	int pixmapHeight = pixmap()->height() + 2 * m_secOffset;

	// title itself
	int textHeight = QApplication::fontMetrics().height();

	// prepare description font
	QFont f = QApplication::font();
	f.setPointSize( f.pointSize() - m_descFontOffset ); // maybe this can be handled better ?
	textHeight += QFontMetrics( f ).height() * m_descLines;
	// Now use whichever is bigger, because we want it to fit always
	int height = QMAX( pixmapHeight, textHeight );
	// Add offsets
	height += 2 * m_offset;

	kdDebug() << k_funcinfo << "FIXME: really calculate min width" << endl;
	return QSize( 150, height );
}
Ejemplo n.º 26
0
void ListViewEditor::setupItems()
{
    itemColumn->setMinValue( 0 );
    itemColumn->setMaxValue( QMAX( numColumns - 1, 0 ) );
    int i = 0;
    QHeader *header = itemsPreview->header();
    for ( QListBoxItem *item = colPreview->firstItem(); item; item = item->next() ) {
	Column *col = findColumn( item );
	if ( !col )
	    continue;
	if ( i >= itemsPreview->columns() )
	    itemsPreview->addColumn( col->text );
	header->setLabel( i, col->pixmap, col->text );
	header->setResizeEnabled( col->resizable, i );
	header->setClickEnabled( col->clickable, i );
	++i;
    }
    while ( itemsPreview->columns() > i )
	itemsPreview->removeColumn( i );

    itemColumn->setValue( QMIN( numColumns - 1, itemColumn->value() ) );
}
Ejemplo n.º 27
0
static int findMatchingPart(const QCString &path,const QCString dir)
{
  int si1;
  int pos1=0,pos2=0;
  while ((si1=path.find('/',pos1))!=-1)
  {
    int si2=dir.find('/',pos2);
    //printf("  found slash at pos %d in path %d: %s<->%s\n",si1,si2,
    //    path.mid(pos1,si1-pos2).data(),dir.mid(pos2).data());
    if (si2==-1 && path.mid(pos1,si1-pos2)==dir.mid(pos2)) // match at end
    {
      return dir.length();
    }
    if (si1!=si2 || path.mid(pos1,si1-pos2)!=dir.mid(pos2,si2-pos2)) // no match in middle
    {
      return QMAX(pos1-1,0);
    }
    pos1=si1+1;
    pos2=si2+1;
  }
  return 0;
}
Ejemplo n.º 28
0
// For the Paperdoll
QString cSkills::getSkillTitle( P_CHAR pChar ) const
{
	QString skillTitle;
	P_PLAYER player = dynamic_cast<P_PLAYER>( pChar );

	if ( Config::instance()->showSkillTitles() && player && !player->isGM() )
	{
		unsigned short skill = 0;
		unsigned short skillValue = 0;

		for ( int i = 0; i < ALLSKILLS; ++i )
		{
			if ( pChar->skillValue( i ) > skillValue )
			{
				skill = i;
				skillValue = pChar->skillValue( i );
			}
		}

		unsigned char title = QMAX( 1, ( ( int ) pChar->skillValue( skill ) - 300 ) / 100 );

		if ( title >= skillRanks.size() )
		{
			pChar->log( LOG_ERROR, "Invalid skill rank information.\n" );
			return skillTitle;
		}

		// Skill not found
		if ( skill >= skills.size() )
		{
			pChar->log( LOG_ERROR, QString( "Skill id out of range: %u.\n" ).arg( skill ) );
			return skillTitle;
		}

		skillTitle = QString( "%1 %2" ).arg( skillRanks[title] ).arg( skills[skill].title );
	}

	return skillTitle;
}
Ejemplo n.º 29
0
void GatewayWidget::resizeEvent(QResizeEvent *) {
  box1->setGeometry(10, 10, width() - 20, height() - 20);

  // calculate the best with for the frame
  int minw = gate_label->sizeHint().width() + 6 + 
    gatewayaddr->sizeHint().width() + 40;

  int minh = 
    QMAX(gatewayaddr->sizeHint().height(),
	gate_label->sizeHint().height()) +
	fontMetrics().lineSpacing() + 20;

  // resize the frame
  int box_x = (width() - minw)/2;
  int box_y = (height() - minh)/2 - 20;
  box->setGeometry(box_x, box_y, minw, minh);

  // now move the lineedits into the frame
  gatewayaddr->resize(gatewayaddr->sizeHint());
  gatewayaddr->move(box->geometry().right() - gatewayaddr->width() - 15,
		    box_y + fontMetrics().lineSpacing()/2 + 10);

  // the labels
  gate_label->resize(gate_label->sizeHint());
  gate_label->move(box_x + 15, gatewayaddr->geometry().top());		

  // move the radiobuttons
  staticgateway->resize(staticgateway->sizeHint());
  defaultgateway->resize(defaultgateway->sizeHint());  
  staticgateway->move(box_x + 25, 
		     box_y - staticgateway->sizeHint().height()/2);
  defaultgateway->move(box_x + 25,
		      staticgateway->geometry().top() - 
		      defaultgateway->sizeHint().height() - 20);

  defaultroute->resize(defaultroute->sizeHint());
  defaultroute->move((width() - defaultroute->width())/2,
		 (box->geometry().bottom() + height())/2);
}
Ejemplo n.º 30
0
void RosterBoxItem::setup()
{
	QListViewItem::setup();
	int h = height();

	QString txt = expandTemplate( 0 ); // single column !!!
	if( txt.isEmpty() ){
		if(v_rt)
			delete v_rt;
		v_rt = 0;
		return;
	}
    
	const QListView* lv = listView();
	const QPixmap* px = pixmap(0);
	int left =  lv->itemMargin() + ((px)?(px->width() + lv->itemMargin()):0);

	v_active = lv->isActiveWindow();
	v_selected = isSelected();

	if ( v_selected  ) {
		txt = QString("<font color=\"%1\">").arg(listView()->colorGroup().color( QColorGroup::HighlightedText ).name()) + txt + "</font>";
	}
	
	if(v_rt)
		delete v_rt;
	v_rt = new QSimpleRichText(txt, lv->font());
	
	v_rt->setWidth(lv->columnWidth(0) - left - depth() * lv->treeStepSize());

	v_widthUsed = v_rt->widthUsed() + left;

	h = QMAX( h, v_rt->height() );

    if ( h % 2 > 0 )
	h++;
    setHeight( h );
}