summaryrefslogtreecommitdiffstats
path: root/kate/app/katesessionpanel.h
blob: 023de53e2744556ccc9c80f493b9448f85d7fe52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
   This file is part of the TDE project

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef __KATE_SESSIONPANEL_H__
#define __KATE_SESSIONPANEL_H__

/*
  The kate session panel displays the available sessions (and their documents)
  in a treeview list and allows for quick switching among them.
  A toolbar on the top also provides quick access to actions needed
  to manage sessions.
*/

#include <tqvbox.h>
#include <tdetoolbar.h>
#include <tdelistview.h>
#include <tqframe.h>
#include <tqlineedit.h>
#include <tqcheckbox.h>
#include <kdialogbase.h>

class KateMainWindow;
class KateViewManager;
class KateSessionManager;
class TDEActionCollection;


//BEGIN KateSessionNameChooser
//FIXME create one single KateSessionNameChooser and reuse it all the time
//FIXME improve string to distinguish between new session and saving an unnamed session
class KateSessionNameChooser : public KDialogBase
{
	Q_OBJECT

	public:

		KateSessionNameChooser(TQWidget *parent, bool showSwitchTo);
	 ~KateSessionNameChooser() {}

		TQString getSessionName(); // return the session name typed by the user
		bool getActivateFlag();     // return whether to switch to the new session or not

	protected slots:

		void slotUser1();          // create new session
		void slotUser2();          // cancel
		void slotTextChanged();    // session name has changed

	protected:
    TQLineEdit *m_sessionNameLE;
    TQCheckBox *m_activateCB;
    bool m_showSwitchTo;       // if true, display the m_activateCB checkbox
};
//BEGIN KateSessionNameChooser


//BEGIN KateSessionPanelToolBarParent
class KateSessionPanelToolBarParent: public TQFrame
{
  Q_OBJECT

  public:
    KateSessionPanelToolBarParent(TQWidget *parent) : TQFrame(parent), m_tbar(0) {}
   ~KateSessionPanelToolBarParent() {}
    void setToolBar(TDEToolBar *tbar);

  protected:
    virtual void resizeEvent (TQResizeEvent*);

  private:
    TDEToolBar *m_tbar;
};
//END KateSessionPanelToolBarParent


//BEGIN KateSessionPanelItem
class KateSessionPanelItem : public TDEListViewItem
{
  public:
    KateSessionPanelItem(TQListView *listview, const TQString &sessionName, int sessionId)
      : TDEListViewItem(listview, sessionName), m_sessionId(sessionId) {}
    KateSessionPanelItem(TQListView *listview, TQListViewItem *after, const TQString &sessionName, int sessionId)
      : TDEListViewItem(listview, after, sessionName), m_sessionId(sessionId) {}

		int  getSessionId() { return m_sessionId; }
		void setSessionId(int sessionId) { m_sessionId = sessionId; }

	protected:
    int m_sessionId;
};
//END KateSessionPanelItem


//BEGIN KateSessionPanel
class KateSessionPanel : public TQVBox
{
  Q_OBJECT

 	friend class KateMainWindow;
 	
  public:

    KateSessionPanel(KateMainWindow *mainWindow=0, KateViewManager *viewManager=0,
                     TQWidget *parent=0, const char *name=0);
    ~KateSessionPanel() {}

  signals:
		/**
		 * Emitted when the session selection in the panel has changed
		 */
		void selectionChanged();
  
  
  public slots:
    void slotNewSession();
    void slotSaveSession();
    void slotSaveSessionAs();
    void slotRenameSession();
    void slotDeleteSession();
    void slotReloadSession();
    void slotActivateSession();
    void slotSessionToggleReadOnly();
    void slotSessionMoveUp();
    void slotSessionMoveDown();
    void slotItemExecuted(TQListViewItem *item);

    void slotSelectionChanged(); 		/** @emit selectionChanged */
    void slotSessionActivated(int newSessionId, int oldSessionId);
    void slotSessionCreated(int sessionId);
    void slotSessionDeleted(int sessionId);
    void slotSessionsSwapped(int sessionIdMin, int sessionIdMax);
    void slotSessionRenamed(int sessionId);
    void slotLVSessionRenamed(TQListViewItem *item);

  protected:
    void setup_toolbar();
    
		/* Checks the session switch option. If the choice is 'ask user',
		   opens a dialog and asks the user what to do.
		   Returns one of the following:
		   - KMessageBox::Cancel : the user wants to abort the current operation
		   - KMessageBox::No     : the user wants to discard the session and continue
		   - KMessageBox::Yes    : the user wants to save the session and continue
		   If the current session is volatile and the session needs to be saved,
		   it will also ask the user to provide a session name.
		*/
    int handleSessionSwitch();

    KateSessionManager *m_sessionManager;
    TDEActionCollection *m_actionCollection;
    TDEToolBar *m_toolbar;
    TDEListView *m_listview;
    int m_columnName;
    int m_columnPixmap;
};
//END KateSessionPanel


#endif //__KATE_SESSIONPANEL_H__