00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __KATE_SESSION_H__
00020 #define __KATE_SESSION_H__
00021
00022 #include "katemain.h"
00023
00024 #include <kdialogbase.h>
00025 #include <ksimpleconfig.h>
00026 #include <ksharedptr.h>
00027 #include <tdeaction.h>
00028
00029 #include <tqobject.h>
00030 #include <tqptrlist.h>
00031 #include <tqvaluelist.h>
00032 #include <tqstringlist.h>
00033 #include <tdelistview.h>
00034
00035 class KateViewSpace;
00036 class KDirWatch;
00037 class KPushButton;
00038 class TDEListView;
00039 class TQCheckBox;
00040 class KateSessionManager;
00041
00042
00043
00047 class KateSession
00048 {
00049 public:
00050
00057 KateSession(const KateSessionManager &manager, const TQString &sessionName, const TQString &fileName);
00058
00065 KateSession(const KateSession &session, const TQString &newSessionName);
00066
00070 ~KateSession();
00071
00075 const TQString& getSessionName() const { return m_sessionName; }
00076
00081 void setSessionName(const TQString &sessionName);
00082
00086 bool isReadOnly() const { return m_readOnly; }
00087
00092 void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
00093
00097 const TQString& getSessionFilename() const { return m_filename; }
00098
00103 bool isStillVolatile() const;
00104
00108 int getDocCount() const { return m_documents.count(); }
00109
00114 void load(bool includeGUIInfo);
00115
00121 void save(bool saveGUIInfo, bool setReadOnly = false);
00122
00126 void activate();
00127
00128
00129 private:
00130
00131 friend class KateViewSpace;
00132
00136 TDEConfig* getConfig() const { return m_config; }
00137
00141 void createFilename();
00142
00143 const KateSessionManager &m_manager;
00144 TQString m_sessionName;
00145 TQString m_filename;
00146 bool m_readOnly;
00147 TQStringList m_documents;
00148 KSimpleConfig *m_config;
00149
00150 };
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00169
00170
00171
00172
00173
00174
00175
00176 class KateSessionManager : public TQObject
00177 {
00178 Q_OBJECT
00179
00180 public:
00181
00182 enum
00183 {
00184 INVALID_SESSION = -1
00185 };
00186
00187
00188 enum
00189 {
00190 STARTUP_NEW = 0,
00191 STARTUP_LAST,
00192 STARTUP_MANUAL
00193 };
00194
00195
00196 enum
00197 {
00198 SWITCH_DISCARD = 0,
00199 SWITCH_SAVE,
00200 SWITCH_ASK
00201 };
00202
00207 static KateSessionManager* self();
00208
00212 ~KateSessionManager();
00213
00219 void saveConfig(bool saveSessions);
00220
00225 const int getStartupOption();
00226
00231 const int getSwitchOption();
00232
00238 void setSwitchOption(int option);
00239
00243 const TQString& getBaseDir() const { return m_baseDir; }
00244
00248 int getSessionCount() const { return m_sessions.count(); }
00249
00253 int getActiveSessionId() const { return m_activeSessionId; }
00254
00258 const TQString& getActiveSessionName() { return m_sessions[m_activeSessionId]->getSessionName(); }
00259
00264 const TQString& getSessionName(int sessionId) ;
00265
00269 KateSession* getActiveSession() { return m_sessions[m_activeSessionId]; }
00270
00275 KateSession* getSessionFromId(int sessionId);
00276
00285 int getSessionIdFromName(const TQString &name);
00286
00290 TQPtrList<KateSession>& getSessionsList() { return m_sessions; }
00291
00299 bool activateSession(int sessionId, bool saveCurr = true);
00300
00309 int newSession(const TQString &sessionName = TQString::null, bool saveCurr = true);
00310
00320 int cloneSession(int sessionId, const TQString &sessionName = TQString::null,
00321 bool activate = true, bool deleteCurr = false);
00322
00326 void reloadActiveSession() { m_sessions[m_activeSessionId]->load(true); }
00327
00333 bool restoreLastSession();
00334
00339 void saveActiveSession() { saveSession(m_activeSessionId); }
00340
00346 void saveSession(int sessionId) { saveSession(sessionId, sessionId == m_activeSessionId); }
00347
00357 bool deleteSession(int sessionId, int actSessId);
00358
00363 void moveSessionForward(int sessionId);
00364
00369 void moveSessionBackward(int sessionId);
00370
00377 void renameSession(int sessionId, const TQString &newSessionName);
00378
00384 void setSessionReadOnlyStatus(int sessionId, bool readOnly);
00385
00386 signals:
00390 void switchOptionChanged();
00391
00397 void sessionActivated(int newSessionId, int oldSessionId);
00398
00403 void sessionCreated(int sessionId);
00404
00409 void sessionSaved(int sessionId);
00410
00415 void sessionDeleted(int sessionId);
00416
00422 void sessionsSwapped(int sessionIdMin, int sessionIdMax);
00423
00428 void sessionRenamed(int sessionId);
00429
00430
00431 protected:
00432 KateSessionManager();
00433
00434
00435 enum
00436 {
00437 SO_STARTUP = 0,
00438 SO_SWITCH,
00439 SO_ALL,
00440 };
00441
00446 void updateSessionOptions(int optionType);
00447
00452 void saveSessionOptions(int optionType);
00453
00460 void swapSessionsPosition(int sessionId1, int sessionId2);
00461
00469 void saveSession(int sessionId, bool saveGUIInfo, bool setReadOnly = false);
00470
00471
00472 TQString m_baseDir;
00473 TQString m_configFile;
00474 int m_activeSessionId;
00475 int m_lastSessionId;
00476 TQPtrList<KateSession> m_sessions;
00477 KSimpleConfig *m_config;
00478 int m_startupOption;
00479 int m_switchOption;
00480
00481 static KateSessionManager *ksm_instance;
00482 };
00483
00484
00485
00486
00487 class KateSessionChooserItem : public TDEListViewItem
00488 {
00489 public:
00490 KateSessionChooserItem(TQListView *listview, const TQString &sessionName, const TQString &nDoc, int sessionId)
00491 : TDEListViewItem(listview, sessionName, nDoc), m_sessionId(sessionId) {}
00492
00493 int getSessionId() { return m_sessionId; }
00494 void setSessionId(int sessionId) { m_sessionId = sessionId; }
00495
00496 protected:
00497 int m_sessionId;
00498 };
00499
00500
00501
00502
00503
00504 class KateSessionChooser : public KDialogBase
00505 {
00506 Q_OBJECT
00507
00508 public:
00509 enum Result
00510 {
00511 RESULT_NO_OP = TQDialog::Rejected,
00512 RESULT_OPEN_EXISTING,
00513 RESULT_OPEN_NEW,
00514 RESULT_QUIT_KATE
00515 };
00516
00517 KateSessionChooser(TQWidget *parent);
00518 ~KateSessionChooser() {}
00519
00520 int getSelectedSessionId();
00521
00522 protected slots:
00523
00524 void slotUser1();
00525 void slotUser2();
00526 void slotUser3();
00527 void slotSelectionChanged();
00528
00529 protected:
00530 TDEListView *m_listview;
00531 };
00532
00533
00534 #endif