File: qlinemarksinfocenter.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 (182 lines) | stat: -rw-r--r-- 4,788 bytes parent folder | download | duplicates (3)
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
175
176
177
178
179
180
181
182
/****************************************************************************
**
** 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 _QLINE_MARKS_INFO_CENTER_H_
#define _QLINE_MARKS_INFO_CENTER_H_

#include "mostQtHeaders.h"

/*!
	\file qlinemarksinfocenter.h
	\brief Definition of the QLineMarksInfoCenter class.
	
	\see QLineMarksInfoCenter
*/

/*!
	\defgroup language Language framework
*/

#include "qce-config.h"

class QEditor;
class QDataStream;
class QDocumentLineHandle;

struct QLineMark
{
	inline QLineMark() : mark(-1), line(-1) {}
	
	inline QLineMark(const QString& f, int l, int m)
	 : mark(m), line(l), file(f)
	{}
	
	inline bool operator == (const QLineMark& m) const
	{ return (line == m.line) && (file == m.file) && (mark == m.mark); }
	
	inline bool operator != (const QLineMark& m) const
	{ return (line != m.line) || (file != m.file) || (mark != m.mark); }
	
	int mark;
	int line;
	QString file;
};

Q_DECLARE_METATYPE(QLineMark)

typedef QList<QLineMark> QLineMarkList;

Q_DECLARE_TYPEINFO(QLineMark, Q_MOVABLE_TYPE);

struct QLineMarkHandle
{
	inline QLineMarkHandle() : mark(-1), line(0) {}
	
	inline QLineMarkHandle(const QString& f, QDocumentLineHandle *l, int m)
	 : mark(m), line(l), file(f)
	{}
	
	inline bool operator == (const QLineMarkHandle& m) const
	{ return (line == m.line) && (file == m.file) && (mark == m.mark); }
	
	inline bool operator != (const QLineMarkHandle& m) const
	{ return (line != m.line) || (file != m.file) || (mark != m.mark); }
	
	int mark;
	QDocumentLineHandle *line;
	QString file;
};

Q_DECLARE_METATYPE(QLineMarkHandle)

typedef QList<QLineMarkHandle> QLineMarkHandleList;

Q_DECLARE_TYPEINFO(QLineMarkHandle, Q_MOVABLE_TYPE);

QCE_EXPORT QDataStream& operator >> (QDataStream& d, QLineMark& m);
QCE_EXPORT QDataStream& operator << (QDataStream& d, const QLineMark& m);

struct QLineMarkType
{
	inline QLineMarkType()
	 : user(false), focus(false), priority(-1), persistency(0)
	{}
	
	bool user;
	bool focus;
	QString id;
    QIcon icon;
	QColor color, defaultColor;
	int priority;
	int persistency;
	QStringList rules;
};

Q_DECLARE_METATYPE(QLineMarkType)

typedef QList<QLineMarkType> QLineMarkTypeList;

Q_DECLARE_TYPEINFO(QLineMarkType, Q_MOVABLE_TYPE);

class QCE_EXPORT QLineMarksInfoCenter : public QObject
{
	friend class QEditor;
	friend class QCodeEdit;
	
	Q_OBJECT
	
	public:
		static QLineMarksInfoCenter* instance();
		static void destroy();
		
		QLineMarkTypeList& markTypes();

		QLineMarkList marks(const QString& file = QString()) const;
		
		QString markTypeId(int id) const;
		int markTypeId(const QString& id) const;
		
		QLineMarkType markType(int id) const;
		QLineMarkType markType(const QString& id) const;

		int priority(int id) const;
		int priority(const QList<int>& marks) const;
		QString priority(const QStringList& marks) const;
		
		QStringList availableMarkTypes(const QString& context = QString()) const;
		QList<QStringList> marksLayout(const QString& context = QString()) const;
		
	public slots:
		void loadMarks(const QString& f);
		void saveMarks(const QString& f);
		
		void loadMarkTypes(const QString& f);
		
		void clear();
		
		void removeMarks(const QString& file);
		
		void addLineMark(const QLineMark& mark);
		void toggleLineMark(const QLineMark& mark);
		void removeLineMark(const QLineMark& mark);
		
		void addLineMark(const QLineMarkHandle& mark);
		void toggleLineMark(const QLineMarkHandle& mark);
		void removeLineMark(const QLineMarkHandle& mark);
		
		void flush(const QString& file);
		
	signals:
		void lineMarkAdded(const QLineMark& mark);
		void lineMarkRemoved(const QLineMark& mark);
		
	protected:
		QLineMarksInfoCenter();
		virtual ~QLineMarksInfoCenter();
		
	protected slots:
		void cursorMoved(QEditor *e);
		void lineDeleted(QDocumentLineHandle *h);
		void markChanged(const QString& f, QDocumentLineHandle *h, int mark, bool on);
		
	private:
		QLineMarkList m_delayed;
		QLineMarkHandleList m_lineMarks;
		QLineMarkTypeList m_lineMarkTypes;
		
		static QLineMarksInfoCenter *m_instance;
};

#endif // !_QLINE_MARKS_INFO_CENTER_H_