Changeset View
Changeset View
Standalone View
Standalone View
src/project/projecttab.cpp
Show All 27 Lines | |||||
28 | #include "prefs.h" | 28 | #include "prefs.h" | ||
29 | #include "catalog.h" | 29 | #include "catalog.h" | ||
30 | 30 | | |||
31 | #include <klocalizedstring.h> | 31 | #include <klocalizedstring.h> | ||
32 | #include <kactioncategory.h> | 32 | #include <kactioncategory.h> | ||
33 | #include <kactioncollection.h> | 33 | #include <kactioncollection.h> | ||
34 | #include <kstandardaction.h> | 34 | #include <kstandardaction.h> | ||
35 | #include <kxmlguifactory.h> | 35 | #include <kxmlguifactory.h> | ||
36 | #include <kprocess.h> | ||||
36 | 37 | | |||
37 | #include <QLineEdit> | 38 | #include <QLineEdit> | ||
38 | #include <QIcon> | 39 | #include <QIcon> | ||
39 | #include <QContextMenuEvent> | 40 | #include <QContextMenuEvent> | ||
40 | #include <QMenu> | 41 | #include <QMenu> | ||
41 | #include <QVBoxLayout> | 42 | #include <QVBoxLayout> | ||
42 | #include <QShortcut> | 43 | #include <QShortcut> | ||
43 | #include <QSortFilterProxyModel> | 44 | #include <QSortFilterProxyModel> | ||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 245 | { | |||
256 | menu.addAction(i18nc("@action:inmenu","Replace in files"),this,SLOT(replaceInFiles())); | 257 | menu.addAction(i18nc("@action:inmenu","Replace in files"),this,SLOT(replaceInFiles())); | ||
257 | menu.addAction(i18nc("@action:inmenu","Spellcheck files"),this,SLOT(spellcheckFiles())); | 258 | menu.addAction(i18nc("@action:inmenu","Spellcheck files"),this,SLOT(spellcheckFiles())); | ||
258 | menu.addSeparator(); | 259 | menu.addSeparator(); | ||
259 | menu->addAction(i18nc("@action:inmenu","Get statistics for subfolders"),m_browser,SLOT(expandItems())); | 260 | menu->addAction(i18nc("@action:inmenu","Get statistics for subfolders"),m_browser,SLOT(expandItems())); | ||
260 | */ | 261 | */ | ||
261 | menu->addAction(i18nc("@action:inmenu", "Add to translation memory"), this, SLOT(scanFilesToTM())); | 262 | menu->addAction(i18nc("@action:inmenu", "Add to translation memory"), this, SLOT(scanFilesToTM())); | ||
262 | 263 | | |||
263 | menu->addAction(i18nc("@action:inmenu", "Search in files"), this, SLOT(searchInFiles())); | 264 | menu->addAction(i18nc("@action:inmenu", "Search in files"), this, SLOT(searchInFiles())); | ||
265 | if (Project::instance()->local()->pologyEnabled()) { | ||||
266 | menu->addAction(i18nc("@action:inmenu", "Launch Pology on files"), this, SLOT(pologyOnFiles())); | ||||
mlaurent: it's better if you use new connect api
as menu->addAction(i18nc("@action:inmenu", "Launch… | |||||
267 | } | ||||
264 | if (QDir(Project::instance()->templatesRoot()).exists()) | 268 | if (QDir(Project::instance()->templatesRoot()).exists()) | ||
265 | menu->addAction(i18nc("@action:inmenu", "Search in files (including templates)"), this, SLOT(searchInFilesInclTempl())); | 269 | menu->addAction(i18nc("@action:inmenu", "Search in files (including templates)"), this, SLOT(searchInFilesInclTempl())); | ||
266 | 270 | | |||
267 | // else if (Project::instance()->model()->hasChildren(/*m_proxyModel->mapToSource(*/(m_browser->currentIndex())) | 271 | // else if (Project::instance()->model()->hasChildren(/*m_proxyModel->mapToSource(*/(m_browser->currentIndex())) | ||
268 | // ) | 272 | // ) | ||
269 | // { | 273 | // { | ||
270 | // menu.addSeparator(); | 274 | // menu.addSeparator(); | ||
271 | // menu.addAction(i18n("Force Scanning"),this,SLOT(slotForceStats())); | 275 | // menu.addAction(i18n("Force Scanning"),this,SLOT(slotForceStats())); | ||
Show All 19 Lines | 294 | while (--i >= 0) { | |||
291 | if (files.at(i).startsWith(templatesRoot)) | 295 | if (files.at(i).startsWith(templatesRoot)) | ||
292 | files.removeAt(i); | 296 | files.removeAt(i); | ||
293 | } | 297 | } | ||
294 | } | 298 | } | ||
295 | 299 | | |||
296 | emit searchRequested(files); | 300 | emit searchRequested(files); | ||
297 | } | 301 | } | ||
298 | 302 | | |||
303 | void ProjectTab::pologyOnFiles() | ||||
304 | { | ||||
305 | QStringList files = m_browser->selectedItems(); | ||||
306 | QString templatesRoot = Project::instance()->templatesRoot(); | ||||
307 | QString filesAsString = QString(); | ||||
mlaurent: not necessary to initialize to QString() it's the default | |||||
308 | int i = files.size(); | ||||
309 | while (--i >= 0) { | ||||
310 | if (files.at(i).endsWith(QStringLiteral(".po"))) | ||||
311 | filesAsString += files.at(i) + QStringLiteral(" "); | ||||
312 | } | ||||
313 | | ||||
314 | QString command = Project::instance()->local()->pologyCommandFile().replace(QStringLiteral("%f"), filesAsString); | ||||
315 | KProcess* m_pologyProcess = new KProcess; | ||||
316 | m_pologyProcess->setShellCommand(command); | ||||
317 | m_pologyProcess->start(); | ||||
318 | } | ||||
319 | | ||||
299 | void ProjectTab::searchInFilesInclTempl() | 320 | void ProjectTab::searchInFilesInclTempl() | ||
300 | { | 321 | { | ||
301 | searchInFiles(true); | 322 | searchInFiles(true); | ||
302 | } | 323 | } | ||
303 | 324 | | |||
304 | void ProjectTab::openFile() | 325 | void ProjectTab::openFile() | ||
305 | { | 326 | { | ||
306 | QStringList files = m_browser->selectedItems(); | 327 | QStringList files = m_browser->selectedItems(); | ||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |
it's better if you use new connect api
as menu->addAction(i18nc("@action:inmenu", "Launch Pology on files"), this, &ProjectTab::pologyOnFiles);