summaryrefslogtreecommitdiffstats
path: root/kate
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2016-03-25 23:42:53 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-03-25 23:42:53 +0900
commit749b05ce92c640ae42548a8929c2eb163d56d6f7 (patch)
tree1dcbb033b581be673c4e53e45b0ec80e32cc1ea3 /kate
parent758b7bda94c4af81bbfc4e884c22db974a7c12c0 (diff)
downloadtdebase-749b05ce92c640ae42548a8929c2eb163d56d6f7.tar.gz
tdebase-749b05ce92c640ae42548a8929c2eb163d56d6f7.zip
Kate session panel: added save_as and reload functionality.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kate')
-rw-r--r--kate/app/katesession.cpp164
-rw-r--r--kate/app/katesession.h75
-rw-r--r--kate/app/katesessionpanel.cpp125
-rw-r--r--kate/app/katesessionpanel.h7
4 files changed, 293 insertions, 78 deletions
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp
index 1ab43c420..9fc865d52 100644
--- a/kate/app/katesession.cpp
+++ b/kate/app/katesession.cpp
@@ -49,7 +49,8 @@
#include <time.h>
// FIXME general: need to keep doc list and current session's m_documents in synchro
-// all the time (doc open, doc closed, doc renamed)
+// all the time (doc open, doc closed, doc renamed).
+// To be done when doc list software is developed
// FIXME add code to handle the various options in Configure Kate -> Application -> Sessions
// String constants
@@ -63,8 +64,8 @@ namespace
const char *KS_NAME = "Name";
const char *KS_OPENDOC = "Open Documents";
const char *KS_READONLY = "ReadOnly";
- const char *KS_UNNAMED = "Unnamed";
const char *KS_OPEN_MAINWINDOWS = "Open MainWindows";
+ const char *KS_UNNAMED = "Unnamed";
// Kate session manager
const char *KSM_DIR = "kate/sessions";
@@ -75,21 +76,53 @@ namespace
}
//BEGIN Kate session
-KateSession::KateSession(const TQString &sessionName, const TQString &filename, bool isFullName) :
- m_sessionName(sessionName), m_filename(filename), m_isFullName(isFullName),
+KateSession::KateSession(const KateSessionManager &manager, const TQString &sessionName,
+ const TQString &fileName) :
+ m_manager(manager), m_sessionName(sessionName), m_filename(fileName),
m_readOnly(false), m_documents(), m_config(NULL)
{
- if (m_isFullName && TDEGlobal::dirs()->exists(m_filename))
+ load(false);
+}
+
+//------------------------------------
+KateSession::KateSession(const KateSession &session, const TQString &newSessionName) :
+ m_manager(session.m_manager), m_sessionName(newSessionName), m_filename(),
+ m_readOnly(false), m_documents(session.m_documents), m_config(NULL)
+{
+ createFilename();
+ m_config = dynamic_cast<KSimpleConfig*>(session.m_config->copyTo(m_filename));
+}
+
+//------------------------------------
+KateSession::~KateSession()
+{
+ if (m_config)
+ {
+ delete m_config;
+ }
+}
+
+//------------------------------------
+void KateSession::setSessionName(const TQString &sessionName)
+{
+ m_sessionName = sessionName.isEmpty() ? i18n(KS_UNNAMED) : sessionName;
+}
+
+//------------------------------------
+void KateSession::load(bool includeGUIInfo)
+{
+ if (m_config)
+ {
+ delete m_config;
+ }
+
+ if (TDEGlobal::dirs()->exists(m_filename))
{
// Create config object if the session file already exists
m_config = new KSimpleConfig(m_filename, m_readOnly);
m_config->setGroup(KS_GENERAL);
- // Session name
- if (m_sessionName.isEmpty())
- {
- m_sessionName = m_config->readEntry(KS_NAME, i18n(KS_UNNAMED));
- }
- // Read only
+ // Session general properties
+ m_sessionName = m_config->readEntry(KS_NAME, i18n(KS_UNNAMED));
m_readOnly = m_config->readBoolEntry(KS_READONLY, false);
// Document list
if (m_config->hasGroup(KS_DOCLIST))
@@ -125,29 +158,23 @@ KateSession::KateSession(const TQString &sessionName, const TQString &filename,
}
}
}
+ else
+ {
+ m_filename = TQString::null;
+ }
if (m_sessionName.isEmpty())
{
m_sessionName = i18n(KS_UNNAMED);
}
- // FIXME: needs to make sure doc list and m_documents are in synchro here
-}
-
-//------------------------------------
-KateSession::~KateSession()
-{
- if (m_config)
+
+ // Update e all current documents if necessary
+ if (includeGUIInfo)
{
- delete m_config;
+ activate();
}
}
//------------------------------------
-void KateSession::setSessionName(const TQString &sessionName)
-{
- m_sessionName = sessionName.isEmpty() ? i18n(KS_UNNAMED) : sessionName;
-}
-
-//------------------------------------
void KateSession::save(bool saveGUIInfo, bool setReadOnly)
{
if (m_readOnly && !setReadOnly)
@@ -156,23 +183,9 @@ void KateSession::save(bool saveGUIInfo, bool setReadOnly)
}
// create a new session filename if needed
- if (!m_isFullName)
+ if (m_filename.isEmpty())
{
- int s = time(0);
- TQCString tname;
- TQString tmpName;
- while (true)
- {
- tname.setNum(s++);
- KMD5 md5(tname);
- tmpName = m_filename + TQString("%1.katesession").arg(md5.hexDigest().data());
- if (!TDEGlobal::dirs()->exists(tmpName))
- {
- m_filename = tmpName;
- m_isFullName = true;
- break;
- }
- }
+ createFilename();
}
// save session config info
@@ -252,6 +265,31 @@ void KateSession::activate()
Kate::Document::setOpenErrorDialogsActivated(true);
}
+
+//------------------------------------
+void KateSession::createFilename()
+{
+ // create a new session filename if needed
+ if (!m_filename.isEmpty())
+ {
+ return;
+ }
+
+ int s = time(0);
+ TQCString tname;
+ TQString tmpName;
+ while (true)
+ {
+ tname.setNum(s++);
+ KMD5 md5(tname);
+ tmpName = m_manager.getBaseDir() + TQString("%1.katesession").arg(md5.hexDigest().data());
+ if (!TDEGlobal::dirs()->exists(tmpName))
+ {
+ m_filename = tmpName;
+ break;
+ }
+ }
+}
//END Kate session
@@ -290,7 +328,7 @@ KateSessionManager::KateSessionManager() :
if (!urlStr.isEmpty() && TDEGlobal::dirs()->exists(urlStr))
{
// Filter out empty URLs or non existing sessions
- m_sessions.append(new KateSession(TQString::null, urlStr, true));
+ m_sessions.append(new KateSession(*this, TQString::null, urlStr));
}
}
}
@@ -301,13 +339,13 @@ KateSessionManager::KateSessionManager() :
TQDir sessionDir(m_baseDir, "*.katesession");
for (unsigned int i = 0; i < sessionDir.count(); ++i)
{
- m_sessions.append(new KateSession(TQString::null, m_baseDir+sessionDir[i], true));
+ m_sessions.append(new KateSession(*this, TQString::null, m_baseDir+sessionDir[i]));
}
}
sessionsCount = (int)m_sessions.count();
if (sessionsCount == 0) // In the worst case, there is no valid session at all
{
- m_sessions.append(new KateSession(TQString::null, m_baseDir, false));
+ m_sessions.append(new KateSession(*this, TQString::null, TQString::null));
}
if (m_activeSessionId < 0 || m_activeSessionId >= (int)m_sessions.count())
{
@@ -361,6 +399,17 @@ void KateSessionManager::saveConfig()
}
//------------------------------------
+const TQString& KateSessionManager::getSessionName(int sessionId)
+{
+ if (sessionId < 0 || sessionId >= (int)m_sessions.count())
+ {
+ return TQString::null;
+ }
+
+ return m_sessions[sessionId]->getSessionName();
+}
+
+//------------------------------------
KateSession* KateSessionManager::getSessionFromId(int sessionId)
{
if (sessionId < 0 || sessionId >= (int)m_sessions.count())
@@ -425,9 +474,33 @@ bool KateSessionManager::activateSession(int sessionId, bool saveCurr)
//------------------------------------
int KateSessionManager::newSession(const TQString &sessionName, bool activate)
{
- m_sessions.append(new KateSession(sessionName, m_baseDir, false));
+ m_sessions.append(new KateSession(*this, sessionName, TQString::null));
+ int newSessionId = m_sessions.count() - 1;
+ emit sessionCreated(newSessionId);
+ if (activate)
+ {
+ activateSession(newSessionId, m_activeSessionId != INVALID_SESSION);
+ }
+ return newSessionId;
+}
+
+//------------------------------------
+int KateSessionManager::cloneSession(int sessionId, const TQString &sessionName, bool activate)
+{
+ if (sessionId < 0 || sessionId >= (int)m_sessions.count())
+ {
+ return INVALID_SESSION;
+ }
+
+ m_sessions.append(new KateSession(*m_sessions[sessionId], sessionName));
int newSessionId = m_sessions.count() - 1;
emit sessionCreated(newSessionId);
+
+ // If cloning the active session, the new session will contain the current status
+ // and the original session will be restored to the last saved state (save as... functionality)
+ m_sessions[newSessionId]->save(true);
+ reloadActiveSession();
+
if (activate)
{
activateSession(newSessionId, m_activeSessionId != INVALID_SESSION);
@@ -560,6 +633,7 @@ void KateSessionManager::renameSession(int sessionId, const TQString &newSession
}
m_sessions[sessionId]->setSessionName(newSessionName);
+ emit sessionRenamed(sessionId);
}
//-------------------------------------------
diff --git a/kate/app/katesession.h b/kate/app/katesession.h
index 3351db150..01357798b 100644
--- a/kate/app/katesession.h
+++ b/kate/app/katesession.h
@@ -39,6 +39,7 @@ class KDirWatch;
class KPushButton;
class TDEListView;
class TQCheckBox;
+class KateSessionManager;
//BEGIN KateSession
@@ -51,13 +52,19 @@ class KateSession
/**
* create a new session and read the config from fileName if it exists
+ * @param manager the session manager handling this session
* @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);
+ KateSession(const KateSessionManager &manager, const TQString &sessionName, const TQString &fileName);
+
+ /**
+ * duplicate an existing session into a new one with the given new name.
+ * If the existing session is read-only, the new one will *not* be read-only by default
+ * @param session the existing session
+ * @param newSessionName the name of the new session
+ */
+ KateSession(const KateSession &session, const TQString &newSessionName);
/**
* Destructor
@@ -89,7 +96,7 @@ class KateSession
/**
* @return the session filename if available, otherwise the null string
*/
- const TQString& getSessionFilename() const { return m_isFullName ? m_filename : TQString::null; }
+ const TQString& getSessionFilename() const { return m_filename; }
/**
* @return the number of documents in the session
@@ -97,6 +104,12 @@ class KateSession
int getDocCount() const { return m_documents.count(); }
/**
+ * Load session info from the saved file
+ * @param includeGUIInfo if true, also load the information about the GUI elements
+ */
+ void load(bool includeGUIInfo);
+
+ /**
* Save session info
* @param saveGUIInfo if true, save also the information about the GUI elements
* @param setReadOnly necessary to save a session that has to be turned to read only
@@ -117,15 +130,18 @@ class KateSession
* @return the session config object
*/
TDEConfig* getConfig() const { return m_config; }
+
+ /**
+ * create a new filename for a session object
+ */
+ void createFilename();
-
+ const KateSessionManager &m_manager; // The session manager that handles this session
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;
- TQStringList m_documents; // document URLs
- KSimpleConfig *m_config; // session config
+ TQStringList m_documents; // document URLs
+ KSimpleConfig *m_config; // session config
};
//END KateSession
@@ -146,6 +162,9 @@ class KateSession
*
* @note The Kate session manager takes ownership of each session object it handles.
*/
+//FIXME update the sessions.list file when switching to another session or to a new session
+//FIXME create a new unnamed session and switch to another session. The first session is saved without
+//asking the user for a new session name. This is wrong.
class KateSessionManager : public TQObject
{
Q_OBJECT
@@ -174,6 +193,11 @@ class KateSessionManager : public TQObject
void saveConfig();
/**
+ * @return the session files folder name
+ */
+ const TQString& getBaseDir() const { return m_baseDir; }
+
+ /**
* @return the active session id
*/
int getActiveSessionId() const { return m_activeSessionId; }
@@ -184,6 +208,12 @@ class KateSessionManager : public TQObject
const TQString& getActiveSessionName() /*FIXME const*/ { return m_sessions[m_activeSessionId]->getSessionName(); }
/**
+ * @param sessionId the id of the session of interest
+ * @return the name of the specified session
+ */
+ const TQString& getSessionName(int sessionId) /*FIXME const*/;
+
+ /**
* @return a reference to the active session
*/
KateSession* getActiveSession() { return m_sessions[m_activeSessionId]; }
@@ -227,6 +257,21 @@ class KateSessionManager : public TQObject
*/
int newSession(const TQString &sessionName = TQString::null, bool activate = true);
+ /**
+ * Create a new session and activate it if required
+ * @param sessionId the id of the session to clone
+ * @param sessionName the new session name
+ * @param activate if true, activate the new session after creation
+ * @return the id of the newly created session
+ * @emit sessionCreated
+ */
+ int cloneSession(int sessionId, const TQString &sessionName = TQString::null, bool activate = true);
+
+ /**
+ * Restore the current active session to the last saved state
+ */
+ void reloadActiveSession() { m_sessions[m_activeSessionId]->load(true); }
+
/**
* Restore the last saved session. Can only be used before
* any other session has been activated, i.e. on Kate's startup
@@ -271,6 +316,7 @@ class KateSessionManager : public TQObject
* Rename the specified session
* @param sessionId the id of the session to rename
* @param newSessionName the new session name
+ * @emit sessionRenamed
*/
void renameSession(int sessionId, const TQString &newSessionName);
@@ -281,7 +327,6 @@ class KateSessionManager : public TQObject
*/
void setSessionReadOnlyStatus(int sessionId, bool readOnly);
-
signals:
/**
* Emitted once a session has been activated
@@ -315,6 +360,12 @@ class KateSessionManager : public TQObject
*/
void sessionsSwapped(int sessionIdMin, int sessionIdMax);
+ /**
+ * Emitted once a session has been renamed
+ * @param sessionId the id of the new session
+ */
+ void sessionRenamed(int sessionId);
+
protected:
KateSessionManager();
@@ -385,7 +436,7 @@ class KateSessionChooser : public KDialogBase
protected:
TDEListView *m_listview;
};
-//BEGIN KateSessionChooser
+//END KateSessionChooser
diff --git a/kate/app/katesessionpanel.cpp b/kate/app/katesessionpanel.cpp
index b3f7ef55b..827dc403d 100644
--- a/kate/app/katesessionpanel.cpp
+++ b/kate/app/katesessionpanel.cpp
@@ -38,9 +38,10 @@ namespace
//BEGIN KateSessionNameChooser
//-------------------------------------------
-KateSessionNameChooser::KateSessionNameChooser(TQWidget *parent)
+KateSessionNameChooser::KateSessionNameChooser(TQWidget *parent, bool showSwitchTo)
: KDialogBase(parent, "", true, i18n("Session Name Chooser"), KDialogBase::User1 | KDialogBase::User2,
- KDialogBase::User2, true, KStdGuiItem::cancel(), KGuiItem(i18n("Continue"), "document-new"))
+ KDialogBase::User2, true, KStdGuiItem::cancel(), KGuiItem(i18n("Continue"), "document-new")),
+ m_showSwitchTo(showSwitchTo)
{
TQHBox *page = new TQHBox(this);
//page->setMinimumSize(300, 100);
@@ -53,13 +54,16 @@ KateSessionNameChooser::KateSessionNameChooser(TQWidget *parent)
label->setText("Please type the new session name:");
m_sessionNameLE = new TQLineEdit(vb);
- m_sessionNameLE->setText(KS_UNNAMED);
+ m_sessionNameLE->setText(i18n(KS_UNNAMED));
m_sessionNameLE->setFocus();
+
+ if (m_showSwitchTo)
+ {
+ m_activateCB = new TQCheckBox(i18n("Switch to the new session"), vb, NULL);
+ m_activateCB->setChecked(true);
+ }
- m_activateCB = new TQCheckBox(i18n("Switch to the new session"), vb, NULL);
- m_activateCB->setChecked(true);
-
- connect (m_sessionNameLE, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotTextChanged()));
+ connect(m_sessionNameLE, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotTextChanged()));
slotTextChanged(); // update button status
}
@@ -72,7 +76,11 @@ TQString KateSessionNameChooser::getSessionName()
//-------------------------------------------
bool KateSessionNameChooser::getActivateFlag()
{
- return m_activateCB->isChecked();
+ if (m_showSwitchTo)
+ {
+ return m_activateCB->isChecked();
+ }
+ return false;
}
//-------------------------------------------
@@ -135,7 +143,7 @@ KateSessionPanel::KateSessionPanel(KateMainWindow *mainWindow, KateViewManager *
m_listview->setMinimumWidth(m_listview->sizeHint().width());
m_listview->setSorting(-1);
m_listview->setResizeMode(TQListView::LastColumn);
- //m_listview->setRootIsDecorated(true); // FIXME to enable after inserting doc list
+ //m_listview->setRootIsDecorated(true); // FIXME disabled until doc list software is developed
connect(m_listview, TQT_SIGNAL(selectionChanged()),
this, TQT_SLOT(slotSelectionChanged()));
@@ -151,8 +159,10 @@ KateSessionPanel::KateSessionPanel(KateMainWindow *mainWindow, KateViewManager *
this, TQT_SLOT(slotSessionDeleted(int)));
connect(m_sessionManager, TQT_SIGNAL(sessionsSwapped(int, int)),
this, TQT_SLOT(slotSessionsSwapped(int, int)));
+ connect(m_sessionManager, TQT_SIGNAL(sessionRenamed(int)),
+ this, TQT_SLOT(slotSessionRenamed(int)));
connect(m_listview, TQT_SIGNAL(itemRenamed(TQListViewItem*)),
- this, TQT_SLOT(slotSessionRenamed(TQListViewItem*)));
+ this, TQT_SLOT(slotLVSessionRenamed(TQListViewItem*)));
TQPtrList<KateSession>& sessions = m_sessionManager->getSessionsList();
for (int idx = sessions.count()-1; idx >= 0; --idx)
@@ -190,12 +200,13 @@ void KateSessionPanel::setup_toolbar()
a = new TDEAction(i18n("Save"), SmallIcon("document-save"), 0,
TQT_TQOBJECT(this), TQT_SLOT(slotSaveSession()), m_actionCollection, "session_save");
- a->setWhatsThis(i18n("Save the current session."));
+ a->setWhatsThis(i18n("Save the selected session."));
a->plug(m_toolbar);
a = new TDEAction(i18n("Save as..."), SmallIcon("document-save-as"), 0,
TQT_TQOBJECT(this), TQT_SLOT(slotSaveSessionAs()), m_actionCollection, "session_save_as");
- a->setWhatsThis(i18n("Save the current session with a different name."));
+ a->setWhatsThis(i18n("Save an unsaved session with a new name or clone an already saved session "
+ "into a new session."));
a->plug(m_toolbar);
a = new TDEAction(i18n("Rename"), SmallIcon("edit_user"), 0,
@@ -208,6 +219,11 @@ void KateSessionPanel::setup_toolbar()
a->setWhatsThis(i18n("Delete the selected session."));
a->plug(m_toolbar);
+ a = new TDEAction(i18n("Reload"), SmallIcon("reload"), 0,
+ TQT_TQOBJECT(this), TQT_SLOT(slotReloadSession()), m_actionCollection, "session_reload");
+ a->setWhatsThis(i18n("Reload the last saved state of the selected session."));
+ a->plug(m_toolbar);
+
m_toolbar->insertLineSeparator();
a = new TDEAction(i18n("Activate"), SmallIcon("forward"), 0,
@@ -232,14 +248,12 @@ void KateSessionPanel::setup_toolbar()
TQT_TQOBJECT(this), TQT_SLOT(slotSessionMoveDown()), m_actionCollection, "session_move_down");
a->setWhatsThis(i18n("Move down the selected session."));
a->plug(m_toolbar);
-
- //FIXME add button to restore a modified session to its original if not yet saved to disk
}
//-------------------------------------------
void KateSessionPanel::slotNewSession()
{
- KateSessionNameChooser *nameChooser = new KateSessionNameChooser(this);
+ KateSessionNameChooser *nameChooser = new KateSessionNameChooser(this, true);
int result = nameChooser->exec();
if (result == TQDialog::Accepted)
{
@@ -264,7 +278,7 @@ void KateSessionPanel::slotSaveSession()
return;
}
- if (ks->getSessionFilename().isEmpty())
+ if (ks->getSessionFilename().isEmpty() && ks->getSessionName() == i18n(KS_UNNAMED))
{
// Session has never been saved before. Ask user for a session name first
slotSaveSessionAs();
@@ -279,7 +293,46 @@ void KateSessionPanel::slotSaveSession()
//-------------------------------------------
void KateSessionPanel::slotSaveSessionAs()
{
-//TODO
+ KateSessionPanelItem *sessionItem = dynamic_cast<KateSessionPanelItem*>(m_listview->selectedItem());
+ if (!sessionItem)
+ {
+ return;
+ }
+ int sessId = sessionItem->getSessionId();
+ KateSession *ks = m_sessionManager->getSessionFromId(sessId);
+ if (!ks)
+ {
+ return;
+ }
+
+ // If the session was never saved before, the session will be saved with a new name.
+ // If the session was already saved once, it will be cloned into a new session.
+ bool cloneSession = true;
+ //FIXME replace ks->getSessionFilename().isEmpty() with a function that tests for m_fileExists
+ if (ks->getSessionFilename().isEmpty() && ks->getSessionName() == i18n(KS_UNNAMED))
+ {
+ // Session has never been saved before.
+ cloneSession = false;
+ }
+ // Get new session name
+ KateSessionNameChooser *nameChooser = new KateSessionNameChooser(this, cloneSession);
+ int result = nameChooser->exec();
+ if (result == TQDialog::Accepted)
+ {
+ if (!cloneSession)
+ {
+ // Save unsaved session
+ m_sessionManager->renameSession(sessId, nameChooser->getSessionName());
+ m_sessionManager->saveSession(sessId);
+ }
+ else
+ {
+ // Clone session
+ m_sessionManager->cloneSession(sessId, nameChooser->getSessionName(), nameChooser->getActivateFlag());
+ }
+ }
+
+ delete nameChooser;
slotSelectionChanged(); // Update the toolbar button status
}
@@ -314,6 +367,24 @@ void KateSessionPanel::slotDeleteSession()
}
//-------------------------------------------
+void KateSessionPanel::slotReloadSession()
+{
+ KateSessionPanelItem *sessionItem = dynamic_cast<KateSessionPanelItem*>(m_listview->selectedItem());
+ if (!sessionItem)
+ {
+ return;
+ }
+ int sessId = sessionItem->getSessionId();
+ if (sessId != m_sessionManager->getActiveSessionId())
+ {
+ return;
+ }
+
+ // Restore active session to the last saved state
+ m_sessionManager->reloadActiveSession();
+}
+
+//-------------------------------------------
void KateSessionPanel::slotActivateSession()
{
KateSessionPanelItem *newSessionItem = dynamic_cast<KateSessionPanelItem*>(m_listview->selectedItem());
@@ -403,6 +474,7 @@ void KateSessionPanel::slotSelectionChanged()
m_actionCollection->action("session_save_as")->setEnabled(false);
m_actionCollection->action("session_rename")->setEnabled(false);
m_actionCollection->action("session_delete")->setEnabled(false);
+ m_actionCollection->action("session_reload")->setEnabled(false);
m_actionCollection->action("session_activate")->setEnabled(false);
m_actionCollection->action("session_move_up")->setEnabled(false);
m_actionCollection->action("session_move_down")->setEnabled(false);
@@ -416,11 +488,13 @@ void KateSessionPanel::slotSelectionChanged()
// Read only sessions can not be saved or renamed
m_actionCollection->action("session_save")->setEnabled(false);
m_actionCollection->action("session_rename")->setEnabled(false);
+ m_actionCollection->action("session_delete")->setEnabled(false);
}
else
{
m_actionCollection->action("session_save")->setEnabled(true);
m_actionCollection->action("session_rename")->setEnabled(true);
+ m_actionCollection->action("session_delete")->setEnabled(true);
}
if (ks->getSessionFilename().isEmpty())
{
@@ -434,7 +508,8 @@ void KateSessionPanel::slotSelectionChanged()
readOnlyAction->setChecked(ks->isReadOnly());
}
m_actionCollection->action("session_save_as")->setEnabled(true);
- m_actionCollection->action("session_delete")->setEnabled(true);
+ m_actionCollection->action("session_reload")->setEnabled(
+ sessionItem->getSessionId() == m_sessionManager->getActiveSessionId());
m_actionCollection->action("session_activate")->setEnabled(true);
m_actionCollection->action("session_move_up")->setEnabled(true);
m_actionCollection->action("session_move_down")->setEnabled(true);
@@ -459,6 +534,7 @@ void KateSessionPanel::slotSessionActivated(int newSessionId, int oldSessionId)
}
item->setPixmap(m_columnPixmap, SmallIcon("ok"));
m_listview->setSelected(item, true);
+ slotSelectionChanged(); // Update the toolbar button status
}
//-------------------------------------------
@@ -557,7 +633,18 @@ void KateSessionPanel::slotSessionsSwapped(int sessionIdMin, int sessionIdMax)
}
//-------------------------------------------
-void KateSessionPanel::slotSessionRenamed(TQListViewItem *item)
+void KateSessionPanel::slotSessionRenamed(int sessionId)
+{
+ TQListViewItem *item = m_listview->firstChild();
+ for (int idx = 0; idx < sessionId; ++idx)
+ {
+ item = item->nextSibling();
+ }
+ item->setText(m_columnName, m_sessionManager->getSessionName(sessionId));
+}
+
+//-------------------------------------------
+void KateSessionPanel::slotLVSessionRenamed(TQListViewItem *item)
{
KateSessionPanelItem *sessionItem = dynamic_cast<KateSessionPanelItem*>(item);
if (!sessionItem)
diff --git a/kate/app/katesessionpanel.h b/kate/app/katesessionpanel.h
index 265d1d8e1..2dd7347a7 100644
--- a/kate/app/katesessionpanel.h
+++ b/kate/app/katesessionpanel.h
@@ -47,7 +47,7 @@ class KateSessionNameChooser : public KDialogBase
public:
- KateSessionNameChooser(TQWidget *parent);
+ KateSessionNameChooser(TQWidget *parent, bool showSwitchTo);
~KateSessionNameChooser() {}
TQString getSessionName(); // return the session name typed by the user
@@ -62,6 +62,7 @@ class KateSessionNameChooser : public KDialogBase
protected:
TQLineEdit *m_sessionNameLE;
TQCheckBox *m_activateCB;
+ bool m_showSwitchTo; // if true, display the m_activateCB checkbox
};
//BEGIN KateSessionNameChooser
@@ -121,6 +122,7 @@ class KateSessionPanel : public TQVBox
void slotSaveSessionAs();
void slotRenameSession();
void slotDeleteSession();
+ void slotReloadSession();
void slotActivateSession();
void slotSessionToggleReadOnly();
void slotSessionMoveUp();
@@ -132,7 +134,8 @@ class KateSessionPanel : public TQVBox
void slotSessionCreated(int sessionId);
void slotSessionDeleted(int sessionId);
void slotSessionsSwapped(int sessionIdMin, int sessionIdMax);
- void slotSessionRenamed(TQListViewItem *item);
+ void slotSessionRenamed(int sessionId);
+ void slotLVSessionRenamed(TQListViewItem *item);
private:
void setup_toolbar();