summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kate/app/kateapp.cpp41
-rw-r--r--kate/app/kateapp.h3
-rw-r--r--kate/app/kateappIface.cpp9
-rw-r--r--kate/app/katemainwindow.cpp14
-rw-r--r--kate/app/katesession.cpp114
-rw-r--r--kate/app/katesession.h786
-rw-r--r--kate/app/katesessionpanel.cpp16
-rw-r--r--kate/app/katesessionpanel.h1
-rw-r--r--kate/app/kateviewspace.cpp11
9 files changed, 567 insertions, 428 deletions
diff --git a/kate/app/kateapp.cpp b/kate/app/kateapp.cpp
index 2ff68ed1a..f6089cb75 100644
--- a/kate/app/kateapp.cpp
+++ b/kate/app/kateapp.cpp
@@ -75,7 +75,6 @@ KateApp::KateApp (TDECmdLineArgs *args)
m_pluginManager = new KatePluginManager (TQT_TQOBJECT(this));
// session manager up
- m_oldSessionManager = new OldKateSessionManager (TQT_TQOBJECT(this));
m_sessionManager = KateSessionManager::self();
// application dcop interface
@@ -109,7 +108,6 @@ KateApp::~KateApp ()
delete m_obj; // cu dcop interface
delete m_pluginManager; // cu plugin manager
delete m_sessionManager; // delete session manager
- delete m_oldSessionManager; // delete session manager
delete m_docManager; // delete document manager. Do this now, or we crash
}
@@ -137,24 +135,22 @@ TQString KateApp::kateVersion (bool fullVersion)
return fullVersion ? TQString ("2.5.%1").arg(KDE::versionMajor()) : TQString ("%1.%2").arg(2.5);
}
-void KateApp::restoreKate ()
+void KateApp::restoreKate()
{
// restore the nice files ;) we need it
- Kate::Document::setOpenErrorDialogsActivated (false);
+ Kate::Document::setOpenErrorDialogsActivated(false);
- // activate again correct session!!!
- sessionConfig()->setGroup("General");
- TQString lastSession (sessionConfig()->readEntry ("Last Session", "default.katesession"));
- oldSessionManager()->activateSession (new OldKateSession (oldSessionManager(), lastSession, ""), false, false, false);
- m_docManager->restoreDocumentList (sessionConfig());
+ // restore last session
+ sessionManager()->restoreLastSession();
+ m_docManager->restoreDocumentList(sessionConfig());
- Kate::Document::setOpenErrorDialogsActivated (true);
+ Kate::Document::setOpenErrorDialogsActivated(true);
// restore all windows ;)
for (int n=1; TDEMainWindow::canBeRestored(n); n++)
newMainWindow(sessionConfig(), TQString ("%1").arg(n));
- // oh, no mainwindow, create one, should not happen, but make sure ;)
+ // no mainwindow, create one, should not happen, but make sure ;)
if (mainWindows() == 0)
newMainWindow ();
@@ -167,17 +163,24 @@ bool KateApp::startupKate ()
// user specified session to open
if (m_args->isSet ("start"))
{
- oldSessionManager()->activateSession (oldSessionManager()->giveSession (TQString::fromLocal8Bit(m_args->getOption("start"))), false, false);
+ // MIKE fixme: need to handle this functionality
+ sessionManager()->activateSession(
+ sessionManager()->getSessionIdFromName(TQString::fromLocal8Bit(m_args->getOption("start"))));
}
else
{
+ // MIKE: for the time being just open last session.
+ // FIXME: need to add support for startup session options
+ sessionManager()->restoreLastSession();
+
+ // MIKE fixme: need to handle this functionality
// let the user choose session if possible
- if (!oldSessionManager()->chooseSession ())
+ /*if (!oldSessionManager()->chooseSession ())
{
// we will exit kate now, notify the rest of the world we are done
TDEStartupInfo::appStarted (startupId());
return false;
- }
+ }*/
}
// oh, no mainwindow, create one, should not happen, but make sure ;)
@@ -264,12 +267,13 @@ bool KateApp::startupKate ()
return true;
}
-void KateApp::shutdownKate (KateMainWindow *win)
+void KateApp::shutdownKate(KateMainWindow *win)
{
if (!win->queryClose_internal())
return;
- oldSessionManager()->saveActiveSession(true, true);
+ // Save current session here to make sure all GUI elements are saved correctly
+ sessionManager()->saveActiveSession();
// detach the dcopClient
dcopClient()->detach();
@@ -291,11 +295,6 @@ KateDocManager *KateApp::documentManager ()
return m_docManager;
}
-OldKateSessionManager *KateApp::oldSessionManager ()
-{
- return m_oldSessionManager;
-}
-
KateSessionManager* KateApp::sessionManager()
{
return m_sessionManager;
diff --git a/kate/app/kateapp.h b/kate/app/kateapp.h
index 73b9553ee..c1c90aa46 100644
--- a/kate/app/kateapp.h
+++ b/kate/app/kateapp.h
@@ -26,7 +26,6 @@
#include <tqvaluelist.h>
-class OldKateSessionManager;
class KateSessionManager;
class KateAppDCOPIface;
@@ -129,7 +128,6 @@ class KDE_EXPORT KateApp : public TDEApplication
* accessor to session manager
* @return session manager instance
*/
- OldKateSessionManager *oldSessionManager ();
KateSessionManager *sessionManager();
/**
@@ -224,7 +222,6 @@ class KDE_EXPORT KateApp : public TDEApplication
/**
* session manager
*/
- OldKateSessionManager *m_oldSessionManager;
KateSessionManager *m_sessionManager;
diff --git a/kate/app/kateappIface.cpp b/kate/app/kateappIface.cpp
index 57f0b63d1..3ce9229b4 100644
--- a/kate/app/kateappIface.cpp
+++ b/kate/app/kateappIface.cpp
@@ -89,16 +89,17 @@ bool KateAppDCOPIface::openInput (TQString text)
return m_app->openInput (text);
}
-bool KateAppDCOPIface::activateSession (TQString session)
+bool KateAppDCOPIface::activateSession(TQString session)
{
- m_app->oldSessionManager()->activateSession (m_app->oldSessionManager()->giveSession (session));
+// MIKE: to fix
+// m_app->sessionManager()->activateSession (m_app->oldSessionManager()->giveSession (session));
return true;
}
-const TQString & KateAppDCOPIface::session() const
+const TQString& KateAppDCOPIface::session() const
{
- return m_app->oldSessionManager()->activeSession()->sessionName();
+ return m_app->sessionManager()->getActiveSessionName();
}
// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
index 1546c575b..527dbdc9c 100644
--- a/kate/app/katemainwindow.cpp
+++ b/kate/app/katemainwindow.cpp
@@ -305,8 +305,9 @@ void KateMainWindow::setupActions()
slotWindowActivated ();
+// MIKE to fix and enable again
// session actions
- new TDEAction(i18n("Menu entry Session->New", "&New"), "list-add", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new");
+/* new TDEAction(i18n("Menu entry Session->New", "&New"), "list-add", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new");
new TDEAction(i18n("&Open..."), "document-open", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionOpen()), actionCollection(), "sessions_open");
new TDEAction(i18n("&Save"), "document-save", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionSave()), actionCollection(), "sessions_save");
new TDEAction(i18n("Save &As..."), "document-save-as", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionSaveAs()), actionCollection(), "sessions_save_as");
@@ -314,6 +315,7 @@ void KateMainWindow::setupActions()
// quick open menu ;)
new OldKateSessionsAction (i18n("&Quick Open"), actionCollection(), "sessions_list");
+*/
}
KateTabWidget *KateMainWindow::tabWidget ()
@@ -370,7 +372,7 @@ bool KateMainWindow::queryClose()
// and save docs if we really close down !
if ( queryClose_internal () )
{
- KateApp::self()->oldSessionManager()->saveActiveSession(true, true);
+ KateApp::self()->sessionManager()->saveActiveSession();
// detach the dcopClient
KateApp::self()->dcopClient()->detach();
@@ -824,7 +826,7 @@ void KateMainWindow::updateCaption (Kate::Document *doc)
c = m_viewManager->activeView()->getDoc()->url().prettyURL();
}
- TQString sessName = KateApp::self()->oldSessionManager()->activeSession()->sessionName();
+ TQString sessName = KateApp::self()->sessionManager()->getActiveSessionName();
if ( !sessName.isEmpty() )
sessName = TQString("%1: ").arg( sessName );
@@ -855,10 +857,8 @@ void KateMainWindow::readProperties(TDEConfig *config)
void KateMainWindow::saveGlobalProperties( TDEConfig* sessionConfig )
{
- KateDocManager::self()->saveDocumentList (sessionConfig);
-
- sessionConfig->setGroup("General");
- sessionConfig->writeEntry ("Last Session", KateApp::self()->oldSessionManager()->activeSession()->sessionFileRelative());
+// MIKE do we still need this code here?
+// KateDocManager::self()->saveDocumentList (sessionConfig);
}
// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp
index c66c171cf..adee747d0 100644
--- a/kate/app/katesession.cpp
+++ b/kate/app/katesession.cpp
@@ -50,6 +50,7 @@
// FIXME general: need to keep doc list and current session's m_documents in synchro
// all the time (doc open, doc closed, doc renamed)
+// FIXME add code to handle the various options in Configure Kate -> Application -> Sessions
// String constants
namespace
@@ -63,6 +64,7 @@ namespace
const char *KS_OPENDOC = "Open Documents";
const char *KS_READONLY = "ReadOnly";
const char *KS_UNNAMED = "Unnamed";
+ const char *KS_OPEN_MAINWINDOWS = "Open MainWindows";
// Kate session manager
const char *KSM_DIR = "kate/sessions";
@@ -162,14 +164,14 @@ void KateSession::setReadOnly(bool readOnly)
}
//------------------------------------
-void KateSession::save(bool saveDocList)
+void KateSession::save(bool saveGUIInfo)
{
if (m_readOnly)
return;
+ // create a new session filename if needed
if (!m_isFullName)
{
- // create a new session filename
int s = time(0);
TQCString tname;
TQString tmpName;
@@ -187,6 +189,7 @@ void KateSession::save(bool saveDocList)
}
}
+ // save session config info
if (!m_config)
{
m_config = new KSimpleConfig(m_filename);
@@ -210,9 +213,20 @@ void KateSession::save(bool saveDocList)
{
m_config->writeEntry(TQString("URL_%1").arg(i), m_documents[i]);
}
- if (saveDocList)
+
+ // save GUI elements info
+ if (saveGUIInfo)
{
KateDocManager::self()->saveDocumentList(m_config);
+ // save main windows info
+ int mwCount = KateApp::self()->mainWindows();
+ m_config->setGroup(KS_OPEN_MAINWINDOWS);
+ m_config->writeEntry(KS_COUNT, mwCount);
+ for (int i=0; i<mwCount; ++i)
+ {
+ m_config->setGroup(TQString("MainWindow%1").arg(i));
+ KateApp::self()->mainWindow(i)->saveProperties(m_config);
+ }
}
m_config->sync();
@@ -221,12 +235,35 @@ void KateSession::save(bool saveDocList)
//------------------------------------
void KateSession::activate()
{
- KateDocManager::self()->closeAllDocuments();
+ if (KateDocManager::self()->documents() > 0)
+ {
+ KateDocManager::self()->closeAllDocuments();
+ }
Kate::Document::setOpenErrorDialogsActivated(false);
if (m_config)
{
KateApp::self()->documentManager()->restoreDocumentList(m_config);
}
+
+ // load main windows info, if it exists
+ if (m_config && m_config->hasGroup(KS_OPEN_MAINWINDOWS))
+ {
+ m_config->setGroup(KS_OPEN_MAINWINDOWS);
+ int mwCount = m_config->readUnsignedNumEntry(KS_COUNT, 1);
+ for (int i=0; i<mwCount; ++i)
+ {
+ if (i >= KateApp::self()->mainWindows())
+ {
+ KateApp::self()->newMainWindow(m_config, TQString("MainWindow%1").arg(i));
+ }
+ else
+ {
+ m_config->setGroup(TQString("MainWindow%1").arg(i));
+ KateApp::self()->mainWindow(i)->readProperties(m_config);
+ }
+ }
+ }
+
Kate::Document::setOpenErrorDialogsActivated(true);
}
@@ -246,7 +283,7 @@ KateSessionManager* KateSessionManager::self()
//------------------------------------
KateSessionManager::KateSessionManager() :
m_baseDir(locateLocal("data", KSM_DIR)+"/"), m_configFile(m_baseDir + KSM_FILE),
- m_sessionsCount(0), m_activeSessionId(-1), m_sessions(), m_config(NULL)
+ m_sessionsCount(0), m_activeSessionId(0), m_firstActivation(true), m_sessions(), m_config(NULL)
{
m_sessions.setAutoDelete(true);
@@ -256,7 +293,8 @@ KateSessionManager::KateSessionManager() :
m_config = new KSimpleConfig(m_configFile);
m_config->setGroup(KSM_SESSIONS_LIST);
m_sessionsCount = m_config->readNumEntry(KSM_SESSIONS_COUNT, 0);
- m_activeSessionId = m_config->readNumEntry(KSM_ACTIVE_SESSION_ID, -1);
+ //FIXME : if m_sessionsCount == 0, create session list from existing session files
+ m_activeSessionId = m_config->readNumEntry(KSM_ACTIVE_SESSION_ID, 0);
for (int i=0; i<m_sessionsCount; ++i)
{
TQString urlStr = m_config->readEntry(TQString("URL_%1").arg(i));
@@ -278,11 +316,18 @@ KateSessionManager::KateSessionManager() :
}
}
m_sessionsCount = static_cast<int>(m_sessions.count());
+ if (m_sessionsCount == 0) // In the worst case, there is no valid session at all
+ {
+ m_sessions.append(new KateSession(TQString::null, m_baseDir, false));
+ ++m_sessionsCount;
+ }
if (m_activeSessionId < 0 || m_activeSessionId >= m_sessionsCount)
{
m_activeSessionId = 0; // Invalid active session was detected. Use first in the list
}
- m_sessions[m_activeSessionId]->activate();
+ //NOTE do not activate any session in the KateSessionManager costructor
+ // since Kate's main window may not be ready yet. The initial session
+ // will be activated by KateApp::startupKate() or void KateApp::restoreKate()
}
//------------------------------------
@@ -316,34 +361,71 @@ void KateSessionManager::saveConfig()
for (int i=0; i<m_sessionsCount; ++i)
{
// Save the session first, to make sure a new session has an associated file
- m_sessions[i]->save(i == m_activeSessionId);
+ m_sessions[i]->save(false);
m_config->writeEntry(TQString("URL_%1").arg(i), m_sessions[i]->getSessionFilename());
}
m_config->sync();
}
//------------------------------------
+int KateSessionManager::getSessionIdFromName(const TQString &name)
+{
+ if (name.isEmpty())
+ return KateSessionManager::INVALID_SESSION;
+
+ for (int i=0; i<m_sessionsCount; ++i)
+ {
+ if (m_sessions[i]->getSessionName() == name)
+ return i;
+ }
+
+ return KateSessionManager::INVALID_SESSION;
+}
+
+//------------------------------------
bool KateSessionManager::activateSession(int sessionId, bool saveCurr)
{
- if (sessionId == m_activeSessionId)
+ if (sessionId < 0)
+ {
+ return false;
+ }
+
+ if (!m_firstActivation && sessionId == m_activeSessionId)
{
return true;
}
- // First check if all documents can be closed safely
- if (KateApp::self()->activeMainWindow())
+ if (!m_firstActivation)
{
- if (!KateApp::self()->activeMainWindow()->queryClose_internal())
- return false;
+ // Do this only if a session has already been activated earlier,
+ if (KateApp::self()->activeMainWindow())
+ {
+ // First check if all documents can be closed safely
+ if (!KateApp::self()->activeMainWindow()->queryClose_internal())
+ return false;
+ }
+ if (saveCurr)
+ {
+ m_sessions[m_activeSessionId]->save(true);
+ }
}
- m_sessions[m_activeSessionId]->save(true);
m_sessions[sessionId]->activate();
m_activeSessionId = sessionId;
+ m_firstActivation = false;
return true;
}
-
+//------------------------------------
+bool KateSessionManager::restoreLastSession()
+{
+ if (!m_firstActivation)
+ {
+ return false;
+ }
+ // NOTE: m_activeSessionId contains the id of the last active session
+ return activateSession(m_activeSessionId, false);
+}
@@ -525,7 +607,7 @@ OldKateSessionManager::~OldKateSessionManager()
OldKateSessionManager *OldKateSessionManager::self()
{
- return KateApp::self()->oldSessionManager ();
+ return (OldKateSessionManager*)KateApp::self()->sessionManager();
}
void OldKateSessionManager::dirty (const TQString &)
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
diff --git a/kate/app/katesessionpanel.cpp b/kate/app/katesessionpanel.cpp
index 93bca5d06..7bb61a308 100644
--- a/kate/app/katesessionpanel.cpp
+++ b/kate/app/katesessionpanel.cpp
@@ -62,7 +62,8 @@ KateSessionPanel::KateSessionPanel(KateMainWindow *mainWindow, KateViewManager *
m_listview->setColumnAlignment(2, TQt::AlignCenter);
m_listview->setMinimumWidth(m_listview->sizeHint().width());
m_listview->setSorting(-1);
- //m_listview->setRootIsDecorated(true); // to enable after inserting doc list
+ //m_listview->setRootIsDecorated(true); // MIKE to enable after inserting doc list
+ connect(m_listview, TQT_SIGNAL(executed(TQListViewItem*)), TQT_SLOT(itemExecuted(TQListViewItem*)));
TQPtrList<KateSession>& sessions = m_sessionManager->getSessionsList();
for (int idx = sessions.count()-1; idx >= 0; --idx)
@@ -210,3 +211,16 @@ void KateSessionPanel::sessionMoveDown()
{
//TODO
}
+
+void KateSessionPanel::itemExecuted(TQListViewItem *item)
+{
+ if (!item)
+ return;
+
+ // First level items are sessions. Executing one, will switch to that session
+ if (!item->parent())
+ {
+ sessionActivate();
+ return;
+ }
+}
diff --git a/kate/app/katesessionpanel.h b/kate/app/katesessionpanel.h
index 71120b7e1..d3baddcb4 100644
--- a/kate/app/katesessionpanel.h
+++ b/kate/app/katesessionpanel.h
@@ -74,6 +74,7 @@ class KateSessionPanel : public TQVBox
void sessionToggleReadOnly();
void sessionMoveUp();
void sessionMoveDown();
+ void itemExecuted(TQListViewItem *item);
private:
void setup_toolbar();
diff --git a/kate/app/kateviewspace.cpp b/kate/app/kateviewspace.cpp
index f53ec7468..7e9622b67 100644
--- a/kate/app/kateviewspace.cpp
+++ b/kate/app/kateviewspace.cpp
@@ -110,15 +110,16 @@ void KateViewSpace::addView(Kate::View* v, bool show)
if ( !m_group.isEmpty() )
{
TQString fn = v->getDoc()->url().prettyURL();
- if ( ! fn.isEmpty() )
+ if (!fn.isEmpty())
{
TQString vgroup = TQString("%1 %2").arg(m_group).arg(fn);
- OldKateSession::Ptr as = OldKateSessionManager::self()->activeSession ();
- if ( as->configRead() && as->configRead()->hasGroup( vgroup ) )
+ KateSession *as = KateSessionManager::self()->getActiveSession();
+ TDEConfig *asCfg = as->getConfig();
+ if (asCfg && asCfg->hasGroup(vgroup))
{
- as->configRead()->setGroup( vgroup );
- v->readSessionConfig ( as->configRead() );
+ asCfg->setGroup(vgroup);
+ v->readSessionConfig(asCfg);
}
}
}