Cute Chess  0.1
pgntoken.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef PGNTOKEN_H
19 #define PGNTOKEN_H
20 
21 #include <QString>
22 #include <QTextCursor>
23 #include <QTextCharFormat>
24 
28 class PgnToken
29 {
30  public:
32  PgnToken();
34  virtual ~PgnToken();
35 
40  bool isEmpty() const;
42  int length() const;
44  virtual QString toString() const = 0;
49  void insert(QTextCursor& cursor);
51  void select(QTextCursor& cursor);
53  void move(int diff);
55  void mergeCharFormat(QTextCursor& cursor,
56  const QTextCharFormat& format);
57 
58  protected:
63  virtual void vInsert(QTextCursor& cursor) = 0;
64 
65  private:
66  int m_begin;
67  int m_end;
68 };
69 
70 #endif // PGNTOKEN_H
void select(QTextCursor &cursor)
Definition: pgntoken.cpp:55
void move(int diff)
Definition: pgntoken.cpp:64
virtual void vInsert(QTextCursor &cursor)=0
virtual ~PgnToken()
Definition: pgntoken.cpp:27
PgnToken()
Definition: pgntoken.cpp:21
int length() const
Definition: pgntoken.cpp:36
virtual QString toString() const =0
void mergeCharFormat(QTextCursor &cursor, const QTextCharFormat &format)
Definition: pgntoken.cpp:73
bool isEmpty() const
Definition: pgntoken.cpp:31
void insert(QTextCursor &cursor)
Definition: pgntoken.cpp:41
A text or HTML token in a PGN game.
Definition: pgntoken.h:28