-
Notifications
You must be signed in to change notification settings - Fork 0
/
textBox.cpp
44 lines (34 loc) · 1.3 KB
/
textBox.cpp
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
#include "textBox.h"
TextBox::TextBox(int _x, int _y, bool _isNumeric, QWidget* parent, QString text) : QLineEdit(text, parent), x(_x), y(_y), isNumericText(_isNumeric)
{
connect(this, SIGNAL(textEdited(QString)), this, SLOT(cellEmitter(QString)));
if(isNumericText && text=="") setText("0");
}
TextBox::~TextBox()
{
}
void TextBox::cellEmitter(QString text)
{
if(y == -1) emit updateTitle(text, x);
else emit updateValue(text, x, y);
}
int TextBox::getX() const {return x;}
int TextBox::getY() const {return y;}
bool TextBox::isNumeric() const{return isNumericText;}
void TextBox::focusOutEvent(QFocusEvent *event)
{
QLineEdit::focusOutEvent(event);
if(y != -1)setStyleSheet("QLineEdit { background: rgb(255, 255, 255); }"); //changes background color
}
void TextBox::focusInEvent(QFocusEvent *event)
{
QLineEdit::focusInEvent(event);
lastSelectedTextBox = {x,y};
if(y != -1)
setStyleSheet("QLineEdit { background: rgba(32, 191, 227, 0.4); }"); //changes background color
somethingWasSelected = true;
}
//STATIC FIELDS AND FUNCTIONS
QPair<int,int> TextBox::lastSelectedTextBox({0,0}); //static definition
bool TextBox::somethingWasSelected = false; //static definition
QPair<int, int> TextBox::getLastSelectedTextBoxCoordinates(){return lastSelectedTextBox;}