mirror-chatterino2/src/messages/wordpart.cpp

108 lines
1.8 KiB
C++
Raw Normal View History

2017-01-18 21:30:23 +01:00
#include "messages/wordpart.h"
#include "messages/word.h"
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2017-01-11 01:08:20 +01:00
2017-04-12 17:46:44 +02:00
WordPart::WordPart(Word &word, int x, int y, int lineNumber, const QString &copyText,
bool allowTrailingSpace)
: _word(word)
, _copyText(copyText)
, _text(word.isText() ? _word.getText() : QString())
, _x(x)
, _y(y)
, _width(word.getWidth())
, _height(word.getHeight())
, _lineNumber(lineNumber)
2017-01-18 04:33:30 +01:00
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
2017-01-11 01:08:20 +01:00
{
}
2017-04-12 17:46:44 +02:00
WordPart::WordPart(Word &word, int x, int y, int width, int height, int lineNumber,
const QString &copyText, const QString &customText, bool allowTrailingSpace)
: _word(word)
, _copyText(copyText)
, _text(customText)
, _x(x)
, _y(y)
, _width(width)
, _height(height)
, _lineNumber(lineNumber)
2017-01-18 04:33:30 +01:00
, _trailingSpace(word.hasTrailingSpace() & allowTrailingSpace)
2017-01-11 01:08:20 +01:00
{
}
2017-04-12 17:46:44 +02:00
const Word &WordPart::getWord() const
{
return _word;
}
int WordPart::getWidth() const
{
return _width;
}
int WordPart::getHeight() const
{
return _height;
}
int WordPart::getX() const
{
return _x;
}
int WordPart::getY() const
{
return _y;
}
void WordPart::setPosition(int x, int y)
{
_x = x;
_y = y;
}
void WordPart::setY(int y)
{
_y = y;
}
int WordPart::getRight() const
{
return _x + _width;
}
int WordPart::getBottom() const
{
return _y + _height;
}
QRect WordPart::getRect() const
{
return QRect(_x, _y, _width, _height);
}
const QString WordPart::getCopyText() const
{
return _copyText;
}
int WordPart::hasTrailingSpace() const
{
return _trailingSpace;
}
const QString &WordPart::getText() const
{
return _text;
}
int WordPart::getLineNumber()
{
return _lineNumber;
}
} // namespace messages
} // namespace chatterino