

Definition at line 86 of file msgedit.cpp.
Public Member Functions | |
| BackTabTextEdit (QWidget *parent=0) | |
| virtual QVariant | loadResource (int type, const QUrl &name) |
| virtual void | keyPressEvent (QKeyEvent *e) |
| virtual void | focusInEvent (QFocusEvent *e) |
Public Attributes | |
| QMap< QUrl, QImage > | m_backTabOmages |
| QImage | m_tabImg |
| QImage | m_newlineImg |
| BackTabTextEdit::BackTabTextEdit | ( | QWidget * | parent = 0 |
) | [inline] |
Loads the resource specified by the given type and name.
This function is an extension of QTextDocument::loadResource().
Reimplemented from QTextEdit.
Definition at line 101 of file msgedit.cpp.
References QTextDocument::addResource(), QString::arg(), QFontMetrics::ascent(), MessageEditor::backTab, backTabImages, Qt::blue, QFontMetrics::boundingRect(), QTextEdit::document(), QImage::fill(), QWidget::font(), QImage::Format_RGB32, MessageEditor::friendlyBackTab, QString::fromAscii(), h, QFontMetrics::height(), i, QTextDocument::ImageResource, QMap< Key, T >::insert(), QImage::isNull(), m_backTabOmages, name, p, qRgb(), qstrlen(), QFont::setItalic(), QMap< Key, T >::value(), w, and QRect::width().
00102 { 00103 QImage img; 00104 if (type == QTextDocument::ImageResource) { 00105 img = m_backTabOmages.value(name); 00106 if (img.isNull()) { 00107 for (uint i = 0; i < qstrlen(MessageEditor::backTab); ++i) { 00108 if (backTabImages[i] && name == QUrl(QLatin1String(backTabImages[i]))) { 00109 00110 QFont fnt = font(); 00111 fnt.setItalic(true); 00112 QFontMetrics fm(fnt); 00113 int h = fm.height(); 00114 00115 QString str = QString::fromAscii("(%1)").arg(MessageEditor::friendlyBackTab[i]); 00116 int w = fm.boundingRect(str).width() + 1; //### 00117 QImage textimg(w, h, QImage::Format_RGB32); 00118 textimg.fill(qRgb(255,255,255)); 00119 00120 QPainter p(&textimg); 00121 p.setPen(QColor(Qt::blue)); 00122 p.setFont(fnt); 00123 p.drawText(0, fm.ascent(), str); //### 00124 document()->addResource(QTextDocument::ImageResource, QUrl(QLatin1String(backTabImages[i])), textimg); 00125 00126 m_backTabOmages.insert(name, textimg); 00127 return textimg; 00128 } 00129 } 00130 } 00131 } 00132 return img; 00133 }
Here is the call graph for this function:

| void BackTabTextEdit::keyPressEvent | ( | QKeyEvent * | e | ) | [virtual] |
Reimplemented from QTextEdit.
Definition at line 142 of file msgedit.cpp.
References QEvent::accept(), QTextCursor::anchor(), QTextCursor::atBlockEnd(), QTextCursor::atBlockStart(), QTextCursor::atEnd(), QTextCursor::atStart(), QTextCursor::beginEditBlock(), QObject::blockSignals(), QTextCursor::charFormat(), QTextEdit::document(), QTextCursor::endEditBlock(), QTextCursor::insertBlock(), QTextCursor::insertImage(), QTextFormat::isImageFormat(), QTextCursor::KeepAnchor, QKeyEvent::key(), Qt::Key_Backspace, Qt::Key_Delete, Qt::Key_Enter, Qt::Key_Return, Qt::Key_Tab, Qt::KeypadModifier, QTextEdit::keyPressEvent(), QKeyEvent::modifiers(), QTextCursor::movePosition(), newlineImageName, QTextCursor::NextCharacter, Qt::NoModifier, QTextCursor::position(), QTextCursor::PreviousCharacter, QTextCursor::removeSelectedText(), tabImageName, and QTextEdit::textCursor().
00143 { 00144 bool eatevent = false; 00145 QTextCursor tc = textCursor(); 00146 if (e->modifiers() == Qt::NoModifier) { 00147 switch (e->key()) { 00148 case Qt::Key_Tab: { 00149 tc = textCursor(); 00150 tc.insertImage(QLatin1String(tabImageName)); 00151 eatevent = true; 00152 break; } 00153 case Qt::Key_Return: { 00154 tc = textCursor(); 00155 document()->blockSignals(true); 00156 tc.beginEditBlock(); 00157 tc.insertImage(QLatin1String(newlineImageName)); 00158 document()->blockSignals(false); 00159 tc.insertBlock(); 00160 tc.endEditBlock(); 00161 eatevent = true; 00162 break; } 00163 case Qt::Key_Backspace: 00164 if (tc.anchor() == tc.position()) { 00165 QTextCursor tc = textCursor(); 00166 if (!tc.atStart() && tc.atBlockStart()) { 00167 tc.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1); 00168 QTextCharFormat fmt = tc.charFormat(); 00169 if (fmt.isImageFormat()) { 00170 tc.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1); 00171 } 00172 tc.removeSelectedText(); 00173 eatevent = true; 00174 } 00175 } 00176 break; 00177 case Qt::Key_Delete: 00178 if (tc.anchor() == tc.position()) { 00179 QTextCursor tc = textCursor(); 00180 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 1); 00181 QTextCharFormat fmt = tc.charFormat(); 00182 if (fmt.isImageFormat()) { 00183 if (!tc.atEnd() && tc.atBlockEnd()) { 00184 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, 1); 00185 } 00186 tc.removeSelectedText(); 00187 eatevent = true; 00188 } 00189 } 00190 break; 00191 } 00192 } 00193 // Also accept Key_Enter on the numpad 00194 if (e->modifiers() == Qt::KeypadModifier && e->key() == Qt::Key_Enter) { 00195 tc = textCursor(); 00196 document()->blockSignals(true); 00197 tc.beginEditBlock(); 00198 tc.insertImage(QLatin1String(newlineImageName)); 00199 document()->blockSignals(false); 00200 tc.insertBlock(); 00201 tc.endEditBlock(); 00202 eatevent = true; 00203 } 00204 00205 00206 if (eatevent) e->accept(); 00207 else QTextEdit::keyPressEvent(e); 00208 }
Here is the call graph for this function:

| void BackTabTextEdit::focusInEvent | ( | QFocusEvent * | e | ) | [virtual] |
Reimplemented from QTextEdit.
Definition at line 135 of file msgedit.cpp.
References QTextEdit::focusInEvent(), TransEditor::gotFocusInEvent(), and QObject::parent().
00136 { 00137 TransEditor *te = qobject_cast<TransEditor*>(parent()); 00138 te->gotFocusInEvent(e); 00139 QTextEdit::focusInEvent(e); 00140 }
Here is the call graph for this function:

Definition at line 97 of file msgedit.cpp.
Definition at line 98 of file msgedit.cpp.
1.5.1