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 <kaction.h> 00028 00029 #include <tqobject.h> 00030 #include <tqvaluelist.h> 00031 00032 class KateSessionManager; 00033 00034 class KDirWatch; 00035 class KListView; 00036 class KPushButton; 00037 00038 class TQCheckBox; 00039 00040 class KateSession : public KShared 00041 { 00042 public: 00046 typedef KSharedPtr<KateSession> Ptr; 00047 00048 public: 00055 KateSession (KateSessionManager *manager, const TQString &fileName, const TQString &name); 00056 00060 void init (); 00061 00065 ~KateSession (); 00066 00071 TQString sessionFile () const; 00072 00077 const TQString &sessionFileRelative () const { return m_sessionFileRel; } 00078 00083 const TQString &sessionName () const { return m_sessionName; } 00084 00089 bool isNew () const { return m_sessionName.isEmpty(); } 00090 00097 bool create (const TQString &name, bool force = false); 00098 00104 bool rename (const TQString &name); 00105 00112 KConfig *configRead (); 00113 00120 KConfig *configWrite (); 00121 00126 unsigned int documents () const { return m_documents; } 00127 00128 private: 00133 TQString m_sessionFileRel; 00134 00138 TQString 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 TQValueList<KateSession::Ptr> KateSessionList; 00162 00163 class KateSessionManager : public TQObject 00164 { 00165 Q_OBJECT 00166 00167 public: 00168 KateSessionManager(TQObject *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 TQString &name); 00199 00205 KateSession::Ptr giveSession (const TQString &name); 00206 00214 bool saveActiveSession (bool tryAsk = false, bool rememberAsLast = false); 00215 00221 inline KateSession::Ptr activeSession () { return m_activeSession; } 00222 00227 inline const TQString &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 TQString &path); 00264 00265 public: 00269 void updateSessionList (); 00270 00271 private: 00275 TQString 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 (TQWidget *parent, const TQString &lastSession); 00294 ~KateSessionChooser (); 00295 00296 KateSession::Ptr selectedSession (); 00297 00298 bool reopenLastSession (); 00299 00300 enum { 00301 resultQuit = TQDialog::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 TQCheckBox *m_useLast; 00331 }; 00332 00333 class KateSessionOpenDialog : public KDialogBase 00334 { 00335 Q_OBJECT 00336 00337 public: 00338 KateSessionOpenDialog (TQWidget *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 (TQWidget *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 TQString& text, TQObject* 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