Sayonara Player
TagLineEdit.h
1 /* TagLineEdit.h */
2 
3 /* Copyright (C) 2011-2016 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef TAGLINEEDIT_H
24 #define TAGLINEEDIT_H
25 
26 #include <QLineEdit>
27 #include <QString>
28 #include <QFocusEvent>
34 
35  int selection_start;
36  int selection_size;
37 
41  void reset(){
42  selection_start = -1;
43  selection_size = 0;
44  }
45 
46  TextSelection(){
47  reset();
48  }
49 };
50 
55 class TagLineEdit : public QLineEdit {
56 
57  Q_OBJECT
58 
59 public:
60  TagLineEdit(QWidget* parent=nullptr);
61 
62 protected:
63 
64  TextSelection _text_selection;
65 
66 protected:
71  void focusInEvent(QFocusEvent* e) override;
72 
77  void focusOutEvent(QFocusEvent* e) override;
78 
79 public:
85 };
86 
87 
88 #endif // TAGLINEEDIT_H
Holds start and size of a selection.
Definition: TagLineEdit.h:33
The TagLineEdit class.
Definition: TagLineEdit.h:55
void focusOutEvent(QFocusEvent *e) override
if selectected_text is empty, TextSelection is resetted. Else the new TextSelection is set...
void reset()
set selection_start to -1 and selection_size to 0
Definition: TagLineEdit.h:41
TextSelection get_text_selection() const
Retrieve the current TextSelection.
void focusInEvent(QFocusEvent *e) override
resets the TextSelection