• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

katesession.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
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 //BEGIN KateSession
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;  // The session manager that handles this session
00144         TQString       m_sessionName;
00145         TQString       m_filename;
00146         bool           m_readOnly;
00147         TQStringList   m_documents;           // document URLs
00148         KSimpleConfig *m_config;              // session config
00149 
00150 };
00151 //END KateSession
00152 
00153 
00154 //BEGIN KateSessionManager
00155 //FIXME (advanced - multiple main windows or multiple Kate instances)
00156 //There should be only one session manager regardless of how many main windows of Kate are open.
00157 //Changes should propagate to all session panels. Different Kate main windows should run different
00158 //sessions. If the user switches to a session already opened in another Kate window, the other window
00159 //should be brought up to the screen (eventually ask user confirmation first).
00160 //This would allow a safe use of multiple Kate main windows/instances without overwriting session information
00161 //among them. Currently the last instance/main window to be closed will overwrite the information previously
00162 //saved by other Kate instances.
00169 //FIXME update the sessions.list file when switching to another session or to a new session
00170 //
00171 //FIXME create new unnamed session, choose 'save' as session switch option. Exit Kate. 
00172 //      Session is saved without asking for a name
00173 //FIXME improve getStartupOption/getSwitchOption/setSwitchOption using new signal
00174 //      KateApp::optionsChanged()
00175 //FIXME add kdDebug statement to ease debugging
00176 class KateSessionManager : public TQObject
00177 {
00178   Q_OBJECT
00179 
00180     public:
00181 
00182     enum
00183     {
00184       INVALID_SESSION = -1
00185     };
00186 
00187     // Session options on Kate startup
00188     enum 
00189     {
00190       STARTUP_NEW = 0,    // New session
00191       STARTUP_LAST,       // Use last session
00192       STARTUP_MANUAL      // Manually choose a session
00193     };
00194         
00195     // Session options on session switch or Kate shutdown
00196     enum 
00197     {
00198       SWITCH_DISCARD = 0, // Don't save current session
00199       SWITCH_SAVE,        // Save current session
00200       SWITCH_ASK          // Ask user what to do
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() /*FIXME const*/ { return m_sessions[m_activeSessionId]->getSessionName(); }
00259 
00264         const TQString& getSessionName(int sessionId) /*FIXME const*/;
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     // Session options on Kate startup
00435     enum 
00436     {
00437       SO_STARTUP = 0,     // session startup option only
00438       SO_SWITCH,          // session switch option only
00439       SO_ALL,             // session startup and switch options
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;                         // folder where session files are stored
00473         TQString m_configFile;                      // file where the session list config is stored
00474         int m_activeSessionId;              // id of the active session
00475     int m_lastSessionId;                // id of the last active session before closing Kate
00476         TQPtrList<KateSession> m_sessions;  // session list
00477         KSimpleConfig *m_config;                // session manager config
00478         int m_startupOption;                // session option on Kate startup
00479         int m_switchOption;                 // session option on session switch or Kate shutdown
00480         
00481         static KateSessionManager *ksm_instance;  // the only KateSessionManager instance
00482 };
00483 //END KateSessionManager
00484 
00485 
00486 //BEGIN KateSessionChooserItem
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 //END KateSessionChooserItem
00500 
00501 
00502 //BEGIN KateSessionChooser
00503 //FIXME create one single KateSessionChooser and reuse it all the time
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();  // return the session id of the selected session
00521 
00522     protected slots:
00523 
00524         void slotUser1();   // open existing session
00525         void slotUser2();   // open new session
00526         void slotUser3();   // quit kate
00527         void slotSelectionChanged();  // list selection has changed
00528 
00529     protected:
00530         TDEListView *m_listview;
00531 };
00532 //END KateSessionChooser
00533 
00534 #endif

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.6.3
This website is maintained by Timothy Pearson.