-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbrowsecommentsdialog.cpp
More file actions
73 lines (57 loc) · 1.56 KB
/
Copy pathbrowsecommentsdialog.cpp
File metadata and controls
73 lines (57 loc) · 1.56 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "browsecommentsdialog.h"
#include "ui_browsecommentsdialog.h"
#include "htmltextedit.h"
#include "sql.h"
BrowseCommentsDialog::BrowseCommentsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::BrowseCommentsDialog)
{
ui->setupUi(this);
ui->txtComments->setReadOnly(false);
connect(ui->btnNext, SIGNAL(clicked()), this, SLOT(OnBtnNext()));
connect(ui->btnPrev, SIGNAL(clicked()), this, SLOT(OnBtnPrev()));
connect(ui->txtKey, &QLineEdit::editingFinished, [=]{
bool bOk;
int commentKey = ui->txtKey->text().toInt(&bOk);
if(bOk)
{
ci = CommentInfo(commentKey-1);
OnBtnNext();
}
});
}
BrowseCommentsDialog::~BrowseCommentsDialog()
{
delete ui;
}
void BrowseCommentsDialog::btnDelete_Clicked()
{
SQL::instance()->deleteComment(ci.commentKey);
this->close();
}
void BrowseCommentsDialog::OnBtnNext()
{
outputChanges();
getComment(+1);
ui->btnNext->setEnabled(ci.commentKey != -1);
}
void BrowseCommentsDialog::OnBtnPrev()
{
outputChanges();
getComment(-1);
ui->btnPrev->setEnabled(ci.commentKey != -1);
}
void BrowseCommentsDialog::getComment(int pos)
{
ci = SQL::instance()->getComment(ci.commentKey, pos);
ui->txtComments->setHtml(ci.comments);
ui->txtKey->setText(tr("%1").arg(ci.commentKey));
//ui->txtUsedByS->setText(ci.usedByStations.join(","));
ui->txtUsedByRoutes->setText(ci.usedByRoutes.join(","));
}
void BrowseCommentsDialog::outputChanges()
{
ci.comments = ui->txtComments->toHtml();
if(ci.commentKey >= 0 || !ci.comments.isEmpty())
SQL::instance()->updateComment(ci.commentKey, ci.comments);
}