Ejemplo n.º 1
0
int QLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 12)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 12;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< Qt::TextFormat*>(_v) = textFormat(); break;
        case 2: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(pixmap())); break;
        case 3: *reinterpret_cast< bool*>(_v) = hasScaledContents(); break;
        case 4: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break;
        case 5: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 6: *reinterpret_cast< int*>(_v) = margin(); break;
        case 7: *reinterpret_cast< int*>(_v) = indent(); break;
        case 8: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break;
        case 9: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break;
        case 10: *reinterpret_cast< bool*>(_v) = hasSelectedText(); break;
        case 11: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setTextFormat(*reinterpret_cast< Qt::TextFormat*>(_v)); break;
        case 2: setPixmap(*reinterpret_cast< QPixmap*>(_v)); break;
        case 3: setScaledContents(*reinterpret_cast< bool*>(_v)); break;
        case 4: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 5: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 6: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 7: setIndent(*reinterpret_cast< int*>(_v)); break;
        case 8: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break;
        case 9: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 2
0
bool TextEdit::isEmpty()
{
    if (paragraphs() < 2){
        QString t = text(0);
        if (textFormat() == QTextEdit::RichText)
            t = unquoteText(t);
        return t.isEmpty();
    }
    return false;
}
Ejemplo n.º 3
0
int QMessageBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: buttonClicked((*reinterpret_cast< QAbstractButton*(*)>(_a[1]))); break;
        case 1: d_func()->_q_buttonClicked((*reinterpret_cast< QAbstractButton*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< Icon*>(_v) = icon(); break;
        case 2: *reinterpret_cast< QPixmap*>(_v) = iconPixmap(); break;
        case 3: *reinterpret_cast< Qt::TextFormat*>(_v) = textFormat(); break;
        case 4: *reinterpret_cast<int*>(_v) = QFlag(standardButtons()); break;
        case 5: *reinterpret_cast< QString*>(_v) = detailedText(); break;
        case 6: *reinterpret_cast< QString*>(_v) = informativeText(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setIcon(*reinterpret_cast< Icon*>(_v)); break;
        case 2: setIconPixmap(*reinterpret_cast< QPixmap*>(_v)); break;
        case 3: setTextFormat(*reinterpret_cast< Qt::TextFormat*>(_v)); break;
        case 4: setStandardButtons(QFlag(*reinterpret_cast<int*>(_v))); break;
        case 5: setDetailedText(*reinterpret_cast< QString*>(_v)); break;
        case 6: setInformativeText(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 4
0
void TextEdit::setTextFormat(QTextEdit::TextFormat format)
{
    if (format == textFormat())
        return;
    if (format == RichText){
        QTextEdit::setTextFormat(format);
        return;
    }
    QString t = plainText(0, paragraphs(), 0, 0);
    QTextEdit::setTextFormat(format);
    setText(t);
}
Ejemplo n.º 5
0
void TextEdit::setTextFormat(QTextEdit::TextFormat format)
{
    if (format == textFormat())
        return;
    if (format == RichText){
        QTextEdit::setTextFormat(format);
        return;
    }
    QString t = unquoteText(text());
    QTextEdit::setTextFormat(format);
    setText(t);
}
Ejemplo n.º 6
0
QTextDrag *TextShow::dragObject(QWidget *parent) const
{
    if (!hasSelectedText())
        return NULL;
#if (COMPAT_QT_VERSION < 0x030000) || (COMPAT_QT_VERSION >= 0x030100)
    if (textFormat() == RichText){
        RichTextDrag *drag = new RichTextDrag(parent);
        drag->setRichText(selectedText());
        return drag;
    }
#endif
    return new QTextDrag(selectedText(), parent );
}
void MainWindow::updateTitle()
{
    // Title Format:
    // {filename.jpg} @ 100% - {program build}
    QString title = "%1 @ %2%3 (%4x%5 %6) - %7 %8";
    QString filename = imageViewer->fileName();
    float zoomFactor = imageViewer->getZoom();
    title = title.arg(filename).arg(zoomFactor*100).arg("%")
            .arg(imageViewer->getImage()->width())
            .arg(imageViewer->getImage()->height())
            .arg(textFormat(imageViewer->getImage()->format()))
            .arg(PROGRAM_NAME).arg(PROGRAM_VER);
    setWindowTitle(title);
}
Ejemplo n.º 8
0
void KSqueezedTextLabel::mouseReleaseEvent(QMouseEvent* ev)
{
#if QT_VERSION >= 0x040700
    if (QApplication::clipboard()->supportsSelection() &&
        textInteractionFlags() != Qt::NoTextInteraction &&
        ev->button() == Qt::LeftButton &&
        !d->fullText.isEmpty() &&
        hasSelectedText()) {
        // Expand "..." when selecting with the mouse
        QString txt = selectedText();
        const QChar ellipsisChar(0x2026); // from qtextengine.cpp
        const int dotsPos = txt.indexOf(ellipsisChar);
        if (dotsPos > -1) {
            // Ex: abcde...yz, selecting de...y  (selectionStart=3)
            // charsBeforeSelection = selectionStart = 2 (ab)
            // charsAfterSelection = 1 (z)
            // final selection length= 26 - 2 - 1 = 23
            const int start = selectionStart();
            int charsAfterSelection = text().length() - start - selectedText().length();
            txt = d->fullText;
            // Strip markup tags
            if (textFormat() == Qt::RichText
                || (textFormat() == Qt::AutoText && Qt::mightBeRichText(txt))) {
                txt.replace(QRegExp(QStringLiteral("<[^>]*>")), QStringLiteral(""));
                // account for stripped characters
                charsAfterSelection -= d->fullText.length() - txt.length();
            }
            txt = txt.mid(selectionStart(), txt.length() - start - charsAfterSelection);
        }
        QApplication::clipboard()->setText(txt, QClipboard::Selection);
    } else
#endif
    {
        QLabel::mouseReleaseEvent(ev);
    }
}
Ejemplo n.º 9
0
void *TextEdit::processEvent(Event *e)
{
    if (m_param == NULL)
        return NULL;
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != m_param)
            return NULL;
        switch (cmd->id){
        case CmdBgColor:
        case CmdFgColor:
        case CmdBold:
        case CmdItalic:
        case CmdUnderline:
        case CmdFont:
            if ((textFormat() == RichText) && !isReadOnly()){
                cmd->flags &= ~BTN_HIDE;
            }else{
                cmd->flags |= BTN_HIDE;
            }
            return e->param();
        default:
            return NULL;
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != m_param)
            return NULL;
        switch (cmd->id){
        case CmdBgColor:{
                Event eWidget(EventCommandWidget, cmd);
                CToolButton *btnBg = (CToolButton*)(eWidget.process());
                if (btnBg){
                    ColorPopup *popup = new ColorPopup(this, background());
                    popup->move(CToolButton::popupPos(btnBg, popup));
                    connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));
                    popup->show();
                }
                return e->param();
            }
        case CmdFgColor:{
                Event eWidget(EventCommandWidget, cmd);
                CToolButton *btnFg = (CToolButton*)(eWidget.process());
                if (btnFg){
                    ColorPopup *popup = new ColorPopup(this, foreground());
                    popup->move(CToolButton::popupPos(btnFg, popup));
                    connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
                    popup->show();
                }
                return e->param();
            }
        case CmdBold:
            m_bSelected = true;
            setBold((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdItalic:
            m_bSelected = true;
            setItalic((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdUnderline:
            m_bSelected = true;
            setUnderline((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdFont:{
#ifdef USE_KDE
                QFont f = font();
                if (KFontDialog::getFont(f, false, topLevelWidget()) != KFontDialog::Accepted)
                    break;
#else
                bool ok = false;
                QFont f = QFontDialog::getFont(&ok, font(), topLevelWidget());
                if (!ok)
                    break;
#endif
                m_bSelected = true;
                setCurrentFont(f);
                break;
            }
        default:
            return NULL;
        }
    }
    return NULL;
}
Ejemplo n.º 10
0
void CustomLabel::paintEvent(QPaintEvent *pe)
{
    if ((!text().isEmpty()) &&
            (textFormat() == Qt::PlainText ||
             (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
    {
        QPainter painter(this);
#ifndef DEBUG_CUSTOMLABEL
        QRectF lr = contentsRect();
        lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
        QStyleOption opt;
        opt.initFrom(this);

        int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
        int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
        if (wordWrap())
            flags |= Qt::TextWordWrap;
        switch (shadowType)
        {
        case NoShadow:
            flags |= TF_NOSHADOW;
            break;
        case DarkShadow:
            flags |= TF_DARKSHADOW;
            break;
        case LightShadow:
            flags |= TF_LIGHTSHADOW;
            break;
        default:
            break;
        }
        QString textToDraw = elidedText();
        style()->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), textToDraw, QPalette::WindowText);
#else // DEBUG_CUSTOMLABEL
        QTextDocument *doc = textDocument();
        QAbstractTextDocumentLayout::PaintContext ctx = textDocumentPaintContext(doc);
        QString shadowKey;
        switch (shadowType)
        {
        case DarkShadow:
            shadowKey = GFX_TEXTSHADOWS;
            break;
        case LightShadow:
            shadowKey = GFX_NOTICEWIDGET;
            break;
        case NoShadow:
        default:
            break;
        }

        // magic numbers
        int dx = -2;
        int dy = -2;
        // adding margins
        dx += contentsMargins().left();
        dy += contentsMargins().top();

# if 1 // for debug set 0
        QGraphicsDropShadowEffect *shadow = qobject_cast<QGraphicsDropShadowEffect *>(GraphicsEffectsStorage::staticStorage(RSR_STORAGE_GRAPHICSEFFECTS)->getFirstEffect(shadowKey));
# else // debug shadow
        QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
        shadow->setColor(Qt::red);
        shadow->setOffset(1, 1);
# endif
        if (shadow)
        {
# if 0 // for "image method" set 1
            QImage shadowedText(size(), QImage::Format_ARGB32_Premultiplied);
#  if defined(Q_WS_MAC) && !defined(__MAC_OS_X_NATIVE_FULLSCREEN)
            // TODO: fix that
            shadowedText.fill(Qt::red); // DUNNO WHY!!!
#  else
            shadowedText.fill(Qt::transparent);
#  endif
            QPainter tmpPainter(&shadowedText);
            tmpPainter.setRenderHint(QPainter::Antialiasing);
            tmpPainter.setRenderHint(QPainter::HighQualityAntialiasing);
            tmpPainter.setRenderHint(QPainter::TextAntialiasing);
            tmpPainter.setRenderHint(QPainter::SmoothPixmapTransform);
            tmpPainter.translate(dx, dy);
            doc->documentLayout()->draw(&tmpPainter, ctx);
            painter.drawImage(0, 0, shadowedText);
# else // text method
            QPalette origPal = ctx.palette;
            ctx.palette.setColor(QPalette::Text, shadow->color());

            // draw shadow
            painter.save();
            painter.translate(dx + shadow->xOffset(), dy + shadow->yOffset());
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();

            ctx.palette = origPal;

            // draw text
            painter.save();
            painter.translate(dx, dy);
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();
# endif // shadow method
        }
        else
        {
            painter.save();
            painter.translate(dx, dy);
            doc->documentLayout()->draw(&painter, ctx);
            painter.restore();
        }
        doc->deleteLater();
#endif // DEBUG_CUSTOMLABEL
    }
    else
        QLabel::paintEvent(pe);
}
Ejemplo n.º 11
0
int QDeclarativeText::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 3: *reinterpret_cast< TextStyle*>(_v) = style(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = styleColor(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< bool*>(_v) = truncated(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumLineCount(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< TextElideMode*>(_v) = elideMode(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 15: *reinterpret_cast< qreal*>(_v) = lineHeight(); break;
        case 16: *reinterpret_cast< LineHeightMode*>(_v) = lineHeightMode(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 2: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setStyle(*reinterpret_cast< TextStyle*>(_v)); break;
        case 4: setStyleColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 10: setMaximumLineCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setElideMode(*reinterpret_cast< TextElideMode*>(_v)); break;
        case 15: setLineHeight(*reinterpret_cast< qreal*>(_v)); break;
        case 16: setLineHeightMode(*reinterpret_cast< LineHeightMode*>(_v)); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        case 10: resetMaximumLineCount(); break;
        }
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 17;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 17;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 12
0
void CustomLabel::paintEvent(QPaintEvent * pe)
{
	if ((!text().isEmpty()) &&
			(textFormat() == Qt::PlainText ||
			 (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
	{
		QPainter painter(this);
		QRectF lr = contentsRect();
		lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
		QStyleOption opt;
		opt.initFrom(this);
		int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
		int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
		if (wordWrap())
			flags |= Qt::TextWordWrap;
		switch (shadowType)
		{
		case NoShadow:
			flags |= TF_NOSHADOW;
			break;
		case DarkShadow:
			flags |= TF_DARKSHADOW;
			break;
		case LightShadow:
			flags |= TF_LIGHTSHADOW;
			break;
		default:
			break;
		}
		QString textToDraw = text();
		int textWidth = lr.width();
		// eliding text
		// TODO: move to text change / resize event handler, make textToDraw a member
		if (elideMode() != Qt::ElideNone)
		{
			QFontMetrics fm = fontMetrics();
			if (!wordWrap())
			{
				textToDraw = fm.elidedText(text(), elideMode(), textWidth);
			}
			else if (elideMode() == Qt::ElideRight)
			{
				// multiline elide
				int pxPerLine = fontMetrics().lineSpacing();
				int lines = lr.height() / pxPerLine + 1;
#ifdef DEBUG_ENABLED
//				if (lines > 1)
//				{
//					qDebug() << pxPerLine << lines << lr << fm.height() << font().toString();
//				}
#endif
#ifdef Q_WS_MAC // mac hack, dunno why
				//lines--;
				// TODO: debug this!!!
#endif
				QStringList srcLines = text().split("\n");
				QStringList dstLines;
				foreach (QString srcLine, srcLines)
				{
					int w = fm.width(srcLine);
					if (w >= textWidth)
					{
						QStringList tmpList = srcLine.split(' ');
						QString s;
						int i = 0;
						while (i < tmpList.count())
						{
							if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
							{
								if (!s.isEmpty())
								{
									dstLines += s;
									s = QString::null;
								}
							}
							if (!s.isEmpty())
							{
								s += " ";
							}
							s += tmpList.at(i);
							i++;
						}
						dstLines += s;
					}
					else
					{
						dstLines += srcLine;
					}
				}
Ejemplo n.º 13
0
int QDeclarativeTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeImplicitSizePaintedItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 47)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 47;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = selectedTextColor(); break;
        case 4: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 5: *reinterpret_cast< HAlignment*>(_v) = hAlign(); break;
        case 6: *reinterpret_cast< VAlignment*>(_v) = vAlign(); break;
        case 7: *reinterpret_cast< WrapMode*>(_v) = wrapMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = lineCount(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = paintedWidth(); break;
        case 10: *reinterpret_cast< qreal*>(_v) = paintedHeight(); break;
        case 11: *reinterpret_cast< TextFormat*>(_v) = textFormat(); break;
        case 12: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 13: *reinterpret_cast< bool*>(_v) = isCursorVisible(); break;
        case 14: *reinterpret_cast< int*>(_v) = cursorPosition(); break;
        case 15: *reinterpret_cast< QRect*>(_v) = cursorRectangle(); break;
        case 16: *reinterpret_cast< QDeclarativeComponent**>(_v) = cursorDelegate(); break;
        case 17: *reinterpret_cast< int*>(_v) = selectionStart(); break;
        case 18: *reinterpret_cast< int*>(_v) = selectionEnd(); break;
        case 19: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        case 20: *reinterpret_cast< bool*>(_v) = focusOnPress(); break;
        case 21: *reinterpret_cast< bool*>(_v) = persistentSelection(); break;
        case 22: *reinterpret_cast< qreal*>(_v) = textMargin(); break;
        case 23: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break;
        case 24: *reinterpret_cast< bool*>(_v) = selectByMouse(); break;
        case 25: *reinterpret_cast< SelectionMode*>(_v) = mouseSelectionMode(); break;
        case 26: *reinterpret_cast< bool*>(_v) = canPaste(); break;
        case 27: *reinterpret_cast< bool*>(_v) = isInputMethodComposing(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setSelectedTextColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 5: setHAlign(*reinterpret_cast< HAlignment*>(_v)); break;
        case 6: setVAlign(*reinterpret_cast< VAlignment*>(_v)); break;
        case 7: setWrapMode(*reinterpret_cast< WrapMode*>(_v)); break;
        case 11: setTextFormat(*reinterpret_cast< TextFormat*>(_v)); break;
        case 12: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 13: setCursorVisible(*reinterpret_cast< bool*>(_v)); break;
        case 14: setCursorPosition(*reinterpret_cast< int*>(_v)); break;
        case 16: setCursorDelegate(*reinterpret_cast< QDeclarativeComponent**>(_v)); break;
        case 20: setFocusOnPress(*reinterpret_cast< bool*>(_v)); break;
        case 21: setPersistentSelection(*reinterpret_cast< bool*>(_v)); break;
        case 22: setTextMargin(*reinterpret_cast< qreal*>(_v)); break;
        case 23: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break;
        case 24: setSelectByMouse(*reinterpret_cast< bool*>(_v)); break;
        case 25: setMouseSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 5: resetHAlign(); break;
        }
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 28;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 28;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 14
0
// -------------------------------------------------------------------------------
void Editor::keyPressEvent( QKeyEvent* pKeyEv )
// -------------------------------------------------------------------------------
{
   if ( !pKeyEv )
      return;

   //std::cout<<"key = "<<pKeyEv->key();

   // If
   //   CTRL + S (save)  or
   //   ALT + left  cursor (history one back / previous entry) or
   //   ALT + right cursor (history one forward / next entry)
   //   CTRL + F (shortcut for "Searching")
   // is called, then ignore it.
   if( ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_S) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Left) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Right) ) ||
       ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_F) ) )
   {
      //std::cout<<" -> ignore"<<std::endl;
      pKeyEv->ignore();
   }
/*

   // if the shift button is down while pressing return or enter, insert a new paragraph
   else if  ( ( (pKeyEv->state() == Qt::ShiftButton ) || (pKeyEv->state() == Qt::ControlButton ) )
              &&
              ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
            )
   {
      if ( LINEBREAK_MODERN == meLinebreakMode )
      {
         //std::cout<<" -> shift/ctrl + enter/return"<<std::endl;
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), 0 ) );
      }
      else
      {
         Q3TextEdit::keyPressEvent( pKeyEv );
      }
   }
*/
   // Workaround Q3TextEdit's default Enter key behavior of adding a paragraph
   // Add control key pressed to it
   else if  ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
   {
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), Qt::ControlButton ) );
   }

   // CTRL + A -> select all
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_A == pKeyEv->key()) )
   {
      selectAll();
   }

   // CTRL + B -> bold
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_B == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setBold( !bold() );
   }

   // CTRL + I -> italic
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_I == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setItalic( !italic() );
   }

   // CTRL + U -> underline
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_U == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setUnderline( !underline() );
   }

   else
   {
      // otherwise call the super-method
      //std::cout<<std::endl;
      Q3TextEdit::keyPressEvent( pKeyEv );
   }
}