Example #1
0
void Thermometer::paintEvent(QPaintEvent *)
{
    painter.begin(this);

    drawTitle();
    drawUnit();
    drawLabel();
    drawDisplay();
    drawScale();
    drawMeter();
    drawRange();
    drawPointer();

    painter.end();
}
Example #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void USplata_zaborg_Delegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    if ( index.column() == durationColumn_2 ){
        double number = index.model()->data(index, Qt::DisplayRole).toDouble();
        QString text = uMToStr2(number);
        QStyleOptionViewItem myOption = option;
        myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
        drawDisplay(painter, myOption, myOption.rect, text);
        drawFocus(painter, myOption, myOption.rect);
    } else{
        QItemDelegate::paint(painter, option, index);
    }
}
void MonetaryDelegate_contabilidad::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QString texto = index.model()->data(index, Qt::DisplayRole).toString();
     texto = Configuracion_global->toFormatoMoneda(texto);
     if(texto =="0,00")
         texto = "";
     QStyleOptionViewItem myOption = option;
     myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
     if(texto.left(1)=="-")
        myOption.palette.setColor(QPalette::Text, Qt::red);
     else
        myOption.palette.setColor(QPalette::Text, Qt::blue);
     drawDisplay(painter, myOption, myOption.rect,texto);
     drawFocus(painter, myOption, myOption.rect);

}
Example #4
0
void ColNumDelegato::paint(QPainter *painter,
                 const QStyleOptionViewItem & option,
                 const QModelIndex & index) const
{

    double numero = index.model()->data(index, Qt::DisplayRole).toDouble();

    QString text = QString("%L1").arg(numero,13,'f',2);

    QStyleOptionViewItem myOption = option;
    myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;

    drawDisplay(painter, myOption, myOption.rect, text);
    drawFocus(painter, myOption, myOption.rect);

}
void TwitterAccountsDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
  if ( checkBoxColumns.contains( index.column() ) ) {
    Qt::CheckState state;
    if ( index.model()->data( index, Qt::DisplayRole ).toBool() )
      state = Qt::Checked;
    else
      state = Qt::Unchecked;

    drawDisplay( painter, option, option.rect, " " );
    drawFocus( painter, option, option.rect );
    drawCheck( painter, option, QRect( option.rect.x()+15, option.rect.y()+3 , option.rect.height()-5, option.rect.height()-5 ), state );
  } else {
    QItemDelegate::paint(painter, option, index);
  }
}
void CTaskDelegate::paint(QPainter* painter,const QStyleOptionViewItem& option,
						  const QModelIndex& index) const
{
	if(index.column()==column)
	{
		QStyleOptionViewItem myOption=option;
		myOption.displayAlignment=Qt::AlignRight|Qt::AlignVCenter;
		QString text=index.model()->data(index,Qt::DisplayRole).toString();

		drawDisplay(painter,myOption,myOption.rect,text);
		drawFocus(painter,myOption,myOption.rect);
	}
	else
	{
		QItemDelegate::paint(painter,option,index);
	}
}
void HighlightDelegate::paint(
        QPainter *painter,
        const QStyleOptionViewItem &option,
        const QModelIndex &index) const
{
    QString data = index.model()->data(index, Qt::DisplayRole).toString();
    if ( data.isEmpty() )
        return;

    if ( index.column() == 0 &&
         index.model()->rowCount()-1 == index.row() )
    {
        QBrush brush(Qt::SolidPattern);
        brush.setColor( Qt::red );
        painter->fillRect( option.rect, brush );
    }
    drawDisplay( painter, option, option.rect, data );
}
void ContractorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	if( index.column() == column )
	{
		QString text = index.model()->data(index, Qt::DisplayRole ).toString();
		text = text.simplified();

		if( text == emptyContractor )
			text = "";

		QStyleOptionViewItem myOption = option;
		myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;

		drawDisplay(painter, myOption, myOption.rect, text );
		drawFocus(painter, myOption, myOption.rect);
	}
	else
		QItemDelegate::paint(painter, option, index );
}
Example #9
0
void TrackDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    if (index.column() == durationColumn) {
        int secs = index.model()->data(index, Qt::DisplayRole).toInt();
        QString text = QString("%1:%2")
                       .arg(secs / 60, 2, 10, QChar('0'))
                       .arg(secs % 60, 2, 10, QChar('0'));

        QStyleOptionViewItem myOption = option;
        myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;

        drawDisplay(painter, myOption, myOption.rect, text);
        drawFocus(painter, myOption, myOption.rect);
    } else{
        QItemDelegate::paint(painter, option, index);
    }
}
Example #10
0
void MFixedRenderer::drawOpaques(MSubMesh * subMesh, MArmature * armature)
{
    M_PROFILE_SCOPE(MFixedRenderer::drawOpaques);
	// data
	MVector3 * vertices = subMesh->getVertices();
	MVector3 * normals = subMesh->getNormals();
	MColor * colors = subMesh->getColors();
	
	if(! vertices)
		return;
	
	MSkinData * skinData = subMesh->getSkinData();
	if(armature && skinData)
	{
		unsigned int verticesSize = subMesh->getVerticesSize();
		unsigned int normalsSize = subMesh->getNormalsSize();
		
		MVector3 * skinVertices = getVertices(verticesSize);
		MVector3 * skinNormals = getNormals(normalsSize);
		
		computeSkinning(armature, skinData, vertices, normals, NULL, skinVertices, skinNormals, NULL);
		subMesh->getBoundingBox()->initFromPoints(skinVertices, verticesSize);
		
		vertices = skinVertices;
		normals = skinNormals;
	}
	
	unsigned int i;
	unsigned int displayNumber = subMesh->getDisplaysNumber();
	for(i=0; i<displayNumber; i++)
	{
		MDisplay * display = subMesh->getDisplay(i);
		if(! display->isVisible())
			continue;
		
		MMaterial * material = display->getMaterial();
		if(material)
		{
			if(material->getBlendMode() == M_BLENDING_NONE)
				drawDisplay(subMesh, display, vertices, normals, colors);
		}
	}
}
void RatingComboBoxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
                                   const QModelIndex& index) const
{
    QVariant value  = index.data(Qt::DisplayRole);
    bool selectable = index.flags() & Qt::ItemIsSelectable;

    if (value.type() == QVariant::Int)
    {
        painter->save();
        drawBackground(painter, option, index);
        drawDisplay(painter, option, option.rect, QString());

        // our custom painting
        drawRating(painter, option.rect, value.toInt(), selectable);

        drawFocus(painter, option, option.rect);
        painter->restore();
    }
    else
    {
        return QItemDelegate::paint(painter, option, index);
    }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void UFormKvytanciiDocDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
	QStyleOptionViewItem myOption = option;
    if ( index.column() == durationColumn_2 ){
		QDate date( index.model()->data(index, Qt::DisplayRole).toDate() );
        QString text = QString("%1.%2.%3")
                       .arg(QVariant(date.day()).toString())
                       .arg(QVariant(date.month()).toString(), 2, QChar('0'))
					   .arg(QVariant(date.year()).toString(), 4, QChar('-'));
        myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
        drawDisplay(painter, myOption, myOption.rect, text);
        drawFocus(painter, myOption, myOption.rect);
	}
	else if ( index.column() == durationColumn_1 ){
		myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
        QItemDelegate::paint(painter, myOption, index);
    }
	else{
        QItemDelegate::paint(painter, option, index);
    }
}
Example #13
0
void TasksViewDelegate::paint( QPainter *painter,
                               const QStyleOptionViewItem &option,
                               const QModelIndex &index ) const
{
    painter->save();

    // Nasty QTreeView clips the painting to the editor geometry!
    // We don't want that....
    painter->setClipRect( option.rect );

    drawBackground( painter, option, index );

    const QVariant checkStateVariant = index.data(Qt::CheckStateRole);
    const Qt::CheckState checkState = static_cast<Qt::CheckState>(checkStateVariant.toInt());

    Layout layout = doLayout( option, index );

    const QRect textRect(option.rect.left(),
                         option.rect.top(),
                         option.rect.width() - layout.cbRect.width(),
                         layout.height);

    // Prepare QStyleOptionViewItem with the wanted alignments
    QStyleOptionViewItem modifiedOption = option;
    modifiedOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
    modifiedOption.decorationAlignment = Qt::AlignLeft | Qt::AlignVCenter;

    // Draw text (task id+name)
    const QString taskName = index.data(Qt::DisplayRole).toString();
    QString elidedTask = elidedTaskName( taskName, painter->font(),
                                         textRect.width() );
    drawDisplay(painter, modifiedOption, textRect, elidedTask);

    // Draw checkbox
    drawCheck(painter, option, layout.cbRect, checkState);
    painter->restore();
}
void DataTypeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if (index.column() == dataTypeColumn)
    {
        QString text = index.model()->data(index, Qt::DisplayRole).toString();
        drawDisplay(painter, option, option.rect, text);
        drawFocus(painter, option, option.rect);
    }
    else if (index.column() == isNull)
    {
        bool is = index.model()->data(index, Qt::DisplayRole).toBool();
        if (is)
        {
            int x = option.rect.x() + (option.rect.width() / 2) - (isNullPixmap.width() / 2);
            int y = option.rect.y() + (option.rect.height() / 2) - (isNullPixmap.height() / 2);
            painter->drawPixmap(x, y, isNullPixmap);
        }
        else
            painter->drawText(option.rect, "");
    }
    else if (index.column() == primary)
    {
        bool is = index.model()->data(index, Qt::DisplayRole).toBool();
        if (is)
        {
            int x = option.rect.x() + (option.rect.width() / 2) - (primaryPixmap.width() / 2);
            int y = option.rect.y() + (option.rect.height() / 2) - (primaryPixmap.height() / 2);
            painter->drawPixmap(x, y, primaryPixmap);
        }
        else
            painter->drawText(option.rect, "");
    }
    else
    {
        QItemDelegate::paint(painter, option, index);
    }
}
// =============================================================================
void TableViewDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    int column = index.column();

    if (column == Col::START_TIME   ||
        column == Col::END_TIME     ||
        column == Col::PAUSE_TIME   ||
        //column == Col::WORKED_TIME  ||
        column == Col::REQUIRED_TIME) {

        QString text = index.model()->data(index, Qt::DisplayRole).toTime().toString("hh:mm");

        QStyleOptionViewItem myOption = option;
        myOption.displayAlignment = Qt::AlignCenter | Qt::AlignVCenter;

        drawDisplay(painter, myOption, myOption.rect, text);
        drawFocus(painter, myOption, myOption.rect);

    } else {
        QItemDelegate::paint(painter, option, index);
    }
}
void LayerListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	QStyleOptionViewItem opt = setOptions(index, option);
	painter->save();

	const canvas::LayerListItem &layer = index.data().value<canvas::LayerListItem>();

	const int myId = static_cast<const canvas::LayerListModel*>(index.model())->myId();
	if(layer.isLockedFor(myId))
		opt.state &= ~QStyle::State_Enabled;

	drawBackground(painter, option, index);

	QRect textrect = opt.rect;

	// Draw layer opacity glyph
	QRect stylerect(opt.rect.topLeft() + QPoint(0, opt.rect.height()/2-12), QSize(24,24));
	drawOpacityGlyph(stylerect, painter, layer.opacity, layer.hidden);

	// Draw layer name
	textrect.setLeft(stylerect.right());

	QString title;
	if(m_showNumbers)
		title = QString("%1 - %2").arg(index.model()->rowCount() - index.row() - 1).arg(layer.title);
	else
		title = layer.title;

	if(index.data(canvas::LayerListModel::IsDefaultRole).toBool()) {
		opt.font.setUnderline(true);
	}

	drawDisplay(painter, opt, textrect, title);

	painter->restore();
}
Example #17
0
/*!
    Renders the delegate using the given \a painter and style \a option for
    the item specified by \a index.

    When reimplementing this function in a subclass, you should update the area
    held by the option's \l{QStyleOption::rect}{rect} variable, using the
    option's \l{QStyleOption::state}{state} variable to determine the state of
    the item to be displayed, and adjust the way it is painted accordingly.

    For example, a selected item may need to be displayed differently to
    unselected items, as shown in the following code:

    \snippet examples/itemviews/pixelator/pixeldelegate.cpp 2
    \dots

    After painting, you should ensure that the painter is returned to its
    the state it was supplied in when this function was called. For example,
    it may be useful to call QPainter::save() before painting and
    QPainter::restore() afterwards.

    \sa QStyle::State
*/
void QItemDelegate::paint(QPainter *painter,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const
{
    Q_D(const QItemDelegate);
    Q_ASSERT(index.isValid());

    QStyleOptionViewItemV4 opt = setOptions(index, option);

    const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(&option);
    opt.features = v2 ? v2->features
                    : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None);
    const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3 *>(&option);
    opt.locale = v3 ? v3->locale : QLocale();
    opt.widget = v3 ? v3->widget : 0;

    // prepare
    painter->save();
    if (d->clipPainting)
        painter->setClipRect(opt.rect);

    // get the data and the rectangles

    QVariant value;

    QPixmap pixmap;
    QRect decorationRect;
    value = index.data(Qt::DecorationRole);
    if (value.isValid()) {
        // ### we need the pixmap to call the virtual function
        pixmap = decoration(opt, value);
        if (value.type() == QVariant::Icon) {
            d->tmp.icon = qvariant_cast<QIcon>(value);
            d->tmp.mode = d->iconMode(option.state);
            d->tmp.state = d->iconState(option.state);
            const QSize size = d->tmp.icon.actualSize(option.decorationSize,
                                                      d->tmp.mode, d->tmp.state);
            decorationRect = QRect(QPoint(0, 0), size);
        } else {
            d->tmp.icon = QIcon();
            decorationRect = QRect(QPoint(0, 0), pixmap.size());
        }
    } else {
        d->tmp.icon = QIcon();
        decorationRect = QRect();
    }

    QString text;
    QRect displayRect;
    value = index.data(Qt::DisplayRole);
    if (value.isValid() && !value.isNull()) {
        text = QItemDelegatePrivate::valueToText(value, opt);
        displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text);
    }

    QRect checkRect;
    Qt::CheckState checkState = Qt::Unchecked;
    value = index.data(Qt::CheckStateRole);
    if (value.isValid()) {
        checkState = static_cast<Qt::CheckState>(value.toInt());
        checkRect = check(opt, opt.rect, value);
    }

    // do the layout

    doLayout(opt, &checkRect, &decorationRect, &displayRect, false);

    // draw the item

    drawBackground(painter, opt, index);
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, decorationRect, pixmap);
    drawDisplay(painter, opt, displayRect, text);
    drawFocus(painter, opt, displayRect);

    // done
    painter->restore();
}
void CalibrationEngine::process(unsigned char *src, unsigned char *dest, SDL_Surface *display) {

	if(!calibration) return;
	drawDisplay( (unsigned char*)(display->pixels));
}
Example #19
0
void AddressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	drawBackground(painter, option, index);

	QRect titleRectangle(option.rect);

	if (static_cast<AddressCompletionModel::EntryType>(index.data(AddressCompletionModel::TypeRole).toInt()) == AddressCompletionModel::HeaderType)
	{
		titleRectangle = titleRectangle.marginsRemoved(QMargins(2, 2, 2, 2));

		if (index.row() != 0)
		{
			QPen pen(Qt::lightGray);
			pen.setWidth(1);
			pen.setStyle(Qt::SolidLine);

			painter->setPen(pen);
			painter->drawLine((option.rect.left() + 5), (option.rect.top() + 3), (option.rect.right() - 5), (option.rect.top() + 3));
		}

		drawDisplay(painter, option, titleRectangle, index.data(AddressCompletionModel::TitleRole).toString());

		return;
	}

	if (option.direction == Qt::RightToLeft)
	{
		titleRectangle.setRight(option.rect.width() - 33);
	}
	else
	{
		titleRectangle.setLeft(33);
	}

	QRect decorationRectangle(option.rect);

	if (option.direction == Qt::RightToLeft)
	{
		decorationRectangle.setLeft(option.rect.width() - 33);
	}
	else
	{
		decorationRectangle.setRight(33);
	}

	decorationRectangle = decorationRectangle.marginsRemoved(QMargins(2, 2, 2, 2));

	QIcon icon(index.data(Qt::DecorationRole).value<QIcon>());

	if (icon.isNull())
	{
		icon = ThemesManager::getIcon(QLatin1String("tab"));
	}

	icon.paint(painter, decorationRectangle, option.decorationAlignment);

	QString url(index.data(Qt::DisplayRole).toString());
	const QString description((m_viewMode == HistoryMode) ? Utils::formatDateTime(index.data(HistoryModel::TimeVisitedRole).toDateTime()) : index.data(AddressCompletionModel::TitleRole).toString());
	QStyleOptionViewItem linkOption(option);

	if (static_cast<AddressCompletionModel::EntryType>(index.data(AddressCompletionModel::TypeRole).toInt()) != AddressCompletionModel::SearchSuggestionType)
	{
		linkOption.palette.setColor(QPalette::Text, option.palette.color(QPalette::Link));
	}

	if (m_displayMode == ColumnsMode)
	{
		const int maxUrlWidth(option.rect.width() / 2);

		url = option.fontMetrics.elidedText(url, Qt::ElideRight, (maxUrlWidth - 40));

		drawDisplay(painter, linkOption, titleRectangle, url);

		if (!description.isEmpty())
		{
			if (option.direction == Qt::RightToLeft)
			{
				titleRectangle.setRight(maxUrlWidth);
			}
			else
			{
				titleRectangle.setLeft(maxUrlWidth);
			}

			drawDisplay(painter, option, titleRectangle, description);
		}

		return;
	}

	drawDisplay(painter, linkOption, titleRectangle, url);

	if (!description.isEmpty())
	{
		const int urlLength(option.fontMetrics.width(url + QLatin1Char(' ')));

		if (urlLength < titleRectangle.width())
		{
			if (option.direction == Qt::RightToLeft)
			{
				titleRectangle.setRight(option.rect.width() - (urlLength + 33));
			}
			else
			{
				titleRectangle.setLeft(urlLength + 33);
			}

			drawDisplay(painter, option, titleRectangle, QLatin1String("- ") + description);
		}
	}
}
Example #20
0
//---------------------------------------------------------------------------------
void
MagicDelegate::paint(QPainter* p_painter, const QStyleOptionViewItem& p_option, const QModelIndex& p_index) const
{
    // Get the item
    MagicAbilityDefinition* item = static_cast<MagicAbilityDefinition*>(p_index.data().value<void*>());

    // Get category name
    QString text = "";
    if (item->id.startsWith("CATEGORY"))
    {
        switch (item->abilityType)
        {
        case MAGICABILITYTYPE_INVALID:
        case NUM_MAGICABILITYTYPES:
            text = tr("Invalid Magic Type for %1").arg(item->id);
            break;

        case MAGICABILITYTYPE_SPELL:
            text = tr("Spells");
            break;

        case MAGICABILITYTYPE_ADEPT_POWER:
            text = tr("Adept Powers");
            break;

        case MAGICABILITYTYPE_COMPLEX_FORM:
            text = tr("Complex Forms");
            break;
        }
    }

    // Get translation
    if (text == "")
    {
        switch (item->abilityType)
        {
        case MAGICABILITYTYPE_INVALID:
        case NUM_MAGICABILITYTYPES:
            text = tr("Invalid Magic Type for %1").arg(item->id);
            break;

        case MAGICABILITYTYPE_SPELL:
            // The spell category has sub-categories, so if it has children, it must be such a category
            if (item->children.size() > 0)
            {
                text = MAGIC_RULES->getSpellCategoryTranslation(item->id);
            }
            else
            {
                text = item->translations[APPSTATUS->getCurrentLocale()];
            }
            break;

        case MAGICABILITYTYPE_COMPLEX_FORM:
        case MAGICABILITYTYPE_ADEPT_POWER:
            text = item->translations[APPSTATUS->getCurrentLocale()];
            break;
        }
    }

    // If this is an adept power, we may need to also show the level
    if (!item->isCategory &&
        item->abilityType == MAGICABILITYTYPE_ADEPT_POWER && _showAdeptPowerLevel)
    {
        int level = CHARACTER_VALUES->getAdeptPowerLevel(item->id);
        if (level != 0)
        {
            text.append(QString(" (%1)").arg(level));
        }
    }

    // Call painter methods for drawing
    p_painter->save();
    p_painter->setClipRect(p_option.rect);

    drawBackground(p_painter, p_option, p_index);
    drawDisplay(p_painter, p_option, p_option.rect, text);
    drawFocus(p_painter, p_option, p_option.rect);

    p_painter->restore();
}
Example #21
0
void MFixedRenderer::drawTransparents(MSubMesh * subMesh, MArmature * armature)
{
    M_PROFILE_SCOPE(MFixedRenderer::drawTransparents);
	MRenderingContext * render = MEngine::getInstance()->getRenderingContext();
	
	// data
	MVector3 * vertices = subMesh->getVertices();
	MVector3 * normals = subMesh->getNormals();
	MColor * colors = subMesh->getColors();
	
	if(! vertices)
		return;

	MSkinData * skinData = subMesh->getSkinData();
	if(armature && skinData)
	{
		unsigned int verticesSize = subMesh->getVerticesSize();
		unsigned int normalsSize = subMesh->getNormalsSize();
		
		MVector3 * skinVertices = getVertices(verticesSize);
		MVector3 * skinNormals = getNormals(normalsSize);
		
		computeSkinning(armature, skinData, vertices, normals, NULL, skinVertices, skinNormals, NULL);
		subMesh->getBoundingBox()->initFromPoints(skinVertices, verticesSize);
		
		vertices = skinVertices;
		normals = skinNormals;
	}
	
	render->setColorMask(0, 0, 0, 0);
	
	unsigned int i;
	unsigned int displayNumber = subMesh->getDisplaysNumber();
	for(i=0; i<displayNumber; i++)
	{
		MDisplay * display = subMesh->getDisplay(i);
		if((! display->isVisible()) || (! display->getMaterial()))
			continue;
		
		if(display->getMaterial()->getBlendMode() == M_BLENDING_ALPHA)
			drawDisplayTriangles(subMesh, display, vertices);
	}
	
	render->setColorMask(1, 1, 1, 1);
	render->setDepthMask(0);
	
	for(i=0; i<displayNumber; i++)
	{
		MDisplay * display = subMesh->getDisplay(i);
		if(! display->isVisible())
			continue;
		
		MMaterial * material = display->getMaterial();
		if(material)
		{
			if(material->getBlendMode() != M_BLENDING_NONE)
				drawDisplay(subMesh, display, vertices, normals, colors);
		}
	}
	
	render->setDepthMask(1);
}
void CalculatorTestApp::handleKey(widgetid_t keyPressed) {

//  keyMap origKeyMap = (keyMap)buttons->getMap();

  switch (keyPressed) {
    case zero:
    case one:
    case two:
    case three:
    case four:
    case five:
    case six:
    case seven:
    case eight:
    case nine:
    case hex_a:
    case hex_b:
    case hex_c:
    case hex_d:
    case hex_e:
    case hex_f:
      keyDigit(keyPressed);
      break;
    case decimal:
      keyDecimal();
      break;
    case enter:
      keyEnter();
      break;
    case clear:
      keyClear();
      break;
    case backspace:
      keyBackspace();
      break;
    case shift:
      keyShift();
      break;
    case ee:
      keyEE();
      break;
    default:
      // the following are functions that accept the current input string
      acceptText();
      switch (keyPressed) {
      case divide:
        keyDivide();
        break;
      case multiply:
        keyMultiply();
        break;
      case add:
        keyAdd();
        break;
      case subtract:
        keySubtract();
        break;
      case inverse:
        keyInverse();
        break;
      case percent:
        keyPercent();
        break;
      case swap:
        keySwap();
        break;
      case changeBase:
        keyBase();
        break;
      case send:
        keySend();
        break;
      case square_f:
        keySquare();
        break;
      case cube_f:
        keyCube();
        break;
      case pow_f:
        keyPow();
        break;
      case exp_f:
        keyExp();
        break;
      case pow10_f:
        keyPow10();
        break;
      case sqrt_f:
        keySqrt();
        break;
      case cubert_f:
        keyCubert();
        break;
      case xroot_f:
        keyXroot();
        break;
      case ln_f:
        keyLn();
        break;
      case log10_f:
        keyLog10();
        break;
      case sin_f:
        keySin();
        break;
      case cos_f:
        keyCos();
        break;
      case tan_f:
        keyTan();
        break;
      case pi_f:
        keyPi();
        break;
      case e_f:
        keyE();
        break;
      case asin_f:
        keyAsin();
        break;
      case acos_f:
        keyAcos();
        break;
      case atan_f:
        keyAtan();
        break;
      case logy_f:
        keyLogy();
        break;
      case log2_f:
        keyLog2();
        break;
      case in2mm_f:
        keyIn2mm();
        break;
      case mm2in_f:
        keyMm2In();
        break;
      case g2lb_f:
        keyG2lb();
        break;
      case lb2g_f:
        keyLb2g();
        break;
      case c2f_f:
        keyC2f();
        break;
      case f2c_f:
        keyF2c();
        break;
      case ppi_f:
        keyPpi();
        break;
      default:
        break;
    }
  }

//  if (origKeyMap == sci_map && buttons->getMap() == sci_map) {
//    buttons->setMap(basic_map);
//  }

  drawDisplay();
}
Example #23
0
void ItemDelegate::paint(QPainter *painter, 
                         const QStyleOptionViewItem &option, 
                         const QModelIndex &index) const
{
    if (option.state & QStyle::State_Selected) {
        painter->fillRect(option.rect, option.palette.highlight());
    } else if (option.state & QStyle::State_MouseOver) {
        QBrush brush(QColor(0, 0, 255, 25));
        painter->fillRect(option.rect, brush);
    }
    Message msg = index.data(Qt::UserRole).value<Message>();
    QStyleOptionViewItem myOption = option;
    QFontMetrics fm(painter->font());
    int width = myOption.rect.width();
    int height = myOption.rect.height();
    int textMargin = fm.height();
    
    Contact contact = g_phoneBook->getContactOfPhoneNum(msg.phonenum);
    QString str;
    if (contact.isValid()) {
        str = contact.name;
    } else {
        str = msg.phonenum;
    }
    myOption.displayAlignment = Qt::AlignCenter;
    QPixmap pixmap;
    QString strStatePix;
    switch (msg.state) {
    case Message::State_Read:
        strStatePix = ":/pic/Read.png";
        break;
    case Message::State_Unread:
        strStatePix = ":/pic/Unread.png";
        break;
    case Message::State_Unsend:
        strStatePix = ":/pic/Unsend.png";
        break;
    case Message::State_Sent:
        strStatePix = ":/pic/Sent.png";
        break;
    case Message::State_SendFail:
        strStatePix = ":/pic/SendFail.png";
        break;
    default:
        qDebug() << "this is a bug" << __FILE__ << __LINE__;
        break;
    }    
    pixmap.load(strStatePix);

    QSize sizePixmap(height / 2 * 0.7, height / 2 * 0.7);
    int pixMargin = (height/2-sizePixmap.height())/2;
    painter->drawPixmap(QRect(myOption.rect.topLeft() + QPoint(pixMargin, pixMargin), sizePixmap), pixmap);
    
    myOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
    QSize sizeName(fm.width(msg.phonenum) + textMargin, height / 2);
    drawDisplay(painter, 
                myOption, 
                QRect(myOption.rect.topLeft() + QPoint(height/2, 0), sizeName),
                str);
    
    QSize sizeDateTime(width - sizePixmap.width() - sizeName.width(), height / 2);
    myOption.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
    drawDisplay(painter, 
                myOption, 
                QRect(myOption.rect.topRight() - QPoint(sizeDateTime.width(), 0), sizeDateTime),
                msg.datetime.toString("yyyy-MM-dd hh:mm:ss"));    
    
    myOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
    drawDisplay(painter, 
                myOption, 
                QRect(option.rect.topLeft() + QPoint(height / 2, height / 2), 
                      QSize(option.rect.width() - height / 2, height / 2)), 
                msg.content);     
}