diff options
author | Michele Calgaro <[email protected]> | 2016-03-10 15:46:16 +0100 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2016-03-10 15:46:16 +0100 |
commit | 758b7bda94c4af81bbfc4e884c22db974a7c12c0 (patch) | |
tree | 715bec5e5f8f8ffa1efb462aa28ed95158af3cb0 /kate/app/katesession.cpp | |
parent | e528df3eb1ee48c55535fc09e7d016a83b38b02e (diff) | |
download | tdebase-758b7bda94c4af81bbfc4e884c22db974a7c12c0.tar.gz tdebase-758b7bda94c4af81bbfc4e884c22db974a7c12c0.zip |
Kate session panel: added save and read-only functionality. Fixed up toolbar buttons status update.
Added ability to activate a session using the ENTER key. Some other code refactoring.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kate/app/katesession.cpp')
-rw-r--r-- | kate/app/katesession.cpp | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp index 17218d2b1..1ab43c420 100644 --- a/kate/app/katesession.cpp +++ b/kate/app/katesession.cpp @@ -91,7 +91,6 @@ KateSession::KateSession(const TQString &sessionName, const TQString &filename, } // Read only m_readOnly = m_config->readBoolEntry(KS_READONLY, false); - m_config->setReadOnly(m_readOnly); // Document list if (m_config->hasGroup(KS_DOCLIST)) { @@ -149,19 +148,9 @@ void KateSession::setSessionName(const TQString &sessionName) } //------------------------------------ -void KateSession::setReadOnly(bool readOnly) +void KateSession::save(bool saveGUIInfo, bool setReadOnly) { - m_readOnly = readOnly; - if (m_config) - { - m_config->setReadOnly(m_readOnly); - } -} - -//------------------------------------ -void KateSession::save(bool saveGUIInfo) -{ - if (m_readOnly) + if (m_readOnly && !setReadOnly) { return; } @@ -349,7 +338,6 @@ KateSessionManager::~KateSessionManager() // FIXME An option need to be added to Configure Kate -> Sessions to allow Kate to ask about // saving unnamed sessions before closing the current session. Default value is off as per // point above. - void KateSessionManager::saveConfig() { if (!m_config) @@ -373,6 +361,17 @@ void KateSessionManager::saveConfig() } //------------------------------------ +KateSession* KateSessionManager::getSessionFromId(int sessionId) +{ + if (sessionId < 0 || sessionId >= (int)m_sessions.count()) + { + return NULL; + } + + return m_sessions[sessionId]; +} + +//------------------------------------ int KateSessionManager::getSessionIdFromName(const TQString &name) { if (name.isEmpty()) @@ -448,6 +447,17 @@ bool KateSessionManager::restoreLastSession() } //------------------------------------------- +void KateSessionManager::saveSession(int sessionId) +{ + if (sessionId < 0 || sessionId >= (int)m_sessions.count()) + { + return; + } + m_sessions[sessionId]->save(sessionId == m_activeSessionId); + emit sessionSaved(sessionId); +} + +//------------------------------------------- bool KateSessionManager::deleteSession(int sessionId) { if (sessionId < 0 || sessionId >= (int)m_sessions.count()) @@ -551,6 +561,19 @@ void KateSessionManager::renameSession(int sessionId, const TQString &newSession m_sessions[sessionId]->setSessionName(newSessionName); } + +//------------------------------------------- +void KateSessionManager::setSessionReadOnlyStatus(int sessionId, bool readOnly) +{ + if (sessionId < 0 || sessionId >= (int)m_sessions.count()) + { + return; + } + + m_sessions[sessionId]->setReadOnly(readOnly); + // Session is saved one last time when making it read only + m_sessions[sessionId]->save(sessionId == m_activeSessionId, true); +} //END KateSessionManager |