• 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
editortab.cpp
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3 
4  Copyright (C) 2007-2012 by Nick Shaforostoff <shafff@ukr.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 **************************************************************************** */
23 
24 #include "editortab.h"
25 #include "actionproxy.h"
26 #include "editorview.h"
27 #include "catalog.h"
28 #include "pos.h"
29 #include "cmd.h"
30 #include "prefs_lokalize.h"
31 
32 #include "completionstorage.h"
33 
34 #define WEBQUERY_ENABLE
35 
36 //views
37 #include "msgctxtview.h"
38 #include "alttransview.h"
39 #include "mergeview.h"
40 #include "cataloglistview.h"
41 #include "glossaryview.h"
42 #ifdef WEBQUERY_ENABLE
43 #include "webqueryview.h"
44 #endif
45 #include "tmview.h"
46 #include "binunitsview.h"
47 
48 #include "phaseswindow.h"
49 #include "projectlocal.h"
50 #include "projectmodel.h"
51 
52 
53 #include "project.h"
54 #include "prefs.h"
55 
56 #include <kglobal.h>
57 #include <klocale.h>
58 #include <kicon.h>
59 #include <ktoolbarpopupaction.h>
60 #include <kmenubar.h>
61 #include <kstatusbar.h>
62 #include <kdebug.h>
63 
64 #if QT_VERSION >= 0x040400
65  #include <kfadewidgeteffect.h>
66 #endif
67 
68 
69 #include <kio/netaccess.h>
70 #include <kaction.h>
71 #include <kactioncollection.h>
72 #include <kstandardaction.h>
73 #include <kstandardshortcut.h>
74 #include <kxmlguifactory.h>
75 #include <kurl.h>
76 #include <kmenu.h>
77 #include <kactioncategory.h>
78 
79 #include <kinputdialog.h>
80 
81 #include <kfiledialog.h>
82 #include <kmessagebox.h>
83 #include <ktabbar.h>
84 
85 #include <QActionGroup>
86 #include <QMdiArea>
87 #include <QMdiSubWindow>
88 #include <QMenuBar>
89 
90 
91 #include <QDir>
92 #include <QTime>
93 #include <threadweaver/ThreadWeaver.h>
94 
95 
96 
97 
98 
99 EditorTab::EditorTab(QWidget* parent, bool valid)
100  : LokalizeSubwindowBase2(parent)
101  , _project(Project::instance())
102  , m_catalog(new Catalog(this))
103  , m_view(new EditorView(this,m_catalog/*,new keyEventHandler(this,m_catalog)*/))
104  , m_sonnetDialog(0)
105  , _spellcheckStartUndoIndex(0)
106  , _spellcheckStop(false)
107  , m_currentIsApproved(true)
108  , m_currentIsUntr(true)
109  , m_fullPathShown(false)
110  , m_doReplaceCalled(false)
111  , _find(0)
112  , _replace(0)
113  , m_syncView(0)
114  , m_syncViewSecondary(0)
115  , m_valid(valid)
116  , m_dbusId(-1)
117 {
118  //QTime chrono;chrono.start();
119 
120  setAcceptDrops(true);
121  setCentralWidget(m_view);
122  setupStatusBar(); //--NOT called from initLater() !
123  setupActions();
124 
125 
126  dbusObjectPath();
127 
128  connect(m_view, SIGNAL(signalChanged(uint)), this, SLOT(msgStrChanged())); msgStrChanged();
129  connect(SettingsController::instance(),SIGNAL(generalSettingsChanged()),m_view, SLOT(settingsChanged()));
130  connect(m_view->tabBar(),SIGNAL(currentChanged(int)),this,SLOT(switchForm(int)));
131 
132  connect(m_view, SIGNAL(gotoEntryRequested(DocPosition)),this,SLOT(gotoEntry(DocPosition)));
133  connect(m_view, SIGNAL(tmLookupRequested(DocPosition::Part,QString)), this, SLOT(lookupSelectionInTranslationMemory()));
134 
135  connect(this, SIGNAL(fileOpened()), this, SLOT(indexWordsForCompletion()),Qt::QueuedConnection);
136 
137  connect (m_catalog,SIGNAL(signalFileAutoSaveFailed(QString)),this,SLOT(fileAutoSaveFailedWarning(QString)));
138 
139 
140  //defer some work to make window appear earlier (~200 msec on my Core Duo)
141  //QTimer::singleShot(0,this,SLOT(initLater()));
142  //kWarning()<<chrono.elapsed();
143 }
144 
145 void EditorTab::initLater()
146 {
147 }
148 
149 EditorTab::~EditorTab()
150 {
151  if (!m_catalog->isEmpty())
152  {
153  emit fileAboutToBeClosed();
154  emit fileClosed();
155  emit fileClosed(currentFile());
156  }
157 
158  ids.removeAll(m_dbusId);
159 }
160 
161 
162 void EditorTab::setupStatusBar()
163 {
164  statusBarItems.insert(ID_STATUS_CURRENT,i18nc("@info:status message entry","Current: %1",0));
165  statusBarItems.insert(ID_STATUS_TOTAL,i18nc("@info:status message entries","Total: %1",0));
166  statusBarItems.insert(ID_STATUS_FUZZY,i18nc("@info:status message entries\n'fuzzy' in gettext terminology","Not ready: %1",0));
167  statusBarItems.insert(ID_STATUS_UNTRANS,i18nc("@info:status message entries","Untranslated: %1",0));
168  statusBarItems.insert(ID_STATUS_ISFUZZY,QString());
169 
170  connect(m_catalog,SIGNAL(signalNumberOfFuzziesChanged()),this,SLOT(numberOfFuzziesChanged()));
171  connect(m_catalog,SIGNAL(signalNumberOfEmptyChanged()),this,SLOT(numberOfUntranslatedChanged()));
172 }
173 
174 void LokalizeSubwindowBase::reflectNonApprovedCount(int count, int total)
175 {
176  QString text=i18nc("@info:status message entries\n'fuzzy' in gettext terminology","Not ready: %1", count);
177  if (count && total)
178  text+=i18nc("percentages in statusbar", " (%1%)", int(100.0*count/total));
179  statusBarItems.insert(ID_STATUS_FUZZY,text);
180 }
181 
182 void LokalizeSubwindowBase::reflectUntranslatedCount(int count, int total)
183 {
184  QString text=i18nc("@info:status message entries","Untranslated: %1", count);
185  if (count && total)
186  text+=i18nc("percentages in statusbar", " (%1%)", int(100.0*count/total));
187  statusBarItems.insert(ID_STATUS_UNTRANS,text);
188 }
189 
190 void EditorTab::numberOfFuzziesChanged()
191 {
192  reflectNonApprovedCount(m_catalog->numberOfNonApproved(),m_catalog->numberOfEntries());
193 }
194 
195 void EditorTab::numberOfUntranslatedChanged()
196 {
197  reflectUntranslatedCount(m_catalog->numberOfUntranslated(),m_catalog->numberOfEntries());
198 }
199 
200 void EditorTab::setupActions()
201 {
202  //all operations that can be done after initial setup
203  //(via QTimer::singleShot) go to initLater()
204 
205  setXMLFile("editorui.rc");
206 
207  KAction *action;
208  KActionCollection* ac=actionCollection();
209  KActionCategory* actionCategory;
210 
211  KActionCategory* file=new KActionCategory(i18nc("@title actions category","File"), ac);;
212  KActionCategory* nav=new KActionCategory(i18nc("@title actions category","Navigation"), ac);
213  KActionCategory* edit=new KActionCategory(i18nc("@title actions category","Editing"), ac);
214  KActionCategory* sync1=new KActionCategory(i18n("Synchronization 1"), ac);
215  KActionCategory* sync2=new KActionCategory(i18n("Synchronization 2"), ac);
216  KActionCategory* tm=new KActionCategory(i18n("Translation Memory"), ac);
217  KActionCategory* glossary=new KActionCategory(i18nc("@title actions category","Glossary"), actionCollection());
218  KActionCategory* tools=new KActionCategory(i18nc("@title actions category","Tools"), actionCollection());
219 
220 
221 
222 //BEGIN dockwidgets
223  int i=0;
224 
225  QVector<KAction*> altactions(ALTTRANS_SHORTCUTS);
226  Qt::Key altlist[ALTTRANS_SHORTCUTS]=
227  {
228  Qt::Key_1,
229  Qt::Key_2,
230  Qt::Key_3,
231  Qt::Key_4,
232  Qt::Key_5,
233  Qt::Key_6,
234  Qt::Key_7,
235  Qt::Key_8,
236  Qt::Key_9
237  };
238  KAction* altaction;
239  for (i=0;i<ALTTRANS_SHORTCUTS;++i)
240  {
241  altaction=tm->addAction(QString("alttrans_insert_%1").arg(i));
242  altaction->setShortcut(Qt::ALT+altlist[i]);
243  altaction->setText(i18nc("@action:inmenu","Insert alternate translation # %1",i));
244  altactions[i]=altaction;
245  }
246 
247  m_altTransView = new AltTransView(this,m_catalog,altactions);
248  addDockWidget(Qt::BottomDockWidgetArea, m_altTransView);
249  actionCollection()->addAction( QLatin1String("showmsgiddiff_action"), m_altTransView->toggleViewAction() );
250  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),m_altTransView,SLOT(slotNewEntryDisplayed(DocPosition)));
251  connect (m_altTransView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
252  connect (m_altTransView,SIGNAL(refreshRequested()),m_view,SLOT(gotoEntry()),Qt::QueuedConnection);
253  connect (m_catalog,SIGNAL(signalFileLoaded()),m_altTransView,SLOT(fileLoaded()));
254 
255  m_syncView = new MergeView(this,m_catalog,true);
256  addDockWidget(Qt::BottomDockWidgetArea, m_syncView);
257  sync1->addAction( QLatin1String("showmergeview_action"), m_syncView->toggleViewAction() );
258  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),m_syncView,SLOT(slotNewEntryDisplayed(DocPosition)));
259  connect (m_catalog,SIGNAL(signalFileLoaded()),m_syncView,SLOT(cleanup()));
260  connect (m_syncView,SIGNAL(gotoEntry(DocPosition,int)),
261  this,SLOT(gotoEntry(DocPosition,int)));
262 
263  m_syncViewSecondary = new MergeView(this,m_catalog,false);
264  addDockWidget(Qt::BottomDockWidgetArea, m_syncViewSecondary);
265  sync2->addAction( QLatin1String("showmergeviewsecondary_action"), m_syncViewSecondary->toggleViewAction() );
266  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),m_syncViewSecondary,SLOT(slotNewEntryDisplayed(DocPosition)));
267  connect (m_catalog,SIGNAL(signalFileLoaded()),m_syncViewSecondary,SLOT(cleanup()));
268  connect (m_catalog,SIGNAL(signalFileLoaded(KUrl)),m_syncViewSecondary,SLOT(mergeOpen(KUrl)),Qt::QueuedConnection);
269  connect (m_syncViewSecondary,SIGNAL(gotoEntry(DocPosition,int)),
270  this,SLOT(gotoEntry(DocPosition,int)));
271 
272  m_transUnitsView = new CatalogView(this,m_catalog);
273  addDockWidget(Qt::LeftDockWidgetArea, m_transUnitsView);
274  actionCollection()->addAction( QLatin1String("showcatalogtreeview_action"), m_transUnitsView->toggleViewAction() );
275  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),m_transUnitsView,SLOT(slotNewEntryDisplayed(DocPosition)));
276  connect (m_transUnitsView,SIGNAL(gotoEntry(DocPosition,int)),this,SLOT(gotoEntry(DocPosition,int)));
277  connect (m_transUnitsView,SIGNAL(escaped()),this,SLOT(setProperFocus()));
278  connect (m_syncView,SIGNAL(mergeCatalogPointerChanged(MergeCatalog*)),
279  m_transUnitsView, SLOT(setMergeCatalogPointer(MergeCatalog*)));
280 
281  m_notesView = new MsgCtxtView(this,m_catalog);
282  addDockWidget(Qt::LeftDockWidgetArea, m_notesView);
283  actionCollection()->addAction( QLatin1String("showmsgctxt_action"), m_notesView->toggleViewAction() );
284  connect(m_catalog,SIGNAL(signalFileLoaded()),m_notesView,SLOT(cleanup()));
285  connect(m_notesView,SIGNAL(srcFileOpenRequested(QString,int)),this,SLOT(dispatchSrcFileOpenRequest(QString,int)));
286  connect(m_view, SIGNAL(signalChanged(uint)), m_notesView, SLOT(removeErrorNotes()));
287  connect(m_notesView,SIGNAL(escaped()),this,SLOT(setProperFocus()));
288 
289  action=edit->addAction(QLatin1String("edit_addnote"),m_notesView,SLOT(addNoteUI()));
290  //action->setShortcut(Qt::CTRL+glist[i]);
291  action->setText(i18nc("@action:inmenu","Add a note"));
292 
293  QVector<KAction*> tmactions(TM_SHORTCUTS);
294  Qt::Key tmlist[TM_SHORTCUTS]=
295  {
296  Qt::Key_1,
297  Qt::Key_2,
298  Qt::Key_3,
299  Qt::Key_4,
300  Qt::Key_5,
301  Qt::Key_6,
302  Qt::Key_7,
303  Qt::Key_8,
304  Qt::Key_9,
305  Qt::Key_0
306  };
307  KAction* tmaction;
308  for (i=0;i<TM_SHORTCUTS;++i)
309  {
310 // action->setVisible(false);
311  tmaction=tm->addAction(QString("tmquery_insert_%1").arg(i));
312  tmaction->setShortcut(Qt::CTRL+tmlist[i]);
313  tmaction->setText(i18nc("@action:inmenu","Insert TM suggestion # %1",i));
314  tmactions[i]=tmaction;
315  }
316  TM::TMView* _tmView = new TM::TMView(this,m_catalog,tmactions);
317  addDockWidget(Qt::BottomDockWidgetArea, _tmView);
318  tm->addAction( QLatin1String("showtmqueryview_action"), _tmView->toggleViewAction() );
319  connect (_tmView,SIGNAL(refreshRequested()),m_view,SLOT(gotoEntry()),Qt::QueuedConnection);
320  connect (_tmView,SIGNAL(refreshRequested()),this,SLOT(msgStrChanged()),Qt::QueuedConnection);
321  connect (_tmView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
322  connect (_tmView,SIGNAL(fileOpenRequested(KUrl,QString,QString)),this,SIGNAL(fileOpenRequested(KUrl,QString,QString)));
323  connect (this,SIGNAL(fileAboutToBeClosed()),m_catalog,SLOT(flushUpdateDBBuffer()));
324  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),m_catalog,SLOT(flushUpdateDBBuffer()));
325  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),_tmView,SLOT(slotNewEntryDisplayed(DocPosition))); //do this after flushUpdateDBBuffer
326 
327  QVector<KAction*> gactions(GLOSSARY_SHORTCUTS);
328  Qt::Key glist[GLOSSARY_SHORTCUTS]=
329  {
330  Qt::Key_E,
331  Qt::Key_H,
332  // Qt::Key_G,
333  // Qt::Key_I,
334  // Qt::Key_J,
335  // Qt::Key_K,
336  Qt::Key_K,
337  Qt::Key_P,
338  Qt::Key_N,
339  // Qt::Key_Q,
340  // Qt::Key_R,
341  // Qt::Key_U,
342  // Qt::Key_V,
343  // Qt::Key_W,
344  // Qt::Key_X,
345  Qt::Key_Y,
346  // Qt::Key_Z,
347  Qt::Key_BraceLeft,
348  Qt::Key_BraceRight,
349  Qt::Key_Semicolon,
350  Qt::Key_Apostrophe
351  };
352  KAction* gaction;
353 // int i=0;
354  for (i=0;i<GLOSSARY_SHORTCUTS;++i)
355  {
356 // action->setVisible(false);
357  gaction=glossary->addAction(QString("glossary_insert_%1").arg(i));
358  gaction->setShortcut(Qt::CTRL+glist[i]);
359  gaction->setText(i18nc("@action:inmenu","Insert # %1 term translation",i));
360  gactions[i]=gaction;
361  }
362 
363  GlossaryNS::GlossaryView* _glossaryView = new GlossaryNS::GlossaryView(this,m_catalog,gactions);
364  addDockWidget(Qt::BottomDockWidgetArea, _glossaryView);
365  glossary->addAction( QLatin1String("showglossaryview_action"), _glossaryView->toggleViewAction() );
366  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),_glossaryView,SLOT(slotNewEntryDisplayed(DocPosition)));
367  connect (_glossaryView,SIGNAL(termInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
368 
369  gaction = glossary->addAction("glossary_define",this,SLOT(defineNewTerm()));
370  gaction->setText(i18nc("@action:inmenu","Define new term"));
371  _glossaryView->addAction(gaction);
372  _glossaryView->setContextMenuPolicy( Qt::ActionsContextMenu);
373 
374 
375  BinUnitsView* binUnitsView=new BinUnitsView(m_catalog,this);
376  addDockWidget(Qt::BottomDockWidgetArea, binUnitsView);
377  edit->addAction( QLatin1String("showbinunitsview_action"), binUnitsView->toggleViewAction() );
378  connect(m_view,SIGNAL(binaryUnitSelectRequested(QString)),binUnitsView,SLOT(selectUnit(QString)));
379 
380 
381 //#ifdef WEBQUERY_ENABLE
382 #if 0
383  QVector<KAction*> wqactions(WEBQUERY_SHORTCUTS);
384  Qt::Key wqlist[WEBQUERY_SHORTCUTS]=
385  {
386  Qt::Key_1,
387  Qt::Key_2,
388  Qt::Key_3,
389  Qt::Key_4,
390  Qt::Key_5,
391  Qt::Key_6,
392  Qt::Key_7,
393  Qt::Key_8,
394  Qt::Key_9,
395  Qt::Key_0,
396  };
397  KAction* wqaction;
398  for (i=0;i<WEBQUERY_SHORTCUTS;++i)
399  {
400 // action->setVisible(false);
401  wqaction=actionCollection()->addAction(QString("webquery_insert_%1").arg(i));
402  wqaction->setShortcut(Qt::CTRL+Qt::ALT+wqlist[i]);
403  //wqaction->setShortcut(Qt::META+wqlist[i]);
404  wqaction->setText(i18nc("@action:inmenu","Insert WebQuery result # %1",i));
405  wqactions[i]=wqaction;
406  }
407  WebQueryView* _webQueryView = new WebQueryView(this,m_catalog,wqactions);
408  addDockWidget(Qt::BottomDockWidgetArea, _webQueryView);
409  actionCollection()->addAction( QLatin1String("showwebqueryview_action"), _webQueryView->toggleViewAction() );
410  connect (this,SIGNAL(signalNewEntryDisplayed(DocPosition)),_webQueryView,SLOT(slotNewEntryDisplayed(DocPosition)));
411  connect (_webQueryView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
412 #endif
413 
414 
415 //END dockwidgets
416 
417 
418 
419 
420  actionCategory=file;
421 
422 // File
423  action=file->addAction(KStandardAction::Save,this, SLOT(saveFile()));
424  action->setEnabled(false);
425  connect (m_catalog,SIGNAL(cleanChanged(bool)),action,SLOT(setDisabled(bool)));
426  connect (m_catalog,SIGNAL(cleanChanged(bool)),this,SLOT(setModificationSign(bool)));
427  file->addAction(KStandardAction::SaveAs,this, SLOT(saveFileAs()));
428  //action = KStandardAction::quit(qApp, SLOT(quit()), ac);
429  //action->setText(i18nc("@action:inmenu","Close all Lokalize windows"));
430 
431  //KStandardAction::quit(kapp, SLOT(quit()), ac);
432  //KStandardAction::quit(this, SLOT(deleteLater()), ac);
433 
434  action = actionCategory->addAction("file_phases");
435  action->setText(i18nc("@action:inmenu","Phases..."));
436  connect(action, SIGNAL(triggered()), SLOT(openPhasesWindow()));
437 
438 #define ADD_ACTION_ICON(_name,_text,_shortcut,_icon)\
439  action = actionCategory->addAction(_name);\
440  action->setText(_text);\
441  action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::_shortcut));\
442  action->setIcon(KIcon(_icon));
443 
444 #define ADD_ACTION_SHORTCUT_ICON(_name,_text,_shortcut,_icon)\
445  action = actionCategory->addAction(_name);\
446  action->setText(_text);\
447  action->setShortcut(QKeySequence( _shortcut ));\
448  action->setIcon(KIcon(_icon));
449 
450 #define ADD_ACTION_SHORTCUT(_name,_text,_shortcut)\
451  action = actionCategory->addAction(_name);\
452  action->setText(_text);\
453  action->setShortcut(QKeySequence( _shortcut ));\
454 
455 
456 //Edit
457  actionCategory=edit;
458  action=edit->addAction(KStandardAction::Undo,this,SLOT(undo()));
459  connect(m_view->viewPort(),SIGNAL(undoRequested()),this,SLOT(undo()));
460  connect(m_catalog,SIGNAL(canUndoChanged(bool)),action,SLOT(setEnabled(bool)) );
461  action->setEnabled(false);
462 
463  action=edit->addAction(KStandardAction::Redo,this,SLOT(redo()));
464  connect(m_view->viewPort(),SIGNAL(redoRequested()),this,SLOT(redo()));
465  connect(m_catalog,SIGNAL(canRedoChanged(bool)),action,SLOT(setEnabled(bool)) );
466  action->setEnabled(false);
467 
468  action=nav->addAction(KStandardAction::Find,this,SLOT(find()));
469  action=nav->addAction(KStandardAction::FindNext,this,SLOT(findNext()));
470  action=nav->addAction(KStandardAction::FindPrev,this,SLOT(findPrev()));
471  action->setText(i18nc("@action:inmenu","Change searching direction"));
472  action=edit->addAction(KStandardAction::Replace,this,SLOT(replace()));
473 
474  connect(m_view,SIGNAL(findRequested()), this,SLOT(find()));
475  connect(m_view,SIGNAL(findNextRequested()), this,SLOT(findNext()));
476  connect(m_view,SIGNAL(replaceRequested()), this,SLOT(replace()));
477 
478 
479 //
480  action = actionCategory->addAction("edit_approve", new KToolBarPopupAction(KIcon("approved"),i18nc("@option:check whether message is marked as translated/reviewed/approved (depending on your role)","Approved"),this));
481  action->setShortcut(QKeySequence( Qt::CTRL+Qt::Key_U ));
482  action->setCheckable(true);
483  connect(action, SIGNAL(triggered()), m_view,SLOT(toggleApprovement()));
484  connect(m_view, SIGNAL(signalApprovedEntryDisplayed(bool)),this,SIGNAL(signalApprovedEntryDisplayed(bool)));
485  connect(this, SIGNAL(signalApprovedEntryDisplayed(bool)),action,SLOT(setChecked(bool)));
486  connect(this, SIGNAL(signalApprovedEntryDisplayed(bool)),this,SLOT(msgStrChanged()),Qt::QueuedConnection);
487  m_approveAction=action;
488  connect(Project::local(), SIGNAL(configChanged()), SLOT(setApproveActionTitle()));
489  connect(m_catalog, SIGNAL(activePhaseChanged()), SLOT(setApproveActionTitle()));
490  setApproveActionTitle();
491  connect(action->menu(), SIGNAL(aboutToShow()),this,SLOT(showStatesMenu()));
492  connect(action->menu(), SIGNAL(triggered(QAction*)),this,SLOT(setState(QAction*)));
493 
494 
495  action = actionCategory->addAction("edit_approve_go_fuzzyUntr");
496  action->setText(i18nc("@action:inmenu","Approve and go to next"));
497  connect(action, SIGNAL(triggered()), SLOT(toggleApprovementGotoNextFuzzyUntr()));
498 
499 
500  action = actionCategory->addAction("edit_nonequiv",m_view,SLOT(setEquivTrans(bool)));
501  action->setText(i18nc("@action:inmenu","Equivalent translation"));
502  action->setCheckable(true);
503  connect(this, SIGNAL(signalEquivTranslatedEntryDisplayed(bool)),action,SLOT(setChecked(bool)));
504 
505 
506  int copyShortcut=Qt::CTRL+Qt::Key_Space;
507  QString systemLang=KGlobal::locale()->language();
508  if (KDE_ISUNLIKELY( systemLang.startsWith("ko")
509  || systemLang.startsWith("ja")
510  || systemLang.startsWith("zh")
511  ))
512  copyShortcut=Qt::ALT+Qt::Key_Space;
513  ADD_ACTION_SHORTCUT_ICON("edit_msgid2msgstr",i18nc("@action:inmenu","Copy source to target"),copyShortcut,"msgid2msgstr")
514  connect(action, SIGNAL(triggered(bool)), m_view->viewPort(),SLOT(source2target()));
515 
516  ADD_ACTION_SHORTCUT("edit_unwrap-target",i18nc("@action:inmenu","Unwrap target"),Qt::CTRL+Qt::Key_I)
517  connect(action, SIGNAL(triggered(bool)), m_view,SLOT(unwrap()));
518 
519  action=edit->addAction("edit_clear-target",m_view->viewPort(),SLOT(removeTargetSubstring()));
520  action->setShortcut(Qt::CTRL+Qt::Key_D);
521  action->setText(i18nc("@action:inmenu","Clear"));
522 
523  action=edit->addAction("edit_completion",m_view,SIGNAL(doExplicitCompletion()));
524  action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_Space);
525  action->setText(i18nc("@action:inmenu","Completion"));
526 
527  action=edit->addAction("edit_tagmenu",m_view->viewPort(),SLOT(tagMenu()));
528  action->setShortcut(Qt::CTRL+Qt::Key_T);
529  action->setText(i18nc("@action:inmenu","Insert Tag"));
530 
531  action=edit->addAction("edit_tagimmediate",m_view->viewPort(),SLOT(tagImmediate()));
532  action->setShortcut(Qt::CTRL+Qt::Key_M);
533  action->setText(i18nc("@action:inmenu","Insert Next Tag"));
534 
535  action=edit->addAction("edit_spellreplace",m_view->viewPort(),SLOT(spellReplace()));
536  action->setShortcut(Qt::CTRL+Qt::Key_Equal);
537  action->setText(i18nc("@action:inmenu","Replace with best spellcheck suggestion"));
538 
539 // action = ac->addAction("glossary_define",m_view,SLOT(defineNewTerm()));
540 // action->setText(i18nc("@action:inmenu","Define new term"));
541 
542 // Go
543  actionCategory=nav;
544  action=nav->addAction(KStandardAction::Next,this, SLOT(gotoNext()));
545  action->setText(i18nc("@action:inmenu entry","&Next"));
546  connect( this, SIGNAL(signalLastDisplayed(bool)),action,SLOT(setDisabled(bool)));
547  connect(m_view->viewPort(),SIGNAL(gotoNextRequested()),this,SLOT(gotoNext()));
548 
549  action=nav->addAction(KStandardAction::Prior,this, SLOT(gotoPrev()));
550  action->setText(i18nc("@action:inmenu entry","&Previous"));
551  connect( this, SIGNAL(signalFirstDisplayed(bool)), action , SLOT(setDisabled(bool)) );
552  connect(m_view->viewPort(),SIGNAL(gotoPrevRequested()),this,SLOT(gotoPrev()));
553 
554  action=nav->addAction(KStandardAction::FirstPage,this, SLOT(gotoFirst()));
555  connect(m_view->viewPort(),SIGNAL(gotoFirstRequested()),this,SLOT(gotoFirst()));
556  action->setText(i18nc("@action:inmenu","&First Entry"));
557  action->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_Home));
558  connect( this, SIGNAL(signalFirstDisplayed(bool)), action , SLOT(setDisabled(bool)) );
559 
560  action=nav->addAction(KStandardAction::LastPage,this, SLOT(gotoLast()));
561  connect(m_view->viewPort(),SIGNAL(gotoLastRequested()),this,SLOT(gotoLast()));
562  action->setText(i18nc("@action:inmenu","&Last Entry"));
563  action->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_End));
564  connect( this, SIGNAL(signalLastDisplayed(bool)),action,SLOT(setDisabled(bool)));
565 
566  action=nav->addAction(KStandardAction::GotoPage,this, SLOT(gotoEntry()));
567  action->setShortcut(Qt::CTRL+Qt::Key_G);
568  action->setText(i18nc("@action:inmenu","Entry by number"));
569 
570  ADD_ACTION_SHORTCUT_ICON("go_prev_fuzzy",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Previous non-empty but not ready"),Qt::CTRL+Qt::Key_PageUp,"prevfuzzy")
571  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoPrevFuzzy()) );
572  connect( m_view->viewPort(), SIGNAL(gotoPrevFuzzyRequested()), this, SLOT(gotoPrevFuzzy()) );
573  connect( this, SIGNAL(signalPriorFuzzyAvailable(bool)),action,SLOT(setEnabled(bool)) );
574 
575  ADD_ACTION_SHORTCUT_ICON("go_next_fuzzy",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Next non-empty but not ready"),Qt::CTRL+Qt::Key_PageDown,"nextfuzzy")
576  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoNextFuzzy()) );
577  connect( m_view->viewPort(), SIGNAL(gotoNextFuzzyRequested()), this, SLOT(gotoNextFuzzy()) );
578  connect( this, SIGNAL(signalNextFuzzyAvailable(bool)),action,SLOT(setEnabled(bool)) );
579 
580  ADD_ACTION_SHORTCUT_ICON("go_prev_untrans",i18nc("@action:inmenu","Previous untranslated"),Qt::ALT+Qt::Key_PageUp,"prevuntranslated")
581  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoPrevUntranslated()));
582  connect( m_view->viewPort(), SIGNAL(gotoPrevUntranslatedRequested()), this, SLOT(gotoPrevUntranslated()) );
583  connect( this, SIGNAL(signalPriorUntranslatedAvailable(bool)),action,SLOT(setEnabled(bool)) );
584 
585  ADD_ACTION_SHORTCUT_ICON("go_next_untrans",i18nc("@action:inmenu","Next untranslated"),Qt::ALT+Qt::Key_PageDown,"nextuntranslated")
586  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoNextUntranslated()));
587  connect( m_view->viewPort(), SIGNAL(gotoNextUntranslatedRequested()), this, SLOT(gotoNextUntranslated()) );
588  connect( this, SIGNAL(signalNextUntranslatedAvailable(bool)),action,SLOT(setEnabled(bool)) );
589 
590  ADD_ACTION_SHORTCUT_ICON("go_prev_fuzzyUntr",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Previous not ready"),Qt::CTRL+Qt::SHIFT/*ALT*/+Qt::Key_PageUp,"prevfuzzyuntrans")
591  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoPrevFuzzyUntr()) );
592  connect( m_view->viewPort(), SIGNAL(gotoPrevFuzzyUntrRequested()), this, SLOT(gotoPrevFuzzyUntr()) );
593  connect( this, SIGNAL(signalPriorFuzzyOrUntrAvailable(bool)),action,SLOT(setEnabled(bool)) );
594 
595  ADD_ACTION_SHORTCUT_ICON("go_next_fuzzyUntr",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Next not ready"),Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown,"nextfuzzyuntrans")
596  connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoNextFuzzyUntr()) );
597  connect( m_view->viewPort(), SIGNAL(gotoNextFuzzyUntrRequested()), this, SLOT(gotoNextFuzzyUntr()) );
598  connect( this, SIGNAL(signalNextFuzzyOrUntrAvailable(bool)),action,SLOT(setEnabled(bool)) );
599 
600  action=nav->addAction("go_focus_earch_line",m_transUnitsView, SLOT(setFocus()));
601  action->setShortcut(Qt::CTRL+Qt::Key_L);
602  action->setText(i18nc("@action:inmenu","Focus the search line of Translation Units view"));
603 
604 
605 //Bookmarks
606  action=nav->addAction(KStandardAction::AddBookmark,m_view,SLOT(toggleBookmark(bool)));
607  //action = ac->addAction("bookmark_do");
608  action->setText(i18nc("@option:check","Bookmark message"));
609  action->setCheckable(true);
610  //connect(action, SIGNAL(triggered(bool)),m_view,SLOT(toggleBookmark(bool)));
611  connect( this, SIGNAL(signalBookmarkDisplayed(bool)),action,SLOT(setChecked(bool)) );
612 
613  action=nav->addAction("bookmark_prior",this,SLOT(gotoPrevBookmark()));
614  action->setText(i18nc("@action:inmenu","Previous bookmark"));
615  connect( this, SIGNAL(signalPriorBookmarkAvailable(bool)),action,SLOT(setEnabled(bool)) );
616 
617  action=nav->addAction("bookmark_next",this,SLOT(gotoNextBookmark()));
618  action->setText(i18nc("@action:inmenu","Next bookmark"));
619  connect( this, SIGNAL(signalNextBookmarkAvailable(bool)),action,SLOT(setEnabled(bool)) );
620 
621 //Tools
622  edit->addAction(KStandardAction::Spelling,this,SLOT(spellcheck()));
623 
624  actionCategory=tm;
625  // xgettext: no-c-format
626  ADD_ACTION_SHORTCUT("tools_tm_batch",i18nc("@action:inmenu","Fill in all exact suggestions"),Qt::CTRL+Qt::ALT+Qt::Key_B)
627  connect( action, SIGNAL(triggered(bool)), _tmView, SLOT(slotBatchTranslate()) );
628 
629  // xgettext: no-c-format
630  ADD_ACTION_SHORTCUT("tools_tm_batch_fuzzy",i18nc("@action:inmenu","Fill in all exact suggestions and mark as fuzzy"),Qt::CTRL+Qt::ALT+Qt::Key_N)
631  connect( action, SIGNAL(triggered(bool)), _tmView, SLOT(slotBatchTranslateFuzzy()) );
632 
633  actionCategory=tools;
634  ADD_ACTION_SHORTCUT("tools_wordcount",i18nc("@action:inmenu","Word count"),Qt::CTRL+Qt::ALT+Qt::Key_C)
635  connect( action, SIGNAL(triggered(bool)), this, SLOT(displayWordCount()) );
636 
637 //MergeMode
638  action = sync1->addAction("merge_open",m_syncView,SLOT(mergeOpen()));
639  action->setText(i18nc("@action:inmenu","Open file for sync/merge"));
640  action->setStatusTip(i18nc("@info:status","Open catalog to be merged into the current one / replicate base file changes to"));
641  action->setToolTip(action->statusTip());
642  action->setWhatsThis(action->statusTip());
643  m_syncView->addAction(action);
644 
645  action = sync1->addAction("merge_prev",m_syncView,SLOT(gotoPrevChanged()));
646  action->setText(i18nc("@action:inmenu","Previous different"));
647  action->setStatusTip(i18nc("@info:status","Previous entry which is translated differently in the file being merged, including empty translations in merge source"));
648  action->setToolTip(action->statusTip());
649  action->setWhatsThis(action->statusTip());
650  action->setShortcut(Qt::ALT+Qt::Key_Up);
651  connect( m_syncView, SIGNAL(signalPriorChangedAvailable(bool)),action,SLOT(setEnabled(bool)) );
652  m_syncView->addAction(action);
653 
654  action = sync1->addAction("merge_next",m_syncView,SLOT(gotoNextChanged()));
655  action->setText(i18nc("@action:inmenu","Next different"));
656  action->setStatusTip(i18nc("@info:status","Next entry which is translated differently in the file being merged, including empty translations in merge source"));
657  action->setToolTip(action->statusTip());
658  action->setWhatsThis(action->statusTip());
659  action->setShortcut(Qt::ALT+Qt::Key_Down);
660  connect( m_syncView, SIGNAL(signalNextChangedAvailable(bool)),action,SLOT(setEnabled(bool)) );
661  m_syncView->addAction(action);
662 
663  action = sync1->addAction("merge_nextapproved",m_syncView,SLOT(gotoNextChangedApproved()));
664  action->setText(i18nc("@action:inmenu","Next different approved"));
665  action->setShortcut(Qt::ALT+Qt::META+Qt::Key_Down);
666  connect( m_syncView, SIGNAL(signalNextChangedAvailable(bool)),action,SLOT(setEnabled(bool)) );
667  m_syncView->addAction(action);
668 
669  action = sync1->addAction("merge_accept",m_syncView,SLOT(mergeAccept()));
670  action->setText(i18nc("@action:inmenu","Copy from merging source"));
671  action->setShortcut(Qt::ALT+Qt::Key_Return);
672  connect( m_syncView, SIGNAL(signalEntryWithMergeDisplayed(bool)),action,SLOT(setEnabled(bool)));
673  m_syncView->addAction(action);
674 
675  action = sync1->addAction("merge_acceptnew",m_syncView,SLOT(mergeAcceptAllForEmpty()));
676  action->setText(i18nc("@action:inmenu","Copy all new translations"));
677  action->setStatusTip(i18nc("@info:status","This changes only empty and non-ready entries in base file"));
678  action->setToolTip(action->statusTip());
679  action->setWhatsThis(action->statusTip());
680  action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_A);
681  m_syncView->addAction(action);
682  //action->setShortcut(Qt::ALT+Qt::Key_E);
683 
684  action = sync1->addAction("merge_back",m_syncView,SLOT(mergeBack()));
685  action->setText(i18nc("@action:inmenu","Copy to merging source"));
686  action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_Return);
687  m_syncView->addAction(action);
688 
689 
690 //Secondary merge
691  action = sync2->addAction("mergesecondary_open",m_syncViewSecondary,SLOT(mergeOpen()));
692  action->setText(i18nc("@action:inmenu","Open file for secondary sync"));
693  action->setStatusTip(i18nc("@info:status","Open catalog to be merged into the current one / replicate base file changes to"));
694  action->setToolTip(action->statusTip());
695  action->setWhatsThis(action->statusTip());
696  m_syncViewSecondary->addAction(action);
697 
698  action = sync2->addAction("mergesecondary_prev",m_syncViewSecondary,SLOT(gotoPrevChanged()));
699  action->setText(i18nc("@action:inmenu","Previous different"));
700  action->setStatusTip(i18nc("@info:status","Previous entry which is translated differently in the file being merged, including empty translations in merge source"));
701  action->setToolTip(action->statusTip());
702  action->setWhatsThis(action->statusTip());
703  connect( m_syncViewSecondary, SIGNAL(signalPriorChangedAvailable(bool)),action,SLOT(setEnabled(bool)) );
704  m_syncViewSecondary->addAction(action);
705 
706  action = sync2->addAction("mergesecondary_next",m_syncViewSecondary,SLOT(gotoNextChanged()));
707  action->setText(i18nc("@action:inmenu","Next different"));
708  action->setStatusTip(i18nc("@info:status","Next entry which is translated differently in the file being merged, including empty translations in merge source"));
709  action->setToolTip(action->statusTip());
710  action->setWhatsThis(action->statusTip());
711  connect( m_syncViewSecondary, SIGNAL(signalNextChangedAvailable(bool)),action,SLOT(setEnabled(bool)) );
712  m_syncViewSecondary->addAction(action);
713 
714  action = sync2->addAction("mergesecondary_accept",m_syncViewSecondary,SLOT(mergeAccept()));
715  action->setText(i18nc("@action:inmenu","Copy from merging source"));
716  connect( m_syncViewSecondary, SIGNAL(signalEntryWithMergeDisplayed(bool)),action,SLOT(setEnabled(bool)));
717  m_syncViewSecondary->addAction(action);
718 
719  action = sync2->addAction("mergesecondary_acceptnew",m_syncViewSecondary,SLOT(mergeAcceptAllForEmpty()));
720  action->setText(i18nc("@action:inmenu","Copy all new translations"));
721  action->setStatusTip(i18nc("@info:status","This changes only empty entries"));
722  action->setToolTip(action->statusTip());
723  action->setWhatsThis(action->statusTip());
724  m_syncViewSecondary->addAction(action);
725 
726  action = sync2->addAction("mergesecondary_back",m_syncViewSecondary,SLOT(mergeBack()));
727  action->setText(i18nc("@action:inmenu","Copy to merging source"));
728  m_syncViewSecondary->addAction(action);
729 
730 }
731 
732 void EditorTab::setProperFocus()
733 {
734  m_view->setProperFocus();
735 }
736 
737 void EditorTab::hideDocks()
738 {
739  if (m_transUnitsView->isFloating())
740  m_transUnitsView->hide();
741 }
742 
743 void EditorTab::showDocks()
744 {
745  return;
746  if (m_transUnitsView->isFloating())
747  m_transUnitsView->show();
748 }
749 
750 void EditorTab::setProperCaption(QString title, bool modified)
751 {
752  if (m_catalog->autoSaveRecovered()) title+=' '+i18nc("editor tab name","(recovered)");
753  setWindowTitle(title+" [*]");
754  setWindowModified(modified);
755 }
756 
757 void EditorTab::setFullPathShown(bool fullPathShown)
758 {
759  m_fullPathShown=fullPathShown;
760 
761  updateCaptionPath();
762  setModificationSign(m_catalog->isClean());
763 }
764 
765 
766 void EditorTab::updateCaptionPath()
767 {
768  KUrl url=m_catalog->url();
769  if (!url.isLocalFile() || !_project->isLoaded())
770  _captionPath=url.pathOrUrl();
771  else
772  {
773  if (m_fullPathShown)
774  {
775  _captionPath=KUrl::relativePath(
776  KUrl(_project->path()).directory()
777  ,url.toLocalFile());
778  if (_captionPath.contains("../.."))
779  _captionPath=url.toLocalFile();
780  else if (_captionPath.startsWith("./"))
781  _captionPath=_captionPath.mid(2);
782  }
783  else
784  _captionPath=url.fileName();
785  }
786 
787 }
788 
789 bool EditorTab::fileOpen(KUrl url, KUrl baseUrl, bool silent)
790 {
791  if (!m_catalog->isClean())
792  {
793  switch (KMessageBox::warningYesNoCancel(SettingsController::instance()->mainWindowPtr(),
794  i18nc("@info","The document contains unsaved changes.\n"
795  "Do you want to save your changes or discard them?"),i18nc("@title:window","Warning"),
796  KStandardGuiItem::save(),KStandardGuiItem::discard())
797  )
798  {
799  case KMessageBox::Yes: if (!saveFile()) return false;
800  case KMessageBox::Cancel: return false;
801  }
802  }
803  if (baseUrl.isEmpty())
804  baseUrl=m_catalog->url();
805 
806  KUrl saidUrl;
807  if (url.isEmpty())
808  {
809  //Prevent crashes
810  Project::instance()->model()->weaver()->suspend();
811  url=KFileDialog::getOpenFileName(baseUrl, Catalog::supportedMimeFilters + " text/x-gettext-translation-template", SettingsController::instance()->mainWindowPtr());
812  Project::instance()->model()->weaver()->resume();
813  //TODO application/x-xliff, windows: just extensions
814  //originalPath=url.path(); never used
815  }
816  else if (!QFile::exists(url.toLocalFile())&&Project::instance()->isLoaded())
817  { //check if we are opening template
818  QString path=url.toLocalFile();
819  path.replace(Project::instance()->poDir(),Project::instance()->potDir());
820  if (QFile::exists(path) || QFile::exists(path=path+'t'))
821  {
822  saidUrl=url;
823  url.setPath(path);
824  }
825  }
826  if (url.isEmpty())
827  return false;
828 
829  QApplication::setOverrideCursor(Qt::WaitCursor);
830 
831  QString prevFilePath=currentFile();
832  bool wasOpen=!m_catalog->isEmpty();
833  if (wasOpen) emit fileAboutToBeClosed();
834  int errorLine=m_catalog->loadFromUrl(url,saidUrl);
835  if (wasOpen&&errorLine==0) {emit fileClosed();emit fileClosed(prevFilePath);}
836 
837  QApplication::restoreOverrideCursor();
838 
839  if (errorLine==0)
840  {
841  statusBarItems.insert(ID_STATUS_TOTAL,i18nc("@info:status message entries","Total: %1", m_catalog->numberOfEntries()));
842  numberOfUntranslatedChanged();
843  numberOfFuzziesChanged();
844 
845  m_currentPos.entry=-1;//so the signals are emitted
846  DocPosition pos(0);
847  //we delay gotoEntry(pos) until project is loaded;
848 
849 
850  //TODO "test" for the name????
851  m_catalog->setActivePhase("test",Project::local()->role());
852 //Project
853  if (url.isLocalFile() && !_project->isLoaded())
854  {
855 //search for it
856  int i=4;
857  QDir dir(url.directory());
858  QStringList proj("*.ktp");
859  proj.append("*.lokalize");
860  dir.setNameFilters(proj);
861  while (--i && !dir.isRoot() && !_project->isLoaded())
862  {
863  if (dir.entryList().isEmpty()) dir.cdUp();
864  else _project->load(dir.absoluteFilePath(dir.entryList().first()));
865  }
866 
867  //enforce autosync
868  m_syncViewSecondary->mergeOpen(url);
869 
870  if (!_project->isLoaded() && _project->desirablePath().isEmpty())
871  {
872  _project->setDesirablePath(url.directory(KUrl::AppendTrailingSlash)+"index.lokalize");
873  //_project->setLangCode(m_catalog->targetLangCode());
874  }
875 
876  }
877 
878  gotoEntry(pos);
879 
880  updateCaptionPath();
881  setModificationSign(m_catalog->isClean());
882 
883 //OK!!!
884  emit fileOpened();
885  return true;
886  }
887 
888  if (!silent)
889  {
890  //KMessageBox::error(this, KIO::NetAccess::lastErrorString() );
891  if (errorLine>0) KMessageBox::error(this, i18nc("@info","Error opening the file <filename>%1</filename>, line: %2",url.pathOrUrl(),errorLine) );
892  else KMessageBox::error(this, i18nc("@info","Error opening the file <filename>%1</filename>",url.pathOrUrl()) );
893  }
894  return false;
895 }
896 
897 bool EditorTab::saveFileAs()
898 {
899  KUrl url=KFileDialog::getSaveUrl(m_catalog->url(),m_catalog->mimetype(),this);
900  if (url.isEmpty()) return false;
901  return saveFile(url);
902 }
903 
904 bool EditorTab::saveFile(const KUrl& url)
905 {
906  if (m_catalog->saveToUrl(url))
907  {
908  updateCaptionPath();
909  setModificationSign(/*clean*/true);
910  emit fileSaved(url.toLocalFile());
911  return true;
912  }
913 
914  if ( KMessageBox::Continue==KMessageBox::warningContinueCancel(this,
915  i18nc("@info","Error saving the file <filename>%1</filename>\n"
916  "Do you want to save to another file or cancel?", m_catalog->url().pathOrUrl()),
917  i18nc("@title","Error"),KStandardGuiItem::save())
918  )
919  return saveFileAs();
920  return false;
921 }
922 
923 void EditorTab::fileAutoSaveFailedWarning(const QString& fileName)
924 {
925  KMessageBox::information(this, i18nc("@info","Could not perform file autosaving.\n"
926  "The target file was <filename>%1</filename>.", fileName) );
927 }
928 
929 EditorState EditorTab::state()
930 {
931  EditorState state;
932  state.dockWidgets=saveState();
933  state.url=m_catalog->url();
934  state.mergeUrl=m_syncView->url();
935  state.entry=m_currentPos.entry;
936  //state.offset=_currentPos.offset;
937  return state;
938 }
939 
940 
941 bool EditorTab::queryClose()
942 {
943  if (m_catalog->isClean()) return true;
944 
945  //TODO caption
946  switch (KMessageBox::warningYesNoCancel(this,
947  i18nc("@info","The document contains unsaved changes.\n"
948  "Do you want to save your changes or discard them?"),i18nc("@title:window","Warning"),
949  KStandardGuiItem::save(),KStandardGuiItem::discard()))
950  {
951  case KMessageBox::Yes: return saveFile();
952  case KMessageBox::No: return true;
953  default: return false;
954  }
955 }
956 
957 
958 void EditorTab::undo()
959 {
960  gotoEntry(m_catalog->undo(),0);
961  msgStrChanged();
962 }
963 
964 void EditorTab::redo()
965 {
966  gotoEntry(m_catalog->redo(),0);
967  msgStrChanged();
968 }
969 
970 void EditorTab::gotoEntry()
971 {
972  DocPosition pos=m_currentPos;
973  pos.entry=KInputDialog::getInteger(
974  i18nc("@title","Jump to Entry"),
975  i18nc("@label:spinbox","Enter entry number:"),
976  pos.entry,1,
977  m_catalog->numberOfEntries(),
978  1,0,this);
979  if (pos.entry)
980  {
981  --(pos.entry);
982  gotoEntry(pos);
983  }
984 }
985 
986 void EditorTab::gotoEntry(DocPosition pos, int selection)
987 {
988  //specially for dbus users
989  if (pos.entry>=m_catalog->numberOfEntries()||pos.entry<0)
990  return;
991  if (!m_catalog->isPlural(pos))
992  pos.form=0;
993 
994  m_currentPos.part=pos.part;//for searching;
995  //UndefPart => called on fuzzy toggle
996 
997 
998  bool newEntry=m_currentPos.entry!=pos.entry || m_currentPos.form!=pos.form;
999  if (newEntry||pos.part==DocPosition::Comment)
1000  {
1001  m_notesView->gotoEntry(pos,pos.part==DocPosition::Comment?selection:0);
1002  if (pos.part==DocPosition::Comment)
1003  {
1004  pos.form=0;
1005  pos.offset=0;
1006  selection=0;
1007  }
1008  }
1009 
1010 
1011  m_view->gotoEntry(pos,selection);
1012  if (pos.part==DocPosition::UndefPart)
1013  m_currentPos.part=DocPosition::Target;
1014 
1015  //QTime time; time.start();
1016 
1017  if (newEntry)
1018  {
1019  m_currentPos=pos;
1020  if (true)
1021  {
1022  emit signalNewEntryDisplayed(pos);
1023  emit entryDisplayed();
1024 
1025  emit signalFirstDisplayed(pos.entry==m_transUnitsView->firstEntry());
1026  emit signalLastDisplayed(pos.entry==m_transUnitsView->lastEntry());
1027 
1028  emit signalPriorFuzzyAvailable(pos.entry>m_catalog->firstFuzzyIndex());
1029  emit signalNextFuzzyAvailable(pos.entry<m_catalog->lastFuzzyIndex());
1030 
1031  emit signalPriorUntranslatedAvailable(pos.entry>m_catalog->firstUntranslatedIndex());
1032  emit signalNextUntranslatedAvailable(pos.entry<m_catalog->lastUntranslatedIndex());
1033 
1034  emit signalPriorFuzzyOrUntrAvailable(pos.entry>m_catalog->firstFuzzyIndex()
1035  ||pos.entry>m_catalog->firstUntranslatedIndex()
1036  );
1037  emit signalNextFuzzyOrUntrAvailable(pos.entry<m_catalog->lastFuzzyIndex()
1038  ||pos.entry<m_catalog->lastUntranslatedIndex());
1039 
1040  emit signalPriorBookmarkAvailable(pos.entry>m_catalog->firstBookmarkIndex());
1041  emit signalNextBookmarkAvailable(pos.entry<m_catalog->lastBookmarkIndex());
1042  emit signalBookmarkDisplayed(m_catalog->isBookmarked(pos.entry));
1043 
1044  emit signalEquivTranslatedEntryDisplayed(m_catalog->isEquivTrans(pos));
1045  emit signalApprovedEntryDisplayed(m_catalog->isApproved(pos));
1046  }
1047 
1048  }
1049 
1050  statusBarItems.insert(ID_STATUS_CURRENT,i18nc("@info:status","Current: %1", m_currentPos.entry+1));
1051  //kDebug()<<"ELA "<<time.elapsed();
1052 }
1053 
1054 void EditorTab::msgStrChanged()
1055 {
1056  bool isUntr=m_catalog->msgstr(m_currentPos).isEmpty();
1057  bool isApproved=m_catalog->isApproved(m_currentPos);
1058  if (isUntr==m_currentIsUntr && isApproved==m_currentIsApproved)
1059  return;
1060 
1061  QString msg;
1062  if (isUntr) msg=i18nc("@info:status","Untranslated");
1063  else if (isApproved)msg=i18nc("@info:status 'non-fuzzy' in gettext terminology","Ready");
1064  else msg=i18nc("@info:status 'fuzzy' in gettext terminology","Needs review");
1065 
1066  /* else
1067  statusBar()->changeItem("",ID_STATUS_ISFUZZY);*/
1068 
1069  statusBarItems.insert(ID_STATUS_ISFUZZY,msg);
1070 
1071  m_currentIsUntr=isUntr;
1072  m_currentIsApproved=isApproved;
1073 }
1074 
1075 void EditorTab::switchForm(int newForm)
1076 {
1077  if (m_currentPos.form==newForm) return;
1078 
1079  DocPosition pos=m_currentPos;
1080  pos.form=newForm;
1081  gotoEntry(pos);
1082 }
1083 
1084 void EditorTab::gotoNextUnfiltered()
1085 {
1086  DocPosition pos=m_currentPos;
1087 
1088  if (switchNext(m_catalog,pos))
1089  gotoEntry(pos);
1090 }
1091 
1092 
1093 void EditorTab::gotoPrevUnfiltered()
1094 {
1095  DocPosition pos=m_currentPos;
1096 
1097  if (switchPrev(m_catalog,pos))
1098  gotoEntry(pos);
1099 }
1100 
1101 void EditorTab::gotoFirstUnfiltered(){gotoEntry(DocPosition(0));}
1102 void EditorTab::gotoLastUnfiltered(){gotoEntry(DocPosition(m_catalog->numberOfEntries()-1));}
1103 
1104 void EditorTab::gotoFirst()
1105 {
1106  DocPosition pos=DocPosition(m_transUnitsView->firstEntry());
1107  if (pos.entry!=-1)
1108  gotoEntry(pos);
1109 }
1110 
1111 void EditorTab::gotoLast()
1112 {
1113  DocPosition pos=DocPosition(m_transUnitsView->lastEntry());
1114  if (pos.entry!=-1)
1115  gotoEntry(pos);
1116 }
1117 
1118 
1119 void EditorTab::gotoNext()
1120 {
1121  DocPosition pos=m_currentPos;
1122  if (m_catalog->isPlural(pos) && pos.form+1<m_catalog->numberOfPluralForms())
1123  pos.form++;
1124  else
1125  pos=DocPosition(m_transUnitsView->nextEntry());
1126 
1127  if (pos.entry!=-1)
1128  gotoEntry(pos);
1129 }
1130 
1131 void EditorTab::gotoPrev()
1132 {
1133  DocPosition pos=m_currentPos;
1134  if (m_catalog->isPlural(pos) && pos.form>0)
1135  pos.form--;
1136  else
1137  pos=DocPosition(m_transUnitsView->prevEntry());
1138 
1139  if (pos.entry!=-1)
1140  gotoEntry(pos);
1141 }
1142 
1143 void EditorTab::gotoPrevFuzzy()
1144 {
1145  DocPosition pos;
1146 
1147  if ( (pos.entry=m_catalog->prevFuzzyIndex(m_currentPos.entry)) == -1)
1148  return;
1149 
1150  gotoEntry(pos);
1151 }
1152 
1153 void EditorTab::gotoNextFuzzy()
1154 {
1155  DocPosition pos;
1156 
1157  if ( (pos.entry=m_catalog->nextFuzzyIndex(m_currentPos.entry)) == -1)
1158  return;
1159 
1160  gotoEntry(pos);
1161 }
1162 
1163 void EditorTab::gotoPrevUntranslated()
1164 {
1165  DocPosition pos;
1166 
1167  if ( (pos.entry=m_catalog->prevUntranslatedIndex(m_currentPos.entry)) == -1)
1168  return;
1169 
1170  gotoEntry(pos);
1171 }
1172 
1173 void EditorTab::gotoNextUntranslated()
1174 {
1175  DocPosition pos;
1176 
1177  if ( (pos.entry=m_catalog->nextUntranslatedIndex(m_currentPos.entry)) == -1)
1178  return;
1179 
1180  gotoEntry(pos);
1181 }
1182 
1183 void EditorTab::gotoPrevFuzzyUntr()
1184 {
1185  DocPosition pos;
1186 
1187  short fu = m_catalog->prevFuzzyIndex(m_currentPos.entry);
1188  short un = m_catalog->prevUntranslatedIndex(m_currentPos.entry);
1189 
1190  pos.entry=fu>un?fu:un;
1191  if ( pos.entry == -1)
1192  return;
1193 
1194  gotoEntry(pos);
1195 }
1196 
1197 bool EditorTab::gotoNextFuzzyUntr(const DocPosition& p)
1198 {
1199  int index=(p.entry==-1)?m_currentPos.entry:p.entry;
1200 
1201  DocPosition pos;
1202 
1203  short fu = m_catalog->nextFuzzyIndex(index);
1204  short un = m_catalog->nextUntranslatedIndex(index);
1205  if ( (fu == -1) && (un == -1) )
1206  return false;
1207 
1208  if (fu == -1) fu=un;
1209  else if (un == -1) un=fu;
1210 
1211  pos.entry=fu<un?fu:un;
1212  gotoEntry(pos);
1213  return true;
1214 }
1215 
1216 
1217 void EditorTab::toggleApprovementGotoNextFuzzyUntr()
1218 {
1219  if(!m_catalog->isApproved(m_currentPos.entry))
1220  m_view->toggleApprovement();
1221  if (!gotoNextFuzzyUntr())
1222  gotoNextFuzzyUntr(DocPosition(-2));//so that we don't skip the first
1223 }
1224 
1225 void EditorTab::setApproveActionTitle()
1226 {
1227  const char* const titles[]={
1228  I18N_NOOP2("@option:check trans-unit state","Translated"),
1229  I18N_NOOP2("@option:check trans-unit state","Signed-off"),
1230  I18N_NOOP2("@option:check trans-unit state","Approved")
1231  };
1232  const char* const helpText[]={
1233  I18N_NOOP2("@info:tooltip","Translation is done (although still may need a review)"),
1234  I18N_NOOP2("@info:tooltip","Translation received positive review"),
1235  I18N_NOOP2("@info:tooltip","Entry is fully localized (i.e. final)")
1236  };
1237 
1238  int role=m_catalog->activePhaseRole();
1239  if (role==ProjectLocal::Undefined)
1240  role=Project::local()->role();
1241  m_approveAction->setText(i18nc("@option:check trans-unit state",titles[role]));
1242  m_approveAction->setToolTip(i18nc("@info:tooltip",helpText[role]));
1243 }
1244 
1245 void EditorTab::showStatesMenu()
1246 {
1247  m_approveAction->menu()->clear();
1248  if (!(m_catalog->capabilities()&ExtendedStates))
1249  {
1250  QAction* a=m_approveAction->menu()->addAction(i18nc("@info:status 'fuzzy' in gettext terminology","Needs review"));
1251  a->setData(QVariant(-1));
1252  a->setCheckable(true);
1253  a->setChecked(!m_catalog->isApproved(m_currentPos));
1254 
1255  a=m_approveAction->menu()->addAction(i18nc("@info:status 'non-fuzzy' in gettext terminology","Ready"));
1256  a->setData(QVariant(-2));
1257  a->setCheckable(true);
1258  a->setChecked(m_catalog->isApproved(m_currentPos));
1259 
1260  return;
1261  }
1262 
1263  TargetState state=m_catalog->state(m_currentPos);
1264 
1265  const char* const* states=Catalog::states();
1266  for (int i=0;i<StateCount;++i)
1267  {
1268  QAction* a=m_approveAction->menu()->addAction(i18n(states[i]));
1269  a->setData(QVariant(i));
1270  a->setCheckable(true);
1271  a->setChecked(state==i);
1272 
1273  if (i==New || i==Translated || i==Final)
1274  m_approveAction->menu()->addSeparator();
1275  }
1276 }
1277 
1278 void EditorTab::setState(QAction* a)
1279 {
1280  if (!(m_catalog->capabilities()&ExtendedStates))
1281  m_view->toggleApprovement();
1282  else
1283  m_view->setState(TargetState(a->data().toInt()));
1284 
1285  m_approveAction->menu()->clear();
1286 }
1287 
1288 void EditorTab::openPhasesWindow()
1289 {
1290  PhasesWindow w(m_catalog, this);
1291  w.exec();
1292 }
1293 
1294 void EditorTab::gotoPrevBookmark()
1295 {
1296  DocPosition pos;
1297 
1298  if ( (pos.entry=m_catalog->prevBookmarkIndex(m_currentPos.entry)) == -1)
1299  return;
1300 
1301  gotoEntry(pos);
1302 }
1303 
1304 void EditorTab::gotoNextBookmark()
1305 {
1306  DocPosition pos;
1307 
1308  if ( (pos.entry=m_catalog->nextBookmarkIndex(m_currentPos.entry)) == -1)
1309  return;
1310 
1311  gotoEntry(pos);
1312 }
1313 
1314 //wrapper for cmdline handling...
1315 void EditorTab::mergeOpen(KUrl url)
1316 {
1317  m_syncView->mergeOpen(url);
1318 }
1319 /*
1320 KUrl EditorWindow::mergeFile()
1321 {
1322  return _mergeView->url();
1323 }
1324 */
1325 
1326 //HACK to prevent redundant repaintings when widget isn't visible
1327 void EditorTab::paintEvent(QPaintEvent* event)
1328 {
1329  if (QMdiSubWindow* sw=qobject_cast<QMdiSubWindow*>(parent()))
1330  {
1331  if (sw->mdiArea()->currentSubWindow()!=sw)
1332  return;
1333  }
1334  LokalizeSubwindowBase2::paintEvent(event);
1335 }
1336 
1337 void EditorTab::indexWordsForCompletion()
1338 {
1339  CompletionStorage::instance()->scanCatalog(m_catalog);
1340 }
1341 
1342 //see also termlabel.h
1343 void EditorTab::defineNewTerm()
1344 {
1345  //TODO just a word under cursor?
1346  QString en(m_view->selectionInSource().toLower());
1347  if (en.isEmpty())
1348  en=m_catalog->msgid(m_currentPos).toLower();
1349 
1350  QString target(m_view->selectionInTarget().toLower());
1351  if (target.isEmpty())
1352  target=m_catalog->msgstr(m_currentPos).toLower();
1353 
1354  _project->defineNewTerm(en,target);
1355 }
1356 
1357 
1358 void EditorTab::reloadFile()
1359 {
1360  KUrl mergeFile=m_syncView->url();
1361  DocPosition p=m_currentPos;
1362  if (!fileOpen(currentUrl()))
1363  return;
1364 
1365  gotoEntry(p);
1366  if (!mergeFile.isEmpty())
1367  mergeOpen(mergeFile);
1368 }
1369 
1370 void EditorTab::dispatchSrcFileOpenRequest(const QString& srcPath, int line)
1371 {
1372  m_srcFileOpenRequestAccepted=false;
1373  emit srcFileOpenRequested(srcPath,line);
1374  if (!m_srcFileOpenRequestAccepted)
1375  KMessageBox::information(this, i18nc("@info","Cannot open source files: no scripts to do so are currently loaded. "
1376  "Refer to the Lokalize handbook for script examples and how to plug them into your project.") );
1377 }
1378 
1379 
1380 //BEGIN DBus interface
1381 #include "editoradaptor.h"
1382 QList<int> EditorTab::ids;
1383 
1384 QString EditorTab::dbusObjectPath()
1385 {
1386  if ( m_dbusId==-1 )
1387  {
1388  m_adaptor=new EditorAdaptor(this);
1389 
1390  int i=0;
1391  while(i<ids.size()&&i==ids.at(i))
1392  ++i;
1393  ids.insert(i,i);
1394  m_dbusId=i;
1395  QDBusConnection::sessionBus().registerObject("/ThisIsWhatYouWant/Editor/" + QString::number(m_dbusId), this);
1396  }
1397  return "/ThisIsWhatYouWant/Editor/" + QString::number(m_dbusId);
1398 }
1399 
1400 
1401 KUrl EditorTab::currentUrl(){return m_catalog->url();}
1402 QByteArray EditorTab::currentFileContents(){return m_catalog->contents();}
1403 QString EditorTab::currentEntryId(){return m_catalog->id(m_currentPos);}
1404 QString EditorTab::selectionInTarget(){return m_view->selectionInTarget();}
1405 QString EditorTab::selectionInSource(){return m_view->selectionInSource();}
1406 
1407 void EditorTab::lookupSelectionInTranslationMemory(){emit tmLookupRequested(selectionInSource(),selectionInTarget());}
1408 
1409 
1410 void EditorTab::setEntryFilteredOut(int entry, bool filteredOut){m_transUnitsView->setEntryFilteredOut(entry, filteredOut);}
1411 void EditorTab::setEntriesFilteredOut(bool filteredOut){m_transUnitsView->setEntriesFilteredOut(filteredOut);}
1412 int EditorTab::entryCount(){return m_catalog->numberOfEntries();}
1413 
1414 QString EditorTab::entrySource(int entry, int form){return m_catalog->sourceWithTags(DocPosition(entry, form)).string;}
1415 QString EditorTab::entryTarget(int entry, int form){return m_catalog->targetWithTags(DocPosition(entry, form)).string;}
1416 int EditorTab::entryPluralFormCount(int entry){return m_catalog->isPlural(entry)?m_catalog->numberOfPluralForms():1;}
1417 bool EditorTab::entryReady(int entry){return m_catalog->isApproved(entry);}
1418 QString EditorTab::sourceLangCode(){return m_catalog->sourceLangCode();}
1419 QString EditorTab::targetLangCode(){return m_catalog->targetLangCode();}
1420 void EditorTab::addEntryNote(int entry, const QString& note){m_notesView->addNote(entry, note);}
1421 void EditorTab::addTemporaryEntryNote(int entry, const QString& note){m_notesView->addTemporaryEntryNote(entry, note);}
1422 
1423 void EditorTab::addAlternateTranslation(int entry, const QString& translation){m_altTransView->addAlternateTranslation(entry, translation);}
1424 void EditorTab::addTemporaryAlternateTranslation(int entry, const QString& translation){m_altTransView->addAlternateTranslation(entry, translation);}
1425 void EditorTab::attachAlternateTranslationFile(const QString& path){m_altTransView->attachAltTransFile(path);}
1426 
1427 void EditorTab::setEntryTarget(int entry, int form, const QString& content)
1428 {
1429  DocPosition pos(entry,form);
1430  //TODO uncomment when trunk is open for new strings
1431  //m_catalog->beginMacro(i18nc("@item Undo action item","Set unit text"));
1432  removeTargetSubstring(m_catalog, pos);
1433  insertCatalogString(m_catalog, pos, CatalogString(content));
1434  //m_catalog->endMacro();
1435  if (m_currentPos==pos)
1436  m_view->gotoEntry();
1437 }
1438 
1439 //END DBus interface
1440 
1441 
1442 #include "editortab.moc"
ProjectLocal::role
PersonRole role() const
Get Role.
Definition: projectlocal.h:30
MsgCtxtView::gotoEntry
void gotoEntry(const DocPosition &, int selection=0)
Definition: msgctxtview.cpp:78
EditorView::selectionInSource
QString selectionInSource() const
Definition: editorview.cpp:310
AltTransView::addAlternateTranslation
void addAlternateTranslation(int entry, const QString &, bool temp=true)
Definition: alttransview.cpp:116
EditorTab::gotoFirst
Q_SCRIPTABLE void gotoFirst()
Definition: editortab.cpp:1104
DocPosition::part
Part part
Definition: pos.h:49
EditorView::gotoEntry
void gotoEntry(DocPosition pos=DocPosition(), int selection=0)
Definition: editorview.cpp:177
EditorTab::targetLangCode
Q_SCRIPTABLE QString targetLangCode()
Definition: editortab.cpp:1419
MergeCatalog
Merge source container.
Definition: mergecatalog.h:71
EditorTab::EditorTab
EditorTab(QWidget *parent, bool valid=true)
Definition: editortab.cpp:99
project.h
QWidget
Catalog::url
const KUrl & url() const
Definition: catalog.h:189
editorview.h
MsgCtxtView::addNote
void addNote(DocPosition, const QString &text)
Definition: msgctxtview.cpp:228
Catalog::targetWithTags
CatalogString targetWithTags(const DocPosition &pos) const
Definition: catalog.cpp:211
CatalogView::nextEntry
int nextEntry()
Definition: cataloglistview.cpp:273
EditorTab::signalApprovedEntryDisplayed
void signalApprovedEntryDisplayed(bool)
Catalog::prevBookmarkIndex
int prevBookmarkIndex(uint index) const
Definition: catalog.h:169
TM_SHORTCUTS
#define TM_SHORTCUTS
Definition: tmview.h:44
EditorTab::showDocks
void showDocks()
Definition: editortab.cpp:743
mergeview.h
Catalog::prevUntranslatedIndex
int prevUntranslatedIndex(uint index) const
Definition: catalog.h:164
Catalog::contents
QByteArray contents()
Definition: catalog.cpp:703
Catalog::targetLangCode
QString targetLangCode() const
Definition: catalog.cpp:474
ProjectModel::weaver
ThreadWeaver::Weaver * weaver()
Definition: projectmodel.h:167
EditorTab::mergeOpen
void mergeOpen(KUrl url=KUrl())
Definition: editortab.cpp:1315
StatusBarProxy::insert
void insert(int, const QString &)
Definition: actionproxy.cpp:97
Catalog::loadFromUrl
int loadFromUrl(const KUrl &url, const KUrl &saidUrl=KUrl(), int *fileSize=0, bool fast=false)
Definition: catalog.cpp:508
EditorTab::saveFile
Q_SCRIPTABLE bool saveFile(const KUrl &url=KUrl())
Definition: editortab.cpp:904
Catalog::numberOfPluralForms
int numberOfPluralForms() const
Definition: catalog.h:150
ADD_ACTION_SHORTCUT_ICON
#define ADD_ACTION_SHORTCUT_ICON(_name, _text, _shortcut, _icon)
isApproved
bool isApproved(TargetState state, ProjectLocal::PersonRole role)
Definition: catalog.cpp:993
QByteArray
DocPosition::Target
Definition: pos.h:44
QWidget::addAction
void addAction(QAction *action)
Translated
Definition: state.h:36
DocPosition::Part
Part
Definition: pos.h:40
EditorView::setState
void setState(TargetState)
Definition: editorview.cpp:350
WebQueryView
unlike other views, we keep data like catalog pointer in our child view: ui_queryControl contains our...
Definition: webqueryview.h:58
EditorTab::currentEntryId
Q_SCRIPTABLE QString currentEntryId()
Definition: editortab.cpp:1403
QAction::setChecked
void setChecked(bool)
QAction::data
QVariant data() const
switchNext
bool switchNext(Catalog *&catalog, DocPosition &pos, int parts)
Definition: pos.cpp:88
CatalogView
Definition: cataloglistview.h:41
EditorState::dockWidgets
QByteArray dockWidgets
Definition: editortab.h:67
pos.h
QList::at
const T & at(int i) const
Project::instance
static Project * instance()
Definition: project.cpp:67
completionstorage.h
QDockWidget::isFloating
bool isFloating() const
EditorTab::signalEntryWithMergeDisplayed
void signalEntryWithMergeDisplayed(bool, const DocPosition &)
EditorTab::setProperCaption
void setProperCaption(QString, bool)
Definition: editortab.cpp:750
CompletionStorage::instance
static CompletionStorage * instance()
Definition: completionstorage.cpp:37
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
CatalogView::prevEntry
int prevEntry()
Definition: cataloglistview.cpp:278
Catalog::activePhaseRole
ProjectLocal::PersonRole activePhaseRole() const
Definition: catalog.h:120
EditorTab::signalEquivTranslatedEntryDisplayed
void signalEquivTranslatedEntryDisplayed(bool)
ProjectLocal::Undefined
Definition: projectlocal.h:13
msgctxtview.h
Catalog::redo
virtual const DocPosition & redo()
Definition: catalog.cpp:746
EditorTab::srcFileOpenRequested
Q_SCRIPTABLE void srcFileOpenRequested(const QString &srcPath, int line)
EditorTab::signalLastDisplayed
void signalLastDisplayed(bool)
QDBusConnection::sessionBus
QDBusConnection sessionBus()
Project::local
static ProjectLocal * local()
Definition: project.h:116
EditorTab::~EditorTab
~EditorTab()
Definition: editortab.cpp:149
ID_STATUS_CURRENT
#define ID_STATUS_CURRENT
Definition: actionproxy.h:93
editortab.h
webqueryview.h
prefs.h
EditorTab::signalNextFuzzyOrUntrAvailable
void signalNextFuzzyOrUntrAvailable(bool)
CatalogString::string
QString string
Definition: catalogstring.h:130
MergeView::url
KUrl url()
Definition: mergeview.cpp:76
cmd.h
EditorView::viewPort
QObject * viewPort()
Definition: editorview.cpp:326
EditorView::toggleApprovement
void toggleApprovement()
Definition: editorview.cpp:339
ALTTRANS_SHORTCUTS
#define ALTTRANS_SHORTCUTS
Definition: alttransview.h:27
QFile::exists
bool exists() const
Catalog::lastUntranslatedIndex
int lastUntranslatedIndex() const
Definition: catalog.h:162
EditorTab::attachAlternateTranslationFile
Q_SCRIPTABLE void attachAlternateTranslationFile(const QString &path)
Definition: editortab.cpp:1425
New
Definition: state.h:32
Catalog::setActivePhase
void setActivePhase(const QString &phase, ProjectLocal::PersonRole role=ProjectLocal::Approver)
Definition: catalog.cpp:339
Project::setDesirablePath
Q_SCRIPTABLE void setDesirablePath(const QString &path)
Definition: project.h:95
Catalog::isEmpty
bool isEmpty(uint index) const
Definition: catalog.cpp:432
EditorTab::gotoLast
Q_SCRIPTABLE void gotoLast()
Definition: editortab.cpp:1111
EditorTab::addEntryNote
Q_SCRIPTABLE void addEntryNote(int entry, const QString &note)
Definition: editortab.cpp:1420
QList::size
int size() const
Catalog::firstUntranslatedIndex
int firstUntranslatedIndex() const
Definition: catalog.h:161
ADD_ACTION_SHORTCUT
#define ADD_ACTION_SHORTCUT(_name, _text, _shortcut)
EditorState::entry
int entry
Definition: editortab.h:70
EditorTab::queryClose
bool queryClose()
Definition: editortab.cpp:941
DocPosition::offset
uint offset
Definition: pos.h:51
DocPosition::entry
int entry
Definition: pos.h:48
EditorTab::signalFirstDisplayed
void signalFirstDisplayed(bool)
Project::defineNewTerm
GlossaryNS::GlossaryWindow * defineNewTerm(QString en=QString(), QString target=QString())
Definition: project.cpp:211
DocPosition
This struct represents a position in a catalog.
Definition: pos.h:38
MergeView::mergeOpen
void mergeOpen(KUrl url=KUrl())
Definition: mergeview.cpp:187
EditorTab::gotoNextUnfiltered
Q_SCRIPTABLE void gotoNextUnfiltered()
Definition: editortab.cpp:1084
EditorTab::signalNewEntryDisplayed
void signalNewEntryDisplayed(const DocPosition &)
QString::number
QString number(int n, int base)
Project
Singleton object that represents project.
Definition: project.h:51
Catalog::undo
virtual const DocPosition & undo()
Definition: catalog.cpp:740
EditorTab::entryCount
Q_SCRIPTABLE int entryCount()
Definition: editortab.cpp:1412
ID_STATUS_TOTAL
#define ID_STATUS_TOTAL
Definition: actionproxy.h:94
EditorView::selectionInTarget
QString selectionInTarget() const
Definition: editorview.cpp:304
removeTargetSubstring
bool removeTargetSubstring(Catalog *catalog, DocPosition pos, int delStart, int delLen)
Definition: cmd.cpp:364
EditorTab::setEntryFilteredOut
Q_SCRIPTABLE void setEntryFilteredOut(int entry, bool filteredOut)
Definition: editortab.cpp:1410
EditorTab::paintEvent
void paintEvent(QPaintEvent *event)
Definition: editortab.cpp:1327
QVariant::toInt
int toInt(bool *ok) const
setText
void setText(QDomElement element, QString text)
Definition: domroutines.cpp:26
LokalizeSubwindowBase::reflectNonApprovedCount
void reflectNonApprovedCount(int count, int total)
Definition: editortab.cpp:174
EditorTab::addTemporaryEntryNote
Q_SCRIPTABLE void addTemporaryEntryNote(int entry, const QString &note)
Definition: editortab.cpp:1421
Insert
Definition: cmd.h:39
GlossaryNS::GlossaryView
Definition: glossaryview.h:45
content
static QString content(QDomElement elem, ContentEditingData *data=0)
walks through XLIFF XML and performs actions depending on ContentEditingData:
Definition: tsstorage.cpp:170
Catalog::firstFuzzyIndex
int firstFuzzyIndex() const
Definition: catalog.h:157
StateCount
Definition: state.h:42
CompletionStorage::scanCatalog
void scanCatalog(Catalog *)
Definition: completionstorage.cpp:48
catalog.h
EditorTab::setEntriesFilteredOut
Q_SCRIPTABLE void setEntriesFilteredOut(bool filteredOut)
Definition: editortab.cpp:1411
Catalog::isBookmarked
bool isBookmarked(uint index) const
Definition: catalog.h:147
EditorTab::currentUrl
KUrl currentUrl()
Definition: editortab.cpp:1401
QString::isEmpty
bool isEmpty() const
EditorState::mergeUrl
KUrl mergeUrl
Definition: editortab.h:69
QList::removeAll
int removeAll(const T &value)
EditorTab::fileOpened
Q_SCRIPTABLE void fileOpened()
EditorTab::gotoLastUnfiltered
Q_SCRIPTABLE void gotoLastUnfiltered()
Definition: editortab.cpp:1102
EditorTab::entrySource
Q_SCRIPTABLE QString entrySource(int entry, int form)
Definition: editortab.cpp:1414
DocPosition::form
char form
Definition: pos.h:50
ID_STATUS_FUZZY
#define ID_STATUS_FUZZY
Definition: actionproxy.h:95
Project::model
ProjectModel * model()
Definition: project.cpp:265
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
projectlocal.h
EditorTab::entryDisplayed
Q_SCRIPTABLE void entryDisplayed()
QApplication::setOverrideCursor
void setOverrideCursor(const QCursor &cursor)
TM::TMView
Definition: tmview.h:49
Project::desirablePath
Q_SCRIPTABLE QString desirablePath() const
Definition: project.h:96
MergeView
Definition: mergeview.h:41
MsgCtxtView::addTemporaryEntryNote
void addTemporaryEntryNote(int entry, const QString &text)
Definition: msgctxtview.cpp:235
cataloglistview.h
QApplication::restoreOverrideCursor
void restoreOverrideCursor()
Catalog::isPlural
bool isPlural(uint index) const
Definition: catalog.cpp:405
EditorTab::signalNextBookmarkAvailable
void signalNextBookmarkAvailable(bool)
EditorTab::gotoFirstUnfiltered
Q_SCRIPTABLE void gotoFirstUnfiltered()
Definition: editortab.cpp:1101
EditorTab::gotoNext
Q_SCRIPTABLE void gotoNext()
Definition: editortab.cpp:1119
CatalogView::lastEntry
int lastEntry()
Definition: cataloglistview.cpp:296
Catalog::nextBookmarkIndex
int nextBookmarkIndex(uint index) const
Definition: catalog.h:168
states
static const char *const states[]
Definition: xliffstorage.cpp:955
EditorTab::signalPriorFuzzyAvailable
void signalPriorFuzzyAvailable(bool)
EditorTab::fileClosed
void fileClosed()
QString
QList< int >
QWidget::hide
void hide()
MsgCtxtView
Definition: msgctxtview.h:38
EditorTab::fileAboutToBeClosed
Q_SCRIPTABLE void fileAboutToBeClosed()
EditorTab::tmLookupRequested
void tmLookupRequested(DocPosition::Part, const QString &)
Project::isLoaded
bool isLoaded() const
Definition: project.h:62
EditorTab::selectionInSource
Q_SCRIPTABLE QString selectionInSource()
Definition: editortab.cpp:1405
LokalizeSubwindowBase::reflectUntranslatedCount
void reflectUntranslatedCount(int count, int total)
Definition: editortab.cpp:182
QStringList
EditorTab::saveFileAs
Q_SCRIPTABLE bool saveFileAs()
Definition: editortab.cpp:897
EditorTab::entryTarget
Q_SCRIPTABLE QString entryTarget(int entry, int form)
Definition: editortab.cpp:1415
QAction::setData
void setData(const QVariant &userData)
QString::toLower
QString toLower() const
EditorState::url
KUrl url
Definition: editortab.h:68
Final
Definition: state.h:40
EditorTab::setFullPathShown
void setFullPathShown(bool)
Definition: editortab.cpp:757
Catalog::capabilities
int capabilities() const
Definition: catalog.cpp:164
Catalog::nextFuzzyIndex
int nextFuzzyIndex(uint index) const
Definition: catalog.h:159
Catalog::firstBookmarkIndex
int firstBookmarkIndex() const
Definition: catalog.h:166
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
SettingsController::instance
static SettingsController * instance()
Definition: prefs.cpp:70
EditorTab::signalPriorFuzzyOrUntrAvailable
void signalPriorFuzzyOrUntrAvailable(bool)
EditorView
This is the main view class for Lokalize Editor.
Definition: editorview.h:55
QWidget::setContextMenuPolicy
void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
Project::load
void load(const QString &file)
Definition: project.cpp:115
EditorTab::entryPluralFormCount
Q_SCRIPTABLE int entryPluralFormCount(int entry)
Definition: editortab.cpp:1416
Catalog::nextUntranslatedIndex
int nextUntranslatedIndex(uint index) const
Definition: catalog.h:163
EditorTab::signalPriorBookmarkAvailable
void signalPriorBookmarkAvailable(bool)
Catalog::lastFuzzyIndex
int lastFuzzyIndex() const
Definition: catalog.h:158
QAction::setCheckable
void setCheckable(bool)
EditorTab::signalPriorUntranslatedAvailable
void signalPriorUntranslatedAvailable(bool)
WEBQUERY_SHORTCUTS
#define WEBQUERY_SHORTCUTS
Definition: webqueryview.h:51
QDir
Catalog::msgid
QString msgid(const DocPosition &) const
Definition: catalog.cpp:187
QString::replace
QString & replace(int position, int n, QChar after)
EditorTab::reloadFile
Q_SCRIPTABLE void reloadFile()
Definition: editortab.cpp:1358
CatalogString
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
Definition: catalogstring.h:128
BinUnitsView
Definition: binunitsview.h:40
insertCatalogString
void insertCatalogString(Catalog *catalog, DocPosition pos, const CatalogString &catStr, int start)
Definition: cmd.cpp:421
ID_STATUS_ISFUZZY
#define ID_STATUS_ISFUZZY
Definition: actionproxy.h:97
alttransview.h
QUndoStack::isClean
bool isClean() const
EditorTab::signalNextFuzzyAvailable
void signalNextFuzzyAvailable(bool)
projectmodel.h
QDockWidget::toggleViewAction
QAction * toggleViewAction() const
QString::mid
QString mid(int position, int n) const
EditorTab::signalBookmarkDisplayed
void signalBookmarkDisplayed(bool)
ExtendedStates
Definition: catalogcapabilities.h:32
QVector< KAction * >
LokalizeSubwindowBase::statusBarItems
StatusBarProxy statusBarItems
Definition: lokalizesubwindowbase.h:63
prefs_lokalize.h
EditorTab::gotoEntry
void gotoEntry(DocPosition pos, int selection=0)
Definition: editortab.cpp:986
EditorTab::state
EditorState state()
Definition: editortab.cpp:929
EditorState
Definition: editortab.h:60
QLatin1String
QKeySequence
EditorTab::currentFile
Q_SCRIPTABLE QString currentFile()
Definition: editortab.h:148
QList::insert
void insert(int i, const T &value)
Catalog::lastBookmarkIndex
int lastBookmarkIndex() const
Definition: catalog.h:167
EditorTab::gotoPrev
Q_SCRIPTABLE void gotoPrev()
Definition: editortab.cpp:1131
Catalog::sourceWithTags
CatalogString sourceWithTags(const DocPosition &pos) const
Definition: catalog.cpp:203
Catalog::id
QString id(const DocPosition &pos) const
Definition: catalog.cpp:314
EditorTab::fileSaved
Q_SCRIPTABLE void fileSaved(const QString &path)
Project::path
QString path() const
Definition: project.h:66
glossaryview.h
QAction
Catalog::isApproved
bool isApproved(uint index) const
Definition: catalog.cpp:410
Catalog::numberOfEntries
int numberOfEntries() const
Definition: catalog.cpp:171
EditorTab::selectionInTarget
Q_SCRIPTABLE QString selectionInTarget()
Definition: editortab.cpp:1404
EditorTab::entryReady
Q_SCRIPTABLE bool entryReady(int entry)
Definition: editortab.cpp:1417
Catalog::numberOfNonApproved
int numberOfNonApproved() const
Definition: catalog.h:152
EditorTab
Editor tab.
Definition: editortab.h:85
Catalog::supportedMimeFilters
static QString supportedMimeFilters
Definition: catalog.h:259
EditorTab::hideDocks
void hideDocks()
Definition: editortab.cpp:737
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
Catalog::sourceLangCode
QString sourceLangCode() const
Definition: catalog.cpp:466
Catalog::prevFuzzyIndex
int prevFuzzyIndex(uint index) const
Definition: catalog.h:160
CatalogView::setEntryFilteredOut
void setEntryFilteredOut(int entry, bool filteredOut)
Definition: cataloglistview.cpp:302
Catalog::mimetype
QString mimetype()
Definition: catalog.cpp:458
QWidget::show
void show()
Catalog::states
static const char *const * states()
Definition: catalog.cpp:79
AltTransView
Definition: alttransview.h:36
Catalog::autoSaveRecovered
bool autoSaveRecovered()
Definition: catalog.h:171
QPaintEvent
EditorTab::currentFileContents
Q_SCRIPTABLE QByteArray currentFileContents()
Definition: editortab.cpp:1402
Catalog::isEquivTrans
bool isEquivTrans(const DocPosition &) const
Definition: catalog.cpp:443
EditorTab::sourceLangCode
Q_SCRIPTABLE QString sourceLangCode()
Definition: editortab.cpp:1418
Catalog::saveToUrl
bool saveToUrl(KUrl url)
Definition: catalog.cpp:615
EditorTab::gotoPrevUnfiltered
Q_SCRIPTABLE void gotoPrevUnfiltered()
Definition: editortab.cpp:1093
TargetState
TargetState
Definition: state.h:30
CatalogView::firstEntry
int firstEntry()
Definition: cataloglistview.cpp:291
LokalizeSubwindowBase2
C++ casting workaround.
Definition: lokalizesubwindowbase.h:70
DocPosition::UndefPart
Definition: pos.h:42
EditorView::tabBar
KTabBar * tabBar()
Definition: editorview.h:62
EditorTab::fileOpenRequested
void fileOpenRequested(const KUrl &path, const QString &str, const QString &ctxt)
Catalog::msgstr
virtual QString msgstr(const DocPosition &) const
Definition: catalog.cpp:195
binunitsview.h
CatalogView::setEntriesFilteredOut
void setEntriesFilteredOut(bool filteredOut=false)
Definition: cataloglistview.cpp:307
actionproxy.h
EditorTab::fileOpen
bool fileOpen(KUrl url=KUrl(), KUrl baseUrl=KUrl(), bool silent=false)
Definition: editortab.cpp:789
EditorAdaptor
ID_STATUS_UNTRANS
#define ID_STATUS_UNTRANS
Definition: actionproxy.h:96
GLOSSARY_SHORTCUTS
#define GLOSSARY_SHORTCUTS
Definition: glossaryview.h:44
EditorTab::signalNextUntranslatedAvailable
void signalNextUntranslatedAvailable(bool)
Catalog::numberOfUntranslated
int numberOfUntranslated() const
Definition: catalog.h:153
tmview.h
EditorTab::addTemporaryAlternateTranslation
Q_SCRIPTABLE void addTemporaryAlternateTranslation(int entry, const QString &translation)
Definition: editortab.cpp:1424
PhasesWindow
Definition: phaseswindow.h:41
switchPrev
bool switchPrev(Catalog *&catalog, DocPosition &pos, int parts)
Definition: pos.cpp:38
QMdiSubWindow
EditorTab::dbusObjectPath
QString dbusObjectPath()
Definition: editortab.cpp:1384
DocPosition::Comment
Definition: pos.h:45
phaseswindow.h
QVariant
EditorTab::setEntryTarget
Q_SCRIPTABLE void setEntryTarget(int entry, int form, const QString &content)
Definition: editortab.cpp:1427
EditorTab::setProperFocus
void setProperFocus()
Definition: editortab.cpp:732
EditorTab::addAlternateTranslation
Q_SCRIPTABLE void addAlternateTranslation(int entry, const QString &translation)
Definition: editortab.cpp:1423
AltTransView::attachAltTransFile
void attachAltTransFile(const QString &)
Definition: alttransview.cpp:109
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:07 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