24 #undef KDE_NO_DEBUG_OUTPUT
35 #include <kcompletionbox.h>
37 #include <QStringBuilder>
39 #include <QPushButton>
42 #include <QApplication>
43 #include <QStyleOptionButton>
48 #include <QMouseEvent>
54 #undef KDE_NO_DEBUG_OUTPUT
58 inline static QImage
generateImage(
const QString& str,
const QFont& font)
63 QStyleOptionButton opt;
64 opt.fontMetrics=QFontMetrics(font);
66 opt.rect=opt.fontMetrics.boundingRect(opt.text).adjusted(0,0,5,5);
69 QImage result(opt.rect.size(),QImage::Format_ARGB32);
71 QPainter painter(&result);
72 QApplication::style()->drawControl(QStyle::CE_PushButton,&opt,&painter);
79 class MyCompletionBox:
public KCompletionBox
82 MyCompletionBox(
QWidget* p):KCompletionBox(p){}
83 QSize sizeHint()
const;
85 bool eventFilter(
QObject* , QEvent* );
88 QSize MyCompletionBox::sizeHint()
const
90 int h = count()?(sizeHintForRow(0)):0;
91 h=qMin(count()*h,10*h) + 2*frameWidth();
92 int w = sizeHintForColumn(0) + verticalScrollBar()->width() + 2*frameWidth();
96 bool MyCompletionBox::eventFilter(
QObject*
object, QEvent* event)
98 if (event->type()==QEvent::KeyPress)
100 QKeyEvent* e =
static_cast<QKeyEvent*
>(event);
101 if (e->key()==Qt::Key_PageDown || e->key()==Qt::Key_PageUp)
107 return KCompletionBox::eventFilter(
object, event);
112 class XliffTextEditSpellInterface:
public KTextEditSpellInterface
116 ~XliffTextEditSpellInterface(){};
118 bool isSpellCheckingEnabled()
const {
return m_enabled;}
119 void setSpellCheckingEnabled(
bool enable);
120 bool shouldBlockBeSpellChecked(
const QString &block)
const{Q_UNUSED(block);
return true;}
126 XliffTextEditSpellInterface::XliffTextEditSpellInterface(
SyntaxHighlighter* highlighter)
127 : KTextEditSpellInterface()
128 , m_enabled(
Settings::autoSpellcheck())
129 , m_highlighter(highlighter)
131 m_highlighter->setActive(m_enabled);
134 void XliffTextEditSpellInterface::setSpellCheckingEnabled(
bool enable)
138 m_highlighter->setActive(enable);
145 , m_currentUnicodeNumber(0)
146 , m_langUsesSpaces(true)
153 setUndoRedoEnabled(
false);
154 setAcceptRichText(
false);
158 connect (document(), SIGNAL(contentsChange(
int,
int,
int)),
this, SLOT(contentsChanged(
int,
int,
int)));
161 connect (catalog,SIGNAL(signalFileLoaded()),
this, SLOT(fileLoaded()));
164 setSpellInterface(
new XliffTextEditSpellInterface(m_highlighter));
165 setHighlighter(m_highlighter);
168 void TranslationUnitTextEdit::fileLoaded()
172 QLocale langLocale(langCode);
174 m_highlighter->setCurrentLanguage(langLocale.name());
176 if (m_highlighter->currentLanguage().isEmpty()) {
177 m_highlighter->setCurrentLanguage(langCode);
181 Qt::LayoutDirection targetLanguageDirection=Qt::LeftToRight;
182 static QLocale::Language rtlLanguages[]={QLocale::Arabic, QLocale::Hebrew, QLocale::Urdu, QLocale::Persian, QLocale::Pashto};
183 int i=
sizeof(rtlLanguages)/
sizeof(QLocale::Arabic);
184 while (--i>=0 && langLocale.language()!=rtlLanguages[i])
187 targetLanguageDirection=Qt::RightToLeft;
188 setLayoutDirection(targetLanguageDirection);
194 static QLocale::Language noSpaceLanguages[]={QLocale::Chinese};
195 i=
sizeof(noSpaceLanguages)/
sizeof(QLocale::Chinese);
196 while (--i>=0 && langLocale.language()!=noSpaceLanguages[i])
198 m_langUsesSpaces=(i==-1);
209 disconnect (document(), SIGNAL(contentsChange(
int,
int,
int)),
this, SLOT(contentsChanged(
int,
int,
int)));
210 m_highlighter->rehighlight();
211 connect (document(), SIGNAL(contentsChange(
int,
int,
int)),
this, SLOT(contentsChanged(
int,
int,
int)));
212 viewport()->setBackgroundRole(approved?QPalette::Base:QPalette::AlternateBase);
218 bool untr=m_catalog->
isEmpty(m_currentPos);
228 bool untr=m_catalog->
isEmpty(m_currentPos);
239 docPosition.
part=m_part;
240 m_currentPos=docPosition;
243 QString target=catalogString.
string;
248 QTextCursor cursor=textCursor();
249 int pos=cursor.position();
250 int anchor=cursor.anchor();
260 disconnect (document(), SIGNAL(contentsChange(
int,
int,
int)),
this, SLOT(contentsChanged(
int,
int,
int)));
262 setContent(catalogString);
264 setContent(catalogString,refStr.
string.isEmpty()?m_catalog->
sourceWithTags(docPosition):refStr);
265 connect (document(), SIGNAL(contentsChange(
int,
int,
int)),
this, SLOT(contentsChanged(
int,
int,
int)));
267 _oldMsgstrAscii=document()->toPlainText();
270 QTextCursor t=textCursor();
271 t.movePosition(QTextCursor::Start);
276 t.setPosition(anchor,QTextCursor::MoveAnchor);
277 int length=pos-anchor;
279 t.movePosition(length<0?QTextCursor::PreviousCharacter:QTextCursor::NextCharacter,QTextCursor::KeepAnchor,qAbs(length));
287 return catalogString;
296 document()->blockSignals(
true);
299 QTextCursor c=textCursor();
302 document()->blockSignals(
false);
308 m_highlighter->rehighlight();
314 virtual int operator()(
const QString& str,
int startingPos);
317 int SearchFunctor::operator()(
const QString& str,
int startingPos)
322 struct AlternativeSearchFunctor:
public SearchFunctor
324 int operator()(
const QString& str,
int startingPos);
327 int AlternativeSearchFunctor::operator()(
const QString& str,
int startingPos)
330 int diffStartPos=str.indexOf(
"{KBABEL", startingPos);
331 int diffEndPos=str.indexOf(
"{/KBABEL", startingPos);
333 int diffPos=qMin(diffStartPos,diffEndPos);
335 diffPos=qMax(diffStartPos,diffEndPos);
337 int result=qMin(tagPos,diffPos);
339 result=qMax(tagPos,diffPos);
347 QTextCharFormat chF=cursor.charFormat();
348 QFont font=cursor.document()->defaultFont();
351 QMap<int,int> posToTag;
352 int i=catStr.
tags.size();
357 posToTag.insert(catStr.
tags.at(i).start,i);
358 posToTag.insert(catStr.
tags.at(i).end,i);
361 QMap<QString,int> sourceTagIdToIndex=refStr.
tagIdToIndex();
362 int refTagIndexOffset=sourceTagIdToIndex.size();
369 SearchFunctor nextStopSymbol=AlternativeSearchFunctor();
371 while ((i = nextStopSymbol(catStr.
string, i)) != -1)
376 if (catStr.
string.at(i+1)==
'/')
378 else if (catStr.
string.at(i+8)==
'D')
386 cursor.insertText(catStr.
string.mid(prev,i-prev));
389 cursor.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor,i-prev);
393 if (!posToTag.contains(i))
398 int tagIndex=posToTag.value(i);
407 text=QString::number(sourceTagIdToIndex.contains(tag.
id)?sourceTagIdToIndex.value(tag.
id):(tagIndex+refTagIndexOffset));
415 name.append(
"-start");
424 if (cursor.document()->resource(QTextDocument::ImageResource, QUrl(name)).isNull())
425 cursor.document()->addResource(QTextDocument::ImageResource, QUrl(name),
generateImage(text,font));
426 cursor.insertImage(name);
427 cursor.setCharFormat(chF);
431 cursor.insertText(catStr.
string.mid(prev));
436 void TranslationUnitTextEdit::contentsChanged(
int offset,
int charsRemoved,
int charsAdded)
440 const QString& editTextAscii=document()->toPlainText();
441 if (editTextAscii==_oldMsgstrAscii)
450 if (KDE_ISUNLIKELY( m_currentPos.
entry==-1 || editText==_oldMsgstr ))
457 if (charsRemoved==0 && editText.isEmpty() && _oldMsgstr.length())
458 charsRemoved=_oldMsgstr.length();
459 if (charsAdded && editText.isEmpty())
461 if (charsRemoved && _oldMsgstr.isEmpty())
469 const QString& addedText=editText.mid(offset,charsAdded);
474 bool markupRemoved=charsRemoved && QString::fromRawData(target.unicode()+offset,charsRemoved).contains(
TAGRANGE_IMAGE_SYMBOL);
476 if (markupRemoved || markupAdded)
481 if (!charsAdded && charsRemoved==1)
483 int i=targetWithTags.
tags.size();
486 if (targetWithTags.
tags.at(i).start==offset || targetWithTags.
tags.at(i).end==offset)
494 else if (!markupAdded)
497 if (modified&&charsAdded)
513 m_catalog->
push(
new DelTextCmd(m_catalog,pos,_oldMsgstr.mid(offset,charsRemoved)));
516 _oldMsgstrAscii=editTextAscii;
530 requestToggleApprovement();
542 if (wordCompletionLength>=3 && len>=wordCompletionLength)
543 doCompletion(offset+1);
544 else if (m_completionBox)
545 m_completionBox->hide();
547 else if (m_completionBox)
548 m_completionBox->hide();
556 if (KDE_ISUNLIKELY( m_currentPos.
entry==-1 ))
562 requestToggleApprovement();
579 QHash<QString,int> id2tagIndex;
580 int i=source.
tags.size();
582 id2tagIndex.insert(source.
tags.at(i).id,i);
586 if (id2tagIndex.contains(tag.
id))
587 source.
tags[id2tagIndex.value(target.
tags.at(i).id)].
id=
"REMOVEME";
591 i=source.
tags.size();
593 if (source.
tags.at(i).id==
"REMOVEME")
594 source.
tags.removeAt(i);
605 QTextCursor cursor=textCursor();
606 cursor.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor,catStr.
string.size());
607 setTextCursor(cursor);
615 QMimeData *mimeData =
new QMimeData;
619 QTextCursor cursor=textCursor();
620 int start=qMin(cursor.anchor(),cursor.position());
621 int end=qMax(cursor.anchor(),cursor.position());
623 QMap<int,int> tagPlaces;
628 catalogString.
string=catalogString.
string.mid(start,end-start);
630 QList<InlineTag>::iterator it=catalogString.
tags.begin();
631 while (it != catalogString.
tags.end())
633 if (!tagPlaces.contains(it->start))
634 it=catalogString.
tags.erase(it);
644 QDataStream out(&a,QIODevice::WriteOnly);
646 qVariantSetValue<CatalogString>(v,catalogString);
648 mimeData->setData(
"application/x-lokalize-xliff+xml",a);
651 QString text=catalogString.
string;
653 mimeData->setText(text);
662 if (source->hasFormat(
"application/x-lokalize-xliff+xml"))
666 QByteArray data=source->data(
"application/x-lokalize-xliff+xml");
667 QDataStream in(&data,QIODevice::ReadOnly);
672 m_catalog->beginMacro(i18nc(
"@item Undo action item",
"Insert text with markup"));
673 QTextCursor cursor=textCursor();
674 if (cursor.hasSelection())
676 start=qMin(cursor.anchor(),cursor.position());
677 int end=qMax(cursor.anchor(),cursor.position());
679 cursor.setPosition(start);
680 setTextCursor(cursor);
686 mimeData.setText(
"");
687 KTextEdit::insertFromMimeData(&mimeData);
688 start=textCursor().position();
692 m_catalog->endMacro();
696 QString text=source->text();
698 insertPlainText(text);
721 if(col == 0 || str.isEmpty())
727 while(pos >= 0 && str.at(pos) ==
'\\')
733 return !(bool)(counter%2);
740 if(keyEvent->matches(QKeySequence::MoveToPreviousPage))
742 else if(keyEvent->matches(QKeySequence::MoveToNextPage))
744 else if(keyEvent->matches(QKeySequence::Undo))
746 else if(keyEvent->matches(QKeySequence::Redo))
748 else if(keyEvent->matches(QKeySequence::Find))
750 else if(keyEvent->matches(QKeySequence::FindNext))
752 else if(keyEvent->matches(QKeySequence::Replace))
754 else if (keyEvent->modifiers() == (Qt::AltModifier|Qt::ControlModifier))
756 if(keyEvent->key()==Qt::Key_Home)
758 else if(keyEvent->key()==Qt::Key_End)
762 return KTextEdit::keyPressEvent(keyEvent);
766 else if( (keyEvent->modifiers()&Qt::AltModifier)
767 &&!keyEvent->text().isEmpty()
768 &&keyEvent->text().at(0).isDigit() )
770 QString text=keyEvent->text();
771 while (!text.isEmpty()&& text.at(0).isDigit() )
773 m_currentUnicodeNumber = 10*m_currentUnicodeNumber+(text.at(0).digitValue());
776 KTextEdit::keyPressEvent(keyEvent);
780 else if (!keyEvent->modifiers()&&(keyEvent->key()==Qt::Key_Backspace||keyEvent->key()==Qt::Key_Delete))
785 if (KDE_ISUNLIKELY( !m_catalog->
isApproved(m_currentPos.
entry) && !textCursor().hasSelection() )
786 && ((textCursor().atStart()&&keyEvent->key()==Qt::Key_Backspace)
787 ||(textCursor().atEnd()&&keyEvent->key()==Qt::Key_Delete) ))
788 requestToggleApprovement();
790 KTextEdit::keyPressEvent(keyEvent);
792 else if( keyEvent->key() == Qt::Key_Space && (keyEvent->modifiers()&Qt::AltModifier) )
793 insertPlainText(QChar(0x00a0U));
794 else if( keyEvent->key() == Qt::Key_Minus && (keyEvent->modifiers()&Qt::AltModifier) )
795 insertPlainText(QChar(0x0000AD));
796 else if (m_catalog->
mimetype()!=
"text/x-gettext-translation")
797 KTextEdit::keyPressEvent(keyEvent);
799 else if(keyEvent->key()==Qt::Key_Return||keyEvent->key()==Qt::Key_Enter)
801 if (m_completionBox&&m_completionBox->isVisible())
803 if (m_completionBox->currentItem())
804 completionActivated(m_completionBox->currentItem()->text());
806 kWarning()<<
"avoided a crash. a case for bug 238835!";
807 m_completionBox->hide();
811 QTextCursor t=textCursor();
812 int pos=t.position();
814 if( keyEvent->modifiers()&Qt::ShiftModifier )
818 &&str.at(pos-1)==
'\\'
828 else if(!(keyEvent->modifiers()&Qt::ControlModifier))
833 &&!str.at(pos-1).isSpace())
835 if(str.at(pos-1)==
'\\'
839 if(pos<2||str.midRef(pos-2,2)!=
"\\n")
842 else if(str.isEmpty())
850 insertPlainText(ins);
853 KTextEdit::keyPressEvent(keyEvent);
855 else if( (keyEvent->modifiers()&Qt::ControlModifier)?
856 (keyEvent->key()==Qt::Key_D) :
857 (keyEvent->key()==Qt::Key_Delete)
858 && textCursor().atEnd())
860 kWarning()<<
"workaround for Qt/X11 bug";
861 QTextCursor t=textCursor();
862 if(!t.hasSelection())
864 int pos=t.position();
867 if (pos==str.size()) --pos;
869 &&str.at(pos) ==
'\\'
881 else if( (!keyEvent->modifiers()&&keyEvent->key()==Qt::Key_Backspace)
882 || ( ( keyEvent->modifiers() & Qt::ControlModifier ) && keyEvent->key() == Qt::Key_H ) )
884 QTextCursor t=textCursor();
885 if(!t.hasSelection())
887 int pos=t.position();
889 if(!str.isEmpty() && pos>0 &&
spclChars.contains(str.at(pos-1)))
891 if(pos>1 && str.at(pos-2)==
'\\' && !
isMasked(str,pos-2))
893 t.deletePreviousChar();
894 t.deletePreviousChar();
901 KTextEdit::keyPressEvent(keyEvent);
903 else if(keyEvent->key() == Qt::Key_Tab)
904 insertPlainText(
"\\t");
906 KTextEdit::keyPressEvent(keyEvent);
911 if ( (e->key()==Qt::Key_Alt) && m_currentUnicodeNumber >= 32 )
913 insertPlainText(QChar( m_currentUnicodeNumber ));
914 m_currentUnicodeNumber=0;
917 KTextEdit::keyReleaseEvent(e);
922 QTextCursor cursor = textCursor();
923 cursor.select(QTextCursor::Document);
924 QString text=cursor.selectedText();
925 text.replace(QChar(8233),
'\n');
943 QTextCursor cursor=textCursor();
944 tag.
start=qMin(cursor.anchor(),cursor.position());
945 tag.
end=qMax(cursor.anchor(),cursor.position())+tag.
isPaired();
949 cursor.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor,tag.
end+1+tag.
isPaired());
953 int TranslationUnitTextEdit::strForMicePosIfUnderTag(QPoint mice,
CatalogString& str,
bool tryHarder)
955 QTextCursor cursor=cursorForPosition(mice);
956 int pos=cursor.position();
958 if (pos==-1 || pos>=str.
string.size())
return -1;
976 int result=str.
tags.size();
977 while(--result>=0 && str.
tags.at(result).start!=pos && str.
tags.at(result).end!=pos)
984 if (event->button()==Qt::LeftButton)
987 int pos=strForMicePosIfUnderTag(event->pos(),str);
995 KTextEdit::mouseReleaseEvent(event);
1002 int pos=strForMicePosIfUnderTag(event->pos(),str);
1005 QString xid=str.
tags.at(pos).xid;
1010 int entry=m_catalog->
unitById(xid);
1015 QAction* result=menu.exec(event->globalPos());
1018 kWarning()<<entry<<xid;
1028 if (textCursor().hasSelection())
1032 if (menu.exec(event->globalPos()))
1040 KTextEdit::contextMenuEvent(event);
1043 QTextCursor wordSelectCursor=cursorForPosition(event->pos());
1044 wordSelectCursor.select(QTextCursor::WordUnderCursor);
1045 if (m_highlighter->isWordMisspelled(wordSelectCursor.selectedText()))
1049 foreach(
const QString& s, m_highlighter->suggestionsForWord(wordSelectCursor.selectedText()))
1050 suggestions.addAction(s);
1051 if (!suggestions.isEmpty())
1053 QAction* answer=suggestions.exec(event->globalPos());
1056 m_catalog->beginMacro(i18nc(
"@item Undo action item",
"Replace text"));
1057 wordSelectCursor.insertText(answer->text());
1058 m_catalog->endMacro();
1072 return KTextEdit::wheelEvent(event);
1074 switch (event->modifiers())
1076 case Qt::ControlModifier:
1077 if (event->delta() > 0)
1082 case Qt::AltModifier:
1083 if (event->delta() > 0)
1088 case Qt::ControlModifier + Qt::ShiftModifier:
1089 if (event->delta() > 0)
1094 case Qt::ShiftModifier:
1095 return KTextEdit::wheelEvent(event);
1097 if (event->delta() > 0)
1106 QTextCursor wordSelectCursor=textCursor();
1107 wordSelectCursor.select(QTextCursor::WordUnderCursor);
1108 if (!m_highlighter->isWordMisspelled(wordSelectCursor.selectedText()))
1111 const QStringList& suggestions=m_highlighter->suggestionsForWord(wordSelectCursor.selectedText());
1112 if (suggestions.isEmpty())
1115 m_catalog->beginMacro(i18nc(
"@item Undo action item",
"Replace text"));
1116 wordSelectCursor.insertText(suggestions.first());
1117 m_catalog->endMacro();
1122 if (event->type()==QEvent::ToolTip)
1124 QHelpEvent *helpEvent =
static_cast<QHelpEvent *
>(
event);
1126 int pos=strForMicePosIfUnderTag(helpEvent->pos(),str,
true);
1129 QString tooltip=str.
tags.at(pos).displayName();
1130 QToolTip::showText(helpEvent->globalPos(),tooltip);
1134 QString langCode=m_highlighter->currentLanguage();
1135 bool nospell=langCode.isEmpty();
1138 QString tip=KGlobal::locale()->languageCodeToName(langCode)%
" ("%langCode%
")";
1140 tip+=
" - "%i18n(
"no spellcheck available");
1141 QToolTip::showText(helpEvent->globalPos(), tip);
1143 return KTextEdit::event(event);
1151 void TranslationUnitTextEdit::doTag(
bool immediate)
1157 int count=sourceWithTags.
tags.size();
1161 bool hasActive=
false;
1162 for (
int i=0;i<count;++i)
1165 txt=menu.addAction(QString::number(i));
1166 txt->setData(QVariant(i));
1167 if (!hasActive && !tagIdToIndex.contains(sourceWithTags.
tags.at(i).id))
1175 menu.setActiveAction(txt);
1178 if (immediate)
return;
1179 txt=menu.exec(mapToGlobal(cursorRect().bottomRight()));
1190 tag.setMinimal(
true);
1194 target.remove(
'\n');
1198 while ((pos=tag.indexIn(en,pos))!=-1)
1202 txt=menu.addAction(tag.cap(0));
1203 pos+=tag.matchedLength();
1205 if (posInMsgStr!=-1 && (posInMsgStr=target.indexOf(tag.cap(0),posInMsgStr))==-1)
1209 insertPlainText(txt->text());
1212 menu.setActiveAction(txt);
1213 }
else if (posInMsgStr!=-1)
1214 posInMsgStr+=tag.matchedLength();
1216 if (!txt || immediate)
1220 txt=menu.exec(mapToGlobal(cursorRect().bottomRight()));
1222 insertPlainText(txt->text());
1230 QString text=sourceWithTags.
string;
1232 QString ctxt=m_catalog->
context(m_currentPos.
entry).first();
1233 QRegExp delimiter(
"\\s*,\\s*");
1237 if( ctxt.startsWith(
"NAME OF TRANSLATORS" ) || text.startsWith(
"_: NAME OF TRANSLATORS\\n" ))
1240 if (!document()->isEmpty())
1245 else if( ctxt.startsWith(
"EMAIL OF TRANSLATORS" ) || text.startsWith(
"_: EMAIL OF TRANSLATORS\\n" )) {
1247 if (!document()->isEmpty())
1252 else if( text.startsWith(
"ROLES_OF_TRANSLATORS" ) )
1254 if (!document()->isEmpty())
1256 out+=
"<othercredit role=\\\"translator\\\">\n"
1257 "<firstname></firstname><surname></surname>\n"
1259 "</affiliation><contrib></contrib></othercredit>";
1261 else if( text.startsWith(
"CREDIT_FOR_TRANSLATORS" ) )
1263 if (!document()->isEmpty())
1271 m_catalog->beginMacro(i18nc(
"@item Undo action item",
"Copy source to target"));
1274 m_catalog->endMacro();
1276 showPos(m_currentPos,sourceWithTags,
false);
1278 requestToggleApprovement();
1280 if (!out.isEmpty()) {
1281 QTextCursor t=textCursor();
1282 t.movePosition(QTextCursor::End);
1288 void TranslationUnitTextEdit::requestToggleApprovement()
1293 bool skip=m_catalog->
isPlural(m_currentPos);
1297 DocPos pos(m_currentPos);
1308 QTextCursor t=textCursor();
1309 t.movePosition(QTextCursor::Start);
1314 void TranslationUnitTextEdit::doCompletion(
int pos)
1323 if (!m_completionBox)
1326 m_completionBox=
new MyCompletionBox(
this);
1327 connect(m_completionBox,SIGNAL(activated(QString)),
this,SLOT(completionActivated(QString)));
1328 m_completionBox->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Preferred);
1331 m_completionBox->setItems(s);
1332 if (s.size() && !s.first().isEmpty())
1334 m_completionBox->setCurrentRow(0);
1336 if (!m_completionBox->isVisible())
1337 m_completionBox->show();
1338 m_completionBox->resize(m_completionBox->sizeHint());
1339 m_completionBox->move(viewport()->mapToGlobal(cursorRect().bottomRight()));
1342 m_completionBox->hide();
1343 kDebug()<<
"hits generated in"<<a.elapsed()<<
"msecs";
1348 doCompletion(textCursor().anchor());
1351 void TranslationUnitTextEdit::completionActivated(
const QString& semiWord)
1353 QTextCursor cursor=textCursor();
1354 cursor.insertText(semiWord);
1355 setTextCursor(cursor);
1358 #include "xlifftextedit.moc"
QStringList context(const DocPosition &pos) const
void setApprovementState(bool a)
void contextMenuEvent(QContextMenuEvent *event)
QStringList makeCompletion(const QString &) const
TagRange is filled from document.
void reflectApprovementState()
CatalogString targetWithTags(const DocPosition &pos) const
static bool isPaired(InlineElement type)
bool removeTargetSubstring(int start=0, int end=-1, bool refresh=true)
how undo system works: undo() and redo() functions call appropriate private method of Catalog to chan...
void wheelEvent(QWheelEvent *event)
QString targetLangCode() const
void toggleApprovementRequested()
int numberOfPluralForms() const
#define TAGRANGE_IMAGE_SYMBOL
static QString authorLocalizedName()
Get authorLocalizedName.
void gotoNextFuzzyUntrRequested()
void keyPressEvent(QKeyEvent *keyEvent)
static Project * instance()
static CompletionStorage * instance()
void mouseReleaseEvent(QMouseEvent *event)
DocPosition currentPos() const
void approvedEntryDisplayed()
static bool mouseWheelGo()
Get MouseWheelGo.
void push(QUndoCommand *cmd)
static QString authorEmail()
Get authorEmail.
void doExplicitCompletion()
TranslationUnitTextEdit(Catalog *catalog, DocPosition::Part part, QWidget *parent=0)
static bool isMasked(const QString &str, uint col)
void cursorPositionChanged(int column)
void insertContent(QTextCursor &cursor, const CatalogString &catStr, const CatalogString &refStr, bool insertText)
CatalogString catalogString(const DocPosition &pos) const
static int wordCompletionLength()
Get WordCompletionLength.
bool isEmpty(uint index) const
bool fillTagPlaces(QMap< int, int > &tagPlaces, const CatalogString &catalogString, int start, int len)
CatalogString cmds helper function.
void gotoNextFuzzyRequested()
bool isModified(DocPos entry) const
This struct represents a position in a catalog.
bool event(QEvent *event)
void keyReleaseEvent(QKeyEvent *e)
QMap< QString, int > tagIdToIndex() const
void gotoPrevFuzzyRequested()
static QImage generateImage(const QString &str, const QFont &font)
void contentsModified(const DocPosition &)
void untranslatedEntryDisplayed()
bool isPlural(uint index) const
void gotoPrevFuzzyUntrRequested()
void translatedEntryDisplayed()
void tagInsertRequested(const InlineTag &tag)
void tmLookupRequested(DocPosition::Part, const QString &)
void emitCursorPositionChanged()
static bool autoApprove()
Get AutoApprove.
static QString spclChars("abfnrtv'?\\")
void adaptCatalogString(CatalogString &target, const CatalogString &ref)
prepares
static SettingsController * instance()
void gotoEntryRequested(const DocPosition &)
void insertCatalogString(CatalogString catStr, int start=0, bool refresh=true)
CatalogString showPos(DocPosition pos, const CatalogString &refStr=CatalogString(), bool keepCursor=true)
makes MsgEdit reflect current entry
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
CatalogString sourceWithTags(const DocPosition &pos) const
bool isApproved(uint index) const
int numberOfEntries() const
static void setAutoSpellcheck(bool v)
Set AutoSpellcheck.
simpler version of DocPosition for use in QMap
void gotoPrevUntranslatedRequested()
void insertTag(InlineTag tag)
This class represents a catalog It uses CatalogStorage interface to work with catalogs in different f...
void binaryUnitSelectRequested(const QString &)
QString sourceLangCode() const
void gotoFirstRequested()
void reflectUntranslatedState()
void gotoNextUntranslatedRequested()
QMimeData * createMimeDataFromSelection() const
void setSourceString(const QString &s)
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
void nonApprovedEntryDisplayed()
void insertFromMimeData(const QMimeData *source)
int unitById(const QString &id) const