32 #include <ktextedit.h>
33 #include <ktextbrowser.h>
34 #include <kcombobox.h>
35 #include <kpushbutton.h>
38 #include <QStackedLayout>
40 #include <QStringListModel>
46 if (keyEvent->modifiers()& Qt::ControlModifier
47 && keyEvent->key()==Qt::Key_Return)
49 else if (keyEvent->key()==Qt::Key_Escape)
52 QPlainTextEdit::keyPressEvent(keyEvent);
57 , m_from(new KComboBox(this))
58 , m_fromLabel(new
QLabel(i18nc(
"@info:label",
"From:"),this))
62 setToolTip(i18nc(
"@info:tooltip",
"Save empty note to remove it"));
63 m_from->setToolTip(i18nc(
"@info:tooltip",
"Author of this note"));
64 m_from->setEditable(
true);
65 m_from->setModel(m_authors);
66 m_from->setAutoCompletion(
true);
67 m_from->completionObject(
true);
69 QVBoxLayout*
main=
new QVBoxLayout(
this);
70 QHBoxLayout* prop=
new QHBoxLayout;
71 main->addLayout(prop);
72 prop->addWidget(m_fromLabel);
73 prop->addWidget(m_from,42);
74 main->addWidget(m_edit);
76 KPushButton* ok=
new KPushButton(KStandardGuiItem::save(),
this);
77 KPushButton* cancel=
new KPushButton(KStandardGuiItem::discard(),
this);
78 ok->setToolTip(i18n(
"Ctrl+Enter"));
79 cancel->setToolTip(i18n(
"Esc"));
83 connect(ok,SIGNAL(clicked()),
this,SIGNAL(
accepted()));
84 connect(cancel,SIGNAL(clicked()),
this,SIGNAL(
rejected()));
86 QHBoxLayout* btns=
new QHBoxLayout;
87 main->addLayout(btns);
90 btns->addWidget(cancel);
95 m_fromLabel->setVisible(v);
96 m_from->setVisible(v);
101 m_note.
content=m_edit->toPlainText();
102 m_note.
from=m_from->currentText();
109 m_edit->setPlainText(note.
content);
110 QString from=note.
from;
112 m_from->setCurrentItem(from,
true);
119 m_authors->setStringList(authors);
120 m_from->completionObject()->insertItems(authors);
126 QTextCursor t=browser->textCursor();
127 t.movePosition(QTextCursor::End);
130 if (!notes.isEmpty())
132 t.insertHtml(i18nc(
"@info XLIFF notes representation",
"<b>Notes:</b>")+
"<br />");
134 foreach(
const Note& note, notes)
136 if (!note.
from.isEmpty())
137 t.insertHtml(
"<i>"+note.
from+
":</i> ");
140 realOffset=t.position();
142 if (!multiple && content.contains(
'\n')) content+=
'\n';
143 content.replace(
'\n',
"<br />");
144 content+=QString(
" (<a href=\"note:/%1\">").arg(i)+i18nc(
"link to edit note",
"edit...")+
"</a>)<br />";
145 t.insertHtml(content);
149 t.insertHtml(
"<a href=\"note:/add\">"+i18nc(
"link to add a note",
"Add...")+
"</a> ");
152 browser->insertHtml(
"<a href=\"note:/add\">"+i18nc(
"link to add a note",
"Add a note...")+
"</a> ");
157 #include "noteeditor.moc"
int main(int argc, char **argv)
static QString authorName()
Get authorName.
static QString content(QDomElement elem, ContentEditingData *data=0)
walks through XLIFF XML and performs actions depending on ContentEditingData:
NoteEditor(QWidget *parent)
static QString escape(QString str)
int displayNotes(KTextBrowser *browser, const QVector< Note > ¬es, int active, bool multiple)
void setNoteAuthors(const QStringList &)
void keyPressEvent(QKeyEvent *e)
void setFromFieldVisible(bool)
void setNote(const Note &, int idx)