void JulySpinBoxFix::widthFix(QString text)
{
	if(pMinimumWidth==0)
		parentSpinBox->setMinimumWidth(textFontWidth(text)+spinMargin);
	else 
		parentSpinBox->setMinimumWidth(qMax(textFontWidth(text)+spinMargin,pMinimumWidth));
}
Esempio n. 2
0
void DepthModel::fixTitleWidths()
{
    int curASize = textFontWidth(" " + baseValues.currentPair.currASign);
    int curBSize = textFontWidth(" " + baseValues.currentPair.currBSign);
    widthPriceTitle = textFontWidth(headerLabels.at(0)) + 20 + curBSize;
    widthVolumeTitle = textFontWidth(headerLabels.at(1)) + 20 + curASize;
    widthSizeTitle = textFontWidth(headerLabels.at(3)) + 20 + curASize;
}
void RulesModel::setHorizontalHeaderLabels(QStringList list)
{
	if(list.count()!=columnsCount)return;
	headerLabels=list;
	stateWidth=qMax(textFontWidth(headerLabels.first()),textFontWidth(julyTr("RULE_STATE_PROCESSING","processing")));
	stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_PENDING","pending")));
	stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_DONE","done")));
	stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_DISABLED","disabled")));
	stateWidth+=12;
	emit headerDataChanged(Qt::Horizontal, 0, columnsCount-1);
}
void TradesModel::setHorizontalHeaderLabels(QStringList list)
{
	if(list.count()!=columnsCount)return;

	textAsk=julyTr("ORDER_TYPE_ASK","ask");
	textBid=julyTr("ORDER_TYPE_BID","bid");
    dateWidth=qMax(qMax(textFontWidth(QDateTime(QDate(2000,12,30),QTime(23,59,59,999)).toString(baseValues.dateTimeFormat)),textFontWidth(QDateTime(QDate(2000,12,30),QTime(12,59,59,999)).toString(baseValues.dateTimeFormat))),textFontWidth(list.at(0)))+10;
	typeWidth=qMax(qMax(textFontWidth(textAsk),textFontWidth(textBid)),textFontWidth(list.at(2)))+10;

	headerLabels=list;
	emit headerDataChanged(Qt::Horizontal, 0, columnsCount-1);
	emit layoutChanged();
}
Esempio n. 5
0
void DepthModel::calculateSize()
{
    if (!somethingChanged)
        return;

    somethingChanged = true;

    double maxPrice = 0.0;
    double maxVolume = 0.0;
    double maxTotal = 0.0;

    double totalSize = 0.0;
    double totalPrice = 0.0;

    if (originalIsAsk)
    {
        for (int n = 0; n < priceList.count(); n++)
        {
            int currentRow = n;

            if (!originalIsAsk)
                currentRow = priceList.count() - currentRow - 1;

            totalSize += volumeList.at(currentRow);
            totalPrice += volumeList.at(currentRow) * priceList.at(currentRow);

            sizeListAt(currentRow) = totalSize;
            sizePriceList[currentRow] = totalPrice;
            sizeListStr[currentRow] = JulyMath::textFromDouble(totalSize, qMin(baseValues.currentPair.currADecimals,
                                      baseValues.decimalsTotalOrderBook));

            maxPrice = qMax(maxPrice, priceList.at(currentRow));
            maxVolume = qMax(maxVolume, volumeList.at(currentRow));
            maxTotal = qMax(maxTotal, sizeListAt(currentRow));
        }
    }
    else
    {
        for (int n = priceList.count() - 1; n >= 0; n--)
        {
            int currentRow = n;

            if (originalIsAsk)
                currentRow = priceList.count() - currentRow - 1;

            totalSize += volumeList.at(currentRow);
            totalPrice += volumeList.at(currentRow) * priceList.at(currentRow);
            sizeListAt(currentRow) = totalSize;
            sizePriceList[currentRow] = totalPrice;
            sizeListStr[currentRow] = JulyMath::textFromDouble(totalSize, qMin(baseValues.currentPair.currADecimals,
                                      baseValues.decimalsTotalOrderBook));

            maxPrice = qMax(maxPrice, priceList.at(currentRow));
            maxVolume = qMax(maxVolume, volumeList.at(currentRow));
            maxTotal = qMax(maxTotal, sizeListAt(currentRow));
        }
    }

    widthPrice = 10 + textFontWidth(JulyMath::textFromDouble(maxPrice, baseValues.currentPair.priceDecimals));
    widthVolume = 10 + textFontWidth(JulyMath::textFromDouble(maxVolume, baseValues.currentPair.currADecimals));
    widthSize = 10 + textFontWidth(JulyMath::textFromDouble(maxTotal, baseValues.currentPair.currADecimals));

    widthPrice = qMax(widthPrice, widthPriceTitle);
    widthVolume = qMax(widthVolume, widthVolumeTitle);
    widthSize = qMax(widthSize, widthSizeTitle);

    int sizeColumn = 2;

    if (isAsk)
        sizeColumn = 1;

    emit dataChanged(index(0, sizeColumn), index(priceList.count() - 1, sizeColumn));
}