kate
katesession.h
Go to the documentation of this file.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 <kaction.h>
00028
00029 #include <qobject.h>
00030 #include <qvaluelist.h>
00031
00032 class KateSessionManager;
00033
00034 class KDirWatch;
00035 class KListView;
00036 class KPushButton;
00037
00038 class QCheckBox;
00039
00040 class KateSession : public KShared
00041 {
00042 public:
00046 typedef KSharedPtr<KateSession> Ptr;
00047
00048 public:
00055 KateSession (KateSessionManager *manager, const QString &fileName, const QString &name);
00056
00060 void init ();
00061
00065 ~KateSession ();
00066
00071 QString sessionFile () const;
00072
00077 const QString &sessionFileRelative () const { return m_sessionFileRel; }
00078
00083 const QString &sessionName () const { return m_sessionName; }
00084
00089 bool isNew () const { return m_sessionName.isEmpty(); }
00090
00097 bool create (const QString &name, bool force = false);
00098
00104 bool rename (const QString &name);
00105
00112 KConfig *configRead ();
00113
00120 KConfig *configWrite ();
00121
00126 unsigned int documents () const { return m_documents; }
00127
00128 private:
00133 QString m_sessionFileRel;
00134
00138 QString m_sessionName;
00139
00143 unsigned int m_documents;
00144
00148 KateSessionManager *m_manager;
00149
00153 KSimpleConfig *m_readConfig;
00154
00158 KSimpleConfig *m_writeConfig;
00159 };
00160
00161 typedef QValueList<KateSession::Ptr> KateSessionList;
00162
00163 class KateSessionManager : public QObject
00164 {
00165 Q_OBJECT
00166
00167 public:
00168 KateSessionManager(QObject *parent);
00169 ~KateSessionManager();
00170
00175 static KateSessionManager *self();
00176
00181 inline KateSessionList & sessionList () { updateSessionList (); return m_sessionList; }
00182
00192 void activateSession (KateSession::Ptr session, bool closeLast = true, bool saveLast = true, bool loadNew = true);
00193
00198 KateSession::Ptr createSession (const QString &name);
00199
00205 KateSession::Ptr giveSession (const QString &name);
00206
00214 bool saveActiveSession (bool tryAsk = false, bool rememberAsLast = false);
00215
00221 inline KateSession::Ptr activeSession () { return m_activeSession; }
00222
00227 inline const QString &sessionsDir () const { return m_sessionsDir; }
00228
00233 bool chooseSession ();
00234
00235 public slots:
00240 void sessionNew ();
00241
00245 void sessionOpen ();
00246
00250 void sessionSave ();
00251
00255 void sessionSaveAs ();
00256
00260 void sessionManage ();
00261
00262 private slots:
00263 void dirty (const QString &path);
00264
00265 public:
00269 void updateSessionList ();
00270
00271 private:
00275 QString m_sessionsDir;
00276
00280 KateSessionList m_sessionList;
00281
00285 KateSession::Ptr m_activeSession;
00286 };
00287
00288 class KateSessionChooser : public KDialogBase
00289 {
00290 Q_OBJECT
00291
00292 public:
00293 KateSessionChooser (QWidget *parent, const QString &lastSession);
00294 ~KateSessionChooser ();
00295
00296 KateSession::Ptr selectedSession ();
00297
00298 bool reopenLastSession ();
00299
00300 enum {
00301 resultQuit = QDialog::Rejected,
00302 resultOpen,
00303 resultNew,
00304 resultNone
00305 };
00306
00307 protected slots:
00311 void slotUser1 ();
00312
00316 void slotUser2 ();
00317
00321 void slotUser3 ();
00322
00326 void selectionChanged ();
00327
00328 private:
00329 KListView *m_sessions;
00330 QCheckBox *m_useLast;
00331 };
00332
00333 class KateSessionOpenDialog : public KDialogBase
00334 {
00335 Q_OBJECT
00336
00337 public:
00338 KateSessionOpenDialog (QWidget *parent);
00339 ~KateSessionOpenDialog ();
00340
00341 KateSession::Ptr selectedSession ();
00342
00343 enum {
00344 resultOk,
00345 resultCancel
00346 };
00347
00348 protected slots:
00352 void slotUser1 ();
00353
00357 void slotUser2 ();
00358
00359 private:
00360 KListView *m_sessions;
00361 };
00362
00363 class KateSessionManageDialog : public KDialogBase
00364 {
00365 Q_OBJECT
00366
00367 public:
00368 KateSessionManageDialog (QWidget *parent);
00369 ~KateSessionManageDialog ();
00370
00371 protected slots:
00375 void slotUser1 ();
00376
00380 void selectionChanged ();
00381
00385 void rename ();
00386
00390 void del ();
00391
00392 private:
00396 void updateSessionList ();
00397
00398 private:
00399 KListView *m_sessions;
00400 KPushButton *m_rename;
00401 KPushButton *m_del;
00402 };
00403
00404 class KateSessionsAction : public KActionMenu
00405 {
00406 Q_OBJECT
00407
00408 public:
00409 KateSessionsAction(const QString& text, QObject* parent = 0, const char* name = 0);
00410 ~KateSessionsAction (){;};
00411
00412 public slots:
00413 void slotAboutToShow();
00414
00415 void openSession (int i);
00416 };
00417
00418 #endif