2017-06-11 09:31:45 +02:00
|
|
|
#include "messages/wordpart.hpp"
|
|
|
|
#include "messages/word.hpp"
|
2017-01-18 21:30:23 +01:00
|
|
|
|
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 ©Text,
|
|
|
|
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-09-12 19:06:16 +02:00
|
|
|
, _trailingSpace(!word.getCopyText().isEmpty() && 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 ©Text, const QString &customText, bool allowTrailingSpace)
|
|
|
|
: _word(word)
|
|
|
|
, _copyText(copyText)
|
|
|
|
, _text(customText)
|
|
|
|
, _x(x)
|
|
|
|
, _y(y)
|
|
|
|
, _width(width)
|
|
|
|
, _height(height)
|
|
|
|
, _lineNumber(lineNumber)
|
2017-09-12 19:06:16 +02:00
|
|
|
, _trailingSpace(!word.getCopyText().isEmpty() && 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
|
|
|
|
{
|
2017-09-12 19:06:16 +02:00
|
|
|
return QRect(_x, _y, _width, _height - 1);
|
2017-04-12 17:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString WordPart::getCopyText() const
|
|
|
|
{
|
|
|
|
return _copyText;
|
|
|
|
}
|
|
|
|
|
|
|
|
int WordPart::hasTrailingSpace() const
|
|
|
|
{
|
|
|
|
return _trailingSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &WordPart::getText() const
|
|
|
|
{
|
|
|
|
return _text;
|
|
|
|
}
|
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
int WordPart::getLineNumber() const
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
return _lineNumber;
|
|
|
|
}
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2017-09-12 19:06:16 +02:00
|
|
|
int WordPart::getCharacterLength() const
|
|
|
|
{
|
|
|
|
// return (this->getWord().isImage() ? 1 : this->getText().length()) + (_trailingSpace ? 1 :
|
|
|
|
// 0);
|
|
|
|
return this->getWord().isImage() ? 2 : this->getText().length() + 1;
|
|
|
|
}
|
|
|
|
|
2017-06-07 10:09:24 +02:00
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|