summaryrefslogtreecommitdiffstats
path: root/kate/app/katesession.h
diff options
context:
space:
mode:
Diffstat (limited to 'kate/app/katesession.h')
-rw-r--r--kate/app/katesession.h786
1 files changed, 415 insertions, 371 deletions
diff --git a/kate/app/katesession.h b/kate/app/katesession.h
index 3904f9f0f..67fb6dc20 100644
--- a/kate/app/katesession.h
+++ b/kate/app/katesession.h
@@ -31,6 +31,8 @@
#include <tqvaluelist.h>
#include <tqstringlist.h>
+class KateViewSpace;
+
class OldKateSessionManager; // Michele - to be removed with OldKateSession
class KDirWatch;
@@ -41,68 +43,76 @@ class TQCheckBox;
class KateSession
{
- public:
+ public:
- /**
- * create a new session and read the config from fileName if it exists
- * @param sessionName session name
- * @param fileName file where session config is saved to/restored from
- * @param isFullName true -> filename is a full filename, used to load/save the session configuration
- * false -> filename is a folder name. This is used for new unsaved sessions
- * to inject the location where the configuration file should be saved
- */
- KateSession(const TQString &sessionName, const TQString &fileName, bool isFullName);
+ /**
+ * create a new session and read the config from fileName if it exists
+ * @param sessionName session name
+ * @param fileName file where session config is saved to/restored from
+ * @param isFullName true -> filename is a full filename, used to load/save the session configuration
+ * false -> filename is a folder name. This is used for new unsaved sessions
+ * to inject the location where the configuration file should be saved
+ */
+ KateSession(const TQString &sessionName, const TQString &fileName, bool isFullName);
- /**
- * Destructor
- */
- ~KateSession();
+ /**
+ * Destructor
+ */
+ ~KateSession();
/**
- * @return the session name
- */
+ * @return the session name
+ */
const TQString& getSessionName() const { return m_sessionName; }
/**
- * Set the new session name
- * @param sessionName the new session name
- */
+ * Set the new session name
+ * @param sessionName the new session name
+ */
void setSessionName(const TQString &sessionName);
/**
- * @return whether the session is read only or not
- */
+ * @return whether the session is read only or not
+ */
bool isReadOnly() const { return m_readOnly; }
/**
- * Set session read only status
- * @param readOnly if true, the session config can not be saved to file
- */
+ * Set session read only status
+ * @param readOnly if true, the session config can not be saved to file
+ */
void setReadOnly(bool readOnly);
/**
- * @return the session filename
- */
+ * @return the session filename
+ */
const TQString& getSessionFilename() const { return m_filename; }
- /**
- * Save session info
- * @param saveDocList if true, save also the information about the documents currently open
- */
- void save(bool saveDocList);
+ /**
+ * Save session info
+ * @param saveGUIInfo if true, save also the information about the GUI elements
+ */
+ void save(bool saveGUIInfo);
- /**
- * Activate the session
- */
- void activate();
-
- private:
- TQString m_sessionName;
- TQString m_filename;
- bool m_isFullName; // true -> m_filename is a full filename
- // false -> m_filename is a folder name.
- bool m_readOnly;
- int m_docCount; // number of documents in the session
- TQStringList m_documents; // document URLs
- KSimpleConfig *m_config; // session config
+ /**
+ * Activate the session
+ */
+ void activate();
+
+ private:
+
+ friend class KateViewSpace;
+ /**
+ * @return the session config object
+ */
+ TDEConfig* getConfig() { return m_config; }
+
+
+ TQString m_sessionName;
+ TQString m_filename;
+ bool m_isFullName; // true -> m_filename is a full filename
+ // false -> m_filename is a folder name.
+ bool m_readOnly;
+ int m_docCount; // number of documents in the session
+ TQStringList m_documents; // document URLs
+ KSimpleConfig *m_config; // session config
};
@@ -110,56 +120,88 @@ class KateSession
//------------------------------------
class KateSessionManager
{
- public:
+ public:
- /**
- * get a pointer to the unique KateSessionManager instance.
- * If the manager does not exist yet, create it.
- */
- static KateSessionManager* self();
+ enum
+ {
+ INVALID_SESSION = -1
+ };
+
+ /**
+ * get a pointer to the unique KateSessionManager instance.
+ * If the manager does not exist yet, create it.
+ */
+ static KateSessionManager* self();
- /**
- * Destructor
- */
- ~KateSessionManager();
+ /**
+ * Destructor
+ */
+ ~KateSessionManager();
- /**
- * Save session manager info
- */
- void saveConfig();
+ /**
+ * Save session manager info
+ */
+ void saveConfig();
- /**
- * @return the active session id
- */
- int getActiveSessionId() const { return m_activeSessionId; }
+ /**
+ * @return the active session id
+ */
+ int getActiveSessionId() const { return m_activeSessionId; }
- /**
- * @return a reference to the active session
- */
- KateSession* getActiveSession() { return m_sessions[m_activeSessionId]; }
+ /**
+ * @return the active session name
+ */
+ const TQString& getActiveSessionName() /*FIXME const*/ { return m_sessions[m_activeSessionId]->getSessionName(); }
+
+ /**
+ * @return a reference to the active session
+ */
+ KateSession* getActiveSession() { return m_sessions[m_activeSessionId]; }
+
+ /**
+ * @return a reference to the sessions list
+ */
+ TQPtrList<KateSession>& getSessionsList() { return m_sessions; }
/**
- * @return a reference to the sessions list
+ * Returns the session id of the first session whose name matches the
+ * provided one
+ * @param name the session name to look for
+ * @return the session id of the matching session if it is found,
+ * otherwise KateSessionManager::INVALID_SESSION.
*/
- TQPtrList<KateSession>& getSessionsList() { return m_sessions; }
+ int getSessionIdFromName(const TQString &name);
+
+ /**
+ * Activates the selected session.
+ * @param sessionId the id of the session to activate
+ * @param saveCurr if true, save the current session before activating the new one
+ * @return whether the session was activated or not
+ */
+ bool activateSession(int sessionId, bool saveCurr = true);
/**
- * Activates the selected session.
- * @param sessionId the id of the session to activate
- * @param saveCurr if true, save the current session before activating the new one
+ * Restore the last saved session. Can only be used before
+ * any other session has been activated, i.e. on Kate's startup
* @return whether the session was activated or not
*/
- bool activateSession(int sessionId, bool saveCurr = true);
+ bool restoreLastSession();
+
+ /**
+ * Saves the active session
+ */
+ void saveActiveSession() { m_sessions[m_activeSessionId]->save(true); }
- private:
- KateSessionManager();
+ private:
+ KateSessionManager();
- TQString m_baseDir; // folder where session files are stored
- TQString m_configFile; // file where the session list config is stored
- int m_sessionsCount; // number of sessions
- int m_activeSessionId; // index of the active session
- TQPtrList<KateSession> m_sessions; // session list
- KSimpleConfig *m_config; // session manager config
+ TQString m_baseDir; // folder where session files are stored
+ TQString m_configFile; // file where the session list config is stored
+ int m_sessionsCount; // number of sessions
+ int m_activeSessionId; // index of the active session
+ bool m_firstActivation; // true until at least one session has been activated
+ TQPtrList<KateSession> m_sessions; // session list
+ KSimpleConfig *m_config; // session manager config
static KateSessionManager *ksm_instance; // the only KateSessionManager instance
};
@@ -173,380 +215,382 @@ class KateSessionManager
//------------------------------------
class OldKateSession : public TDEShared
{
- public:
- /**
- * Define a Shared-Pointer type
- */
- typedef TDESharedPtr<OldKateSession> Ptr;
+ public:
+ /**
+ * Define a Shared-Pointer type
+ */
+ typedef TDESharedPtr<OldKateSession> Ptr;
- public:
- /**
- * create a session from given file
- * @param fileName session filename, relative
- * @param name session name
- * @param manager pointer to the manager
- */
- OldKateSession (OldKateSessionManager *manager, const TQString &fileName, const TQString &name);
+ public:
+ /**
+ * create a session from given file
+ * @param fileName session filename, relative
+ * @param name session name
+ * @param manager pointer to the manager
+ */
+ OldKateSession ( OldKateSessionManager *manager, const TQString &fileName, const TQString &name );
- /**
- * init the session object, after construction or create
- */
- void init ();
+ /**
+ * init the session object, after construction or create
+ */
+ void init ();
- /**
- * destruct me
- */
- ~OldKateSession ();
+ /**
+ * destruct me
+ */
+ ~OldKateSession ();
- /**
- * session filename, absolute, calculated out of relative filename + session dir
- * @return absolute path to session file
- */
- TQString sessionFile () const;
+ /**
+ * session filename, absolute, calculated out of relative filename + session dir
+ * @return absolute path to session file
+ */
+ TQString sessionFile () const;
- /**
- * relative session filename
- * @return relative filename for this session
- */
- const TQString &sessionFileRelative () const { return m_sessionFileRel; }
+ /**
+ * relative session filename
+ * @return relative filename for this session
+ */
+ const TQString &sessionFileRelative () const { return m_sessionFileRel; }
- /**
- * session name
- * @return name for this session
- */
- const TQString &sessionName () const { return m_sessionName; }
+ /**
+ * session name
+ * @return name for this session
+ */
+ const TQString &sessionName () const { return m_sessionName; }
- /**
- * is this a valid session? if not, don't use any session if this is
- * the active one
- */
- bool isNew () const { return m_sessionName.isEmpty(); }
+ /**
+ * is this a valid session? if not, don't use any session if this is
+ * the active one
+ */
+ bool isNew () const { return m_sessionName.isEmpty(); }
- /**
- * create the session file, if not existing
- * @param name name for this session
- * @param force force to create new file
- * @return true if created, false if no creation needed
- */
- bool create (const TQString &name, bool force = false);
+ /**
+ * create the session file, if not existing
+ * @param name name for this session
+ * @param force force to create new file
+ * @return true if created, false if no creation needed
+ */
+ bool create ( const TQString &name, bool force = false );
- /**
- * rename this session
- * @param name new name
- * @return success
- */
- bool rename (const TQString &name);
+ /**
+ * rename this session
+ * @param name new name
+ * @return success
+ */
+ bool rename ( const TQString &name );
- /**
- * config to read
- * on first access, will create the config object, delete will be done automagic
- * return 0 if we have no file to read config from atm
- * @return config to read from
- */
- TDEConfig *configRead ();
+ /**
+ * config to read
+ * on first access, will create the config object, delete will be done automagic
+ * return 0 if we have no file to read config from atm
+ * @return config to read from
+ */
+ TDEConfig *configRead ();
- /**
- * config to write
- * on first access, will create the config object, delete will be done automagic
- * return 0 if we have no file to write config to atm
- * @return config to write from
- */
- TDEConfig *configWrite ();
+ /**
+ * config to write
+ * on first access, will create the config object, delete will be done automagic
+ * return 0 if we have no file to write config to atm
+ * @return config to write from
+ */
+ TDEConfig *configWrite ();
- /**
- * count of documents in this session
- * @return documents count
- */
- unsigned int documents () const { return m_documents; }
+ /**
+ * count of documents in this session
+ * @return documents count
+ */
+ unsigned int documents () const { return m_documents; }
- private:
- /**
- * session filename, in local location we can write to
- * relative filename to the session dirs :)
- */
- TQString m_sessionFileRel;
+ private:
+ /**
+ * session filename, in local location we can write to
+ * relative filename to the session dirs :)
+ */
+ TQString m_sessionFileRel;
- /**
- * session name, extracted from the file, to display to the user
- */
- TQString m_sessionName;
+ /**
+ * session name, extracted from the file, to display to the user
+ */
+ TQString m_sessionName;
- /**
- * number of document of this session
- */
- unsigned int m_documents;
+ /**
+ * number of document of this session
+ */
+ unsigned int m_documents;
- /**
- * OldKateSessionMananger
- */
- OldKateSessionManager *m_manager;
+ /**
+ * OldKateSessionMananger
+ */
+ OldKateSessionManager *m_manager;
- /**
- * simpleconfig to read from
- */
- KSimpleConfig *m_readConfig;
+ /**
+ * simpleconfig to read from
+ */
+ KSimpleConfig *m_readConfig;
- /**
- * simpleconfig to write to
- */
- KSimpleConfig *m_writeConfig;
+ /**
+ * simpleconfig to write to
+ */
+ KSimpleConfig *m_writeConfig;
};
typedef TQValueList<OldKateSession::Ptr> OldKateSessionList;
class OldKateSessionManager : public TQObject
{
- Q_OBJECT
+ Q_OBJECT
- public:
- OldKateSessionManager(TQObject *parent);
- ~OldKateSessionManager();
+ public:
+ OldKateSessionManager ( TQObject *parent );
+ ~OldKateSessionManager();
- /**
- * allow access to this :)
- * @return instance of the session manager
- */
- static OldKateSessionManager *self();
+ /**
+ * allow access to this :)
+ * @return instance of the session manager
+ */
+ static OldKateSessionManager *self();
- /**
- * allow access to the session list
- * kept up to date by watching the dir
- */
- inline OldKateSessionList & sessionList () { updateSessionList (); return m_sessionList; }
+ /**
+ * allow access to the session list
+ * kept up to date by watching the dir
+ */
+ inline OldKateSessionList & sessionList () { updateSessionList (); return m_sessionList; }
- /**
- * activate a session
- * first, it will look if a session with this name exists in list
- * if yes, it will use this session, else it will create a new session file
- * @param session session to activate
- * @param closeLast try to close last session or not?
- * @param saveLast try to save last session or not?
- * @param loadNew load new session stuff?
- */
- void activateSession (OldKateSession::Ptr session, bool closeLast = true, bool saveLast = true, bool loadNew = true);
+ /**
+ * activate a session
+ * first, it will look if a session with this name exists in list
+ * if yes, it will use this session, else it will create a new session file
+ * @param session session to activate
+ * @param closeLast try to close last session or not?
+ * @param saveLast try to save last session or not?
+ * @param loadNew load new session stuff?
+ */
+ void activateSession ( OldKateSession::Ptr session, bool closeLast = true, bool saveLast = true, bool loadNew = true );
- /**
- * create a new session
- * @param name session name
- */
- OldKateSession::Ptr createSession (const TQString &name);
+ /**
+ * create a new session
+ * @param name session name
+ */
+ OldKateSession::Ptr createSession ( const TQString &name );
- /**
- * return session with given name
- * if no existing session matches, create new one with this name
- * @param name session name
- */
- OldKateSession::Ptr giveSession (const TQString &name);
+ /**
+ * return session with given name
+ * if no existing session matches, create new one with this name
+ * @param name session name
+ */
+ OldKateSession::Ptr giveSession ( const TQString &name );
- /**
- * save current session
- * for sessions without filename: save nothing
- * @param tryAsk should we ask user if needed?
- * @param rememberAsLast remember this session as last used?
- * @return success
- */
- bool saveActiveSession (bool tryAsk = false, bool rememberAsLast = false);
+ /**
+ * save current session
+ * for sessions without filename: save nothing
+ * @param tryAsk should we ask user if needed?
+ * @param rememberAsLast remember this session as last used?
+ * @return success
+ */
+ bool saveActiveSession ( bool tryAsk = false, bool rememberAsLast = false );
- /**
- * return the current active session
- * sessionFile == empty means we have no session around for this instance of kate
- * @return session active atm
- */
- inline OldKateSession::Ptr activeSession () { return m_activeSession; }
+ /**
+ * return the current active session
+ * sessionFile == empty means we have no session around for this instance of kate
+ * @return session active atm
+ */
+ inline OldKateSession::Ptr activeSession () { return m_activeSession; }
- /**
- * session dir
- * @return global session dir
- */
- inline const TQString &sessionsDir () const { return m_sessionsDir; }
+ /**
+ * session dir
+ * @return global session dir
+ */
+ inline const TQString &sessionsDir () const { return m_sessionsDir; }
- /**
- * initial session chooser, on app start
- * @return success, if false, app should exit
- */
- bool chooseSession ();
+ /**
+ * initial session chooser, on app start
+ * @return success, if false, app should exit
+ */
+ bool chooseSession ();
- public slots:
- /**
- * try to start a new session
- * asks user first for name
- */
- void sessionNew ();
+ public slots:
+ /**
+ * try to start a new session
+ * asks user first for name
+ */
+ void sessionNew ();
- /**
- * try to open a existing session
- */
- void sessionOpen ();
+ /**
+ * try to open a existing session
+ */
+ void sessionOpen ();
- /**
- * try to save current session
- */
- void sessionSave ();
+ /**
+ * try to save current session
+ */
+ void sessionSave ();
- /**
- * try to save as current session
- */
- void sessionSaveAs ();
+ /**
+ * try to save as current session
+ */
+ void sessionSaveAs ();
- /**
- * show dialog to manage our sessions
- */
- void sessionManage ();
+ /**
+ * show dialog to manage our sessions
+ */
+ void sessionManage ();
- private slots:
- void dirty (const TQString &path);
+ private slots:
+ void dirty ( const TQString &path );
- public:
- /**
- * trigger update of session list
- */
- void updateSessionList ();
+ public:
+ /**
+ * trigger update of session list
+ */
+ void updateSessionList ();
- private:
- /**
- * absolute path to dir in home dir where to store the sessions
- */
- TQString m_sessionsDir;
+ private:
+ /**
+ * absolute path to dir in home dir where to store the sessions
+ */
+ TQString m_sessionsDir;
- /**
- * list of current available sessions
- */
- OldKateSessionList m_sessionList;
+ /**
+ * list of current available sessions
+ */
+ OldKateSessionList m_sessionList;
- /**
- * current active session
- */
- OldKateSession::Ptr m_activeSession;
+ /**
+ * current active session
+ */
+ OldKateSession::Ptr m_activeSession;
};
class OldKateSessionChooser : public KDialogBase
{
- Q_OBJECT
+ Q_OBJECT
- public:
- OldKateSessionChooser (TQWidget *parent, const TQString &lastSession);
- ~OldKateSessionChooser ();
+ public:
+ OldKateSessionChooser ( TQWidget *parent, const TQString &lastSession );
+ ~OldKateSessionChooser ();
- OldKateSession::Ptr selectedSession ();
+ OldKateSession::Ptr selectedSession ();
- bool reopenLastSession ();
+ bool reopenLastSession ();
- enum {
- resultQuit = TQDialog::Rejected,
- resultOpen,
- resultNew,
- resultNone
- };
+ enum
+ {
+ resultQuit = TQDialog::Rejected,
+ resultOpen,
+ resultNew,
+ resultNone
+ };
- protected slots:
- /**
- * open session
- */
- void slotUser1 ();
+ protected slots:
+ /**
+ * open session
+ */
+ void slotUser1 ();
- /**
- * new session
- */
- void slotUser2 ();
+ /**
+ * new session
+ */
+ void slotUser2 ();
- /**
- * quit kate
- */
- void slotUser3 ();
+ /**
+ * quit kate
+ */
+ void slotUser3 ();
- /**
- * selection has changed
- */
- void selectionChanged ();
+ /**
+ * selection has changed
+ */
+ void selectionChanged ();
- private:
- TDEListView *m_sessions;
- TQCheckBox *m_useLast;
+ private:
+ TDEListView *m_sessions;
+ TQCheckBox *m_useLast;
};
class OldKateSessionOpenDialog : public KDialogBase
{
- Q_OBJECT
+ Q_OBJECT
- public:
- OldKateSessionOpenDialog (TQWidget *parent);
- ~OldKateSessionOpenDialog ();
+ public:
+ OldKateSessionOpenDialog ( TQWidget *parent );
+ ~OldKateSessionOpenDialog ();
- OldKateSession::Ptr selectedSession ();
+ OldKateSession::Ptr selectedSession ();
- enum {
- resultOk,
- resultCancel
- };
+ enum
+ {
+ resultOk,
+ resultCancel
+ };
- protected slots:
- /**
- * cancel pressed
- */
- void slotUser1 ();
+ protected slots:
+ /**
+ * cancel pressed
+ */
+ void slotUser1 ();
- /**
- * ok pressed
- */
- void slotUser2 ();
+ /**
+ * ok pressed
+ */
+ void slotUser2 ();
- private:
- TDEListView *m_sessions;
+ private:
+ TDEListView *m_sessions;
};
class OldKateSessionManageDialog : public KDialogBase
{
- Q_OBJECT
-
- public:
- OldKateSessionManageDialog (TQWidget *parent);
- ~OldKateSessionManageDialog ();
+ Q_OBJECT
- protected slots:
- /**
- * close pressed
- */
- void slotUser1 ();
+ public:
+ OldKateSessionManageDialog ( TQWidget *parent );
+ ~OldKateSessionManageDialog ();
- /**
- * selection has changed
- */
- void selectionChanged ();
+ protected slots:
+ /**
+ * close pressed
+ */
+ void slotUser1 ();
- /**
- * try to rename session
- */
- void rename ();
+ /**
+ * selection has changed
+ */
+ void selectionChanged ();
- /**
- * try to delete session
- */
- void del ();
+ /**
+ * try to rename session
+ */
+ void rename ();
- private:
- /**
- * update our list
- */
- void updateSessionList ();
+ /**
+ * try to delete session
+ */
+ void del ();
- private:
- TDEListView *m_sessions;
- KPushButton *m_rename;
- KPushButton *m_del;
+ private:
+ /**
+ * update our list
+ */
+ void updateSessionList ();
+
+ private:
+ TDEListView *m_sessions;
+ KPushButton *m_rename;
+ KPushButton *m_del;
};
class OldKateSessionsAction : public TDEActionMenu
{
- Q_OBJECT
+ Q_OBJECT
- public:
- OldKateSessionsAction(const TQString& text, TQObject* parent = 0, const char* name = 0);
- ~OldKateSessionsAction (){;};
+ public:
+ OldKateSessionsAction ( const TQString& text, TQObject* parent = 0, const char* name = 0 );
+ ~OldKateSessionsAction () {;};
- public slots:
- void slotAboutToShow();
+ public slots:
+ void slotAboutToShow();
- void openSession (int i);
+ void openSession ( int i );
};
#endif