summaryrefslogtreecommitdiffstats
path: root/kate/app/katesession.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2016-03-10 18:35:21 +0900
committerMichele Calgaro <[email protected]>2016-03-10 18:35:21 +0900
commite528df3eb1ee48c55535fc09e7d016a83b38b02e (patch)
treee5f5bc61231714080fc49abc0cb5409ebba41f9b /kate/app/katesession.cpp
parent93c96f301cc324ea0a38df701f70dc7bfce4b314 (diff)
downloadtdebase-e528df3eb1ee48c55535fc09e7d016a83b38b02e.tar.gz
tdebase-e528df3eb1ee48c55535fc09e7d016a83b38b02e.zip
Kate session panel: added move up/down and rename functionality.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kate/app/katesession.cpp')
-rw-r--r--kate/app/katesession.cpp79
1 files changed, 74 insertions, 5 deletions
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp
index 1380b19d0..17218d2b1 100644
--- a/kate/app/katesession.cpp
+++ b/kate/app/katesession.cpp
@@ -145,11 +145,7 @@ KateSession::~KateSession()
//------------------------------------
void KateSession::setSessionName(const TQString &sessionName)
{
- m_sessionName = sessionName;
- if (m_sessionName.isEmpty())
- {
- m_sessionName = i18n(KS_UNNAMED);
- }
+ m_sessionName = sessionName.isEmpty() ? i18n(KS_UNNAMED) : sessionName;
}
//------------------------------------
@@ -455,7 +451,9 @@ bool KateSessionManager::restoreLastSession()
bool KateSessionManager::deleteSession(int sessionId)
{
if (sessionId < 0 || sessionId >= (int)m_sessions.count())
+ {
return false;
+ }
// delete session file if it exists
const TQString &filename = m_sessions[sessionId]->getSessionFilename();
@@ -482,6 +480,77 @@ bool KateSessionManager::deleteSession(int sessionId)
return true;
}
+
+//-------------------------------------------
+void KateSessionManager::swapSessionsPosition(int sessionId1, int sessionId2)
+{
+ if (sessionId1 < 0 || sessionId1 >= (int)m_sessions.count() ||
+ sessionId2 < 0 || sessionId2 >= (int)m_sessions.count() ||
+ sessionId1 == sessionId2)
+ {
+ return;
+ }
+
+ int idxMin, idxMax;
+ if (sessionId1 < sessionId2)
+ {
+ idxMin = sessionId1;
+ idxMax = sessionId2;
+ }
+ else
+ {
+ idxMin = sessionId2;
+ idxMax = sessionId1;
+ }
+
+ KateSession *sessMax = m_sessions.take(idxMax);
+ KateSession *sessMin = m_sessions.take(idxMin);
+ m_sessions.insert(idxMin, sessMax);
+ m_sessions.insert(idxMax, sessMin);
+ if (m_activeSessionId == sessionId1)
+ {
+ m_activeSessionId = sessionId2;
+ }
+ else if (m_activeSessionId == sessionId2)
+ {
+ m_activeSessionId = sessionId1;
+ }
+
+ emit sessionsSwapped(idxMin, idxMax);
+}
+
+//-------------------------------------------
+void KateSessionManager::moveSessionForward(int sessionId)
+{
+ if (sessionId < 0 || sessionId >= ((int)m_sessions.count() - 1))
+ {
+ return;
+ }
+
+ swapSessionsPosition(sessionId, sessionId + 1);
+}
+
+//-------------------------------------------
+void KateSessionManager::moveSessionBackward(int sessionId)
+{
+ if (sessionId < 1 || sessionId >= (int)m_sessions.count())
+ {
+ return;
+ }
+
+ swapSessionsPosition(sessionId, sessionId - 1);
+}
+
+//-------------------------------------------
+void KateSessionManager::renameSession(int sessionId, const TQString &newSessionName)
+{
+ if (sessionId < 0 || sessionId >= (int)m_sessions.count())
+ {
+ return;
+ }
+
+ m_sessions[sessionId]->setSessionName(newSessionName);
+}
//END KateSessionManager