~ubuntu-branches/ubuntu/maverick/juffed/maverick-proposed

« back to all changes in this revision

Viewing changes to src/Manager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2010-07-22 15:01:58 UTC
  • Revision ID: james.westby@ubuntu.com-20100722150158-m3792gi6tj0y8zl6
Tags: upstream-0.8.1
ImportĀ upstreamĀ versionĀ 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
JuffEd - An advanced text editor
 
3
Copyright 2007-2009 Mikhail Murzin
 
4
 
 
5
This program is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU General Public License 
 
7
version 2 as published by the Free Software Foundation.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
GNU General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU General Public License
 
15
along with this program; if not, write to the Free Software
 
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
17
*/
 
18
 
 
19
#include "Manager.h"
 
20
 
 
21
//#define JUFF_RICH_DOC
 
22
 
 
23
#include <QtCore/QFile>
 
24
#include <QtCore/QMap>
 
25
#include <QtGui/QActionGroup>
 
26
#include <QtGui/QApplication>
 
27
#include <QtGui/QClipboard>
 
28
#include <QtGui/QInputDialog>
 
29
#include <QtGui/QMenu>
 
30
#include <QtGui/QMessageBox>
 
31
#include <QtGui/QPushButton>
 
32
#include <QtGui/QToolBar>
 
33
 
 
34
#include "AppInfo.h"
 
35
#include "CharsetsSettings.h"
 
36
#include "CommandStorage.h"
 
37
#include "DocHandler.h"
 
38
#include "Document.h"
 
39
#include "Functions.h"
 
40
#include "MainSettings.h"
 
41
#include "NullDoc.h"
 
42
#include "Parameter.h"
 
43
#include "PluginManager.h"
 
44
#include "SciDocHandler.h"
 
45
#include "gui/StatusLabel.h"
 
46
#include "gui/Viewer.h"
 
47
#include "gui/GUI.h"
 
48
 
 
49
#include "Log.h"
 
50
#include "gui/GUIManager.h"
 
51
 
 
52
#ifdef JUFF_RICH_DOC
 
53
#include "RichDocHandler.h"
 
54
#endif
 
55
 
 
56
static const char* EMPTY_SESSION = "_empty_session_";
 
