Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added line property for a message node #122

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/core/qttsdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ void QtTsMessage::setFileName(const QString &file)
Q_EMIT fileNameChanged();
}

int QtTsMessage::line() const
{
return QByteArray(m_message.child("location").attribute("line").value()).toInt();
}

void QtTsMessage::setLine(int line)
{
LOG("QtTsMessage::setLine", line);
m_message.child("location").attribute("line").set_value(QByteArray::number(line).constData());
qobject_cast<QtTsDocument *>(parent())->setHasChanged(true);
Q_EMIT lineChanged();
}

QString QtTsMessage::comment() const
{
return QString::fromLatin1(m_message.child("comment").text().as_string());
Expand Down
5 changes: 5 additions & 0 deletions src/core/qttsdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class QtTsMessage : public QObject
Q_OBJECT
Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged)
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(int line READ line WRITE setLine NOTIFY lineChanged)
Q_PROPERTY(QString translation READ translation WRITE setTranslation NOTIFY translationChanged)
Q_PROPERTY(QString comment READ comment WRITE setComment NOTIFY commentChanged)
Q_PROPERTY(QString context READ context CONSTANT)
Expand All @@ -31,6 +32,9 @@ class QtTsMessage : public QObject
QString fileName() const;
void setFileName(const QString &name);

int line() const;
void setLine(int line);

QString source() const;
void setSource(const QString &source);

Expand All @@ -44,6 +48,7 @@ class QtTsMessage : public QObject

signals:
void fileNameChanged();
void lineChanged();
void sourceChanged();
void translationChanged();
void commentChanged();
Expand Down
Loading