コード例 #1
0
/*!
   Calculate the minimum length that is needed to draw the scale

   \param font Font used for painting the labels

   \sa extent()
*/
int QwtScaleDraw::minLength( const QFont &font ) const
{
    int startDist, endDist;
    getBorderDistHint( font, startDist, endDist );

    const QwtScaleDiv &sd = scaleDiv();

    const uint minorCount =
        sd.ticks( QwtScaleDiv::MinorTick ).count() +
        sd.ticks( QwtScaleDiv::MediumTick ).count();
    const uint majorCount =
        sd.ticks( QwtScaleDiv::MajorTick ).count();

    int lengthForLabels = 0;
    if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
    {
        if ( majorCount >= 2 )
            lengthForLabels = minLabelDist( font ) * ( majorCount - 1 );
    }

    int lengthForTicks = 0;
    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
    {
        const double pw = qMax( 1, penWidth() );  // penwidth can be zero
        lengthForTicks = qCeil( ( majorCount + minorCount ) * ( pw + 1.0 ) );
    }

    return startDist + endDist + qMax( lengthForLabels, lengthForTicks );
}
コード例 #2
0
ファイル: qwt_thermo.cpp プロジェクト: 151706061/sofa
/*!
  \return Minimum size hint
  \warning The return value depends on the font and the scale.
  \sa sizeHint()
*/
QSize QwtThermo::minimumSizeHint() const
{
    int w = 0, h = 0;

    if ( d_data->scalePosition != NoScale )
    {
        const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
        const int sdLength = scaleDraw()->minLength( font() );

        w = sdLength;
        h = d_data->pipeWidth + sdExtent + d_data->spacing;

    }
    else // no scale
    {
        w = 200;
        h = d_data->pipeWidth;
    }

    if ( d_data->orientation == Qt::Vertical )
        qSwap( w, h );

    w += 2 * d_data->borderWidth;
    h += 2 * d_data->borderWidth;

    // finally add the margins
    int left, right, top, bottom;
    getContentsMargins( &left, &top, &right, &bottom );
    w += left + right;
    h += top + bottom;

    return QSize( w, h );
}
コード例 #3
0
qreal SoftSlider::tickSpan(qreal min, qreal max, qreal space, qreal minsep)
{
    if (space == 0)
        return qInf();

    qreal jmp = minsep * (max - min) / space;

    qreal b = 1;

    while (b * 10 <= jmp)
        b *= 10;

    if (jmp > 0)
        while (b / 10 >= jmp)
            b /= 10;

    int q = qCeil(jmp / b);

    if (q > 5)
        return b * 10;

    if (q > 2)
        return b * 5;

    if (q > 1)
        return b * 2;

    return b;
}
コード例 #4
0
void QSGTextNode::addTextDecorations(Decoration decorations, const QPointF &position,
                                     const QColor &color, qreal width, qreal lineThickness,
                                     qreal underlinePos, qreal ascent)
{
    QRectF line(position.x(), position.y() - lineThickness / 2.0, width, lineThickness);

    if (decorations & Underline) {
        int underlinePosition = qCeil(underlinePos);
        QRectF underline(line);
        underline.translate(0.0, underlinePosition);
        appendChildNode(new QSGSimpleRectNode(underline, color));
    }

    if (decorations & Overline) {
        QRectF overline(line);
        overline.translate(0.0, -ascent);
        appendChildNode(new QSGSimpleRectNode(overline, color));
    }

    if (decorations & StrikeOut) {
        QRectF strikeOut(line);
        strikeOut.translate(0.0, ascent / -3.0);
        appendChildNode(new QSGSimpleRectNode(strikeOut, color));
    }
}
コード例 #5
0
ファイル: qdeclarativerectangle.cpp プロジェクト: maxxant/qt
void QDeclarativeRectangle::generateRoundedRect()
{
    Q_D(QDeclarativeRectangle);
    if (d->rectImage.isNull()) {
        const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
        const int radius = qCeil(d->radius);    //ensure odd numbered width/height so we get 1-pixel center

        QString key = QLatin1String("q_") % QString::number(pw) % d->color.name() % QString::number(d->color.alpha(), 16) % QLatin1Char('_') % QString::number(radius);
        if (d->pen && d->pen->isValid())
            key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16);

        if (!QPixmapCache::find(key, &d->rectImage)) {
            d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
            d->rectImage.fill(Qt::transparent);
            QPainter p(&(d->rectImage));
            p.setRenderHint(QPainter::Antialiasing);
            if (d->pen && d->pen->isValid()) {
                QPen pn(QColor(d->pen->color()), d->pen->width());
                p.setPen(pn);
            } else {
                p.setPen(Qt::NoPen);
            }
            p.setBrush(d->color);
            if (pw%2)
                p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
            else
                p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);

            // end painting before inserting pixmap
            // to pixmap cache to avoid a deep copy
            p.end();
            QPixmapCache::insert(key, d->rectImage);
        }
    }
}
コード例 #6
0
// Set waveform sample rate.
void SpikePlot_CV::setSampleRate(double newSampleRate)
{
    // Calculate time step, in msec.
    tStepMsec = 1000.0 / newSampleRate;

    // Calculate number of time steps in 3 msec sample.
    totalTSteps = qCeil(3.0 / tStepMsec) + 1;

    // Calculate number of time steps in the 1 msec pre-trigger
    // display interval.
    preTriggerTSteps = qCeil(1.0 / tStepMsec);

    // Clear old waveforms since the sample rate has changed.
    numSpikeWaveforms = 0;
    startingNewChannel = true;
}
コード例 #7
0
/*virtual*/
int ListItemContainer::maxItemCountInItemBuffer() const
{
    int count = AbstractItemContainer::maxItemCountInItemBuffer();

    if (count > 0) {
        int currentItemCount = m_items.count();
        qreal heightOfOneItem = 0;
        if (currentItemCount > 0)
        {
            heightOfOneItem = m_layout->effectiveSizeHint(Qt::PreferredSize).height() / currentItemCount;
        }
        int guess = 0;
        if( heightOfOneItem <= 0 ) {
            if (m_prototype) {
                heightOfOneItem = m_prototype->effectiveSizeHint(Qt::PreferredSize).height();
            }
            else
                heightOfOneItem = 50; // TODO magic number, do we have better guess if prototype is not set?
        }
        if (heightOfOneItem > 0) {
            guess = qCeil(m_itemView->boundingRect().height() / heightOfOneItem) + m_bufferSize;

            if (guess < currentItemCount) {
                if( guess > currentItemCount-2) { // TODO magic number here, Can we use buffer size?
                    guess = currentItemCount;
                }
            }
        }
        count = qMin(guess, count);
    }
    return count;
}
コード例 #8
0
void Downloader::getTags()
{
	if (m_sites->empty())
	{
		std::cerr << "No valid source found" << std::endl;
		return;
	}

	m_waiting = 0;
	m_cancelled = false;

	for (int i = 0; i < m_sites->size(); ++i)
	{
		int pages = qCeil((float)m_max / m_perpage);
		if (pages <= 0 || m_perpage <= 0 || m_max <= 0)
			pages = 1;
		Site *site = m_sites->at(i);
		connect(site, &Site::finishedLoadingTags, this, &Downloader::finishedLoadingTags);
		for (int p = 0; p < pages; ++p)
		{
			m_pagesP->append(QPair<Site*, int>(site, m_page + p));
			m_opagesP->append(QPair<Site*, int>(site, m_page + p));
			m_waiting++;
		}
	}

	loadNext();
}
コード例 #9
0
void Downloader::getUrls()
{
	if (m_sites->empty())
	{
		std::cerr << "No valid source found" << std::endl;
		return;
	}

	m_waiting = 0;
	m_ignored = 0;
	m_duplicates = 0;
	m_cancelled = false;
	auto sites = Site::getAllSites();

	for (int i = 0; i < m_sites->size(); ++i)
	{
		int pages = qCeil((float)m_max / m_perpage);
		if (pages <= 0 || m_perpage <= 0 || m_max <= 0)
			pages = 1;
		for (int p = 0; p < pages; ++p)
		{
			Page *page = new Page(m_sites->at(i), sites, m_tags, m_page + p, m_perpage, m_postfiltering, true, this);
			connect(page, &Page::finishedLoading, this, &Downloader::finishedLoadingUrls);

			m_pages->append(page);
			m_opages->append(page);
			m_waiting++;
		}
	}

	loadNext();
}
コード例 #10
0
ファイル: qgsalignraster.cpp プロジェクト: giserfly/QGIS
static double ceil_with_tolerance( double value )
{
  if ( qAbs( value - qRound( value ) ) < 1e-6 )
    return qRound( value );
  else
    return qCeil( value );
}
コード例 #11
0
void SingleCellViewGraphPanelPlotWidget::optimiseAxis(const int &pAxisId,
                                                      double &pMin,
                                                      double &pMax) const
{
    // Make sure that the given values are different

    if (pMin == pMax) {
        // The given values are the same, so update them so that we can properly
        // optimise them below

        double powerValue = pMin?qFloor(log10(qAbs(pMin)))-1.0:0.0;

        pMin = pMin-pow(10.0, powerValue);
        pMax = pMax+pow(10.0, powerValue);
    }

    // Optimise the axis' values so that they fall onto a factor of the axis'
    // minor step

    uint base = axisScaleEngine(pAxisId)->base();
    double majorStep = QwtScaleArithmetic::divideInterval(pMax-pMin,
                                                          axisMaxMajor(pAxisId),
                                                          base);
    double minorStep = QwtScaleArithmetic::divideInterval(majorStep,
                                                          axisMaxMinor(pAxisId),
                                                          base);

    pMin = qFloor(pMin/minorStep)*minorStep;
    pMax = qCeil(pMax/minorStep)*minorStep;
}
コード例 #12
0
//--------------------------------------------------------------------------------------------------
//	FUNCTION: paint
//--------------------------------------------------------------------------------------------------
void QProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;
	if (std::isnan(progress) || progress <= 0.0 || progress >= 100.0)
	{
		QStyledItemDelegate::paint(painter, option, index);
	}
	else
	{
		const QFontMetrics &fm = option.fontMetrics;
		auto height = qMin(qCeil(QFontMetricsF(fm).height()) + 2, option.rect.height());
		int adjust = (option.rect.height() - height) / 2;

		double progress = index.data(QExecutableModel::ProgressRole).toDouble() * 100;

		QStyleOptionProgressBar progressBarOption;
		progressBarOption.rect = option.rect.adjusted(2, adjust, -2, -adjust);
		progressBarOption.rect.setWidth(option.rect.width() - 2 * 2);
		progressBarOption.minimum = 0;
		progressBarOption.maximum = 100;
		progressBarOption.progress = progress;

		if (option.state & QStyle::State_Selected)
		{
			painter->setBrush(option.palette.highlightedText());
		}

		QApplication::style()->drawControl(QStyle::CE_ProgressBar,
			&progressBarOption, painter);
	}
}
コード例 #13
0
void LanczosShader::createKernel(float delta, int *size)
{
    const float a = 2.0;

    // The two outermost samples always fall at points where the lanczos
    // function returns 0, so we'll skip them.
    const int sampleCount = qBound(3, qCeil(delta * a) * 2 + 1 - 2, 29);
    const int center = sampleCount / 2;
    const int kernelSize = center + 1;
    const float factor = 1.0 / delta;

    QVector<float> values(kernelSize);
    float sum = 0;

    for (int i = 0; i < kernelSize; i++) {
        const float val = lanczos(i * factor, a);
        sum += i > 0 ? val * 2 : val;
        values[i] = val;
    }

    memset(m_kernel, 0, 16 * sizeof(QVector4D));

    // Normalize the kernel
    for (int i = 0; i < kernelSize; i++) {
        const float val = values[i] / sum;
        m_kernel[i] = QVector4D(val, val, val, val);
    }

    *size = kernelSize;
}
コード例 #14
0
ファイル: qwt_thermo.cpp プロジェクト: PrincetonPAVE/old_igvc
/*!
  \brief Return a minimum size hint
  \warning The return value depends on the font and the scale.
  \sa sizeHint()
*/
QSize QwtThermo::minimumSizeHint() const
{
    int w = 0, h = 0;

    if ( d_data->scalePos != NoScale )
    {
        const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
        const int sdLength = scaleDraw()->minLength( font() );

        w = sdLength;
        h = d_data->thermoWidth + sdExtent +
            d_data->borderWidth + d_data->scaleDist;

    }
    else // no scale
    {
        w = 200;
        h = d_data->thermoWidth;
    }

    if ( d_data->orientation == Qt::Vertical )
        qSwap( w, h );

    w += 2 * d_data->borderWidth;
    h += 2 * d_data->borderWidth;

    return QSize( w, h );
}
コード例 #15
0
void TextDocument::drawBackground(QPainter* painter, const QRect& bounds)
{
    if (d.highlights.isEmpty() && d.lowlight == -1)
        return;

    const int margin = qCeil(documentMargin());
    const QAbstractTextDocumentLayout* layout = documentLayout();

    static QPointer<TextLowlight> lowlightFrame = 0;
    if (!lowlightFrame)
        lowlightFrame = new TextLowlight(static_cast<QWidget*>(painter->device()));

    static QPointer<TextHighlight> highlightFrame = 0;
    if (!highlightFrame)
        highlightFrame = new TextHighlight(static_cast<QWidget*>(painter->device()));

    if (d.lowlight != -1) {
        const QAbstractTextDocumentLayout* layout = documentLayout();
        const int margin = qCeil(documentMargin());
        const QTextBlock to = findBlockByNumber(d.lowlight);
        if (to.isValid()) {
            QRect br = layout->blockBoundingRect(to).toAlignedRect();
            br.setTop(0);
            if (bounds.intersects(br)) {
                br.adjust(-margin - 1, 0, margin + 1, 2);
                painter->translate(br.topLeft());
                lowlightFrame->setGeometry(br);
                lowlightFrame->render(painter);
                painter->translate(-br.topLeft());
            }
        }
    }

    foreach (int highlight, d.highlights) {
        QTextBlock block = findBlockByNumber(highlight);
        if (block.isValid()) {
            QRect br = layout->blockBoundingRect(block).toAlignedRect();
            if (bounds.intersects(br)) {
                br.adjust(-margin - 1, 0, margin + 1, 2);
                painter->translate(br.topLeft());
                highlightFrame->setGeometry(br);
                highlightFrame->render(painter);
                painter->translate(-br.topLeft());
            }
        }
    }
}
コード例 #16
0
ファイル: imagepicker.cpp プロジェクト: sonic414/lmc-clone
lmcImagePicker::lmcImagePicker(
        QWidget *parent,
        QList<QString>* source,
        int picSize,
        int columns,
        int* selected,
        int actionIndex )
    : QTableWidget(parent)
{
	setMouseTracking(true);

	setBackgroundRole(QPalette::Window);
	setIconSize(QSize(picSize, picSize));
	setFrameShape(QFrame::NoFrame);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setEditTriggers(QAbstractItemView::NoEditTriggers);
	setSelectionMode(QAbstractItemView::NoSelection);
	setShowGrid(false);
	horizontalHeader()->setVisible(false);
	verticalHeader()->setVisible(false);
	setStyleSheet("QTableWidget { padding: 4px }");	// padding around table

	max_col = columns;
	int max_row = qCeil(source->count() / (qreal)max_col);

	setColumnCount(max_col);
	setRowCount(max_row);

	int cellSize = picSize + 8;
	verticalHeader()->setDefaultSectionSize(cellSize);
	verticalHeader()->setMinimumSectionSize(cellSize);
	horizontalHeader()->setDefaultSectionSize(cellSize);
	horizontalHeader()->setMinimumSectionSize(cellSize);

	//	set min and max size of table, with padding included
	setMinimumSize(max_col * cellSize + 8, max_row * cellSize + 8);
	setMaximumSize(max_col * cellSize + 8, max_row * cellSize + 8);

	for(int i = 0; i < max_row; i++) {
		for(int j = 0; j < max_col; j++) {
			int k = (i * max_col) + j;

			QTableWidgetItem* item = new QTableWidgetItem();
			item->setData(TypeRole, 0);
			if(k < source->count()) {
				item->setIcon(QIcon(source->value(k)));
				item->setData(TypeRole, 1);
				item->setSizeHint(QSize(picSize, picSize));
				item->setBackground(this->palette().window());
			}
			setItem(i, j, item);
		}
	}

	this->actionIndex = actionIndex;
	this->selected = selected;
	this->hoverItem = NULL;
}
コード例 #17
0
/*!
  \brief Return a minimum size hint
  \warning The return value of QwtKnob::minimumSizeHint() depends on the
           font and the scale.
*/
QSize QwtKnob::minimumSizeHint() const
{
    // Add the scale radial thickness to the knobWidth
    const int sh = qCeil( scaleDraw()->extent( font() ) );
    const int d = 2 * sh + 2 * d_data->scaleDist + d_data->knobWidth;

    return QSize( d, d );
}
コード例 #18
0
void QDeclarativeFlow::doPositioning(QSizeF *contentSize)
{
    Q_D(QDeclarativeFlow);

    int hoffset = 0;
    int voffset = 0;
    int linemax = 0;

    for (int i = 0; i < positionedItems.count(); ++i) {
        const PositionedItem &child = positionedItems.at(i);
        if (!child.item || isInvisible(child.item))
            continue;

        if (d->flow == LeftToRight)  {
            if (hoffset && hoffset + child.item->width() > width()) {
                hoffset = 0;
                voffset += linemax + spacing();
                linemax = 0;
            }
        } else {
            if (voffset && voffset + child.item->height() > height()) {
                voffset = 0;
                hoffset += linemax + spacing();
                linemax = 0;
            }
        }

        if(child.item->x() != hoffset || child.item->y() != voffset){
            positionX(hoffset, child);
            positionY(voffset, child);
        }

        contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width()));
        contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height()));

        if (d->flow == LeftToRight)  {
            hoffset += child.item->width();
            hoffset += spacing();
            linemax = qMax(linemax, qCeil(child.item->height()));
        } else {
            voffset += child.item->height();
            voffset += spacing();
            linemax = qMax(linemax, qCeil(child.item->width()));
        }
    }
}
コード例 #19
0
ファイル: sourceeditor.cpp プロジェクト: olegwtf/wside
void SourceEditor::linesCountChanged()
{
    int marginWidth = qCeil( qLn( lines() ) / qLn(10) + 0.000001 );

    if (marginWidth != m_marginWidth) {
        m_marginWidth = marginWidth;
        setMarginWidth(NumberMargin, QString(marginWidth, '3') + ' ');
    }
}
コード例 #20
0
ファイル: qsvgstyle.cpp プロジェクト: wpbest/copperspice
void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
{
    qreal totalTimeElapsed = node->document()->currentElapsed();
    if (totalTimeElapsed < m_from || m_finished)
        return;

    qreal animationFrame = 0;
    if (m_totalRunningTime != 0)
        animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;

    if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
        m_finished = true;
        animationFrame = m_repeatCount;
    }

    qreal percentOfAnimation = animationFrame;
    if (percentOfAnimation > 1) {
        percentOfAnimation -= ((int)percentOfAnimation);
    }

    qreal currentPosition = percentOfAnimation * (m_colors.count() - 1);

    int startElem = qFloor(currentPosition);
    int endElem   = qCeil(currentPosition);
    QColor start = m_colors[startElem];
    QColor end = m_colors[endElem];

    qreal percentOfColorMorph = currentPosition;
    if (percentOfColorMorph > 1) {
        percentOfColorMorph -= ((int)percentOfColorMorph);
    }

    // Interpolate between the two fixed colors start and end
    qreal aDiff = (end.alpha() - start.alpha()) * percentOfColorMorph;
    qreal rDiff = (end.red()   - start.red()) * percentOfColorMorph;
    qreal gDiff = (end.green() - start.green()) * percentOfColorMorph;
    qreal bDiff = (end.blue()  - start.blue()) * percentOfColorMorph;

    int alpha  = int(start.alpha() + aDiff);
    int red    = int(start.red() + rDiff);
    int green  = int(start.green() + gDiff);
    int blue   = int(start.blue() + bDiff);

    QColor color(red, green, blue, alpha);

    if (m_fill) {
        QBrush b = p->brush();
        m_oldBrush = b;
        b.setColor(color);
        p->setBrush(b);
    } else {
        QPen pen = p->pen();
        m_oldPen = pen;
        pen.setColor(color);
        p->setPen(pen);
    }
}
コード例 #21
0
static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect)
{
    const double pw = pixelRect.width();
    const double ph = pixelRect.height();

    const double dx1 = pixelRect.left() - rect.left();
    const double dx2 = pixelRect.right() - rect.right();
    const double dy1 = pixelRect.top() - rect.top();
    const double dy2 = pixelRect.bottom() - rect.bottom();

    QRectF r;
    r.setLeft( pixelRect.left() - qCeil( dx1 / pw ) * pw );
    r.setTop( pixelRect.top() - qCeil( dy1 / ph ) * ph );
    r.setRight( pixelRect.right() - qFloor( dx2 / pw ) * pw );
    r.setBottom( pixelRect.bottom() - qFloor( dy2 / ph ) * ph );

    return r;
}
コード例 #22
0
ファイル: utility.cpp プロジェクト: zjucsxxd/Cstitch
int averageCharacterWidth(const QFont& font) {

  const QFontMetrics metrics(font);
  int totalWidth = 0;
  for (int i = 32; i < 128; ++i) {
    totalWidth += metrics.width(QChar(i));
  }
  return qCeil(totalWidth/97.);
}
コード例 #23
0
/*!
    Marks areas of the cache that intersect with the given \a rect as dirty and
    in need of being refreshed.

    \sa clearCache()
*/
void QDeclarativePaintedItem::dirtyCache(const QRect& rect)
{
    Q_D(QDeclarativePaintedItem);
    QRect srect(qCeil(rect.x()*d->contentsScale),
            qCeil(rect.y()*d->contentsScale),
            qCeil(rect.width()*d->contentsScale),
            qCeil(rect.height()*d->contentsScale));
    for (int i=0; i < d->imagecache.count(); ) {
        QDeclarativePaintedItemPrivate::ImageCacheItem *c = d->imagecache[i];
        QRect isect = (c->area & srect) | c->dirty;
        if (isect == c->area && !inpaint) {
            delete d->imagecache.takeAt(i);
        } else {
            c->dirty = isect;
            ++i;
        }
    }
}
コード例 #24
0
ファイル: Keyboard.cpp プロジェクト: cescobaz/01Converter
Keyboard::Keyboard(int base, int columns, QWidget *parent)
{
    QGridLayout *gridLayout = new QGridLayout;
    gridLayout->setSpacing(0);
    gridLayout->setMargin(0);
    gridLayout->setContentsMargins(0,0,0,0);
    this->setLayout(gridLayout);

    int elementsCount = base + 1;
    while (elementsCount % columns != 0)
        elementsCount++;
    int rows = qCeil(qreal(elementsCount) / qreal(columns));
    int column = 0, row = 0;
    for (int v = 0; v < elementsCount; ++v) {
        char c;
        if (v < 9) {
            c = '0' + v;
        }
        else {
            c = 'A' + v - 10;
        }
        if (base != 2) {
            c++; // do not start with '0'
        }

        QString value;
        if ((base == 2 && v + 1 > base) || (base != 2 && v + 1 >= base)) {
            if (column + 1 == columns) {
                value = QString("delete");
            }
            else if (((column + 1) / 2) == columns / 2) {
                value = "0";
            }
            else {
                value = "";
            }
        }
        else {
            value = QString(c);
        }

        QPushButton *button = new QPushButton(value);
        button->setObjectName(value);
        if (value == "") {
            button->setEnabled(false);
        }
        connect(button, SIGNAL(pressed()), this, SLOT(pressedButton()));
        gridLayout->addWidget(button,row,column);

        column = (column + 1) % columns;
        if (column == 0) {
            row = (row + 1);
        }
    }

}
コード例 #25
0
ファイル: qwt_dial.cpp プロジェクト: ClaFio/GoldenCheetah
/*!
  \brief Return a minimum size hint
  \warning The return value of QwtDial::minimumSizeHint() depends on the
           font and the scale.
*/
QSize QwtDial::minimumSizeHint() const
{
    int sh = 0;
    if ( d_data->scaleDraw )
        sh = qCeil( d_data->scaleDraw->extent( font() ) );

    const int d = 3 * sh + 2 * lineWidth();

    return QSize( d, d );
}
コード例 #26
0
ファイル: Canvas.cpp プロジェクト: johntyree/HsQML
QSGTexture* HsQMLCanvasBackEnd::updateFBO(qreal w, qreal h)
{
    if (HsQMLCanvas::Inline == mDisplayMode) {
        if (!mFBO || w != mCanvasWidth || h != mCanvasHeight) {
            mCanvasWidth = w;
            mCanvasHeight = h;
            QSize dims(qCeil(mCanvasWidth), qCeil(mCanvasHeight));
            mFBO.reset(new QOpenGLFramebufferObject(
                dims, QOpenGLFramebufferObject::Depth));
            mTexture.reset(mWindow->createTextureFromId(
                mFBO->texture(), dims, QQuickWindow::TextureHasAlphaChannel));
        }
    }
    else {
        mTexture.reset();
        mFBO.reset();
    }
    return mTexture.data();
}
コード例 #27
0
void dtkComposerNodeNumberOperatorUnaryCeil::run(void)
{
    if (d->receiver.dataType() == QMetaType::Double) {
        d->value_i = qCeil(*(d->receiver.data<double>()));
        d->emitter.setData<qlonglong>(&d->value_i);

    } else {
        d->emitter.setData<qlonglong>(d->receiver.data<qlonglong>());
    }
}
コード例 #28
0
ファイル: plotaxes.cpp プロジェクト: Sylla/updraft
void PlotAxes::setLimits(qreal min, qreal max, qreal minTime, qreal maxTime) {
  this->min = min;
  this->max = max;
  this->minTime = minTime;
  this->maxTime = maxTime;
  this->firstHour = qCeil(minTime / 3600);
  this->lastHour = qFloor(maxTime / 3600);

  setGeometry(rect);
}
コード例 #29
0
ファイル: owncloudpropagator.cpp プロジェクト: msphn/client
int OwncloudPropagator::maximumActiveTransferJob()
{
    if (_downloadLimit.fetchAndAddAcquire(0) != 0
        || _uploadLimit.fetchAndAddAcquire(0) != 0
        || !_syncOptions._parallelNetworkJobs) {
        // disable parallelism when there is a network limit.
        return 1;
    }
    return qMin(3, qCeil(hardMaximumActiveJob() / 2.));
}
コード例 #30
0
/*!
   \brief Calculate a scale division for a date/time interval

   \param x1 First interval limit
   \param x2 Second interval limit
   \param maxMajorSteps Maximum for the number of major steps
   \param maxMinorSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.
   \return Calculated scale division
*/
QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
{
    if ( maxMajorSteps < 1 )
        maxMajorSteps = 1;

    const double min = qMin( x1, x2 );
    const double max = qMax( x1, x2 );

    const QDateTime from = toDateTime( min );
    const QDateTime to = toDateTime( max );

    if ( from == to )
        return QwtScaleDiv();

    stepSize = qAbs( stepSize );
    if ( stepSize > 0.0 )
    {
        // as interval types above hours are not equidistant
        // ( even days might have 23/25 hours because of daylight saving )
        // the stepSize is used as a hint only

        maxMajorSteps = qCeil( ( max - min ) / stepSize );
    }

    const QwtDate::IntervalType intvType = 
        intervalType( from, to, maxMajorSteps );

    QwtScaleDiv scaleDiv;

    if ( intvType == QwtDate::Millisecond )
    {
        // for milliseconds and below we can use the decimal system
        scaleDiv = QwtLinearScaleEngine::divideScale( min, max,
            maxMajorSteps, maxMinorSteps, stepSize );
    }
    else
    {
        const QDateTime minDate = QwtDate::floor( from, intvType );
        const QDateTime maxDate = QwtDate::ceil( to, intvType );

        scaleDiv = buildScaleDiv( minDate, maxDate, 
            maxMajorSteps, maxMinorSteps, intvType );

        // scaleDiv has been calculated from an extended interval
        // adjusted to the step size. We have to shrink it again.

        scaleDiv = scaleDiv.bounded( min, max );
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}