summaryrefslogtreecommitdiffstats
path: root/kate
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2016-10-02 21:20:29 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-10-02 21:20:29 +0900
commit67642abd943f30babeea0c44397cc40e7c2c1b9e (patch)
tree0511683531ec72366fd8e22d5b0c8ab61c3a0ba9 /kate
parent8644afed0d8e383cf3576c598b2ca76833a74e33 (diff)
downloadtdebase-67642abd943f30babeea0c44397cc40e7c2c1b9e.tar.gz
tdebase-67642abd943f30babeea0c44397cc40e7c2c1b9e.zip
Kate session panel: removed no longer used OldKateSession and OldKateSessionManager code.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kate')
-rw-r--r--kate/app/katesession.cpp698
-rw-r--r--kate/app/katesession.h343
2 files changed, 1 insertions, 1040 deletions
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp
index 91f655613..1f7817f01 100644
--- a/kate/app/katesession.cpp
+++ b/kate/app/katesession.cpp
@@ -898,704 +898,6 @@ void KateSessionChooser::slotSelectionChanged()
}
//END KateSessionChooser
-
-
-
-
-//------------------------------------
-//------------------------------------
-//------------------------------------
-//------------------------------------
-OldKateSession::OldKateSession (OldKateSessionManager *manager, const TQString &fileName, const TQString &name)
- : m_sessionFileRel (fileName)
- , m_sessionName (name)
- , m_documents (0)
- , m_manager (manager)
- , m_readConfig (0)
- , m_writeConfig (0)
-{
- init ();
-}
-
-void OldKateSession::init ()
-{
- // given file exists, use it to load some stuff ;)
- if (!m_sessionFileRel.isEmpty() && TDEGlobal::dirs()->exists(sessionFile ()))
- {
- KSimpleConfig config (sessionFile (), true);
-
- if (m_sessionName.isEmpty())
- {
- // get the name out of the file
- if (m_sessionFileRel == "default.katesession")
- m_sessionName = i18n("Default Session");
- else
- {
- config.setGroup ("General");
- m_sessionName = config.readEntry ("Name", i18n ("Unnamed Session"));
- }
- }
-
- // get the document count
- config.setGroup ("Open Documents");
- m_documents = config.readUnsignedNumEntry("Count", 0);
-
- return;
- }
-
- // filename not empty, create the file
- // anders: When will this ever happen???
- if (!m_sessionFileRel.isEmpty())
- {
- kdDebug(13001)<<"Kate::Session: initializing unexisting file!"<<endl;
- // uhh, no name given
- if (m_sessionName.isEmpty())
- {
- if (m_sessionFileRel == "default.katesession")
- m_sessionName = i18n("Default Session");
- else
- m_sessionName = i18n("Session (%1)").arg(TQTime::currentTime().toString(Qt::LocalDate));
- }
-
- // create the file, write name to it!
- KSimpleConfig config (sessionFile ());
- config.setGroup ("General");
- config.writeEntry ("Name", m_sessionName);
-
- config.sync ();
- }
-}
-
-OldKateSession::~OldKateSession ()
-{
- delete m_readConfig;
- delete m_writeConfig;
-}
-
-TQString OldKateSession::sessionFile () const
-{
- return m_manager->sessionsDir() + "/" + m_sessionFileRel;
-}
-
-bool OldKateSession::create (const TQString &name, bool force)
-{
- if (!force && (name.isEmpty() || !m_sessionFileRel.isEmpty()))
- return false;
-
- delete m_writeConfig;
- m_writeConfig = 0;
-
- delete m_readConfig;
- m_readConfig = 0;
-
- m_sessionName = name;
-
- // get a usable filename
- int s = time(0);
- TQCString tname;
- while (true)
- {
- tname.setNum (s++);
- KMD5 md5 (tname);
- m_sessionFileRel = TQString ("%1.katesession").arg (md5.hexDigest().data());
-
- if (!TDEGlobal::dirs()->exists(sessionFile ()))
- break;
- }
-
- // create the file, write name to it!
- KSimpleConfig config (sessionFile ());
- config.setGroup ("General");
- config.writeEntry ("Name", m_sessionName);
- config.sync ();
-
- // reinit ourselfs ;)
- init ();
-
- return true;
-}
-
-bool OldKateSession::rename (const TQString &name)
-{
- if (name.isEmpty () || m_sessionFileRel.isEmpty() || m_sessionFileRel == "default.katesession")
- return false;
-
- m_sessionName = name;
-
- TDEConfig config (sessionFile (), false, false);
- config.setGroup ("General");
- config.writeEntry ("Name", m_sessionName);
- config.sync ();
-
- return true;
-}
-
-TDEConfig *OldKateSession::configRead ()
-{
- if (m_sessionFileRel.isEmpty())
- return 0;
-
- if (m_readConfig)
- return m_readConfig;
-
- return m_readConfig = new KSimpleConfig (sessionFile (), true);
-}
-
-TDEConfig *OldKateSession::configWrite ()
-{
- if (m_sessionFileRel.isEmpty())
- return 0;
-
- if (m_writeConfig)
- return m_writeConfig;
-
- m_writeConfig = new KSimpleConfig (sessionFile ());
- m_writeConfig->setGroup ("General");
- m_writeConfig->writeEntry ("Name", m_sessionName);
-
- return m_writeConfig;
-}
-
-OldKateSessionManager::OldKateSessionManager (TQObject *parent)
- : TQObject (parent)
- , m_sessionsDir (locateLocal( "data", "kate/sessions"))
- , m_activeSession (new OldKateSession (this, "", ""))
-{
- kdDebug() << "LOCAL SESSION DIR: " << m_sessionsDir << endl;
-
- // create dir if needed
- TDEGlobal::dirs()->makeDir (m_sessionsDir);
-}
-
-OldKateSessionManager::~OldKateSessionManager()
-{
-}
-
-OldKateSessionManager *OldKateSessionManager::self()
-{
- return (OldKateSessionManager*)KateApp::self()->sessionManager();
-}
-
-void OldKateSessionManager::dirty (const TQString &)
-{
- updateSessionList ();
-}
-
-void OldKateSessionManager::updateSessionList ()
-{
- m_sessionList.clear ();
-
- // Let's get a list of all session we have atm
- TQDir dir (m_sessionsDir, "*.katesession");
-
- bool foundDefault = false;
- for (unsigned int i=0; i < dir.count(); ++i)
- {
- OldKateSession *session = new OldKateSession (this, dir[i], "");
- m_sessionList.append (session);
-
- kdDebug () << "FOUND SESSION: " << session->sessionName() << " FILE: " << session->sessionFile() << endl;
-
- if (!foundDefault && (dir[i] == "default.katesession"))
- foundDefault = true;
- }
-
- // add default session, if not there
- if (!foundDefault)
- m_sessionList.append (new OldKateSession (this, "default.katesession", i18n("Default Session")));
-
- qHeapSort(m_sessionList);
-}
-
-void OldKateSessionManager::activateSession (OldKateSession::Ptr session, bool closeLast, bool saveLast, bool loadNew)
-{
- // don't reload.
- // ### comparing the pointers directly is b0rk3d :(
- if ( ! session->sessionName().isEmpty() && session->sessionName() == m_activeSession->sessionName() )
- return;
- // try to close last session
- if (closeLast)
- {
- if (KateApp::self()->activeMainWindow())
- {
- if (!KateApp::self()->activeMainWindow()->queryClose_internal())
- return;
- }
- }
-
- // save last session or not?
- if (saveLast)
- saveActiveSession (true);
-
- // really close last
- if (closeLast)
- {
- KateDocManager::self()->closeAllDocuments ();
- }
-
- // set the new session
- m_activeSession = session;
-
- if (loadNew)
- {
- // open the new session
- Kate::Document::setOpenErrorDialogsActivated (false);
-
- TDEConfig *sc = activeSession()->configRead();
-
- if (sc)
- KateApp::self()->documentManager()->restoreDocumentList (sc);
-
- // if we have no session config object, try to load the default
- // (anonymous/unnamed sessions)
- if ( ! sc )
- sc = new KSimpleConfig( sessionsDir() + "/default.katesession" );
-
- // window config
- if (sc)
- {
- TDEConfig *c = KateApp::self()->config();
- c->setGroup("General");
-
- if (c->readBoolEntry("Restore Window Configuration", true))
- {
- // a new, named session, read settings of the default session.
- if ( ! sc->hasGroup("Open MainWindows") )
- sc = new KSimpleConfig( sessionsDir() + "/default.katesession" );
-
- sc->setGroup ("Open MainWindows");
- unsigned int wCount = sc->readUnsignedNumEntry("Count", 1);
-
- for (unsigned int i=0; i < wCount; ++i)
- {
- if (i >= KateApp::self()->mainWindows())
- {
- KateApp::self()->newMainWindow(sc, TQString ("MainWindow%1").arg(i));
- }
- else
- {
- sc->setGroup(TQString ("MainWindow%1").arg(i));
- KateApp::self()->mainWindow(i)->readProperties (sc);
- }
- }
-
- if (wCount > 0)
- {
- while (wCount < KateApp::self()->mainWindows())
- {
- KateMainWindow *w = KateApp::self()->mainWindow(KateApp::self()->mainWindows()-1);
- KateApp::self()->removeMainWindow (w);
- delete w;
- }
- }
- }
- }
-
- Kate::Document::setOpenErrorDialogsActivated (true);
- }
-}
-
-OldKateSession::Ptr OldKateSessionManager::createSession (const TQString &name)
-{
- OldKateSession::Ptr s = new OldKateSession (this, "", "");
- s->create (name);
-
- return s;
-}
-
-OldKateSession::Ptr OldKateSessionManager::giveSession (const TQString &name)
-{
- if (name.isEmpty())
- return new OldKateSession (this, "", "");
-
- updateSessionList();
-
- for (unsigned int i=0; i < m_sessionList.count(); ++i)
- {
- if (m_sessionList[i]->sessionName() == name)
- return m_sessionList[i];
- }
-
- return createSession (name);
-}
-
-bool OldKateSessionManager::saveActiveSession (bool tryAsk, bool rememberAsLast)
-{
- if (tryAsk)
- {
- // app config
- TDEConfig *c = KateApp::self()->config();
- c->setGroup("General");
-
- TQString sesExit (c->readEntry ("Session Exit", "save"));
-
- if (sesExit == "discard")
- return true;
-
- if (sesExit == "ask")
- {
- KDialogBase* dlg = new KDialogBase(i18n ("Save Session?")
- , KDialogBase::Yes | KDialogBase::No
- , KDialogBase::Yes, KDialogBase::No
- );
-
- bool dontAgain = false;
- int res = KMessageBox::createKMessageBox(dlg, TQMessageBox::Question,
- i18n("Save current session?"), TQStringList(),
- i18n("Do not ask again"), &dontAgain, KMessageBox::Notify);
-
- // remember to not ask again with right setting
- if (dontAgain)
- {
- c->setGroup("General");
-
- if (res == KDialogBase::No)
- c->writeEntry ("Session Exit", "discard");
- else
- c->writeEntry ("Session Exit", "save");
- }
-
- if (res == KDialogBase::No)
- return true;
- }
- }
-
- TDEConfig *sc = activeSession()->configWrite();
-
- if (!sc)
- return false;
-
- KateDocManager::self()->saveDocumentList (sc);
-
- sc->setGroup ("Open MainWindows");
- sc->writeEntry ("Count", KateApp::self()->mainWindows ());
-
- // save config for all windows around ;)
- for (unsigned int i=0; i < KateApp::self()->mainWindows (); ++i )
- {
- sc->setGroup(TQString ("MainWindow%1").arg(i));
- KateApp::self()->mainWindow(i)->saveProperties (sc);
- }
-
- sc->sync();
-
- if (rememberAsLast)
- {
- TDEConfig *c = KateApp::self()->config();
- c->setGroup("General");
- c->sync ();
- }
-
- return true;
-}
-
-void OldKateSessionManager::sessionNew ()
-{
- activateSession (new OldKateSession (this, "", ""));
-}
-
-void OldKateSessionManager::sessionOpen ()
-{
- OldKateSessionOpenDialog *chooser = new OldKateSessionOpenDialog (0);
-
- int res = chooser->exec ();
-
- if (res == OldKateSessionOpenDialog::resultCancel)
- {
- delete chooser;
- return;
- }
-
- OldKateSession::Ptr s = chooser->selectedSession ();
-
- if (s)
- activateSession (s);
-
- delete chooser;
-}
-
-void OldKateSessionManager::sessionSave ()
-{
- // if the active session is valid, just save it :)
- if (saveActiveSession ())
- return;
-
- bool ok = false;
- TQString name = KInputDialog::getText (i18n("Specify Name for Current Session"), i18n("Session name:"), "", &ok);
-
- if (!ok)
- return;
-
- if (name.isEmpty())
- {
- KMessageBox::error (0, i18n("To save a new session, you must specify a name."), i18n ("Missing Session Name"));
- return;
- }
-
- activeSession()->create (name);
- saveActiveSession ();
-}
-
-void OldKateSessionManager::sessionSaveAs ()
-{
- bool ok = false;
- TQString name = KInputDialog::getText (i18n("Specify New Name for Current Session"), i18n("Session name:"), "", &ok);
-
- if (!ok)
- return;
-
- if (name.isEmpty())
- {
- KMessageBox::error (0, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
- return;
- }
-
- activeSession()->create (name, true);
- saveActiveSession ();
-}
-
-
-void OldKateSessionManager::sessionManage ()
-{
- OldKateSessionManageDialog *dlg = new OldKateSessionManageDialog (0);
-
- dlg->exec ();
-
- delete dlg;
-}
-
-//BEGIN CHOOSER DIALOG
-
-class OldKateSessionChooserItem : public TQListViewItem
-{
- public:
- OldKateSessionChooserItem (TDEListView *lv, OldKateSession::Ptr s)
- : TQListViewItem (lv, s->sessionName())
- , session (s)
- {
- TQString docs;
- docs.setNum (s->documents());
- setText (1, docs);
- }
-
- OldKateSession::Ptr session;
-};
-
-
-//END CHOOSER DIALOG
-
-//BEGIN OPEN DIALOG
-
-OldKateSessionOpenDialog::OldKateSessionOpenDialog (TQWidget *parent)
- : KDialogBase ( parent
- , ""
- , true
- , i18n ("Open Session")
- , KDialogBase::User1 | KDialogBase::User2
- , KDialogBase::User2
- , false
- , KStdGuiItem::cancel ()
- , KGuiItem( i18n("&Open"), "document-open")
- )
-{
- TQHBox *page = new TQHBox (this);
- page->setMinimumSize (400, 200);
- setMainWidget(page);
-
- TQHBox *hb = new TQHBox (page);
-
- TQVBox *vb = new TQVBox (hb);
-
- m_sessions = new TDEListView (vb);
- m_sessions->addColumn (i18n("Session Name"));
- m_sessions->addColumn (i18n("Open Documents"));
- m_sessions->setResizeMode (TQListView::AllColumns);
- m_sessions->setSelectionMode (TQListView::Single);
- m_sessions->setAllColumnsShowFocus (true);
-
- connect (m_sessions, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)), this, TQT_SLOT(slotUser2()));
-
- OldKateSessionList &slist (OldKateSessionManager::self()->sessionList());
- for (unsigned int i=0; i < slist.count(); ++i)
- {
- new OldKateSessionChooserItem (m_sessions, slist[i]);
- }
-
- setResult (resultCancel);
-}
-
-OldKateSessionOpenDialog::~OldKateSessionOpenDialog ()
-{
-}
-
-OldKateSession::Ptr OldKateSessionOpenDialog::selectedSession ()
-{
- OldKateSessionChooserItem *item = (OldKateSessionChooserItem *) m_sessions->selectedItem ();
-
- if (!item)
- return 0;
-
- return item->session;
-}
-
-void OldKateSessionOpenDialog::slotUser1 ()
-{
- done (resultCancel);
-}
-
-void OldKateSessionOpenDialog::slotUser2 ()
-{
- done (resultOk);
-}
-
-//END OPEN DIALOG
-
-//BEGIN MANAGE DIALOG
-
-OldKateSessionManageDialog::OldKateSessionManageDialog (TQWidget *parent)
- : KDialogBase ( parent
- , ""
- , true
- , i18n ("Manage Sessions")
- , KDialogBase::User1
- , KDialogBase::User1
- , false
- , KStdGuiItem::close ()
- )
-{
- TQHBox *page = new TQHBox (this);
- page->setMinimumSize (400, 200);
- setMainWidget(page);
-
- TQHBox *hb = new TQHBox (page);
- hb->setSpacing (KDialog::spacingHint());
-
- m_sessions = new TDEListView (hb);
- m_sessions->addColumn (i18n("Session Name"));
- m_sessions->addColumn (i18n("Open Documents"));
- m_sessions->setResizeMode (TQListView::AllColumns);
- m_sessions->setSelectionMode (TQListView::Single);
- m_sessions->setAllColumnsShowFocus (true);
-
- connect (m_sessions, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(selectionChanged()));
-
- updateSessionList ();
-
- TQWidget *vb = new TQWidget (hb);
- TQVBoxLayout *vbl = new TQVBoxLayout (vb);
- vbl->setSpacing (KDialog::spacingHint());
-
- m_rename = new KPushButton (i18n("&Rename..."), vb);
- connect (m_rename, TQT_SIGNAL(clicked()), this, TQT_SLOT(rename()));
- vbl->addWidget (m_rename);
-
- m_del = new KPushButton (KStdGuiItem::del (), vb);
- connect (m_del, TQT_SIGNAL(clicked()), this, TQT_SLOT(del()));
- vbl->addWidget (m_del);
-
- vbl->addStretch ();
-
- // trigger action update
- selectionChanged ();
-}
-
-OldKateSessionManageDialog::~OldKateSessionManageDialog ()
-{
-}
-
-void OldKateSessionManageDialog::slotUser1 ()
-{
- done (0);
-}
-
-
-void OldKateSessionManageDialog::selectionChanged ()
-{
- OldKateSessionChooserItem *item = (OldKateSessionChooserItem *) m_sessions->selectedItem ();
-
- m_rename->setEnabled (item && item->session->sessionFileRelative() != "default.katesession");
- m_del->setEnabled (item && item->session->sessionFileRelative() != "default.katesession");
-}
-
-void OldKateSessionManageDialog::rename ()
-{
- OldKateSessionChooserItem *item = (OldKateSessionChooserItem *) m_sessions->selectedItem ();
-
- if (!item || item->session->sessionFileRelative() == "default.katesession")
- return;
-
- bool ok = false;
- TQString name = KInputDialog::getText (i18n("Specify New Name for Session"), i18n("Session name:"), item->session->sessionName(), &ok);
-
- if (!ok)
- return;
-
- if (name.isEmpty())
- {
- KMessageBox::error (0, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
- return;
- }
-
- item->session->rename (name);
- updateSessionList ();
-}
-
-void OldKateSessionManageDialog::del ()
-{
- OldKateSessionChooserItem *item = (OldKateSessionChooserItem *) m_sessions->selectedItem ();
-
- if (!item || item->session->sessionFileRelative() == "default.katesession")
- return;
-
- TQFile::remove (item->session->sessionFile());
- OldKateSessionManager::self()->updateSessionList ();
- updateSessionList ();
-}
-
-void OldKateSessionManageDialog::updateSessionList ()
-{
- m_sessions->clear ();
-
- OldKateSessionList &slist (OldKateSessionManager::self()->sessionList());
- for (unsigned int i=0; i < slist.count(); ++i)
- {
- new OldKateSessionChooserItem (m_sessions, slist[i]);
- }
-}
-
-//END MANAGE DIALOG
-
-
-OldKateSessionsAction::OldKateSessionsAction(const TQString& text, TQObject* parent, const char* name )
- : TDEActionMenu(text, parent, name)
-{
- connect(popupMenu(),TQT_SIGNAL(aboutToShow()),this,TQT_SLOT(slotAboutToShow()));
-}
-
-void OldKateSessionsAction::slotAboutToShow()
-{
- popupMenu()->clear ();
-
- OldKateSessionList &slist (OldKateSessionManager::self()->sessionList());
- for (unsigned int i=0; i < slist.count(); ++i)
- {
- popupMenu()->insertItem (
- slist[i]->sessionName(),
- this, TQT_SLOT (openSession (int)), 0,
- i );
- }
-}
-
-void OldKateSessionsAction::openSession (int i)
-{
- OldKateSessionList &slist (OldKateSessionManager::self()->sessionList());
-
- if ((uint)i >= slist.count())
- return;
-
- OldKateSessionManager::self()->activateSession(slist[(uint)i]);
-}
-
#include "katesession.moc"
// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/app/katesession.h b/kate/app/katesession.h
index d073d8411..50db624b6 100644
--- a/kate/app/katesession.h
+++ b/kate/app/katesession.h
@@ -174,6 +174,7 @@ class KateSession
// Session is saved without asking for a name
//FIXME improve getStartupOption/getSwitchOption/setSwitchOption using new signal
// KateApp::optionsChanged()
+//FIXME add kdDebug statement to ease debugging
class KateSessionManager : public TQObject
{
Q_OBJECT
@@ -527,346 +528,4 @@ class KateSessionChooser : public KDialogBase
};
//END KateSessionChooser
-
-
-
-//------------------------------------
-//------------------------------------
-//------------------------------------
-class OldKateSessionManager;
-class OldKateSession : public TDEShared
-{
- 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 );
-
- /**
- * init the session object, after construction or create
- */
- void init ();
-
- /**
- * destruct me
- */
- ~OldKateSession ();
-
- /**
- * 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; }
-
- /**
- * 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(); }
-
- /**
- * 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 );
-
- /**
- * 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 ();
-
- /**
- * 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;
-
- /**
- * session name, extracted from the file, to display to the user
- */
- TQString m_sessionName;
-
- /**
- * number of document of this session
- */
- unsigned int m_documents;
-
- /**
- * OldKateSessionMananger
- */
- OldKateSessionManager *m_manager;
-
- /**
- * simpleconfig to read from
- */
- KSimpleConfig *m_readConfig;
-
- /**
- * simpleconfig to write to
- */
- KSimpleConfig *m_writeConfig;
-};
-
-typedef TQValueList<OldKateSession::Ptr> OldKateSessionList;
-
-class OldKateSessionManager : public TQObject
-{
- Q_OBJECT
-
- public:
- OldKateSessionManager ( TQObject *parent );
- ~OldKateSessionManager();
-
- /**
- * 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; }
-
- /**
- * 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 );
-
- /**
- * 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 );
-
- /**
- * 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; }
-
- /**
- * 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 ();
-
- /**
- * try to open a existing session
- */
- void sessionOpen ();
-
- /**
- * try to save current session
- */
- void sessionSave ();
-
- /**
- * try to save as current session
- */
- void sessionSaveAs ();
-
- /**
- * show dialog to manage our sessions
- */
- void sessionManage ();
-
- private slots:
- void dirty ( const TQString &path );
-
- public:
- /**
- * trigger update of session list
- */
- void updateSessionList ();
-
- private:
- /**
- * absolute path to dir in home dir where to store the sessions
- */
- TQString m_sessionsDir;
-
- /**
- * list of current available sessions
- */
- OldKateSessionList m_sessionList;
-
- /**
- * current active session
- */
- OldKateSession::Ptr m_activeSession;
-};
-
-
-class OldKateSessionOpenDialog : public KDialogBase
-{
- Q_OBJECT
-
- public:
- OldKateSessionOpenDialog ( TQWidget *parent );
- ~OldKateSessionOpenDialog ();
-
- OldKateSession::Ptr selectedSession ();
-
- enum
- {
- resultOk,
- resultCancel
- };
-
- protected slots:
- /**
- * cancel pressed
- */
- void slotUser1 ();
-
- /**
- * ok pressed
- */
- void slotUser2 ();
-
- private:
- TDEListView *m_sessions;
-};
-
-class OldKateSessionManageDialog : public KDialogBase
-{
- Q_OBJECT
-
- public:
- OldKateSessionManageDialog ( TQWidget *parent );
- ~OldKateSessionManageDialog ();
-
- protected slots:
- /**
- * close pressed
- */
- void slotUser1 ();
-
- /**
- * selection has changed
- */
- void selectionChanged ();
-
- /**
- * try to rename session
- */
- void rename ();
-
- /**
- * try to delete session
- */
- void del ();
-
- private:
- /**
- * update our list
- */
- void updateSessionList ();
-
- private:
- TDEListView *m_sessions;
- KPushButton *m_rename;
- KPushButton *m_del;
-};
-
-class OldKateSessionsAction : public TDEActionMenu
-{
- Q_OBJECT
-
- public:
- OldKateSessionsAction ( const TQString& text, TQObject* parent = 0, const char* name = 0 );
- ~OldKateSessionsAction () {;};
-
- public slots:
- void slotAboutToShow();
-
- void openSession ( int i );
-};
-
#endif