File: qeditsession.h

package info (click to toggle)
texstudio 2.11.2%2Bdebian-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 41,292 kB
  • ctags: 12,405
  • sloc: cpp: 93,072; xml: 10,217; ansic: 4,153; sh: 145; makefile: 56
file content (139 lines) | stat: -rw-r--r-- 3,180 bytes parent folder | download | duplicates (7)
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
/****************************************************************************
**
** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
**
** This file is part of the Edyuk project <http://edyuk.org>
** 
** This file may be used under the terms of the GNU General Public License
** version 3 as published by the Free Software Foundation and appearing in the
** file GPL.txt included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef _QEDIT_SESSION_H_
#define _QEDIT_SESSION_H_

#include "mostQtHeaders.h"

#include "qce-config.h"

/*!
	\file qeditsession.h
	\brief Definition of the QEditSession class.
*/

class QEditor;

class QDocument;
class QDocumentCursor;
class QDocumentCommand;

class QDataStream;

class QCE_EXPORT QEditSession : public QObject
{
	Q_OBJECT
	
	public:
		enum SessionFormat
		{
			QCESession0,
			QCESession1,
			
			FormatCount
		};
		
		QEditSession(QObject *p = 0);
		QEditSession(const QString& f, QObject *p = 0);
		virtual ~QEditSession();
		
		int autoUpdateInterval() const;
		
		int format() const;
		
		QString fileName() const;
		
	public slots:
		virtual void addEditor(QEditor *e);
		virtual void removeEditor(QEditor *e);
		
		virtual void updateData();
		
		virtual void setAutoUpdateInterval(int ms);
		
		virtual void setFormat(int fmt);
		
		virtual void setFileName(const QString& filename, bool restore = false);
		
		virtual void clear(bool cleanup = false);
		
		virtual void save();
		virtual void restore();
		
		virtual void save(QDataStream& s);
		virtual void restore(QDataStream& s);
		
	signals:
		void restored(QEditor *e);
		
	protected slots:
		virtual void destroyed(QObject *o);
		
		virtual void saved(QEditor *e, const QString& fn);
		virtual void loaded(QEditor *e, const QString& fn);
		
	protected:
		virtual void timerEvent(QTimerEvent *e);
		
		virtual QEditor* createEditor();
		
	public:
		struct Cursor
		{
			Cursor()
			 : beginLine(-1), beginColumn(-1), endLine(-1), endColumn(-1) {}
			
			Cursor(int line, int column)
			 : beginLine(line), beginColumn(column), endLine(-1), endColumn(-1) {}
			
			Cursor(const Cursor& c)
			 : beginLine(c.beginLine), beginColumn(c.beginColumn), endLine(c.endLine), endColumn(c.endColumn) {}
			
			Cursor(const QDocumentCursor& c);
			
			QDocumentCursor toDocumentCursor(QDocument *d) const;
			
			int beginLine;
			int beginColumn;
			int endLine;
			int endColumn;
		};
		
		struct Document
		{
			quint8 flags;
			QString fileName;
			QDateTime timeStamp;
			
			int scrollX, scrollY;
			
			QList<Cursor> cursors;
			QHash<int, QList<int> > marks;
		};
		
	protected:
		virtual void update(QEditor *e, Document *d);
		
		int m_id;
		int m_delay;
		int m_format;
		QString m_fileName;
		
		QList<QEditor*> m_editors;
		QList<Document*> m_sessionData;
};

#endif // ! _QEDIT_SESSION_H_