57
 
 
58
namespace Juff {
 
59
 
 
60
class Manager::Interior {
 
61
public:
 
62
        Interior(Manager* m, GUI::GUI* gui) : stayAlive_(false) {
 
63
                viewer_ = new GUI::Viewer();
 
64
                gui_ = gui;
 
65
                pluginManager_ = 0;
 
66
 
 
67
                mainTB_ = new QToolBar("Main");
 
68
                fileMenu_ = new QMenu(QObject::tr("&File"));
 
69
                editMenu_ = new QMenu(QObject::tr("&Edit"));
 
70
                viewMenu_ = new QMenu(QObject::tr("&View"));
 
71
                formatMenu_ = new QMenu(QObject::tr("Fo&rmat"));
 
72
                charsetMenu_ = new QMenu(QObject::tr("&Charset"));
 
73
                recentFilesMenu_ = new QMenu(QObject::tr("Recent files"));
 
74
                sessionsMenu_ = new QMenu(QObject::tr("Sessions"));
 
75
                connect(recentFilesMenu_, SIGNAL(aboutToShow()), m, SLOT(initRecentFilesMenu()));
 
76
                connect(sessionsMenu_, SIGNAL(aboutToShow()), m, SLOT(initSessionsMenu()));
 
77
 
 
78
                chActGr_ = new QActionGroup(m);
 
79
 
 
80
                QString recentFiles = MainSettings::recentFiles();
 
81
                if ( !recentFiles.isEmpty() ) {
 
82
                        QStringList fileList = recentFiles.split(";");
 
83
                        int count = fileList.count();
 
84
                        for(int i = count - 1; i >= 0; --i) {
 
85
                                const QString& fileName = fileList.at(i);
 
86
                                addToRecentFiles(fileName);
 
87
                        }
 
88
                }
 
89
 
 
90
                posL_ = new GUI::StatusLabel("");
 
91
                nameL_ = new GUI::StatusLabel("");
 
92
                charsetL_ = new GUI::StatusLabel("");
 
93
                linesL_ = new GUI::StatusLabel("");
 
94
                posL_->setMinimumWidth(130);
 
95
                posL_->setToolTip(QObject::tr("Cursor position"));
 
96
                nameL_->setToolTip(QObject::tr("File full name"));
 
97
                charsetL_->setToolTip(QObject::tr("Current character set"));
 
98
                linesL_->setToolTip(QObject::tr("Lines count"));
 
99
                charsetL_->setMenu(charsetMenu_);
 
100
                
 
101
                gui_->addStatusWidget(posL_);
 
102
                gui_->addStatusWidget(nameL_);
 
103
                gui_->addStatusWidget(linesL_);
 
104
                gui_->addStatusWidget(charsetL_);
 
105
 
 
106
                posL_->hide();
 
107
                nameL_->hide();
 
108
                charsetL_->hide();
 
109
                linesL_->hide();
 
110
                
 
111
                fileNameStatusMenu_ = new QMenu();
 
112
                nameL_->setMenu(fileNameStatusMenu_);
 
113
        }
 
114
        ~Interior() {
 
115
                delete recentFilesMenu_;
 
116
                delete chActGr_;
 
117
                delete fileMenu_;
 
118
                delete editMenu_;
 
119
                delete viewMenu_;
 
120
                delete charsetMenu_;
 
121
                delete mainTB_;
 
122
                delete viewer_;
 
123
                if ( pluginManager_ )
 
124
                        delete pluginManager_;
 
125
                delete fileNameStatusMenu_;
 
126
        }
 
127
 
 
128
        Document* getDocByView(QWidget* w) {
 
129
                if ( w ) {
 
130
                        foreach (Document* doc, docs1_) {
 
131
                                if ( doc->widget() == w )
 
132
                                        return doc;
 
133
                        }
 
134
                        foreach (Document* doc, docs2_) {
 
135
                                if ( doc->widget() == w )
 
136
                                        return doc;
 
137
                        }
 
138
                }
 
139
                return NullDoc::instance();
 
140
        }
 
141
        DocHandler* getHandlerByDoc(Document* doc) {
 
142
                if ( doc && !doc->isNull() ) {
 
143
                        QString type = doc->type();
 
144
                        if ( handlers_.contains(type) ) {
 
145
                                return handlers_[type];
 
146
                        }
 
147
                }
 
148
                return 0;
 
149
        }
 
150
 
 
151
        void addToRecentFiles(const QString& fileName) {
 
152
                recentFiles_.removeAll(fileName);
 
153
                recentFiles_.push_front(fileName);
 
154
                if ( recentFiles_.count() > MainSettings::recentFilesCount() )
 
155
                        recentFiles_.removeLast();
 
156
 
 
157
                MainSettings::setRecentFiles(recentFiles_.join(";"));
 
158
        }
 
159
 
 
160
        void displayFileName(const QString& fileName) {
 
161
                if ( Juff::isNoname(fileName) )
 
162
                        nameL_->setText(QString(" %1 ").arg(Juff::getDocTitle(fileName)));
 
163
                else
 
164
                        nameL_->setText(QString(" %1 ").arg(fileName));
 
165
        }
 
166
        
 
167
        void displayCharset(const QString& charset) {
 
168
                charsetL_->setText(QString(" %1 ").arg(charset));
 
169
                charsetL_->setToolTip(QObject::tr("Current character set: %1").arg(charset));
 
170
                if ( QAction* chAct = charsetActions_[charset] )
 
171
                        chAct->setChecked(true);
 
172
        }
 
173
        
 
174
        QMap<QString, DocHandler*> handlers_;
 
175
        QMap<QString, QWidgetList> statusWidgets_;
 
176
        QString docOldType_;
 
177
        QMap<QString, Document*> docs1_;
 
178
        QMap<QString, Document*> docs2_;
 
179
        QString sessionName_;
 
180
        GUI::Viewer* viewer_;
 
181
        GUI::GUI* gui_;
 
182
        PluginManager* pluginManager_;
 
183
        QToolBar* mainTB_;
 
184
        QMenu* fileMenu_;
 
185
        QMenu* editMenu_;
 
186
        QMenu* viewMenu_;
 
187
        QMenu* formatMenu_;
 
188
        QMenu* charsetMenu_;
 
189
        QMap<QString, QAction*> charsetActions_;
 
190
        QActionGroup* chActGr_;
 
191
        QMenu* recentFilesMenu_;
 
192
        QMenu* sessionsMenu_;
 
193
        QStringList recentFiles_;
 
194
        GUI::StatusLabel* posL_;
 
195
        GUI::StatusLabel* nameL_;
 
196
        GUI::StatusLabel* charsetL_;
 
197
        GUI::StatusLabel* linesL_;
 
198
        bool stayAlive_;
 
199
        
 
200
        QMenu* fileNameStatusMenu_;
 
201
};
 
202
 
 
203
Manager::Manager(GUI::GUI* gui) : QObject(), ManagerInterface() {
 
204
        JUFFENTRY;
 
205
 
 
206
        registerCommands();
 
207
        mInt_ = new Interior(this, gui);
 
208
 
 
209
        CommandStorage::instance()->registerCommand(ID_DOC_NEXT, mInt_->viewer_, SLOT(nextDoc()));
 
210
        CommandStorage::instance()->registerCommand(ID_DOC_PREV, mInt_->viewer_, SLOT(prevDoc()));
 
211
 
 
212
        initMainMenu();
 
213
        initMainToolBar();
 
214
 
 
215
 
 
216
        gui->updateTitle("", "", false);
 
217
        gui->setCentralWidget(mInt_->viewer_->widget());
 
218
 
 
219
 
 
220
        //      TODO : add a proper engines loading
 
221
        //      engines
 
222
/*      SimpleDocHandler* simpleDH = new SimpleDocHandler();
 
223
        addDocHandler(simpleDH);
 
224
*/      
 
225
 
 
226
#ifdef JUFF_RICH_DOC
 
227
        RichDocHandler* richDH = new RichDocHandler();
 
228
        addDocHandler(richDH);
 
229
#endif
 
230
 
 
231
        SciDocHandler* sciDH = new SciDocHandler();
 
232
 
 
233
        // Need to call it here because Keybindings plugin 
 
234
        // needs to have updated shortcuts
 
235
        CommandStorage::instance()->updateShortcuts();
 
236
 
 
237
        //      TODO : add a proper engines list initialization
 
238
        mInt_->pluginManager_ = new PluginManager(QStringList() << /*"simple" <<*/ "rich" << "sci", this, gui);
 
239
        mInt_->pluginManager_->loadPlugins();
 
240
 
 
241
        addDocHandler(sciDH);
 
242
 
 
243
        //      recent files
 
244
        QAction* saveAct = CommandStorage::instance()->action(ID_FILE_SAVE);
 
245
        if ( mInt_->fileMenu_ && saveAct ) {
 
246
                mInt_->fileMenu_->insertMenu(saveAct, mInt_->recentFilesMenu_);
 
247
        }
 
248
        //      format menu
 
249
        mInt_->formatMenu_->addMenu(mInt_->charsetMenu_);
 
250
        //
 
251
 
 
252
 
 
253
        mInt_->viewer_->widget()->addAction(CommandStorage::instance()->action(ID_DOC_NEXT));
 
254
        mInt_->viewer_->widget()->addAction(CommandStorage::instance()->action(ID_DOC_PREV));
 
255
 
 
256
        connect(mInt_->viewer_, SIGNAL(curDocChanged(QWidget*)), SLOT(onCurDocChanged(QWidget*)));
 
257
        connect(mInt_->viewer_, SIGNAL(requestDocName(QWidget*, QString&)), SLOT(onDocNameRequested(QWidget*, QString&)));
 
258
        connect(mInt_->viewer_, SIGNAL(requestDocClose(QWidget*)), SLOT(onDocCloseRequested(QWidget*)));
 
259
        connect(mInt_->viewer_, SIGNAL(requestNewDoc()), SLOT(fileNew()));
 
260
        connect(gui, SIGNAL(settingsApplied()), SLOT(applySettings()));
 
261
        connect(gui, SIGNAL(closeRequested(bool&)), this, SLOT(onCloseEvent(bool&)));
 
262
        connect(mInt_->viewer_, SIGNAL(requestOpenDoc(const QString&)), this, SLOT(openDoc(const QString&)));
 
263
        connect(mInt_->posL_, SIGNAL(clicked()), SLOT(gotoLine()));
 
264
        connect(mInt_->linesL_, SIGNAL(clicked()), SLOT(gotoLine()));
 
265
#if QT_VERSION >= 0x040500
 
266
        connect(mInt_->viewer_, SIGNAL(tabMoved(int, int)), mInt_->pluginManager_, SLOT(notifyTabMoved(int, int)));
 
267
#endif
 
268
 
 
269
        mInt_->fileNameStatusMenu_->addAction(tr("Copy to clipboard"), this, SLOT(copyFileName()));
 
270
        //////////////////
 
271
        //      GUI Controls
 
272
 
 
273
        //      menus from engines
 
274
        MenuList standardMenus;
 
275
        standardMenus << mInt_->fileMenu_ << mInt_->editMenu_ 
 
276
                      << mInt_->viewMenu_ << mInt_->formatMenu_;
 
277
        MenuList sciMenus = sciDH->menus();
 
278
        sciMenus << mInt_->pluginManager_->getMenus("sci");
 
279
        mInt_->gui_->addMenus("all", standardMenus);
 
280
        mInt_->gui_->addMenus("sci", sciMenus);
 
281
        //      toolbars from engines
 
282
        mInt_->gui_->addToolBar("all", mInt_->mainTB_);
 
283
        mInt_->gui_->addToolBars("sci", sciDH->toolBars());
 
284
        
 
285
#ifdef JUFF_RICH_DOC
 
286
        MenuList richMenus = richDH->menus();
 
287
        richMenus << mInt_->pluginManager_->getMenus("rich");
 
288
        mInt_->gui_->addMenus("rich", richMenus);
 
289
        mInt_->gui_->addToolBars("rich", richDH->toolBars());
 
290
#endif
 
291
 
 
292
        //      controls from plugins
 
293
        MenuID ids[] = { ID_MENU_FILE, ID_MENU_EDIT, ID_MENU_VIEW, ID_MENU_FORMAT, ID_MENU_TOOLS, ID_MENU_NONE };
 
294
        QString engines[] = { "sci", "rich", "all", "" };
 
295
        int ei = 0;
 
296
        while ( !engines[ei].isEmpty() ) {
 
297
                QString engine = engines[ei];
 
298
 
 
299
                //      toolbars
 
300
                mInt_->gui_->addToolBars(engine, mInt_->pluginManager_->getToolBars(engine));
 
301
 
 
302
                //      docks
 
303
                QWidgetList docks = mInt_->pluginManager_->getDocks(engine);
 
304
                mInt_->gui_->addDocks(engine, docks);
 
305
 
 
306
                //      items to main menus
 
307
                int i = 0;
 
308
                while ( ids[i] != ID_MENU_NONE ) {
 
309
                        MenuID id = ids[i];
 
310
                        QMenu* menu = 0;
 
311
                        switch ( id ) {
 
312
                                case ID_MENU_FILE : menu = mInt_->fileMenu_; break;
 
313
                                case ID_MENU_EDIT : menu = mInt_->editMenu_; break;
 
314
                                case ID_MENU_VIEW : menu = mInt_->viewMenu_; break;
 
315
                                case ID_MENU_FORMAT : menu = mInt_->formatMenu_; break;
 
316
                                case ID_MENU_TOOLS : menu = mInt_->gui_->toolsMenu(); break;
 
317
                                default: ;
 
318
                        }
 
319
                        if ( menu ) {
 
320
                                ActionList actions = mInt_->pluginManager_->getMainMenuActions(engine, id);
 
321
                                mInt_->gui_->addActions(engine, actions);
 
322
                                foreach (QAction* act, actions)
 
323
                                        menu->addAction(act);
 
324
                        }
 
325
                        ++i;
 
326
                }
 
327
                ++ei;
 
328
        }
 
329
        //
 
330
 
 
331
        mInt_->gui_->addMenus("all", mInt_->pluginManager_->getMenus("all"));
 
332
 
 
333
        applySettings(false);
 
334
 
 
335
        //      restore toolbars and docks positions
 
336
        mInt_->gui_->restoreState();
 
337
}
 
338
 
 
339
Manager::~Manager() {
 
340
        JUFFDTOR;
 
341
}
 
342
 
 
343
void Manager::registerCommands() {
 
344
        CommandStorage* st = CommandStorage::instance();
 
345
        st->registerCommand(ID_FILE_NEW,        this, SLOT(fileNew()));
 
346
//      st->registerCommand(ID_FILE_NEW_RICH,   this, SLOT(fileNewRich()));
 
347
        st->registerCommand(ID_FILE_OPEN,       this, SLOT(fileOpen()));
 
348
        st->registerCommand(ID_FILE_SAVE,       this, SLOT(fileSave()));
 
349
        st->registerCommand(ID_FILE_SAVE_AS,    this, SLOT(fileSaveAs()));
 
350
        st->registerCommand(ID_FILE_SAVE_ALL,   this, SLOT(fileSaveAll()));
 
351
        st->registerCommand(ID_FILE_RELOAD,     this, SLOT(fileReload()));
 
352
        st->registerCommand(ID_FILE_CLOSE,      this, SLOT(fileClose()));
 
353
        st->registerCommand(ID_FILE_CLOSE_ALL,  this, SLOT(fileCloseAll()));
 
354
        st->registerCommand(ID_FILE_PRINT,      this, SLOT(filePrint()));
 
355
        st->registerCommand(ID_EXIT,            this, SLOT(exit()));
 
356
        //
 
357
        st->registerCommand(ID_FILE_NEW_RICH,   this, SLOT(fileNewRich()));
 
358
        //
 
359
        st->registerCommand(ID_SESSION_NEW,     this, SLOT(sessionNew()));
 
360
        st->registerCommand(ID_SESSION_OPEN,    this, SLOT(sessionOpen()));
 
361
        st->registerCommand(ID_SESSION_SAVE,    this, SLOT(sessionSave()));
 
362
        st->registerCommand(ID_SESSION_SAVE_AS, this, SLOT(sessionSaveAs()));
 
363
        //
 
364
        st->registerCommand(ID_EDIT_UNDO,       this, SLOT(editUndo()));
 
365
        st->registerCommand(ID_EDIT_REDO,       this, SLOT(editRedo()));
 
366
        st->registerCommand(ID_EDIT_CUT,        this, SLOT(editCut()));
 
367
        st->registerCommand(ID_EDIT_COPY,       this, SLOT(editCopy()));
 
368
        st->registerCommand(ID_EDIT_PASTE,      this, SLOT(editPaste()));
 
369
        //
 
370
        st->registerCommand(ID_FIND,            this, SLOT(find()));
 
371
        st->registerCommand(ID_FIND_NEXT,       this, SLOT(findNext()));
 
372
        st->registerCommand(ID_FIND_PREV,       this, SLOT(findPrev()));
 
373
        st->registerCommand(ID_REPLACE,         this, SLOT(replace()));
 
374
        st->registerCommand(ID_GOTO_LINE,       this, SLOT(gotoLine()));
 
375
}
 
376
 
 
377
void Manager::initMainMenu() {
 
378
        CommandStorage* st = CommandStorage::instance();
 
379
        mInt_->fileMenu_->addAction(st->action(ID_FILE_NEW));
 
380
//      mInt_->fileMenu_->addAction(st->action(ID_FILE_NEW_RICH));
 
381
        mInt_->fileMenu_->addAction(st->action(ID_FILE_OPEN));
 
382
        mInt_->fileMenu_->addAction(st->action(ID_FILE_SAVE));
 
383
        mInt_->fileMenu_->addAction(st->action(ID_FILE_SAVE_AS));
 
384
        mInt_->fileMenu_->addAction(st->action(ID_FILE_SAVE_ALL));
 
385
        mInt_->fileMenu_->addAction(st->action(ID_FILE_RELOAD));
 
386
        mInt_->fileMenu_->addAction(st->action(ID_SEPARATOR));
 
387
        mInt_->fileMenu_->addAction(st->action(ID_FILE_CLOSE));
 
388
        mInt_->fileMenu_->addAction(st->action(ID_FILE_CLOSE_ALL));
 
389
        mInt_->fileMenu_->addAction(st->action(ID_FILE_PRINT));
 
390
        mInt_->fileMenu_->addAction(st->action(ID_SEPARATOR));
 
391
        mInt_->fileMenu_->addMenu(mInt_->sessionsMenu_);
 
392
        mInt_->fileMenu_->addAction(st->action(ID_SEPARATOR));
 
393
        mInt_->fileMenu_->addAction(st->action(ID_EXIT));
 
394
        
 
395
        mInt_->editMenu_->addAction(st->action(ID_EDIT_UNDO));
 
396
        mInt_->editMenu_->addAction(st->action(ID_EDIT_REDO));
 
397
        mInt_->editMenu_->addAction(st->action(ID_SEPARATOR));
 
398
        mInt_->editMenu_->addAction(st->action(ID_EDIT_CUT));
 
399
        mInt_->editMenu_->addAction(st->action(ID_EDIT_COPY));
 
400
        mInt_->editMenu_->addAction(st->action(ID_EDIT_PASTE));
 
401
        mInt_->editMenu_->addAction(st->action(ID_SEPARATOR));
 
402
        mInt_->editMenu_->addAction(st->action(ID_FIND));
 
403
        mInt_->editMenu_->addAction(st->action(ID_FIND_NEXT));
 
404
        mInt_->editMenu_->addAction(st->action(ID_FIND_PREV));
 
405
        mInt_->editMenu_->addAction(st->action(ID_REPLACE));
 
406
        mInt_->editMenu_->addAction(st->action(ID_SEPARATOR));
 
407
        mInt_->editMenu_->addAction(st->action(ID_GOTO_LINE));
 
408
}
 
409
 
 
410
void Manager::initMainToolBar() {
 
411
        QToolBar* tb = mInt_->mainTB_;
 
412
        CommandStorage* st = CommandStorage::instance();
 
413
        QString tbStr = MainSettings::toolBar();
 
414
        if ( tbStr.isEmpty() ) {
 
415
                tb->addAction(st->action(ID_FILE_NEW));
 
416
                tb->addAction(st->action(ID_FILE_OPEN));
 
417
                tb->addAction(st->action(ID_FILE_SAVE));
 
418
                tb->addAction(st->action(ID_SEPARATOR));
 
419
                tb->addAction(st->action(ID_FILE_PRINT));
 
420
                tb->addAction(st->action(ID_SEPARATOR));
 
421
                tb->addAction(st->action(ID_EDIT_UNDO));
 
422
                tb->addAction(st->action(ID_EDIT_REDO));
 
423
                tb->addAction(st->action(ID_SEPARATOR));
 
424
                tb->addAction(st->action(ID_EDIT_CUT));
 
425
                tb->addAction(st->action(ID_EDIT_COPY));
 
426
                tb->addAction(st->action(ID_EDIT_PASTE));
 
427
        }
 
428
        else {
 
429
                QStringList items = tbStr.split('|');
 
430
                foreach (QString item, items) {
 
431
                        CommandID id = ID_NONE;
 
432
                        if ( item == "sep" )
 
433
                                id = ID_SEPARATOR;
 
434
                        else if ( item == "new" )
 
435
                                id = ID_FILE_NEW;
 
436
                        else if ( item == "open" )
 
437
                                id = ID_FILE_OPEN;
 
438
                        else if ( item == "save" )
 
439
                                id = ID_FILE_SAVE;
 
440
                        else if ( item == "print" )
 
441
                                id = ID_FILE_PRINT;
 
442
                        else if ( item == "undo" )
 
443
                                id = ID_EDIT_UNDO;
 
444
                        else if ( item == "redo" )
 
445
                                id = ID_EDIT_REDO;
 
446
                        else if ( item == "cut" )
 
447
                                id = ID_EDIT_CUT;
 
448
                        else if ( item == "copy" )
 
449
                                id = ID_EDIT_COPY;
 
450
                        else if ( item == "paste" )
 
451
                                id = ID_EDIT_PASTE;
 
452
                        else if ( item == "find" )
 
453
                                id = ID_FIND;
 
454
                        else if ( item == "replace" )
 
455
                                id = ID_REPLACE;
 
456
                        
 
457
                        if ( id != ID_NONE )
 
458
                                tb->addAction(st->action(id));
 
459
                }
 
460
        }
 
461
}
 
462
 
 
463
void Manager::initCharsetMenu() {
 
464
        JUFFENTRY;
 
465
 
 
466
        mInt_->charsetMenu_->clear();
 
467
        mInt_->charsetActions_.clear();
 
468
        foreach (QAction* a, mInt_->chActGr_->actions())
 
469
                mInt_->chActGr_->removeAction(a);
 
470
 
 
471
 
 
472
        QStringList charsets = CharsetsSettings::getCharsetsList();
 
473
        foreach (QString charset, charsets) {
 
474
                if ( CharsetsSettings::charsetEnabled(charset) ) {
 
475
                        QAction* action = mInt_->charsetMenu_->addAction(charset, this, SLOT(charsetSelected()));
 
476
                        action->setCheckable(true);
 
477
                        mInt_->charsetActions_[charset] = action;
 
478
                        mInt_->chActGr_->addAction(action);
 
479
                }
 
480
        }
 
481
}
 
482
 
 
483
void Manager::initRecentFilesMenu() {
 
484
        JUFFENTRY;
 
485
 
 
486
        if ( mInt_->recentFilesMenu_ == 0 )
 
487
                return;
 
488
 
 
489
        mInt_->recentFilesMenu_->clear();
 
490
        
 
491
        foreach (QString fileName, mInt_->recentFiles_) {
 
492
                mInt_->recentFilesMenu_->addAction(fileName, this, SLOT(fileRecent()));
 
493
        }
 
494
        
 
495
        if ( mInt_->recentFiles_.count() == 0 )
 
496
                mInt_->recentFilesMenu_->setEnabled(false);
 
497
        else
 
498
                mInt_->recentFilesMenu_->setEnabled(true);
 
499
}
 
500
 
 
501
void Manager::initSessionsMenu() {
 
502
        JUFFENTRY;
 
503
        
 
504
        CommandStorage* st = CommandStorage::instance();
 
505
        mInt_->sessionsMenu_->clear();
 
506
        mInt_->sessionsMenu_->addAction(st->action(ID_SESSION_NEW));
 
507
        mInt_->sessionsMenu_->addAction(st->action(ID_SESSION_OPEN));
 
508
        mInt_->sessionsMenu_->addAction(st->action(ID_SESSION_SAVE));
 
509
        mInt_->sessionsMenu_->addAction(st->action(ID_SESSION_SAVE_AS));
 
510
        
 
511
        QStringList sessions;
 
512
        QDir sessionDir(AppInfo::configDirPath() + "/sessions/");
 
513
        if (sessionDir.exists()) {
 
514
                sessions = sessionDir.entryList(QDir::Files | QDir::NoSymLinks);
 
515
                if ( !sessions.isEmpty() )
 
516
                                mInt_->sessionsMenu_->addSeparator();
 
517
 
 
518
                foreach (QString session, sessions) {
 
519
                        if (session.compare(EMPTY_SESSION) != 0) {
 
520
                                mInt_->sessionsMenu_->addAction(session, this, SLOT(session()));
 
521
                        }
 
522
                }
 
523
        }
 
524
}
 
525
 
 
526
bool Manager::closeWithConfirmation(Document* doc) {
 
527
        if ( !doc || doc->isNull() )
 
528
                return true;
 
529
        
 
530
        bool result = true;
 
531
        if ( doc->isModified() ) {
 
532
                //      TODO : move this question to GUI
 
533
                QString str = tr("The document ") + doc->fileName();
 
534
                str += tr(" has been modified.\nDo you want to save your changes?");
 
535
                int ret = QMessageBox::warning(mInt_->viewer_->widget(), tr("Close document"),
 
536
                                str, QMessageBox::Save | QMessageBox::Discard
 
537
                                | QMessageBox::Cancel, QMessageBox::Save);
 
538
 
 
539
                switch (ret) {
 
540
                        case QMessageBox::Save:
 
541
                                if ( fileSave() ) {
 
542
                                        closeDoc(doc);
 
543
                                }
 
544
                                else {
 
545
                                        result = false;
 
546
                                }
 
547
                                break;
 
548
 
 
549
                        case QMessageBox::Discard:
 
550
                                closeDoc(doc);
 
551
                                break;
 
552
 
 
553
                        case QMessageBox::Cancel:
 
554
                                result = false;
 
555
                                break;
 
556
                }
 
557
        }
 
558
        else {
 
559
                closeDoc(doc);
 
560
        }
 
561
 
 
562
        return result;
 
563
}
 
564
 
 
565
bool Manager::confirmExit() {
 
566
        JUFFENTRY;
 
567
 
 
568
        MainSettings::setLastSessionName(mInt_->sessionName_);
 
569
        if ( MainSettings::saveSessionOnClose() ) {
 
570
                saveSess(mInt_->sessionName_);
 
571
        }
 
572
        
 
573
        return closeSess();
 
574
}
 
575
 
 
576
void Manager::onCloseEvent(bool& confirm) {
 
577
        confirm = confirmExit();
 
578
        if ( confirm )
 
579
                mInt_->gui_->saveState();
 
580
}
 
581
 
 
582
void Manager::exit() {
 
583
        JUFFENTRY;
 
584
 
 
585
        if ( confirmExit() ) {
 
586
                mInt_->gui_->saveState();
 
587
                qApp->quit();
 
588
        }
 
589
}
 
590
 
 
591
void Manager::addDocHandler(DocHandler* handler) {
 
592
        if ( !handler )
 
593
                return;
 
594
 
 
595
        QString type = handler->type();
 
596
        if ( mInt_->handlers_.contains(type) ) {
 
597
                mInt_->handlers_[type]->disconnect();
 
598
                delete mInt_->handlers_[type];
 
599
        }
 
600
        mInt_->handlers_[type] = handler;
 
601
        mInt_->statusWidgets_[type] = handler->statusWidgets();
 
602
        foreach (QWidget* w, mInt_->statusWidgets_[type]) {
 
603
                mInt_->gui_->addStatusWidget(w);
 
604
                w->hide();
 
605
        }
 
606
        handler->addContextMenuActions(mInt_->pluginManager_->getContextMenuActions(type));
 
607
 
 
608
        QAction* act = 0;
 
609
        foreach(act, handler->menuActions(ID_MENU_EDIT)) {
 
610
                mInt_->editMenu_->addAction(act);
 
611
                mInt_->gui_->addAction(type, act);
 
612
        }
 
613
        foreach(act, handler->menuActions(ID_MENU_VIEW)) {
 
614
                mInt_->viewMenu_->addAction(act);
 
615
                mInt_->gui_->addAction(type, act);
 
616
        }
 
617
        foreach(act, handler->menuActions(ID_MENU_FORMAT)) {
 
618
                mInt_->formatMenu_->addAction(act);
 
619
                mInt_->gui_->addAction(type, act);
 
620
        }
 
621
        QMenu* toolsMenu = mInt_->gui_->toolsMenu();
 
622
        foreach(act, handler->menuActions(ID_MENU_TOOLS)) {
 
623
                toolsMenu->addAction(act);
 
624
                mInt_->gui_->addAction(type, act);
 
625
        }
 
626
        connect(handler, SIGNAL(getCurDoc()), SLOT(curDoc()));
 
627
}
 
628
 
 
629
void Manager::applySettings(bool save /* = true*/) {
 
630
        mInt_->viewer_->applySettings();
 
631
        mInt_->gui_->setToolBarIconSize(MainSettings::iconSize());
 
632
        mInt_->gui_->setToolButtonStyle((Qt::ToolButtonStyle)MainSettings::toolButtonStyle());
 
633
        IconManager::instance()->setCurrentIconTheme(MainSettings::iconTheme(), MainSettings::iconSize());
 
634
        CommandStorage::instance()->updateIcons();
 
635
 
 
636
        QMap<QString, Document*>::iterator it = mInt_->docs1_.begin();
 
637
        for (; it != mInt_->docs1_.end(); it++) {
 
638
                it.value()->applySettings();
 
639
        }
 
640
         
 
641
        it = mInt_->docs2_.begin();
 
642
        for (; it != mInt_->docs2_.end(); it++) {
 
643
                it.value()->applySettings();
 
644
        }
 
645
        
 
646
        initCharsetMenu();
 
647
        
 
648
        mInt_->pluginManager_->applySettings();
 
649
        
 
650
        // this needs to be called after 
 
651
        // PluginManager->applySettings() is called
 
652
        CommandStorage::instance()->updateShortcuts();
 
653
        
 
654
//      if ( save )
 
655
                Settings::write();
 
656
}
 
657
 
 
658
Document* Manager::curDoc() const {
 
659
        JUFFENTRY;
 
660
 
 
661
        QWidget* w = mInt_->viewer_->curDoc();
 
662
        if ( !w )
 
663
                JUFFDEBUG("widget is 0");
 
664
        return mInt_->getDocByView(w);
 
665
}
 
666
 
 
667
 
 
668
void Manager::openDoc(const QString& fileName) {
 
669
                        
 
670
        mInt_->gui_->activateMW();
 
671
        
 
672
        //      check if this file is already opened
 
673
        if ( mInt_->docs1_.contains(fileName) ) {
 
674
                mInt_->viewer_->activateDoc(mInt_->docs1_[fileName]);
 
675
        }
 
676
        else if ( mInt_->docs2_.contains(fileName) ) {
 
677
                mInt_->viewer_->activateDoc(mInt_->docs2_[fileName]);
 
678
        }
 
679
        else {
 
680
                if ( QFileInfo(fileName).isFile() ) {
 
681
                        Document* cur = curDoc();
 
682
                        createDoc("sci", fileName);
 
683
                        mInt_->addToRecentFiles(fileName);
 
684
 
 
685
                        //      close the previous document if it was alone and not modified
 
686
                        if ( docCount() == 2 && cur && isNoname(cur->fileName()) && !cur->isModified() )
 
687
                                closeDoc(cur);
 
688
                }
 
689
                else if ( QFileInfo(fileName).isDir() ) {
 
690
                        QDir dir(fileName);
 
691
                        QStringList files = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
 
692
                        foreach (QString dirItem, files) {
 
693
                                openDoc(dir.absoluteFilePath(dirItem));
 
694
                        }
 
695
                }
 
696
        }
 
697
}
 
698
 
 
699
void Manager::createDoc(const QString& type, const QString& fileName) {
 
700
        JUFFENTRY;
 
701
 
 
702
        if ( !fileName.isEmpty() && !QFileInfo(fileName).exists() ) {
 
703
                QMessageBox::information(NULL, tr("Warning"), tr("Document '%1' doesn't exist").arg(fileName));
 
704
        }
 
705
        
 
706
        DocHandler* h = mInt_->handlers_[type];
 
707
        if ( h ) {
 
708
                Document* doc = h->createDoc(fileName);
 
709
                if ( doc ) {
 
710
                        QString fName = doc->fileName();
 
711
                        
 
712
                        connect(doc, SIGNAL(modified(bool)), SLOT(docModified(bool)));
 
713
                        connect(doc, SIGNAL(fileNameChanged(const QString&)), SLOT(docFileNameChanged(const QString&)));
 
714
                        connect(doc, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(onCursorPositionChanged(int, int)));
 
715
                        connect(doc, SIGNAL(linesCountChanged(int)), this, SLOT(onLinesCountChanged(int)));
 
716
                        connect(doc, SIGNAL(contextMenuCalled(int, int)), this, SLOT(onContextMenuCalled(int, int)));
 
717
                        
 
718
                        mInt_->docs1_[fName] = doc;
 
719
                        mInt_->viewer_->addDoc(doc, 1);
 
720
 
 
721
                        mInt_->pluginManager_->notifyDocCreated(fName);
 
722
                        
 
723
                        if ( mInt_->posL_->isHidden() ) {
 
724
                                mInt_->posL_->show();
 
725
                                mInt_->nameL_->show();
 
726
                                mInt_->charsetL_->show();
 
727
                                mInt_->linesL_->show();
 
728
                        }
 
729
                }
 
730
        }
 
731
}
 
732
 
 
733
bool Manager::saveDoc(Document* doc, const QString& fileName, const QString& charset) {
 
734
        JUFFENTRY;
 
735
 
 
736
        if ( !doc || doc->isNull() )
 
737
                return false;
 
738
 
 
739
        QString name = fileName;
 
740
        
 
741
        if ( QFile::exists(fileName) && !QFileInfo(fileName).isWritable() ) {
 
742
                //      file exists and is not writabe. Ask what to do.
 
743
                
 
744
                QString msg = tr("File '%1' is read-only.").arg(QFileInfo(name).fileName()) + "\n";
 
745
                msg += tr("What do you want to do?");
 
746
                QMessageBox msgBox(QMessageBox::Information, tr("Warning"), msg, QMessageBox::NoButton, mInt_->viewer_->widget());
 
747
                QPushButton* owrBtn = msgBox.addButton(tr("Overwrite"), QMessageBox::YesRole);
 
748
                QPushButton* savBtn = msgBox.addButton(tr("Save as"), QMessageBox::ApplyRole);
 
749
                msgBox.addButton(QMessageBox::Cancel);
 
750
                bool resolved = false;
 
751
                do {
 
752
                        msgBox.exec();
 
753
                        QAbstractButton* btn = msgBox.clickedButton();
 
754
                        if ( btn == owrBtn ) {
 
755
                                //      Try to change permissions and save
 
756
                                QFile::Permissions perm = QFile::permissions(name);
 
757
                                if ( QFile::setPermissions(name, perm | QFile::WriteUser) ) {
 
758
                                        resolved = true;
 
759
                                }
 
760
                                else {
 
761
                                        //      Can't change permissions
 
762
                                        mInt_->gui_->displayError(tr("Can't change permissions: Access denied"));
 
763
                                        return false;
 
764
                                }
 
765
                        }
 
766
                        else if ( btn == savBtn ) {
 
767
                                //      Choose file name
 
768
                                if ( fileSaveAs() )
 
769
                                        return true;
 
770
                        }
 
771
                        else {
 
772
                                return false;
 
773
                        }
 
774
                } while ( !resolved );
 
775
        }
 
776
 
 
777
        //      make a backup copy if it is necessary
 
778
        if ( MainSettings::makeBackupOnSave() ) {
 
779
                QString bkpName = name + "~";
 
780
                if ( QFile::exists(bkpName) ) {
 
781
                        QFile::remove(bkpName);
 
782
                }
 
783
                QFile::copy(name, bkpName);
 
784
        }
 
785
 
 
786
        MainSettings::setLastSaveDir(QFileInfo(name).absolutePath());
 
787
 
 
788
        QString err;
 
789
        if ( !doc->save(name, charset, err) ) {
 
790
                Log::debug("Not saved...");
 
791
                mInt_->gui_->displayError(err);
 
792
                return false;
 
793
        }
 
794
 
 
795
        mInt_->pluginManager_->notifyDocSaved(name);
 
796
 
 
797
        return true;
 
798
}
 
799
 
 
800
void Manager::closeDoc(Document* doc) {
 
801
        JUFFENTRY;
 
802
 
 
803
        if ( !doc || doc->isNull() )
 
804
                return;
 
805
        
 
806
        Log::debug(doc->fileName());
 
807
        
 
808
        mInt_->docs1_.remove(doc->fileName());
 
809
        mInt_->docs2_.remove(doc->fileName());
 
810
        mInt_->viewer_->removeDoc(doc);
 
811
        mInt_->pluginManager_->notifyDocClosed(doc->fileName());
 
812
        delete doc;
 
813
        
 
814
        Document* d = curDoc();
 
815
        if ( d && !d->isNull() ) {
 
816
                d->widget()->setFocus();
 
817
        }
 
818
        else {
 
819
                mInt_->posL_->hide();
 
820
                mInt_->nameL_->hide();
 
821
                mInt_->charsetL_->hide();
 
822
                mInt_->linesL_->hide();
 
823
                
 
824
                if ( !mInt_->stayAlive_ && MainSettings::exitOnLastDocClosed() )
 
825
                        exit();
 
826
        }
 
827
}
 
828
 
 
829
bool Manager::closeAllDocs() {
 
830
        JUFFENTRY;
 
831
 
 
832
        //      If this method was called we don't want to exit the app
 
833
        //      after the last document was closed (if this option was chosen
 
834
        //      in settings dialog). Set the 'stayAlive' flag and unset it afterwards.
 
835
        mInt_->stayAlive_ = true;
 
836
        while ( !curDoc()->isNull() ) {
 
837
                if ( !fileClose() ) {
 
838
                        return false;
 
839
                }
 
840
        }
 
841
        mInt_->stayAlive_ = false;
 
842
        mInt_->gui_->updateTitle("", mInt_->sessionName_, false);
 
843
 
 
844
        return true;
 
845
}
 
846
 
 
847
 
 
848
 
 
849
 
 
850
////////////////////////////////////////////////////////////////////////////////
 
851
////////////////////////////////////////////////////////////////////////////////
 
852
 
 
853
void Manager::fileNew() {
 
854
        JUFFENTRY;
 
855
        createDoc("sci", "");
 
856
}
 
857
 
 
858
void Manager::fileNewRich() {
 
859
        JUFFENTRY;
 
860
 
 
861
        createDoc("rich", "");
 
862
}
 
863
 
 
864
void Manager::fileOpen() {
 
865
        JUFFENTRY;
 
866
        QString startDir = MainSettings::lastOpenDir();
 
867
 
 
868
        Document* doc = curDoc();
 
869
        
 
870
        if ( MainSettings::syncOpenDialogToCurDoc() ) {
 
871
                if ( !doc->isNull() && !isNoname(doc->fileName()) )
 
872
                        startDir = QFileInfo(doc->fileName()).absolutePath();
 
873
        }
 
874
 
 
875
        QString filters = "All files (*)";
 
876
        DocHandler* handler = mInt_->getHandlerByDoc(doc);
 
877
        if ( handler ) {
 
878
                filters = handler->fileFilters();
 
879
        }
 
880
        
 
881
        QStringList files = mInt_->gui_->getOpenFileNames(startDir, filters);
 
882
        if ( files.count() > 0 ) {
 
883
                QString fileName = "";
 
884
                foreach (fileName, files) {
 
885
                        openDoc(fileName);
 
886
                }
 
887
                MainSettings::setLastOpenDir(QFileInfo(fileName).absolutePath());
 
888
        }
 
889
}
 
890
 
 
891
void Manager::fileRecent() {
 
892
        JUFFENTRY;
 
893
 
 
894
        QAction* a = qobject_cast<QAction*>(sender());
 
895
        if ( !a )
 
896
                return;
 
897
        
 
898
        QString fileName = a->text();
 
899
        if ( !fileName.isEmpty() ) {
 
900
                openDoc(fileName);
 
901
        }
 
902
}
 
903
 
 
904
void Manager::session() {
 
905
        JUFFENTRY;
 
906
 
 
907
        QAction* a = qobject_cast<QAction*>(sender());
 
908
        if ( !a )
 
909
                return;
 
910
        
 
911
        QString sessName = a->text();
 
912
        if ( closeSess() && !sessName.isEmpty() ) {
 
913
                if ( openSess(sessName) ) {
 
914
                }
 
915
        }
 
916
}
 
917
 
 
918
bool Manager::fileSave() {
 
919
        JUFFENTRY;
 
920
        
 
921
        Document* doc = curDoc();
 
922
        
 
923
        if ( !doc->isNull() ) {
 
924
                //      we have a document opened
 
925
                
 
926
                if ( !Juff::isNoname(doc->fileName()) && !doc->isModified() )
 
927
                        return false;
 
928
 
 
929
                if ( Juff::isNoname(doc->fileName()) ) {
 
930
                        //      document doesn't have a file name. Call "Save as"
 
931
                        
 
932
                        return fileSaveAs();
 
933
                }
 
934
                else {
 
935
                        if ( saveDoc(doc, doc->fileName(), doc->charset()) ) {
 
936
                                doc->setModified(false);
 
937
                                return true;
 
938
                        }
 
939
                        else {
 
940
                                return false;
 
941
                        }
 
942
                }
 
943
        }
 
944
        else {
 
945
                Log::debug("Null");
 
946
                return false;
 
947
        }
 
948
}
 
949
 
 
950
bool Manager::fileSaveAs() {
 
951
        JUFFENTRY;
 
952
        
 
953
        Document* doc = curDoc();
 
954
        
 
955
        if ( !doc->isNull() ) {
 
956
                QString filters = "All files (*)";
 
957
                DocHandler* handler = mInt_->getHandlerByDoc(doc);
 
958
                if ( handler ) {
 
959
                        filters = handler->fileFilters();
 
960
                }
 
961
                
 
962
                bool asCopy = false;
 
963
                QString charset = doc->charset();
 
964
                QString fName = mInt_->gui_->getSaveFileName(doc->fileName(), filters, asCopy, charset);
 
965
                if ( !fName.isEmpty() ) {
 
966
                        if ( saveDoc(doc, fName, charset) ) {
 
967
                                if ( !asCopy ) {
 
968
                                        doc->setFileName(fName);
 
969
                                        doc->setCharset(charset);
 
970
                                        mInt_->displayCharset(doc->charset());
 
971
                                        doc->setModified(false);
 
972
                                        mInt_->displayFileName(fName);
 
973
                                }
 
974
                                return true;
 
975
                        }
 
976
                }
 
977
        }
 
978
        return false;
 
979
}
 
980
 
 
981
void Manager::fileSaveAll() {
 
982
        JUFFENTRY;
 
983
        
 
984
        QMap<QString, Document*>::iterator it = mInt_->docs1_.begin();
 
985
        while ( it != mInt_->docs1_.end() ) {
 
986
                Document* doc = it.value();
 
987
                if ( doc && doc->isModified() ) {
 
988
                        if ( Juff::isNoname(doc->fileName()) ) {
 
989
                                mInt_->viewer_->activateDoc(doc);
 
990
                                fileSaveAs();
 
991
                        }
 
992
                        else {
 
993
                                if ( saveDoc(doc, doc->fileName(), doc->charset()) ) {
 
994
                                        doc->setModified(false);
 
995
                                }
 
996
                        }
 
997
                }
 
998
                it++;
 
999
        }
 
1000
}
 
1001
 
 
1002
void Manager::fileReload() {
 
1003
        Document* doc = curDoc();
 
1004
        
 
1005
        if ( !doc->isNull() ) {
 
1006
                doc->reload();
 
1007
        }
 
1008
}
 
1009
 
 
1010
bool Manager::fileClose() {
 
1011
        JUFFENTRY;
 
1012
        
 
1013
        Document* doc = curDoc();
 
1014
        bool result = closeWithConfirmation(doc);
 
1015
        
 
1016
 
 
1017
        if ( curDoc()->isNull() )
 
1018
                mInt_->gui_->updateTitle("", mInt_->sessionName_, false);
 
1019
 
 
1020
        return result;
 
1021
}
 
1022
 
 
1023
void Manager::fileCloseAll() {
 
1024
        closeAllDocs();
 
1025
}
 
1026
 
 
1027
void Manager::filePrint() {
 
1028
        JUFFENTRY;
 
1029
        
 
1030
        Document* doc = curDoc();
 
1031
        if ( !doc->isNull() )
 
1032
                doc->print();
 
1033
}
 
1034
 
 
1035
 
 
1036
void Manager::sessionNew() {
 
1037
        JUFFENTRY;
 
1038
        
 
1039
        if ( closeAllDocs() ) {
 
1040
                mInt_->sessionName_ = "";
 
1041
                fileNew();
 
1042
        }
 
1043
}
 
1044
 
 
1045
void Manager::sessionOpen() {
 
1046
        JUFFENTRY;
 
1047
        
 
1048
        saveSess(mInt_->sessionName_);
 
1049
        
 
1050
        bool accepted = false;
 
1051
        QString sessName = mInt_->gui_->getOpenSessionName(accepted);
 
1052
        if ( accepted && closeSess() ) {
 
1053
                if ( !sessName.isEmpty() ) {
 
1054
                        //      open session
 
1055
                        if ( openSess(sessName) ) {
 
1056
                        }
 
1057
                }
 
1058
                else {
 
1059
                        //      new session
 
1060
                        sessionNew();
 
1061
                }
 
1062
        }
 
1063
}
 
1064
 
 
1065
void Manager::sessionSave() {
 
1066
        JUFFENTRY;
 
1067
        
 
1068
        if ( mInt_->sessionName_.isEmpty() ) {
 
1069
                sessionSaveAs();
 
1070
        }
 
1071
        else {
 
1072
                saveSess(mInt_->sessionName_);
 
1073
        }
 
1074
}
 
1075
 
 
1076
void Manager::sessionSaveAs() {
 
1077
        JUFFENTRY;
 
1078
        
 
1079
        QString sessName = mInt_->gui_->getSaveSessionName(mInt_->sessionName_);
 
1080
        if ( !sessName.isEmpty() ) {
 
1081
                saveSess(sessName);
 
1082
                mInt_->sessionName_ = sessName;
 
1083
                Document* doc = curDoc();
 
1084
                QString fileName = doc->isNull() ? "" : doc->fileName();
 
1085
                mInt_->gui_->updateTitle(fileName, sessName, false);
 
1086
        }
 
1087
}
 
1088
 
 
1089
void Manager::writePanelViews(QFile& file, int panel) {
 
1090
        QWidgetList views;
 
1091
        
 
1092
        mInt_->viewer_->getViewsList(panel, views);
 
1093
        foreach (QWidget* w, views) {
 
1094
                Document* doc = mInt_->getDocByView(w);
 
1095
                if ( doc && !doc->isNull() && !isNoname(doc->fileName()) ) {
 
1096
                        int scrPos = doc->curScrollPos();
 
1097
                        int line = doc->curLine();
 
1098
                        file.write((QString("%1:%2:%3\n")
 
1099
                                .arg(doc->fileName()).arg(scrPos).arg(line)).toLocal8Bit());
 
1100
                }
 
1101
        }
 
1102
}
 
1103
 
 
1104
bool Manager::openSess(const QString& name) {
 
1105
        JUFFENTRY;
 
1106
 
 
1107
        QString sessName = name.isEmpty() ? EMPTY_SESSION : name;
 
1108
        
 
1109
        QFile sess(AppInfo::configDirPath() + "/sessions/" + sessName);
 
1110
        if ( sess.open(QIODevice::ReadOnly) ) {
 
1111
                QString fileName("");
 
1112
                while ( !sess.atEnd() ) {
 
1113
                        QString lineStr = QString::fromLocal8Bit(sess.readLine()).simplified();
 
1114
#ifdef Q_OS_WIN
 
1115
                        fileName = lineStr.section(':', -4, -3);
 
1116
#else
 
1117
                        fileName = lineStr.section(':', -3, -3);
 
1118
#endif
 
1119
                        Log::debug(QString("          Opening file '%1'").arg(fileName));
 
1120
                        int scrPos = lineStr.section(':', -2, -2).toInt();
 
1121
                        int line = lineStr.section(':', -1, -1).toInt();
 
1122
                        Log::debug(QString("          Position: %1, scroll: %2").arg(line).arg(scrPos));
 
1123
                        if ( !fileName.isEmpty() ) {
 
1124
                                createDoc("sci", fileName);
 
1125
                                Log::debug("          Doc created");
 
1126
                                Document* doc = curDoc();
 
1127
                                if ( !doc->isNull() ) {
 
1128
                                        doc->gotoLine(line);
 
1129
                                        doc->setScrollPos(scrPos);
 
1130
                                }
 
1131
                        }
 
1132
                }
 
1133
 
 
1134
                sess.close();
 
1135
                
 
1136
                mInt_->sessionName_ = sessName;
 
1137
                Document* doc = curDoc();
 
1138
                QString curFileName = doc->isNull() ? "" : doc->fileName();
 
1139
                mInt_->gui_->updateTitle(curFileName, sessName, false);
 
1140
                
 
1141
                return true;
 
1142
        }
 
1143
        return false;
 
1144
}
 
1145
 
 
1146
bool Manager::saveSess(const QString& name) {
 
1147
        JUFFENTRY;
 
1148
        
 
1149
        QString sessName = name.isEmpty() ? EMPTY_SESSION : name;
 
1150
        
 
1151
        QFile sess(AppInfo::configDirPath() + "/sessions/" + sessName);
 
1152
        if ( sess.open(QIODevice::WriteOnly | QIODevice::Truncate) ) {
 
1153
                writePanelViews(sess, 1);
 
1154
                sess.close();
 
1155
                return true;
 
1156
        }
 
1157
        else {
 
1158
                //      TODO :  Add error display here
 
1159
                return false;
 
1160
        }
 
1161
}
 
1162
 
 
1163
bool Manager::closeSess() {
 
1164
        if ( !closeAllDocs() )
 
1165
                return false;
 
1166
        
 
1167
        mInt_->sessionName_ = "";
 
1168
        mInt_->gui_->updateTitle("", "", false);
 
1169
        return true;
 
1170
}
 
1171
 
 
1172
void Manager::restoreSession() {
 
1173
        JUFFENTRY;
 
1174
 
 
1175
        int startupVariant = MainSettings::startupVariant();
 
1176
        switch ( startupVariant ) {
 
1177
                case 1:
 
1178
                        {
 
1179
                                QString sessName = MainSettings::lastSessionName();
 
1180
                                if ( openSess(sessName) ) {
 
1181
                                }
 
1182
                                if ( docCount() == 0 )
 
1183
                                        fileNew();
 
1184
                        }
 
1185
                        break;
 
1186
                
 
1187
                case 2:
 
1188
                        sessionNew();
 
1189
                        break;
 
1190
                        
 
1191
                case 0: 
 
1192
                default:
 
1193
                        sessionOpen();
 
1194
        }
 
1195
        
 
1196
        Log::debug("Session restored");
 
1197
}
 
1198
 
 
1199
 
 
1200
 
 
1201
 
 
1202
void Manager::editUndo() {
 
1203
        JUFFENTRY;
 
1204
        
 
1205
        Document* doc = curDoc();
 
1206
        if ( !doc->isNull() )
 
1207
                doc->undo();
 
1208
}
 
1209
 
 
1210
void Manager::editRedo() {
 
1211
        JUFFENTRY;
 
1212
        
 
1213
        Document* doc = curDoc();
 
1214
        if ( !doc->isNull() )
 
1215
                doc->redo();
 
1216
}
 
1217
 
 
1218
void Manager::editCut() {
 
1219
        JUFFENTRY;
 
1220
        
 
1221
        Document* doc = curDoc();
 
1222
        if ( !doc->isNull() )
 
1223
                doc->cut();
 
1224
}
 
1225
 
 
1226
void Manager::editCopy() {
 
1227
        JUFFENTRY;
 
1228
        
 
1229
        Document* doc = curDoc();
 
1230
        if ( !doc->isNull() )
 
1231
                doc->copy();
 
1232
}
 
1233
 
 
1234
void Manager::editPaste() {
 
1235
        JUFFENTRY;
 
1236
        
 
1237
        Document* doc = curDoc();
 
1238
        if ( !doc->isNull() )
 
1239
                doc->paste();
 
1240
}
 
1241
 
 
1242
void Manager::findImpl(bool replc) {
 
1243
        Document* doc = curDoc();
 
1244
        if ( !doc->isNull() ) {
 
1245
                DocFindFlags flags(replc);
 
1246
                QString str1, str2;
 
1247
                int line1, col1, line2, col2;
 
1248
                doc->getSelection(line1, col1, line2, col2);
 
1249
                if ( line1 == line2 ) {
 
1250
                        if ( col1 != col2 ) {
 
1251
                                str1 = doc->selectedText();
 
1252
                        }
 
1253
                        else {
 
1254
                                str1 = doc->wordUnderCursor();
 
1255
                        }
 
1256
                }
 
1257
                if ( mInt_->gui_->getFindParams(str1, str2, flags) ) {
 
1258
                        if ( flags.replace ) {
 
1259
                                doc->replace(str1, str2, flags);
 
1260
                        }
 
1261
                        else {
 
1262
                                doc->find(str1, flags);
 
1263
                        }
 
1264
                }
 
1265
        }
 
1266
}
 
1267
 
 
1268
void Manager::find() {
 
1269
        JUFFENTRY;
 
1270
        findImpl(false);
 
1271
}
 
1272
        
 
1273
void Manager::replace() {
 
1274
        JUFFENTRY;
 
1275
        findImpl(true);
 
1276
}
 
1277
 
 
1278
void Manager::findNext() {
 
1279
        JUFFENTRY;
 
1280
        
 
1281
        Document* doc = curDoc();
 
1282
        if ( !doc->isNull() ) {
 
1283
                QString lastText = mInt_->gui_->lastFindText();
 
1284
                if ( lastText.isEmpty() ) {
 
1285
                        find();
 
1286
                }
 
1287
                else {
 
1288
                        DocFindFlags flags = mInt_->gui_->lastFlags();
 
1289
                        flags.replace = false;
 
1290
                        flags.backwards = false;
 
1291
                        doc->find(lastText, flags);
 
1292
                }
 
1293
        }
 
1294
}
 
1295
 
 
1296
void Manager::findPrev() {
 
1297
        JUFFENTRY;
 
1298
        
 
1299
        Document* doc = curDoc();
 
1300
        if ( !doc->isNull() ) {
 
1301
                QString lastText = mInt_->gui_->lastFindText();
 
1302
                if ( lastText.isEmpty() ) {
 
1303
                        find();
 
1304
                }
 
1305
                else {
 
1306
                        DocFindFlags flags = mInt_->gui_->lastFlags();
 
1307
                        flags.replace = false;
 
1308
                        flags.backwards = true;
 
1309
                        doc->find(lastText, flags);
 
1310
                }
 
1311
        }
 
1312
}
 
1313
 
 
1314
void Manager::gotoLine() {
 
1315
        JUFFENTRY;
 
1316
        
 
1317
        Document* doc = curDoc();
 
1318
        if ( !doc->isNull() ) {
 
1319
                bool ok = false;
 
1320
                int line = QInputDialog::getInteger(doc->widget(), tr("Go to line"), 
 
1321
                                tr("Go to line") + QString(" (1 - %1):").arg(doc->lineCount()), 
 
1322
                                1, 1, doc->lineCount(), 1, &ok);
 
1323
                if ( ok )
 
1324
                        doc->gotoLine(line - 1);
 
1325
        }
 
1326
}
 
1327
 
 
1328
void Manager::charsetSelected() {
 
1329
        JUFFENTRY;
 
1330
 
 
1331
        QAction* a = qobject_cast<QAction*>(sender());
 
1332
        if ( a != 0 ) {
 
1333
                Document* doc = curDoc();
 
1334
                if ( doc && !doc->isNull() ) {
 
1335
                        doc->setCharset(a->text(), true);
 
1336
                        mInt_->displayCharset(doc->charset());
 
1337
                }
 
1338
        }
 
1339
}
 
1340
 
 
1341
 
 
1342
 
 
1343
void Manager::docModified(bool mod) {
 
1344
        JUFFENTRY;
 
1345
 
 
1346
        Document* doc = qobject_cast<Document*>(sender());
 
1347
 
 
1348
        if ( doc ) {
 
1349
                mInt_->gui_->updateTitle(doc->fileName(), mInt_->sessionName_, mod);
 
1350
                mInt_->viewer_->setDocModified(doc, mod);
 
1351
                mInt_->pluginManager_->notifyDocModified(doc->fileName(), mod);
 
1352
        }
 
1353
}
 
1354
 
 
1355
void Manager::onCursorPositionChanged(int line, int col) {
 
1356
        mInt_->posL_->setText(tr("Row: %1, Col: %2").arg(line+1).arg(col+1));
 
1357
}
 
1358
 
 
1359
void Manager::onLinesCountChanged(int lines) {
 
1360
        mInt_->linesL_->setText(tr(" Lines: %1 ").arg(lines));
 
1361
        mInt_->linesL_->setToolTip(QObject::tr("Lines count: %1").arg(lines));
 
1362
}
 
1363
 
 
1364
void Manager::onContextMenuCalled(int line, int col) {
 
1365
        mInt_->pluginManager_->notifyContextMenuCalled(line, col);
 
1366
}
 
1367
 
 
1368
void Manager::docFileNameChanged(const QString& oldName) {
 
1369
        JUFFENTRY;
 
1370
 
 
1371
        Document* doc = qobject_cast<Document*>(sender());
 
1372
        
 
1373
        if ( doc ) {
 
1374
                if ( mInt_->docs1_.contains(oldName) ) {
 
1375
                        mInt_->docs1_.remove(oldName);
 
1376
                        mInt_->docs1_[doc->fileName()] = doc;
 
1377
                }
 
1378
                else if ( mInt_->docs2_.contains(oldName) ) {
 
1379
                        mInt_->docs2_.remove(oldName);
 
1380
                        mInt_->docs2_[doc->fileName()] = doc;
 
1381
                }
 
1382
                else {
 
1383
                        return;
 
1384
                }
 
1385
                mInt_->gui_->updateTitle(doc->fileName(), mInt_->sessionName_, doc->isModified());
 
1386
                mInt_->viewer_->updateDocTitle(doc);
 
1387
                mInt_->pluginManager_->notifyDocRenamed(oldName, doc->fileName());
 
1388
        }
 
1389
}
 
1390
 
 
1391
 
 
1392
void Manager::onCurDocChanged(QWidget* w) {
 
1393
        JUFFENTRY;
 
1394
 
 
1395
        if ( w ) {
 
1396
                Document* doc = mInt_->getDocByView(w);
 
1397
                if ( !doc->isNull() ) {
 
1398
                        QString type = doc->type();
 
1399
                        DocHandler* handler = mInt_->handlers_[type];
 
1400
                        if ( handler ) {
 
1401
                                handler->docActivated(doc);
 
1402
                        }
 
1403
                        else {
 
1404
                                Log::debug("<no type>");
 
1405
                        }
 
1406
 
 
1407
                        //      status bar
 
1408
                        mInt_->displayFileName(doc->fileName());
 
1409
                        mInt_->displayCharset(doc->charset());
 
1410
                        int line = -1, col = -1;
 
1411
                        doc->getCursorPos(line, col);
 
1412
                        mInt_->posL_->setText(tr(" Row: %1, Col: %2 ").arg(line+1).arg(col+1));
 
1413
                        mInt_->linesL_->setText(tr(" Lines: %1 ").arg(doc->lineCount()));
 
1414
                        mInt_->linesL_->setToolTip(tr("Lines count: %1 ").arg(doc->lineCount()));
 
1415
 
 
1416
                        if ( type != mInt_->docOldType_ ) {
 
1417
                                if ( mInt_->statusWidgets_.contains(mInt_->docOldType_) ) {
 
1418
                                        foreach (QWidget* w, mInt_->statusWidgets_[mInt_->docOldType_] ) {
 
1419
                                                w->hide();
 
1420
                                        }
 
1421
                                }
 
1422
                                if ( mInt_->statusWidgets_.contains(type) ) {
 
1423
                                        foreach (QWidget* w, mInt_->statusWidgets_[type] ) {
 
1424
                                                w->show();
 
1425
                                        }
 
1426
                                }
 
1427
                                mInt_->docOldType_ = type;
 
1428
                        }
 
1429
                                
 
1430
                        if ( QAction* chAct = mInt_->charsetActions_[doc->charset()] )
 
1431
                                chAct->setChecked(true);
 
1432
                        else if ( mInt_->chActGr_->checkedAction() )
 
1433
                                mInt_->chActGr_->checkedAction()->setChecked(false);
 
1434
 
 
1435
                        doc->updateActivated();
 
1436
                        mInt_->gui_->updateTitle(doc->fileName(), mInt_->sessionName_, doc->isModified());
 
1437
                        mInt_->pluginManager_->notifyDocActivated(doc->fileName());
 
1438
 
 
1439
                        mInt_->gui_->setCurType(type);
 
1440
                }
 
1441
                else {
 
1442
                        mInt_->gui_->updateTitle("", "", false);
 
1443
                        
 
1444
                        //      status bar
 
1445
                        mInt_->displayFileName("");
 
1446
                        mInt_->displayCharset("");
 
1447
                        mInt_->posL_->setText("  ");
 
1448
                        if ( mInt_->statusWidgets_.contains(mInt_->docOldType_) ) {
 
1449
                                foreach (QWidget* w, mInt_->statusWidgets_[mInt_->docOldType_] ) {
 
1450
                                        w->hide();
 
1451
                                }
 
1452
                        }
 
1453
                        mInt_->docOldType_ = "";
 
1454
                }
 
1455
        }
 
1456
        else {
 
1457
                //      status bar
 
1458
                mInt_->displayFileName("");
 
1459
                mInt_->displayCharset("");
 
1460
                mInt_->posL_->setText("  ");
 
1461
                if ( mInt_->statusWidgets_.contains(mInt_->docOldType_) ) {
 
1462
                        foreach (QWidget* w, mInt_->statusWidgets_[mInt_->docOldType_] ) {
 
1463
                                w->hide();
 
1464
                        }
 
1465
                }
 
1466
                mInt_->docOldType_ = "";
 
1467
                mInt_->gui_->setCurType("all");
 
1468
        }
 
1469
}
 
1470
 
 
1471
void Manager::onDocCloseRequested(QWidget* w) {
 
1472
        JUFFENTRY;
 
1473
        
 
1474
        Document* doc = mInt_->getDocByView(w);
 
1475
        closeWithConfirmation(doc);
 
1476
        
 
1477
        if ( curDoc()->isNull() )
 
1478
                mInt_->gui_->updateTitle("", mInt_->sessionName_, false);
 
1479
}
 
1480
 
 
1481
void Manager::onDocNameRequested(QWidget* w, QString& fileName) {
 
1482
        JUFFENTRY;
 
1483
        Document* doc = mInt_->getDocByView(w);
 
1484
        fileName = doc->isNull() ? "" : doc->fileName();
 
1485
}
 
1486
 
 
1487
 
 
1488
 
 
1489
 
 
1490
 
 
1491
 
 
1492
 
 
1493
 
 
1494
 
 
1495
int Manager::docCount() const {
 
1496
        return mInt_->docs1_.count() + mInt_->docs2_.count();
 
1497
}
 
1498
 
 
1499
void Manager::getDocList(QStringList& list) const {
 
1500
        JUFFENTRY;
 
1501
        
 
1502
        list.clear();
 
1503
        list << mInt_->docs1_.keys();
 
1504
        list << mInt_->docs2_.keys();
 
1505
}
 
1506
 
 
1507
void Manager::getCurDocName(QString& fileName) const {
 
1508
        JUFFENTRY;
 
1509
        
 
1510
        Document* doc = curDoc();
 
1511
        if ( !doc->isNull() ) {
 
1512
                fileName = doc->fileName();
 
1513
        }
 
1514
        else {
 
1515
                fileName = "";
 
1516
        }
 
1517
}
 
1518
 
 
1519
void Manager::getDocText(const QString& fileName, QString& text) {
 
1520
        JUFFENTRY;
 
1521
        
 
1522
        if ( mInt_->docs1_.contains(fileName) ) {
 
1523
                text = mInt_->docs1_[fileName]->text();
 
1524
        }
 
1525
        else if ( mInt_->docs2_.contains(fileName) ) {
 
1526
                text = mInt_->docs2_[fileName]->text();
 
1527
        }
 
1528
        else {
 
1529
                text = QString();
 
1530
        }
 
1531
}
 
1532
 
 
1533
void Manager::getDocText(const QString& fileName, int line, QString& text) {
 
1534
        JUFFENTRY;
 
1535
        
 
1536
        if ( mInt_->docs1_.contains(fileName) ) {
 
1537
                text = mInt_->docs1_[fileName]->text(line);
 
1538
        }
 
1539
        else if ( mInt_->docs2_.contains(fileName) ) {
 
1540
                text = mInt_->docs2_[fileName]->text(line);
 
1541
        }
 
1542
        else {
 
1543
                text = QString();
 
1544
        }
 
1545
}
 
1546
 
 
1547
void Manager::getCurrentDocText(QString& text) {
 
1548
        Document* doc = curDoc();
 
1549
        if ( !doc->isNull() ) {
 
1550
                getDocText(doc->fileName(), text);
 
1551
        }
 
1552
        else {
 
1553
                text = "";
 
1554
        }
 
1555
}
 
1556
 
 
1557
void Manager::getCurrentDocText(int line, QString& text) {
 
1558
        Document* doc = curDoc();
 
1559
        if ( !doc->isNull() ) {
 
1560
                getDocText(doc->fileName(), line, text);
 
1561
        }
 
1562
        else {
 
1563
                text = "";
 
1564
        }
 
1565
}
 
1566
 
 
1567
QString Manager::getCurDocCharset() {
 
1568
        Document* doc = curDoc();
 
1569
        if ( !doc->isNull() ) {
 
1570
                return doc->charset();
 
1571
        }
 
1572
        else {
 
1573
                return "";
 
1574
        }
 
1575
}
 
1576
 
 
1577
void Manager::setCurDocCharset(const QString& charset) {
 
1578
        Document* doc = curDoc();
 
1579
        if ( !doc->isNull() ) {
 
1580
                doc->setCharset(charset, true);
 
1581
                mInt_->displayCharset(doc->charset());
 
1582
        }
 
1583
}
 
1584
 
 
1585
 
 
1586
void Manager::getCursorPos(int& line, int& col) {
 
1587
        JUFFENTRY;
 
1588
        
 
1589
        Document* doc = curDoc();
 
1590
        if ( !doc->isNull() ) {
 
1591
                doc->getCursorPos(line, col);
 
1592
        }
 
1593
        else {
 
1594
                line = col = -1;
 
1595
        }
 
1596
}
 
1597
 
 
1598
void Manager::getSelection(int& line1, int& col1, int& line2, int& col2) {
 
1599
        JUFFENTRY;
 
1600
        
 
1601
        Document* doc = curDoc();
 
1602
        if ( !doc->isNull() ) {
 
1603
                doc->getSelection(line1, col1, line2, col2);
 
1604
        }
 
1605
}
 
1606
 
 
1607
void Manager::getSelectedText(QString& text) {
 
1608
        JUFFENTRY;
 
1609
        
 
1610
        Document* doc = curDoc();
 
1611
        if ( !doc->isNull() ) {
 
1612
                text = doc->selectedText();
 
1613
        }
 
1614
}
 
1615
 
 
1616
void Manager::setCursorPos(int line, int col) {
 
1617
        JUFFENTRY;
 
1618
 
 
1619
        Document* doc = curDoc();
 
1620
        if ( !doc->isNull() ) {
 
1621
                doc->setCursorPos(line, col);
 
1622
        }
 
1623
}
 
1624
 
 
1625
void Manager::setSelection(int line1, int col1, int line2, int col2) {
 
1626
        JUFFENTRY;
 
1627
        
 
1628
        Document* doc = curDoc();
 
1629
        if ( !doc->isNull() ) {
 
1630
                doc->setSelection(line1, col1, line2, col2);
 
1631
        }
 
1632
}
 
1633
 
 
1634
void Manager::removeSelectedText() {
 
1635
        JUFFENTRY;
 
1636
        
 
1637
        Document* doc = curDoc();
 
1638
        if ( !doc->isNull() ) {
 
1639
                doc->removeSelectedText();
 
1640
        }
 
1641
}
 
1642
 
 
1643
void Manager::replaceSelectedText(const QString& text) {
 
1644
        JUFFENTRY;
 
1645
        
 
1646
        Document* doc = curDoc();
 
1647
        if ( !doc->isNull() ) {
 
1648
                doc->replaceSelectedText(text);
 
1649
        }
 
1650
}
 
1651
 
 
1652
void Manager::insertText(const QString& text) {
 
1653
        JUFFENTRY;
 
1654
        
 
1655
        Document* doc = curDoc();
 
1656
        if ( !doc->isNull() ) {
 
1657
                doc->insertText(text);
 
1658
        }
 
1659
}
 
1660
 
 
1661
bool Manager::closeDoc(const QString& fileName) {
 
1662
        JUFFENTRY;
 
1663
        
 
1664
        if ( mInt_->docs1_.contains(fileName) ) {
 
1665
                Document* doc = mInt_->docs1_[fileName];
 
1666
                return closeWithConfirmation(doc);
 
1667
        }
 
1668
        else if ( mInt_->docs2_.contains(fileName) ) {
 
1669
                Document* doc = mInt_->docs2_[fileName];
 
1670
                return closeWithConfirmation(doc);
 
1671
        }
 
1672
        else {
 
1673
                return true;
 
1674
        }
 
1675
}
 
1676
 
 
1677
void Manager::saveDoc(const QString& fileName) {
 
1678
        Document* doc = 0;
 
1679
        if ( mInt_->docs1_.contains(fileName) ) {
 
1680
                doc = mInt_->docs1_[fileName];
 
1681
        }
 
1682
        else if ( mInt_->docs2_.contains(fileName) ) {
 
1683
                doc = mInt_->docs2_[fileName];
 
1684
        }
 
1685
        
 
1686
        if ( Juff::isNoname(fileName) ) {
 
1687
                //      document doesn't have a file name. Call "Save as"
 
1688
                
 
1689
                fileSaveAs();
 
1690
        }
 
1691
        else {
 
1692
                if ( saveDoc(doc, fileName, doc->charset()) ) {
 
1693
                        doc->setModified(false);
 
1694
                }
 
1695
        }
 
1696
}
 
1697
 
 
1698
QWidget* Manager::mainWindow() const {
 
1699
        return mInt_->viewer_->widget();
 
1700
}
 
1701
 
 
1702
 
 
1703
 
 
1704
void Manager::copyFileName() {
 
1705
        QApplication::clipboard()->setText(mInt_->nameL_->text().trimmed());
 
1706
}
 
1707
 
 
1708
 
 
1709
}       //      namespace Juff