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

kate

  • kate
  • app
katesession.h
1 /* This file is part of the KDE project
2  Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef __KATE_SESSION_H__
20 #define __KATE_SESSION_H__
21 
22 #include "katemain.h"
23 
24 #include <kdialogbase.h>
25 #include <ksimpleconfig.h>
26 #include <ksharedptr.h>
27 #include <tdeaction.h>
28 
29 #include <tqobject.h>
30 #include <tqptrlist.h>
31 #include <tqvaluelist.h>
32 #include <tqstringlist.h>
33 #include <tdelistview.h>
34 
35 class KateViewSpace;
36 class KDirWatch;
37 class KPushButton;
38 class TDEListView;
39 class TQCheckBox;
40 class KateSessionManager;
41 
42 
43 //BEGIN KateSession
47 class KateSession
48 {
49  public:
50 
57  KateSession(const KateSessionManager &manager, const TQString &sessionName, const TQString &fileName);
58 
65  KateSession(const KateSession &session, const TQString &newSessionName);
66 
70  ~KateSession();
71 
75  const TQString& getSessionName() const { return m_sessionName; }
76 
81  void setSessionName(const TQString &sessionName);
82 
86  bool isReadOnly() const { return m_readOnly; }
87 
92  void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
93 
97  const TQString& getSessionFilename() const { return m_filename; }
98 
103  bool isStillVolatile() const;
104 
108  int getDocCount() const { return m_documents.count(); }
109 
114  void load(bool includeGUIInfo);
115 
121  void save(bool saveGUIInfo, bool setReadOnly = false);
122 
126  void activate();
127 
128 
129  private:
130 
131  friend class KateViewSpace;
132 
136  TDEConfig* getConfig() const { return m_config; }
137 
141  void createFilename();
142 
143  const KateSessionManager &m_manager; // The session manager that handles this session
144  TQString m_sessionName;
145  TQString m_filename;
146  bool m_readOnly;
147  TQStringList m_documents; // document URLs
148  KSimpleConfig *m_config; // session config
149 
150 };
151 //END KateSession
152 
153 
154 //BEGIN KateSessionManager
155 //FIXME (advanced - multiple main windows or multiple Kate instances)
156 //There should be only one session manager regardless of how many main windows of Kate are open.
157 //Changes should propagate to all session panels. Different Kate main windows should run different
158 //sessions. If the user switches to a session already opened in another Kate window, the other window
159 //should be brought up to the screen (eventually ask user confirmation first).
160 //This would allow a safe use of multiple Kate main windows/instances without overwriting session information
161 //among them. Currently the last instance/main window to be closed will overwrite the information previously
162 //saved by other Kate instances.
169 //FIXME update the sessions.list file when switching to another session or to a new session
170 //
171 //FIXME create new unnamed session, choose 'save' as session switch option. Exit Kate.
172 // Session is saved without asking for a name
173 //FIXME improve getStartupOption/getSwitchOption/setSwitchOption using new signal
174 // KateApp::optionsChanged()
175 //FIXME add kdDebug statement to ease debugging
176 class KateSessionManager : public TQObject
177 {
178  TQ_OBJECT
179 
180  public:
181 
182  enum
183  {
184  INVALID_SESSION = -1
185  };
186 
187  // Session options on Kate startup
188  enum
189  {
190  STARTUP_NEW = 0, // New session
191  STARTUP_LAST, // Use last session
192  STARTUP_MANUAL // Manually choose a session
193  };
194 
195  // Session options on session switch or Kate shutdown
196  enum
197  {
198  SWITCH_DISCARD = 0, // Don't save current session
199  SWITCH_SAVE, // Save current session
200  SWITCH_ASK // Ask user what to do
201  };
202 
207  static KateSessionManager* self();
208 
212  ~KateSessionManager();
213 
219  void saveConfig(bool saveSessions);
220 
225  const int getStartupOption();
226 
231  const int getSwitchOption();
232 
238  void setSwitchOption(int option);
239 
243  const TQString& getBaseDir() const { return m_baseDir; }
244 
248  int getSessionCount() const { return m_sessions.count(); }
249 
253  int getActiveSessionId() const { return m_activeSessionId; }
254 
258  const TQString& getActiveSessionName() /*FIXME const*/ { return m_sessions[m_activeSessionId]->getSessionName(); }
259 
264  const TQString& getSessionName(int sessionId) /*FIXME const*/;
265 
269  KateSession* getActiveSession() { return m_sessions[m_activeSessionId]; }
270 
275  KateSession* getSessionFromId(int sessionId);
276 
285  int getSessionIdFromName(const TQString &name);
286 
290  TQPtrList<KateSession>& getSessionsList() { return m_sessions; }
291 
299  bool activateSession(int sessionId, bool saveCurr = true);
300 
309  int newSession(const TQString &sessionName = TQString::null, bool saveCurr = true);
310 
320  int cloneSession(int sessionId, const TQString &sessionName = TQString::null,
321  bool activate = true, bool deleteCurr = false);
322 
326  void reloadActiveSession() { m_sessions[m_activeSessionId]->load(true); }
327 
333  bool restoreLastSession();
334 
339  void saveActiveSession() { saveSession(m_activeSessionId); }
340 
346  void saveSession(int sessionId) { saveSession(sessionId, sessionId == m_activeSessionId); }
347 
357  bool deleteSession(int sessionId, int actSessId);
358 
363  void moveSessionForward(int sessionId);
364 
369  void moveSessionBackward(int sessionId);
370 
377  void renameSession(int sessionId, const TQString &newSessionName);
378 
384  void setSessionReadOnlyStatus(int sessionId, bool readOnly);
385 
386  signals:
390  void switchOptionChanged();
391 
397  void sessionActivated(int newSessionId, int oldSessionId);
398 
403  void sessionCreated(int sessionId);
404 
409  void sessionSaved(int sessionId);
410 
415  void sessionDeleted(int sessionId);
416 
422  void sessionsSwapped(int sessionIdMin, int sessionIdMax);
423 
428  void sessionRenamed(int sessionId);
429 
430 
431  protected:
432  KateSessionManager();
433 
434  // Session options on Kate startup
435  enum
436  {
437  SO_STARTUP = 0, // session startup option only
438  SO_SWITCH, // session switch option only
439  SO_ALL, // session startup and switch options
440  };
441 
446  void updateSessionOptions(int optionType);
447 
452  void saveSessionOptions(int optionType);
453 
460  void swapSessionsPosition(int sessionId1, int sessionId2);
461 
469  void saveSession(int sessionId, bool saveGUIInfo, bool setReadOnly = false);
470 
471 
472  TQString m_baseDir; // folder where session files are stored
473  TQString m_configFile; // file where the session list config is stored
474  int m_activeSessionId; // id of the active session
475  int m_lastSessionId; // id of the last active session before closing Kate
476  TQPtrList<KateSession> m_sessions; // session list
477  KSimpleConfig *m_config; // session manager config
478  int m_startupOption; // session option on Kate startup
479  int m_switchOption; // session option on session switch or Kate shutdown
480 
481  static KateSessionManager *ksm_instance; // the only KateSessionManager instance
482 };
483 //END KateSessionManager
484 
485 
486 //BEGIN KateSessionChooserItem
487 class KateSessionChooserItem : public TDEListViewItem
488 {
489  public:
490  KateSessionChooserItem(TQListView *listview, const TQString &sessionName, const TQString &nDoc, int sessionId)
491  : TDEListViewItem(listview, sessionName, nDoc), m_sessionId(sessionId) {}
492 
493  int getSessionId() { return m_sessionId; }
494  void setSessionId(int sessionId) { m_sessionId = sessionId; }
495 
496  protected:
497  int m_sessionId;
498 };
499 //END KateSessionChooserItem
500 
501 
502 //BEGIN KateSessionChooser
503 //FIXME create one single KateSessionChooser and reuse it all the time
504 class KateSessionChooser : public KDialogBase
505 {
506  TQ_OBJECT
507 
508  public:
509  enum Result
510  {
511  RESULT_NO_OP = TQDialog::Rejected,
512  RESULT_OPEN_EXISTING,
513  RESULT_OPEN_NEW,
514  RESULT_QUIT_KATE
515  };
516 
517  KateSessionChooser(TQWidget *parent);
518  ~KateSessionChooser() {}
519 
520  int getSelectedSessionId(); // return the session id of the selected session
521 
522  protected slots:
523 
524  void slotUser1(); // open existing session
525  void slotUser2(); // open new session
526  void slotUser3(); // quit kate
527  void slotSelectionChanged(); // list selection has changed
528 
529  protected:
530  TDEListView *m_listview;
531 };
532 //END KateSessionChooser
533 
534 #endif
KateSessionManager::getActiveSession
KateSession * getActiveSession()
Definition: katesession.h:269
KateSession::load
void load(bool includeGUIInfo)
Load session info from the saved file.
Definition: katesession.cpp:132
KateSessionManager::getActiveSessionId
int getActiveSessionId() const
Definition: katesession.h:253
KateSession::activate
void activate()
Activate the session.
Definition: katesession.cpp:255
KateSessionManager::saveActiveSession
void saveActiveSession()
Saves the active session sessionSaved (through invoked "void saveSession(int)" method) ...
Definition: katesession.h:339
KateSessionManager::getSessionsList
TQPtrList< KateSession > & getSessionsList()
Definition: katesession.h:290
KateSessionManager
The Kate session manager.
Definition: katesession.h:176
KateSession::~KateSession
~KateSession()
Destructor.
Definition: katesession.cpp:111
KateSession::isReadOnly
bool isReadOnly() const
Definition: katesession.h:86
KateSessionManager::reloadActiveSession
void reloadActiveSession()
Restore the current active session to the last saved state.
Definition: katesession.h:326
KateSession::getSessionName
const TQString & getSessionName() const
Definition: katesession.h:75
KateSession::getDocCount
int getDocCount() const
Definition: katesession.h:108
KateSessionManager::saveSession
void saveSession(int sessionId)
Save the specified session.
Definition: katesession.h:346
KateSession
An object representing a Kate&#39;s session.
Definition: katesession.h:47
KateSession::setSessionName
void setSessionName(const TQString &sessionName)
Set the new session name.
Definition: katesession.cpp:120
KateSession::setReadOnly
void setReadOnly(bool readOnly)
Set session read only status.
Definition: katesession.h:92
KateSessionManager::getSessionCount
int getSessionCount() const
Definition: katesession.h:248
KateSession::KateSession
KateSession(const KateSessionManager &manager, const TQString &sessionName, const TQString &fileName)
create a new session and read the config from fileName if it exists
Definition: katesession.cpp:88
KateSessionManager::getBaseDir
const TQString & getBaseDir() const
Definition: katesession.h:243
KateSession::save
void save(bool saveGUIInfo, bool setReadOnly=false)
Save session info.
Definition: katesession.cpp:198
KateSession::getSessionFilename
const TQString & getSessionFilename() const
Definition: katesession.h:97
KateSession::isStillVolatile
bool isStillVolatile() const
Definition: katesession.cpp:126
KateSessionManager::getActiveSessionName
const TQString & getActiveSessionName()
Definition: katesession.h:258

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.8.13
This website is maintained by Timothy Pearson.