• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

lokalize

  • sources
  • kde-4.14
  • kdesdk
  • lokalize
  • src
  • catalog
catalog.cpp
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3  This file contains parts of KBabel code
4 
5  Copyright (C) 1999-2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
6  2001-2005 by Stanislav Visnovsky <visnovsky@kde.org>
7  2006 by Nicolas Goutte <goutte@kde.org>
8  2007-2012 by Nick Shaforostoff <shafff@ukr.net>
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 
24  In addition, as a special exception, the copyright holders give
25  permission to link the code of this program with any edition of
26  the Qt library by Trolltech AS, Norway (or with modified versions
27  of Qt that use the same license as Qt), and distribute linked
28  combinations including the two. You must obey the GNU General
29  Public License in all respects for all of the code used other than
30  Qt. If you modify this file, you may extend this exception to
31  your version of the file, but you are not obligated to do so. If
32  you do not wish to do so, delete this exception statement from
33  your version.
34 
35 **************************************************************************** */
36 // #define KDE_NO_DEBUG_OUTPUT
37 
38 #include "catalog.h"
39 #include "catalog_private.h"
40 #include "project.h"
41 #include "projectmodel.h" //to notify about modification
42 
43 #include "catalogstorage.h"
44 #include "gettextstorage.h"
45 #include "gettextimport.h"
46 #include "gettextexport.h"
47 #include "xliffstorage.h"
48 #include "tsstorage.h"
49 
50 #include "mergecatalog.h"
51 
52 #include "version.h"
53 #include "prefs_lokalize.h"
54 #include "jobs.h"
55 
56 #include <threadweaver/ThreadWeaver.h>
57 
58 #include <QProcess>
59 #include <QString>
60 #include <QMap>
61 
62 #include <kdebug.h>
63 #include <kglobal.h>
64 #include <klocale.h>
65 #include <kdatetime.h>
66 
67 #include <kio/netaccess.h>
68 #include <ktemporaryfile.h>
69 
70 QString Catalog::supportedMimeFilters("text/x-gettext-translation application/x-xliff application/x-linguist");
71 
72 static const char* const extensions[]={".po",".pot",".xlf", ".ts"};
73 
74 static const char* const xliff_states[]={
75  I18N_NOOP("New"),I18N_NOOP("Needs translation"),I18N_NOOP("Needs full localization"),I18N_NOOP("Needs adaptation"),I18N_NOOP("Translated"),
76  I18N_NOOP("Needs translation review"),I18N_NOOP("Needs full localization review"),I18N_NOOP("Needs adaptation review"),I18N_NOOP("Final"),
77  I18N_NOOP("Signed-off")};
78 
79 const char* const* Catalog::states()
80 {
81  return xliff_states;
82 }
83 
84 QStringList Catalog::supportedExtensions()
85 {
86  QStringList result;
87  int i=sizeof(extensions)/sizeof(char*);
88  while (--i>=0)
89  result.append(QString(extensions[i]));
90  return result;
91 }
92 
93 bool Catalog::extIsSupported(const QString& path)
94 {
95  QStringList ext=supportedExtensions();
96  int i=ext.size();
97  while (--i>=0 && !path.endsWith(ext.at(i)))
98  ;
99  return i!=-1;
100 }
101 
102 Catalog::Catalog(QObject *parent)
103  : QUndoStack(parent)
104  , d(new CatalogPrivate(this))
105  , m_storage(0)
106 {
107  //cause refresh events for files modified from lokalize itself aint delivered automatically
108  connect(this,SIGNAL(signalFileSaved(KUrl)),
109  Project::instance()->model(),SLOT(slotFileSaved(KUrl)),Qt::QueuedConnection);
110 
111 
112  QTimer* t=&(d->_autoSaveTimer);
113  t->setInterval(5*60*1000);
114  t->setSingleShot(false);
115  connect(t, SIGNAL(timeout()), this,SLOT(doAutoSave()));
116  connect(this,SIGNAL(signalFileSaved()), t,SLOT(start()));
117  connect(this,SIGNAL(signalFileLoaded()), t,SLOT(start()));
118  connect(this,SIGNAL(indexChanged(int)),this,SLOT(setAutoSaveDirty()));
119  connect(Project::local(),SIGNAL(configChanged()),this,SLOT(projectConfigChanged()));
120 }
121 
122 Catalog::~Catalog()
123 {
124  clear();
125  delete d;
126  //delete m_storage; //deleted in clear();
127 }
128 
129 
130 void Catalog::clear()
131 {
132  setIndex(cleanIndex());//to keep TM in sync
133  QUndoStack::clear();
134  d->_errorIndex.clear();
135  d->_nonApprovedIndex.clear();
136  d->_emptyIndex.clear();
137  delete m_storage;m_storage=0;
138  d->_url.clear();
139  d->_lastModifiedPos=DocPosition();
140  d->_modifiedEntries.clear();
141 
142  while (!d->_altTransCatalogs.isEmpty())
143  d->_altTransCatalogs.takeFirst()->deleteLater();
144 
145  d->_altTranslations.clear();
146 /*
147  d->msgidDiffList.clear();
148  d->msgstr2MsgidDiffList.clear();
149  d->diffCache.clear();
150  */
151 }
152 
153 
154 
155 void Catalog::push(QUndoCommand* cmd)
156 {
157  generatePhaseForCatalogIfNeeded(this);
158  QUndoStack::push(cmd);
159 }
160 
161 
162 //BEGIN STORAGE TRANSLATION
163 
164 int Catalog::capabilities() const
165 {
166  if (KDE_ISUNLIKELY( !m_storage )) return 0;
167 
168  return m_storage->capabilities();
169 }
170 
171 int Catalog::numberOfEntries() const
172 {
173  if (KDE_ISUNLIKELY( !m_storage )) return 0;
174 
175  return m_storage->size();
176 }
177 
178 
179 static DocPosition alterForSinglePlural(const Catalog* th, DocPosition pos)
180 {
181  //if source lang is english (implied) and target lang has only 1 plural form (e.g. Chinese)
182  if (KDE_ISUNLIKELY(th->numberOfPluralForms()==1 && th->isPlural(pos)))
183  pos.form=1;
184  return pos;
185 }
186 
187 QString Catalog::msgid(const DocPosition& pos) const
188 {
189  if (KDE_ISUNLIKELY( !m_storage ))
190  return d->CatalogPrivate::_emptyStr;
191 
192  return m_storage->source(alterForSinglePlural(this, pos));
193 }
194 
195 QString Catalog::msgstr(const DocPosition& pos) const
196 {
197  if (KDE_ISUNLIKELY( !m_storage ))
198  return d->CatalogPrivate::_emptyStr;
199 
200  return m_storage->target(pos);
201 }
202 
203 CatalogString Catalog::sourceWithTags(const DocPosition& pos) const
204 {
205  if (KDE_ISUNLIKELY( !m_storage ))
206  return CatalogString();
207 
208  return m_storage->sourceWithTags(alterForSinglePlural(this, pos));
209 
210 }
211 CatalogString Catalog::targetWithTags(const DocPosition& pos) const
212 {
213  if (KDE_ISUNLIKELY( !m_storage ))
214  return CatalogString();
215 
216  return m_storage->targetWithTags(pos);
217 }
218 
219 CatalogString Catalog::catalogString(const DocPosition& pos) const
220 {
221  if (KDE_ISUNLIKELY( !m_storage ))
222  return CatalogString();
223 
224  return m_storage->catalogString(pos.part==DocPosition::Source?alterForSinglePlural(this, pos):pos);
225 }
226 
227 
228 QVector<Note> Catalog::notes(const DocPosition& pos) const
229 {
230  if (KDE_ISUNLIKELY( !m_storage ))
231  return QVector<Note>();
232 
233  return m_storage->notes(pos);
234 }
235 
236 QVector<Note> Catalog::developerNotes(const DocPosition& pos) const
237 {
238  if (KDE_ISUNLIKELY( !m_storage ))
239  return QVector<Note>();
240 
241  return m_storage->developerNotes(pos);
242 }
243 
244 Note Catalog::setNote(const DocPosition& pos, const Note& note)
245 {
246  if (KDE_ISUNLIKELY( !m_storage ))
247  return Note();
248 
249  return m_storage->setNote(pos,note);
250 }
251 
252 QStringList Catalog::noteAuthors() const
253 {
254  if (KDE_ISUNLIKELY( !m_storage ))
255  return QStringList();
256 
257  return m_storage->noteAuthors();
258 }
259 
260 void Catalog::attachAltTransCatalog(Catalog* altCat)
261 {
262  d->_altTransCatalogs.append(altCat);
263  if (numberOfEntries()!=altCat->numberOfEntries())
264  kWarning()<<altCat->url().prettyUrl()<<"has different number of entries";
265 }
266 
267 void Catalog::attachAltTrans(int entry, const AltTrans& trans)
268 {
269  d->_altTranslations.insert(entry, trans);
270 }
271 
272 QVector<AltTrans> Catalog::altTrans(const DocPosition& pos) const
273 {
274  QVector<AltTrans> result;
275  if (m_storage)
276  result=m_storage->altTrans(pos);
277 
278  foreach(Catalog* altCat, d->_altTransCatalogs)
279  {
280  if (pos.entry>=altCat->numberOfEntries())
281  {
282  kDebug()<<"ignoring"<<altCat->url().prettyUrl()<<"this time because"<<pos.entry<<"<"<<altCat->numberOfEntries();
283  continue;
284  }
285 
286  if (altCat->source(pos)!=source(pos))
287  {
288  kDebug()<<"ignoring"<<altCat->url().prettyUrl()<<"this time because <source>s don't match";
289  continue;
290  }
291 
292  QString target=altCat->msgstr(pos);
293  if (!target.isEmpty() && altCat->isApproved(pos))
294  {
295  result<<AltTrans();
296  result.last().target=target;
297  result.last().type=AltTrans::Reference;
298  result.last().origin=altCat->url().prettyUrl();
299  }
300  }
301  if (d->_altTranslations.contains(pos.entry))
302  result<<d->_altTranslations.value(pos.entry);
303  return result;
304 }
305 
306 QStringList Catalog::sourceFiles(const DocPosition& pos) const
307 {
308  if (KDE_ISUNLIKELY( !m_storage ))
309  return QStringList();
310 
311  return m_storage->sourceFiles(pos);
312 }
313 
314 QString Catalog::id(const DocPosition& pos) const
315 {
316  if (KDE_ISUNLIKELY( !m_storage ))
317  return d->CatalogPrivate::_emptyStr;
318 
319  return m_storage->id(pos);
320 }
321 
322 QStringList Catalog::context(const DocPosition& pos) const
323 {
324  if (KDE_ISUNLIKELY( !m_storage ))
325  return QStringList();
326 
327  return m_storage->context(pos);
328 }
329 
330 QString Catalog::setPhase(const DocPosition& pos, const QString& phase)
331 {
332  if (KDE_ISUNLIKELY( !m_storage ))
333  return QString();
334 
335  return m_storage->setPhase(pos,phase);
336 }
337 
338 
339 void Catalog::setActivePhase(const QString& phase, ProjectLocal::PersonRole role)
340 {
341  d->_phase=phase;
342  d->_phaseRole=role;
343  updateApprovedEmptyIndexCache();
344  emit activePhaseChanged();
345 }
346 
347 void Catalog::updateApprovedEmptyIndexCache()
348 {
349  if (KDE_ISUNLIKELY( !m_storage ))
350  return;
351 
352  //index cache TODO profile?
353  d->_nonApprovedIndex.clear();
354  d->_emptyIndex.clear();
355 
356  DocPosition pos(0);
357  const int limit=m_storage->size();
358  while (pos.entry<limit)
359  {
360  if (!isApproved(pos))
361  d->_nonApprovedIndex << pos.entry;
362  if (m_storage->isEmpty(pos))
363  d->_emptyIndex << pos.entry;
364 
365  ++(pos.entry);
366  }
367 
368  emit signalNumberOfFuzziesChanged();
369  emit signalNumberOfEmptyChanged();
370 }
371 
372 QString Catalog::phase(const DocPosition& pos) const
373 {
374  if (KDE_ISUNLIKELY( !m_storage ))
375  return QString();
376 
377  return m_storage->phase(pos);
378 }
379 
380 Phase Catalog::phase(const QString& name) const
381 {
382  return m_storage->phase(name);
383 }
384 
385 QList<Phase> Catalog::allPhases() const
386 {
387  return m_storage->allPhases();
388 }
389 
390 QVector<Note> Catalog::phaseNotes(const QString& phase) const
391 {
392  return m_storage->phaseNotes(phase);
393 }
394 
395 QVector<Note> Catalog::setPhaseNotes(const QString& phase, QVector<Note> notes)
396 {
397  return m_storage->setPhaseNotes(phase, notes);
398 }
399 
400 QMap<QString,Tool> Catalog::allTools() const
401 {
402  return m_storage->allTools();
403 }
404 
405 bool Catalog::isPlural(uint index) const
406 {
407  return m_storage && m_storage->isPlural(DocPosition(index));
408 }
409 
410 bool Catalog::isApproved(uint index) const
411 {
412  if (KDE_ISUNLIKELY( !m_storage ))
413  return false;
414 
415  bool extendedStates=m_storage->capabilities()&ExtendedStates;
416 
417  return (extendedStates&&::isApproved(state(DocPosition(index)),activePhaseRole()))
418  ||(!extendedStates&&m_storage->isApproved(DocPosition(index)));
419 }
420 
421 TargetState Catalog::state(const DocPosition& pos) const
422 {
423  if (KDE_ISUNLIKELY( !m_storage ))
424  return NeedsTranslation;
425 
426  if (m_storage->capabilities()&ExtendedStates)
427  return m_storage->state(pos);
428  else
429  return closestState(m_storage->isApproved(pos), activePhaseRole());
430 }
431 
432 bool Catalog::isEmpty(uint index) const
433 {
434  return m_storage && m_storage->isEmpty(DocPosition(index));
435 }
436 
437 bool Catalog::isEmpty(const DocPosition& pos) const
438 {
439  return m_storage && m_storage->isEmpty(pos);
440 }
441 
442 
443 bool Catalog::isEquivTrans(const DocPosition& pos) const
444 {
445  return m_storage && m_storage->isEquivTrans(pos);
446 }
447 
448 int Catalog::binUnitsCount() const
449 {
450  return m_storage?m_storage->binUnitsCount():0;
451 }
452 
453 int Catalog::unitById(const QString& id) const
454 {
455  return m_storage?m_storage->unitById(id):0;
456 }
457 
458 QString Catalog::mimetype()
459 {
460  if (KDE_ISUNLIKELY( !m_storage ))
461  return QString();
462 
463  return m_storage->mimetype();
464 }
465 
466 QString Catalog::sourceLangCode() const
467 {
468  if (KDE_ISUNLIKELY( !m_storage ))
469  return QString();
470 
471  return m_storage->sourceLangCode();
472 }
473 
474 QString Catalog::targetLangCode() const
475 {
476  if (KDE_ISUNLIKELY( !m_storage ))
477  return QString();
478 
479  return m_storage->targetLangCode();
480 }
481 
482 //END STORAGE TRANSLATION
483 
484 //BEGIN OPEN/SAVE
485 #define DOESNTEXIST -1
486 #define ISNTREADABLE -2
487 #define UNKNOWNFORMAT -3
488 
489 KAutoSaveFile* Catalog::checkAutoSave(const KUrl& url)
490 {
491  KAutoSaveFile* autoSave=0;
492  QList<KAutoSaveFile*> staleFiles = KAutoSaveFile::staleFiles(url);
493  foreach (KAutoSaveFile *stale, staleFiles)
494  {
495  if (stale->open(QIODevice::ReadOnly) && !autoSave)
496  {
497  autoSave=stale;
498  autoSave->setParent(this);
499  }
500  else
501  stale->deleteLater();
502  }
503  if (autoSave)
504  kWarning()<<"autoSave"<<autoSave->fileName();
505  return autoSave;
506 }
507 
508 int Catalog::loadFromUrl(const KUrl& url, const KUrl& saidUrl, int* fileSize, bool fast)
509 {
510  bool readOnly=false;
511  if (url.isLocalFile())
512  {
513  QFileInfo info(url.toLocalFile());
514  if(KDE_ISUNLIKELY( !info.exists() || info.isDir()) )
515  return DOESNTEXIST;
516  if(KDE_ISUNLIKELY( !info.isReadable() ))
517  return ISNTREADABLE;
518  readOnly=!info.isWritable();
519  }
520  else
521  return DOESNTEXIST;
522 
523 
524  QTime a;a.start();
525 
526  QString target;
527  //if(KDE_ISUNLIKELY( !KIO::NetAccess::download(url,target,NULL) ))
528  // return ISNTREADABLE;
529  //QFile* file=new QFile(target);
530  QFile* file=new QFile(url.toLocalFile());
531  file->deleteLater();//kung-fu
532  if (!file->open(QIODevice::ReadOnly))
533  return ISNTREADABLE;//TODO
534 
535  CatalogStorage* storage=0;
536  const QString& fileName=url.fileName();
537  if (fileName.endsWith(".po")||fileName.endsWith(".pot"))
538  storage=new GettextCatalog::GettextStorage;
539  else if (fileName.endsWith(".xlf")||fileName.endsWith(".xliff"))
540  storage=new XliffStorage;
541  else if (fileName.endsWith(".ts"))
542  storage=new TsStorage;
543  else
544  {
545  //try harder
546  QTextStream in(file);
547  int i=0;
548  bool gettext=false;
549  while (!in.atEnd()&& i<64 && !gettext)
550  gettext=in.readLine().contains("msgid");
551  if (gettext) storage=new GettextCatalog::GettextStorage;
552  else return UNKNOWNFORMAT;
553  }
554 
555  int line=storage->load(file);
556 
557  file->close();
558  KIO::NetAccess::removeTempFile(target);
559 
560  if (KDE_ISUNLIKELY(line!=0 || (!storage->size() && (line=-1) ) ))
561  {
562  delete storage;
563  return line;
564  }
565 
566  kWarning() <<"file opened in"<<a.elapsed();
567 
568  //ok...
569  clear();
570 
571  //commit transaction
572  m_storage=storage;
573 
574  updateApprovedEmptyIndexCache();
575 
576  d->_numberOfPluralForms = storage->numberOfPluralForms();
577  d->_autoSaveDirty=true;
578  d->_readOnly=readOnly;
579  d->_url=saidUrl.isEmpty()?url:saidUrl;
580 
581  if (!fast)
582  {
583  KAutoSaveFile* autoSave=checkAutoSave(d->_url);
584  d->_autoSaveRecovered=autoSave;
585  if (autoSave)
586  {
587  d->_autoSave->deleteLater();
588  d->_autoSave=autoSave;
589 
590  //restore 'modified' status for entries
591  MergeCatalog* mergeCatalog=new MergeCatalog(this,this);
592  int errorLine=mergeCatalog->loadFromUrl(KUrl::fromPath(autoSave->fileName()));
593  if (KDE_ISLIKELY(errorLine==0))
594  mergeCatalog->copyToBaseCatalog();
595  mergeCatalog->deleteLater();
596  }
597  else
598  d->_autoSave->setManagedFile(d->_url);
599  }
600 
601  if (fileSize)
602  *fileSize=file->size();
603 
604  emit signalFileLoaded();
605  emit signalFileLoaded(d->_url);
606  return 0;
607 }
608 
609 bool Catalog::save()
610 {
611  return saveToUrl(d->_url);
612 }
613 
614 //this function is not called if QUndoStack::isClean() !
615 bool Catalog::saveToUrl(KUrl url)
616 {
617  if (KDE_ISUNLIKELY( !m_storage ))
618  return true;
619 
620  bool nameChanged=false;
621  if (KDE_ISLIKELY( url.isEmpty() ))
622  url = d->_url;
623  else
624  nameChanged=true;
625 
626 
627  bool remote=!url.isLocalFile();
628  QFile* file;
629  if (KDE_ISUNLIKELY( remote ))
630  file=new KTemporaryFile();
631  else
632  {
633  QString localFilePath=url.toLocalFile();
634  QString localPath=QFileInfo(localFilePath).absolutePath();
635  if (!QFileInfo(localPath).exists())
636  if (!QDir::root().mkpath(localPath))
637  return false;
638  file=new QFile(localFilePath);
639  }
640  file->deleteLater(); //kung-fu ;)
641  if (KDE_ISUNLIKELY( !file->open(QIODevice::WriteOnly) )) //i18n("Wasn't able to open file %1",filename.ascii());
642  return false;
643 
644  bool belongsToProject=url.path().contains(Project::instance()->poDir());
645  if (KDE_ISUNLIKELY( !m_storage->save(file, belongsToProject) ))
646  return false;
647 
648  QString localFile=file->fileName();
649  file->close();
650  if (KDE_ISUNLIKELY(remote && !KIO::NetAccess::upload(localFile, url, NULL) ))
651  return false;
652 
653  d->_autoSave->remove();
654  setClean(); //undo/redo
655  if (nameChanged)
656  {
657  d->_url=url;
658  d->_autoSave->setManagedFile(url);
659  }
660  d->_autoSaveRecovered=false;
661 
662  //Settings::self()->setCurrentGroup("Bookmarks");
663  //Settings::self()->addItemIntList(d->_url.url(),d->_bookmarkIndex);
664 
665  emit signalFileSaved();
666  emit signalFileSaved(url);
667  return true;
668 /*
669  else if (status==NO_PERMISSIONS)
670  {
671  if (KMessageBox::warningContinueCancel(this,
672  i18n("You do not have permission to write to file:\n%1\n"
673  "Do you want to save to another file or cancel?", _currentURL.prettyUrl()),
674  i18n("Error"),KStandardGuiItem::save())==KMessageBox::Continue)
675  return fileSaveAs();
676 
677  }
678 */
679 }
680 
681 void Catalog::doAutoSave()
682 {
683  if (isClean()||!(d->_autoSaveDirty))
684  return;
685  if (KDE_ISUNLIKELY( !m_storage ))
686  return;
687  if (!d->_autoSave->open(QIODevice::WriteOnly))
688  {
689  emit signalFileAutoSaveFailed(d->_autoSave->fileName());
690  return;
691  }
692  qWarning()<<"doAutoSave"<<d->_autoSave->fileName();
693  m_storage->save(d->_autoSave);
694  d->_autoSave->close();
695  d->_autoSaveDirty=false;
696 }
697 
698 void Catalog::projectConfigChanged()
699 {
700  setActivePhase(activePhase(), Project::local()->role());
701 }
702 
703 QByteArray Catalog::contents()
704 {
705  QBuffer buf;
706  buf.open(QIODevice::WriteOnly);
707  m_storage->save(&buf);
708  buf.close();
709  return buf.data();
710 }
711 
712 //END OPEN/SAVE
713 
714 
715 
722 static void updateDB(
723  const QString& filePath,
724  const QString& ctxt,
725  const CatalogString& english,
726  const CatalogString& newTarget,
727  int form,
728  bool approved
729  //const DocPosition&,//for back tracking
730  )
731 {
732  TM::UpdateJob* j=new TM::UpdateJob(filePath,ctxt,english,newTarget,form,approved,
733  Project::instance()->projectID());
734  j->connect(j,SIGNAL(done(ThreadWeaver::Job*)),j,SLOT(deleteLater()));
735  ThreadWeaver::Weaver::instance()->enqueue(j);
736 }
737 
738 
739 //BEGIN UNDO/REDO
740 const DocPosition& Catalog::undo()
741 {
742  QUndoStack::undo();
743  return d->_lastModifiedPos;
744 }
745 
746 const DocPosition& Catalog::redo()
747 {
748  QUndoStack::redo();
749  return d->_lastModifiedPos;
750 }
751 
752 void Catalog::flushUpdateDBBuffer()
753 {
754  if (!Settings::autoaddTM())
755  return;
756 
757  DocPosition pos=d->_lastModifiedPos;
758  if (pos.entry==-1 || pos.entry>=numberOfEntries())
759  {
760  //nothing to flush
761  //kWarning()<<"nothing to flush or new file opened";
762  return;
763  }
764  if (Project::instance()->targetLangCode()!=targetLangCode())
765  {
766  kWarning()<<"not updating because target languages don't match";
767  return;
768  }
769  kWarning()<<"updating!!";
770  int form=-1;
771  if (isPlural(pos.entry))
772  form=pos.form;
773  updateDB(url().pathOrUrl(),
774  context(pos.entry).first(),
775  sourceWithTags(pos),
776  targetWithTags(pos),
777  form,
778  isApproved(pos.entry));
779 
780  d->_lastModifiedPos=DocPosition();
781 }
782 
783 void Catalog::setLastModifiedPos(const DocPosition& pos)
784 {
785  if (pos.entry>=numberOfEntries()) //bin-units
786  return;
787 
788  bool entryChanged=DocPos(d->_lastModifiedPos)!=DocPos(pos);
789  if (entryChanged)
790  flushUpdateDBBuffer();
791 
792  d->_lastModifiedPos=pos;
793 }
794 
795 bool CatalogPrivate::addToEmptyIndexIfAppropriate(CatalogStorage* storage, const DocPosition& pos, bool alreadyEmpty)
796 {
797  if ((!pos.offset)&&(storage->target(pos).isEmpty())&&(!alreadyEmpty))
798  {
799  insertInList(_emptyIndex,pos.entry);
800  return true;
801  }
802  return false;
803 }
804 
805 void Catalog::targetDelete(const DocPosition& pos, int count)
806 {
807  if (KDE_ISUNLIKELY( !m_storage ))
808  return;
809 
810  bool alreadyEmpty = m_storage->isEmpty(pos);
811  m_storage->targetDelete(pos,count);
812 
813  if (d->addToEmptyIndexIfAppropriate(m_storage,pos,alreadyEmpty))
814  emit signalNumberOfEmptyChanged();
815  emit signalEntryModified(pos);
816 }
817 
818 bool CatalogPrivate::removeFromUntransIndexIfAppropriate(CatalogStorage* storage, const DocPosition& pos)
819 {
820  if ((!pos.offset)&&(storage->isEmpty(pos)))
821  {
822  _emptyIndex.removeAll(pos.entry);
823  return true;
824  }
825  return false;
826 }
827 
828 void Catalog::targetInsert(const DocPosition& pos, const QString& arg)
829 {
830  if (KDE_ISUNLIKELY( !m_storage ))
831  return;
832 
833  if (d->removeFromUntransIndexIfAppropriate(m_storage,pos))
834  emit signalNumberOfEmptyChanged();
835 
836  m_storage->targetInsert(pos,arg);
837  emit signalEntryModified(pos);
838 }
839 
840 void Catalog::targetInsertTag(const DocPosition& pos, const InlineTag& tag)
841 {
842  if (KDE_ISUNLIKELY( !m_storage ))
843  return;
844 
845  if (d->removeFromUntransIndexIfAppropriate(m_storage,pos))
846  emit signalNumberOfEmptyChanged();
847 
848  m_storage->targetInsertTag(pos,tag);
849  emit signalEntryModified(pos);
850 }
851 
852 InlineTag Catalog::targetDeleteTag(const DocPosition& pos)
853 {
854  if (KDE_ISUNLIKELY( !m_storage ))
855  return InlineTag();
856 
857  bool alreadyEmpty = m_storage->isEmpty(pos);
858  InlineTag tag=m_storage->targetDeleteTag(pos);
859 
860  if (d->addToEmptyIndexIfAppropriate(m_storage,pos,alreadyEmpty))
861  emit signalNumberOfEmptyChanged();
862  emit signalEntryModified(pos);
863  return tag;
864 }
865 
866 void Catalog::setTarget(DocPosition pos, const CatalogString& s)
867 {
868  //TODO for case of markup present
869  m_storage->setTarget(pos, s.string);
870 }
871 
872 TargetState Catalog::setState(const DocPosition& pos, TargetState state)
873 {
874  bool extendedStates=m_storage->capabilities()&ExtendedStates;
875  bool approved=::isApproved(state,activePhaseRole());
876  if (KDE_ISUNLIKELY( !m_storage
877  || (extendedStates && m_storage->state(pos)==state)
878  || (!extendedStates && m_storage->isApproved(pos)==approved)))
879  return this->state(pos);
880 
881  TargetState prevState;
882  if (extendedStates)
883  {
884  prevState=m_storage->setState(pos,state);
885  d->_statesIndex[prevState].removeAll(pos.entry);
886  insertInList(d->_statesIndex[state],pos.entry);
887  }
888  else
889  {
890  prevState=closestState(!approved,activePhaseRole());
891  m_storage->setApproved(pos,approved);
892  }
893 
894  if (!approved)
895  insertInList(d->_nonApprovedIndex,pos.entry);
896  else
897  d->_nonApprovedIndex.removeAll(pos.entry);
898 
899  emit signalNumberOfFuzziesChanged();
900  emit signalEntryModified(pos);
901 
902  return prevState;
903 }
904 
905 Phase Catalog::updatePhase(const Phase& phase)
906 {
907  return m_storage->updatePhase(phase);
908 }
909 
910 void Catalog::setEquivTrans(const DocPosition& pos, bool equivTrans)
911 {
912  if (m_storage) m_storage->setEquivTrans(pos, equivTrans);
913 }
914 
915 bool Catalog::setModified(DocPos entry, bool modified)
916 {
917  if (modified)
918  {
919  if (d->_modifiedEntries.contains(entry))
920  return false;
921  d->_modifiedEntries.insert(entry);
922  }
923  else
924  d->_modifiedEntries.remove(entry);
925  return true;
926 }
927 
928 bool Catalog::isModified(DocPos entry) const
929 {
930  return d->_modifiedEntries.contains(entry);
931 }
932 
933 bool Catalog::isModified(int entry) const
934 {
935  if (!isPlural(entry))
936  return isModified(DocPos(entry,0));
937 
938  int f=numberOfPluralForms();
939  while(--f>=0)
940  if (isModified(DocPos(entry,f)))
941  return true;
942  return false;
943 }
944 
945 //END UNDO/REDO
946 
947 
948 
949 
950 int findNextInList(const QLinkedList<int>& list, int index)
951 {
952  int nextIndex=-1;
953  foreach(int key, list)
954  {
955  if (KDE_ISUNLIKELY( key>index ))
956  {
957  nextIndex = key;
958  break;
959  }
960  }
961  return nextIndex;
962 }
963 
964 int findPrevInList(const QLinkedList<int>& list, int index)
965 {
966  int prevIndex=-1;
967  foreach(int key, list)
968  {
969  if (KDE_ISUNLIKELY( key>=index ))
970  break;
971  prevIndex = key;
972  }
973  return prevIndex;
974 }
975 
976 void insertInList(QLinkedList<int>& list, int index)
977 {
978  QLinkedList<int>::Iterator it=list.begin();
979  while(it != list.end() && index > *it)
980  ++it;
981  list.insert(it,index);
982 }
983 
984 void Catalog::setBookmark(uint idx, bool set)
985 {
986  if (set)
987  insertInList(d->_bookmarkIndex,idx);
988  else
989  d->_bookmarkIndex.removeAll(idx);
990 }
991 
992 
993 bool isApproved(TargetState state, ProjectLocal::PersonRole role)
994 {
995  static const TargetState marginStates[]={Translated, Final, SignedOff};
996  return state>=marginStates[role];
997 }
998 
999 bool isApproved(TargetState state)
1000 {
1001  static const TargetState marginStates[]={Translated, Final, SignedOff};
1002  return state==marginStates[0] || state==marginStates[1] || state==marginStates[2];
1003 }
1004 
1005 TargetState closestState(bool approved, ProjectLocal::PersonRole role)
1006 {
1007  static const TargetState approvementStates[][3]={
1008  {NeedsTranslation, NeedsReviewTranslation, NeedsReviewTranslation},
1009  {Translated, Final, SignedOff}
1010  };
1011  return approvementStates[approved][role];
1012 }
1013 
1014 
1015 bool Catalog::isObsolete(int entry) const
1016 {
1017  if (KDE_ISUNLIKELY( !m_storage ))
1018  return false;
1019 
1020  return m_storage->isObsolete(entry);
1021 }
1022 
1023 
1024 #include "catalog.moc"
Catalog::context
QStringList context(const DocPosition &pos) const
Definition: catalog.cpp:322
XliffStorage
Definition: xliffstorage.h:32
QTimer::setInterval
void setInterval(int msec)
xliffstorage.h
DocPosition::part
Part part
Definition: pos.h:49
CatalogPrivate::_phase
QString _phase
Definition: catalog_private.h:107
MergeCatalog
Merge source container.
Definition: mergecatalog.h:71
project.h
ProjectLocal::PersonRole
PersonRole
Definition: projectlocal.h:13
Catalog::url
const KUrl & url() const
Definition: catalog.h:189
Catalog::targetWithTags
CatalogString targetWithTags(const DocPosition &pos) const
Definition: catalog.cpp:211
QUndoCommand
CatalogStorage::allPhases
virtual QList< Phase > allPhases() const
Definition: catalogstorage.h:79
Catalog::altTrans
QVector< AltTrans > altTrans(const DocPosition &pos) const
Definition: catalog.cpp:272
CatalogStorage::targetInsert
virtual void targetInsert(const DocPosition &pos, const QString &arg)=0
CatalogStorage::source
virtual QString source(const DocPosition &pos) const =0
flat-model interface (ignores XLIFF grouping)
QMap::contains
bool contains(const Key &key) const
CatalogPrivate::removeFromUntransIndexIfAppropriate
bool removeFromUntransIndexIfAppropriate(CatalogStorage *, const DocPosition &pos)
Definition: catalog.cpp:818
CatalogPrivate::_errorIndex
QLinkedList< int > _errorIndex
Definition: catalog_private.h:91
CatalogStorage::setState
virtual TargetState setState(const DocPosition &, TargetState)
Definition: catalogstorage.h:136
Catalog::contents
QByteArray contents()
Definition: catalog.cpp:703
Catalog::targetLangCode
QString targetLangCode() const
Definition: catalog.cpp:474
Catalog::loadFromUrl
int loadFromUrl(const KUrl &url, const KUrl &saidUrl=KUrl(), int *fileSize=0, bool fast=false)
Definition: catalog.cpp:508
Catalog::setEquivTrans
void setEquivTrans(const DocPosition &, bool equivTrans)
Definition: catalog.cpp:910
Catalog::supportedExtensions
static QStringList supportedExtensions()
Definition: catalog.cpp:84
Catalog::numberOfPluralForms
int numberOfPluralForms() const
Definition: catalog.h:150
QTextStream::readLine
QString readLine(qint64 maxlen)
isApproved
bool isApproved(TargetState state, ProjectLocal::PersonRole role)
Definition: catalog.cpp:993
QByteArray
CatalogPrivate::_modifiedEntries
QSet< DocPos > _modifiedEntries
Definition: catalog_private.h:105
CatalogStorage::catalogString
virtual CatalogString catalogString(const DocPosition &pos) const =0
CatalogPrivate::_bookmarkIndex
QLinkedList< int > _bookmarkIndex
Definition: catalog_private.h:93
Translated
Definition: state.h:36
Catalog::setState
TargetState setState(const DocPosition &pos, TargetState state)
Definition: catalog.cpp:872
CatalogStorage::targetInsertTag
virtual void targetInsertTag(const DocPosition &, const InlineTag &)
Definition: catalogstorage.h:76
QUndoStack::clear
void clear()
CatalogPrivate::_numberOfPluralForms
int _numberOfPluralForms
Definition: catalog_private.h:78
Catalog::m_storage
CatalogStorage * m_storage
Definition: catalog.h:243
CatalogStorage::setApproved
virtual void setApproved(const DocPosition &, bool approved)
Definition: catalogstorage.h:134
QLinkedList::begin
iterator begin()
QLinkedList::takeFirst
T takeFirst()
Catalog::signalNumberOfFuzziesChanged
void signalNumberOfFuzziesChanged()
QList::at
const T & at(int i) const
QMap< QString, Tool >
Project::instance
static Project * instance()
Definition: project.cpp:67
catalogstorage.h
QFile::fileName
QString fileName() const
generatePhaseForCatalogIfNeeded
void generatePhaseForCatalogIfNeeded(Catalog *catalog)
Definition: phase.cpp:47
QVector::last
T & last()
Catalog::isEmpty
bool isEmpty()
Definition: catalog.h:174
Catalog::phaseNotes
QVector< Note > phaseNotes(const QString &phase) const
Definition: catalog.cpp:390
ISNTREADABLE
#define ISNTREADABLE
Definition: catalog.cpp:486
CatalogStorage::notes
virtual QVector< Note > notes(const DocPosition &pos) const =0
Catalog::activePhaseRole
ProjectLocal::PersonRole activePhaseRole() const
Definition: catalog.h:120
Note
Definition: note.h:29
CatalogPrivate::_url
KUrl _url
url of the po-file, that belongs to this catalog
Definition: catalog_private.h:66
QLinkedList::insert
iterator insert(iterator before, const T &value)
Catalog::MergeCatalog
friend class MergeCatalog
Definition: catalog.h:255
Catalog::redo
virtual const DocPosition & redo()
Definition: catalog.cpp:746
Catalog::signalFileLoaded
Q_SCRIPTABLE void signalFileLoaded()
Catalog::push
void push(QUndoCommand *cmd)
Definition: catalog.cpp:155
CatalogPrivate::_autoSave
KAutoSaveFile * _autoSave
Definition: catalog_private.h:81
QBuffer
CatalogStorage::target
virtual QString target(const DocPosition &pos) const =0
Project::local
static ProjectLocal * local()
Definition: project.h:116
CatalogString::string
QString string
Definition: catalogstring.h:130
Catalog::save
bool save()
Definition: catalog.cpp:609
Catalog::binUnitsCount
int binUnitsCount() const
so DocPosition::entry may actually be < size()+binUnitsCount()
Definition: catalog.cpp:448
QSet::insert
const_iterator insert(const T &value)
tsstorage.h
CatalogStorage::isObsolete
virtual bool isObsolete(int entry) const
Definition: catalogstorage.h:138
Catalog::catalogString
CatalogString catalogString(const DocPosition &pos) const
Definition: catalog.cpp:219
QMap::clear
void clear()
Catalog::attachAltTrans
void attachAltTrans(int entry, const AltTrans &trans)
Definition: catalog.cpp:267
CatalogStorage::updatePhase
virtual Phase updatePhase(const Phase &)
Definition: catalogstorage.h:78
findPrevInList
int findPrevInList(const QLinkedList< int > &list, int index)
Definition: catalog.cpp:964
QDir::root
QDir root()
CatalogStorage::setTarget
virtual void setTarget(const DocPosition &pos, const QString &arg)=0
CatalogStorage::mimetype
virtual QString mimetype() const =0
Settings::autoaddTM
static bool autoaddTM()
Get AutoaddTM.
Definition: prefs_lokalize.h:331
QTime
CatalogPrivate::_phaseRole
ProjectLocal::PersonRole _phaseRole
Definition: catalog_private.h:108
Catalog::setActivePhase
void setActivePhase(const QString &phase, ProjectLocal::PersonRole role=ProjectLocal::Approver)
Definition: catalog.cpp:339
QFile
QLinkedList::end
iterator end()
Catalog::allPhases
QList< Phase > allPhases() const
Definition: catalog.cpp:385
CatalogStorage::phase
virtual QString phase(const DocPosition &pos) const
Definition: catalogstorage.h:94
QTextStream
CatalogStorage::sourceFiles
virtual QStringList sourceFiles(const DocPosition &pos) const =0
Catalog::activePhase
QString activePhase() const
Definition: catalog.h:119
QList::size
int size() const
NeedsTranslation
Definition: state.h:33
Catalog::isModified
bool isModified(DocPos entry) const
Definition: catalog.cpp:928
CatalogPrivate::_emptyIndex
QLinkedList< int > _emptyIndex
Definition: catalog_private.h:90
DocPosition::offset
uint offset
Definition: pos.h:51
DocPosition::entry
int entry
Definition: pos.h:48
Catalog::developerNotes
QVector< Note > developerNotes(const DocPosition &pos) const
Definition: catalog.cpp:236
Catalog::setModified
bool setModified(DocPos entry, bool modif)
Definition: catalog.cpp:915
Catalog::extIsSupported
static bool extIsSupported(const QString &path)
Definition: catalog.cpp:93
CatalogPrivate::_nonApprovedIndex
QLinkedList< int > _nonApprovedIndex
Definition: catalog_private.h:89
DocPosition
This struct represents a position in a catalog.
Definition: pos.h:38
CatalogStorage::phaseNotes
virtual QVector< Note > phaseNotes(const QString &phase) const
Definition: catalogstorage.h:96
QLinkedList< int >
Catalog::setTarget
void setTarget(DocPosition pos, const CatalogString &s)
Definition: catalog.cpp:866
Catalog::targetDeleteTag
InlineTag targetDeleteTag(const DocPosition &pos)
Definition: catalog.cpp:852
QTime::elapsed
int elapsed() const
Catalog::target
QString target(const DocPosition &pos) const
Definition: catalog.h:96
CatalogStorage::sourceWithTags
virtual CatalogString sourceWithTags(DocPosition pos) const =0
TsStorage
Definition: tsstorage.h:32
CatalogStorage::targetLangCode
QString targetLangCode() const
Definition: catalogstorage.h:149
QList::append
void append(const T &value)
Catalog::undo
virtual const DocPosition & undo()
Definition: catalog.cpp:740
QUndoStack::setIndex
void setIndex(int idx)
QTextStream::atEnd
bool atEnd() const
QTimer
QLinkedList::isEmpty
bool isEmpty() const
alterForSinglePlural
static DocPosition alterForSinglePlural(const Catalog *th, DocPosition pos)
Definition: catalog.cpp:179
CatalogStorage::sourceLangCode
QString sourceLangCode() const
Definition: catalogstorage.h:148
Catalog::signalFileSaved
Q_SCRIPTABLE void signalFileSaved()
catalog_private.h
QObject
CatalogPrivate::_lastModifiedPos
DocPosition _lastModifiedPos
Definition: catalog_private.h:103
Catalog::targetInsertTag
void targetInsertTag(const DocPosition &pos, const InlineTag &tag)
Definition: catalog.cpp:840
catalog.h
Catalog::isObsolete
bool isObsolete(int entry) const
Definition: catalog.cpp:1015
Catalog::noteAuthors
QStringList noteAuthors() const
Definition: catalog.cpp:252
Catalog::flushUpdateDBBuffer
void flushUpdateDBBuffer()
updates DB for _posBuffer and accompanying _originalForLastModified
Definition: catalog.cpp:752
QString::isEmpty
bool isEmpty() const
DocPosition::form
char form
Definition: pos.h:50
CatalogStorage::isEquivTrans
virtual bool isEquivTrans(const DocPosition &) const
Definition: catalogstorage.h:130
Catalog::doAutoSave
void doAutoSave()
Definition: catalog.cpp:681
CatalogStorage::targetWithTags
virtual CatalogString targetWithTags(DocPosition pos) const =0
CatalogStorage::developerNotes
virtual QVector< Note > developerNotes(const DocPosition &pos) const =0
QUndoStack::cleanIndex
int cleanIndex() const
NeedsReviewTranslation
Definition: state.h:37
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
QUndoStack::setClean
void setClean()
Catalog::isPlural
bool isPlural(uint index) const
Definition: catalog.cpp:405
QBuffer::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > flags)
QObject::deleteLater
void deleteLater()
QList::first
T & first()
CatalogStorage::binUnitsCount
virtual int binUnitsCount() const
Definition: catalogstorage.h:140
CatalogPrivate::_autoSaveTimer
QTimer _autoSaveTimer
Definition: catalog_private.h:80
Catalog::setPhaseNotes
QVector< Note > setPhaseNotes(const QString &phase, QVector< Note >)
Definition: catalog.cpp:395
QString
QList< Phase >
Catalog::setAutoSaveDirty
void setAutoSaveDirty()
Definition: catalog.h:209
mergecatalog.h
Catalog::d
CatalogPrivate * d
Definition: catalog.h:242
Catalog::checkAutoSave
virtual KAutoSaveFile * checkAutoSave(const KUrl &url)
Definition: catalog.cpp:489
Phase
Definition: phase.h:34
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
UNKNOWNFORMAT
#define UNKNOWNFORMAT
Definition: catalog.cpp:487
CatalogStorage
Abstract interface for storage of translation file.
Definition: catalogstorage.h:45
SignedOff
Definition: state.h:41
CatalogStorage::unitById
virtual int unitById(const QString &id) const
Definition: catalogstorage.h:141
Catalog::projectConfigChanged
void projectConfigChanged()
Definition: catalog.cpp:698
QStringList
QBuffer::data
const QByteArray & data() const
CatalogStorage::setPhaseNotes
virtual QVector< Note > setPhaseNotes(const QString &phase, QVector< Note > notes)
Definition: catalogstorage.h:97
CatalogStorage::setEquivTrans
virtual void setEquivTrans(const DocPosition &, bool equivTrans)
Definition: catalogstorage.h:131
QFileInfo
AltTrans::Reference
Definition: alttrans.h:33
QUndoStack::indexChanged
void indexChanged(int idx)
CatalogStorage::altTrans
virtual QVector< AltTrans > altTrans(const DocPosition &pos) const =0
Catalog::activePhaseChanged
void activePhaseChanged()
Final
Definition: state.h:40
Catalog::capabilities
int capabilities() const
Definition: catalog.cpp:164
xliff_states
static const char *const xliff_states[]
Definition: catalog.cpp:74
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QFile::size
virtual qint64 size() const
Catalog::phase
QString phase(const DocPosition &pos) const
Definition: catalog.cpp:372
Catalog::signalNumberOfEmptyChanged
void signalNumberOfEmptyChanged()
CatalogStorage::save
virtual bool save(QIODevice *device, bool belongsToProject=false)=0
Catalog::~Catalog
virtual ~Catalog()
Definition: catalog.cpp:122
Catalog::targetInsert
void targetInsert(const DocPosition &pos, const QString &arg)
Definition: catalog.cpp:828
QFile::close
virtual void close()
QSet::contains
bool contains(const T &value) const
Catalog::setNote
Note setNote(const DocPosition &pos, const Note &note)
pos.form is note number
Definition: catalog.cpp:244
version.h
updateDB
static void updateDB(const QString &filePath, const QString &ctxt, const CatalogString &english, const CatalogString &newTarget, int form, bool approved)
helper method to keep db in a good shape :) called on 1) entry switch 2) automatic editing code like ...
Definition: catalog.cpp:722
Catalog::msgid
QString msgid(const DocPosition &) const
Definition: catalog.cpp:187
CatalogString
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
Definition: catalogstring.h:128
jobs.h
Catalog::updatePhase
Phase updatePhase(const Phase &phase)
Definition: catalog.cpp:905
QUndoStack::isClean
bool isClean() const
CatalogPrivate::addToEmptyIndexIfAppropriate
bool addToEmptyIndexIfAppropriate(CatalogStorage *, const DocPosition &pos, bool alreadyEmpty)
Definition: catalog.cpp:795
QBuffer::close
virtual void close()
projectmodel.h
insertInList
void insertInList(QLinkedList< int > &list, int index)
Definition: catalog.cpp:976
Catalog::clear
void clear()
Definition: catalog.cpp:130
QUndoStack::redo
void redo()
QSet::remove
bool remove(const T &value)
ExtendedStates
Definition: catalogcapabilities.h:32
QVector
prefs_lokalize.h
Catalog::signalEntryModified
void signalEntryModified(const DocPosition &)
Catalog::attachAltTransCatalog
void attachAltTransCatalog(Catalog *)
Definition: catalog.cpp:260
CatalogStorage::isEmpty
virtual bool isEmpty(const DocPosition &) const =0
CatalogPrivate::_altTranslations
QMap< int, AltTrans > _altTranslations
Definition: catalog_private.h:99
CatalogStorage::isPlural
virtual bool isPlural(const DocPosition &) const =0
CatalogStorage::size
virtual int size() const =0
Catalog::sourceWithTags
CatalogString sourceWithTags(const DocPosition &pos) const
Definition: catalog.cpp:203
Catalog::id
QString id(const DocPosition &pos) const
Definition: catalog.cpp:314
DocPosition::Source
Definition: pos.h:43
CatalogStorage::setNote
virtual Note setNote(DocPosition pos, const Note &note)=0
Catalog::isApproved
bool isApproved(uint index) const
Definition: catalog.cpp:410
CatalogStorage::noteAuthors
virtual QStringList noteAuthors() const
Definition: catalogstorage.h:89
CatalogPrivate::_autoSaveRecovered
bool _autoSaveRecovered
Definition: catalog_private.h:83
Catalog::numberOfEntries
int numberOfEntries() const
Definition: catalog.cpp:171
Catalog::targetDelete
void targetDelete(const DocPosition &pos, int count)
Definition: catalog.cpp:805
CatalogPrivate::_statesIndex
QVector< QLinkedList< int > > _statesIndex
Definition: catalog_private.h:95
DocPos
simpler version of DocPosition for use in QMap
Definition: pos.h:82
QUndoStack
gettextexport.h
Catalog::source
QString source(const DocPosition &pos) const
Definition: catalog.h:95
CatalogStorage::targetDelete
virtual void targetDelete(const DocPosition &pos, int count)=0
edit operations used by undo/redo system and sync-mode
CatalogPrivate::_readOnly
bool _readOnly
Definition: catalog_private.h:85
Catalog::supportedMimeFilters
static QString supportedMimeFilters
Definition: catalog.h:259
CatalogStorage::allTools
virtual QMap< QString, Tool > allTools() const
Definition: catalogstorage.h:80
QUndoStack::undo
void undo()
CatalogStorage::load
virtual int load(QIODevice *device)=0
gettextstorage.h
QTime::start
void start()
Catalog
This class represents a catalog It uses CatalogStorage interface to work with catalogs in different f...
Definition: catalog.h:74
Catalog::state
TargetState state(const DocPosition &pos) const
Definition: catalog.cpp:421
QMap::insert
iterator insert(const Key &key, const T &value)
Catalog::sourceLangCode
QString sourceLangCode() const
Definition: catalog.cpp:466
CatalogStorage::capabilities
virtual int capabilities() const =0
Catalog::setBookmark
void setBookmark(uint, bool)
Definition: catalog.cpp:984
Catalog::mimetype
QString mimetype()
Definition: catalog.cpp:458
Catalog::states
static const char *const * states()
Definition: catalog.cpp:79
findNextInList
int findNextInList(const QLinkedList< int > &list, int index)
Definition: catalog.cpp:950
Catalog::Catalog
Catalog(QObject *parent)
Definition: catalog.cpp:102
gettextimport.h
Catalog::notes
QVector< Note > notes(const DocPosition &pos) const
Definition: catalog.cpp:228
Catalog::signalFileAutoSaveFailed
void signalFileAutoSaveFailed(const QString &)
QSet::clear
void clear()
Catalog::isEquivTrans
bool isEquivTrans(const DocPosition &) const
Definition: catalog.cpp:443
GettextCatalog::GettextStorage
Implementation of storage for Gettext PO.
Definition: gettextstorage.h:39
DOESNTEXIST
#define DOESNTEXIST
Definition: catalog.cpp:485
Catalog::sourceFiles
QStringList sourceFiles(const DocPosition &pos) const
Definition: catalog.cpp:306
Catalog::saveToUrl
bool saveToUrl(KUrl url)
Definition: catalog.cpp:615
CatalogPrivate
Definition: catalog_private.h:60
QFileInfo::absolutePath
QString absolutePath() const
Catalog::updateApprovedEmptyIndexCache
void updateApprovedEmptyIndexCache()
Definition: catalog.cpp:347
CatalogStorage::numberOfPluralForms
int numberOfPluralForms() const
Definition: catalogstorage.h:57
QLinkedList::removeAll
int removeAll(const T &value)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
TargetState
TargetState
Definition: state.h:30
CatalogStorage::state
virtual TargetState state(const DocPosition &) const
Definition: catalogstorage.h:135
Catalog::msgstr
virtual QString msgstr(const DocPosition &) const
Definition: catalog.cpp:195
Catalog::setLastModifiedPos
void setLastModifiedPos(const DocPosition &)
(EDITING) accessed from undo/redo code called BEFORE modification
Definition: catalog.cpp:783
Catalog::setPhase
QString setPhase(const DocPosition &pos, const QString &phase)
Definition: catalog.cpp:330
CatalogStorage::context
virtual QStringList context(const DocPosition &) const =0
Catalog::allTools
QMap< QString, Tool > allTools() const
Definition: catalog.cpp:400
AltTrans
Definition: alttrans.h:30
extensions
static const char *const extensions[]
Definition: catalog.cpp:72
CatalogStorage::targetDeleteTag
virtual InlineTag targetDeleteTag(const DocPosition &)
Definition: catalogstorage.h:77
InlineTag
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
Definition: catalogstring.h:44
CatalogStorage::setPhase
virtual QString setPhase(const DocPosition &pos, const QString &phase)
Definition: catalogstorage.h:93
QUndoStack::push
void push(QUndoCommand *cmd)
QLinkedList::append
void append(const T &value)
CatalogStorage::id
virtual QString id(const DocPosition &) const =0
entry id unique for this file
TM::UpdateJob
used to eliminate a lot of duplicate entries
Definition: jobs.h:196
Catalog::unitById
int unitById(const QString &id) const
Definition: catalog.cpp:453
QLinkedList::clear
void clear()
QMap::value
const T value(const Key &key) const
QTimer::setSingleShot
void setSingleShot(bool singleShot)
closestState
TargetState closestState(bool approved, ProjectLocal::PersonRole role)
Definition: catalog.cpp:1005
CatalogPrivate::_altTransCatalogs
QLinkedList< Catalog * > _altTransCatalogs
Definition: catalog_private.h:98
MergeCatalog::loadFromUrl
int loadFromUrl(const KUrl &url)
Definition: mergecatalog.cpp:163
CatalogPrivate::_autoSaveDirty
bool _autoSaveDirty
Definition: catalog_private.h:82
CatalogStorage::isApproved
virtual bool isApproved(const DocPosition &) const
Definition: catalogstorage.h:133
MergeCatalog::copyToBaseCatalog
void copyToBaseCatalog(DocPosition &pos)
Definition: mergecatalog.cpp:263
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

lokalize

Skip menu "lokalize"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal