summaryrefslogtreecommitdiffstats
path: root/kate/app/katesessionpanel.h
blob: 6899d68e91430c799c5654a25d97a3d061e7f593 (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
/* This file is part of the TDE project
   Copyright (C) 2015-2016 Michele Calgaro <micheleDOTcalgaro__AT__yahooDOTit>

   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
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

  public:

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


  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();
    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();
    
		/* In case the current session is still volatile, asks the user whether
		   he wants to save or discard the session.
		   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
		   In case the user decides to save the session, the function also sets
		   the new session name provided in the dialog box.
		*/
    int handleVolatileSession();

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


#endif //__KATE_SESSIONPANEL_H__