source: trunk/tools/designer/editor/parenmatcher.h

Last change on this file was 197, checked in by rudi, 14 years ago

Added QtDesigner

File size: 1.9 KB
Line 
1 /**********************************************************************
2** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of Qt Designer.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#ifndef PARENMATCHER_H
28#define PARENMATCHER_H
29
30#include <qstring.h>
31#include <qvaluelist.h>
32
33class QTextCursor;
34
35struct Paren
36{
37 Paren() : type( Open ), chr( ' ' ), pos( -1 ) {}
38 Paren( int t, const QChar &c, int p ) : type( (Type)t ), chr( c ), pos( p ) {}
39 enum Type { Open, Closed };
40 Type type;
41 QChar chr;
42 int pos;
43
44 Q_DUMMY_COMPARISON_OPERATOR( Paren )
45};
46
47typedef QValueList<Paren> ParenList;
48
49class ParenMatcher
50{
51public:
52 enum Selection {
53 Match = 1,
54 Mismatch
55 };
56
57 ParenMatcher();
58
59 virtual bool match( QTextCursor *c );
60
61 void setEnabled( bool b ) { enabled = b; }
62
63private:
64 bool checkOpenParen( QTextCursor *c );
65 bool checkClosedParen( QTextCursor *c );
66
67 bool enabled;
68
69};
70
71#endif
Note: See TracBrowser for help on using the repository browser.