1
/* ****************************************************************************
2
This file is part of KAider
4
Copyright (C) 2007 by Nick Shaforostoff <shafff@ukr.net>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
In addition, as a special exception, the copyright holders give
21
permission to link the code of this program with any edition of
22
the Qt library by Trolltech AS, Norway (or with modified versions
23
of Qt that use the same license as Qt), and distribute linked
24
combinations including the two. You must obey the GNU General
25
Public License in all respects for all of the code used other than
26
Qt. If you modify this file, you may extend this exception to
27
your version of the file, but you are not obligated to do so. If
28
you do not wish to do so, delete this exception statement from
31
**************************************************************************** */
32
#define KDE_NO_DEBUG_OUTPUT
34
#include "msgiddiffview.h"
42
#include <ktextedit.h>
46
MsgIdDiff::MsgIdDiff(QWidget* parent, Catalog* catalog)
47
: QDockWidget ( i18nc("@title:window","Original Diff"), parent)
48
, m_browser(new KTextEdit(this))
50
, m_normTitle(i18nc("@title:window","Original Diff"))
51
, m_hasInfoTitle(m_normTitle+" [*]")
56
setObjectName("msgIdDiff");
58
setToolTip(i18nc("@info:tooltip","Sometimes, if original is changed, its translation becomes <emphasis>fuzzy</emphasis>. This window shows the difference between new original string and the old one, so that you can see what changes should be applied to translation."));
60
m_browser->setReadOnly(true);
63
MsgIdDiff::~MsgIdDiff()
68
void MsgIdDiff::slotNewEntryDisplayed(uint index)
71
QTimer::singleShot(0,this,SLOT(process()));
74
void MsgIdDiff::process()
76
if (m_entry==m_prevEntry)
78
if (m_catalog->numberOfEntries()<=m_entry)
79
return;//because of Qt::QueuedConnection
82
QString oldStr(m_catalog->comment(m_entry));
83
if (!oldStr.contains("#|"))
88
setWindowTitle(m_normTitle);
97
setWindowTitle(m_hasInfoTitle);
99
QString newStr(m_catalog->msgid(m_entry));
101
oldStr.replace("#| msgid_plural \"","#| \"");
102
newStr.replace("#| msgid_plural \"","#| \"");
108
//get rid of other info (eg fuzzy marks)
109
oldStr.remove(QRegExp("\\#[^\\|][^\n]*\n"));
110
oldStr.remove(QRegExp("\\#[^\\|].*$"));
112
if (oldStr.contains("#| msgid \"\""))
114
oldStr.remove("#| \"");
115
oldStr.remove(QRegExp("\"\n"));
116
oldStr.remove(QRegExp("\"$"));
119
oldStr.replace("\\n"," \\n ");
120
newStr.replace("\\n"," \\n ");
121
oldStr.remove("#| msgid \"");
125
oldStr.remove("#| msgid \"");
126
oldStr.remove(QRegExp("\"$"));
127
oldStr.remove("\"\n");
130
QString result(wordDiff(oldStr,
132
Project::instance()->accel(),
133
Project::instance()->markup()
135
result.replace("\\n","\\n<br>");
137
m_browser->setHtml(result);
138
// m_browser->setPlainText(result);
140
// oldStr.replace("\\n","\\n\n");
141
// newStr.replace("\\n","\\n\n");
143
// kDebug()<<"ELA "<<time.elapsed();
146
#include "msgiddiffview.moc"