-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow_tab_journal.cpp
55 lines (48 loc) · 1.53 KB
/
mainwindow_tab_journal.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
45
46
47
48
49
50
51
52
53
54
55
#include "mainwindow.h"
#include "../Lib/alertsound.h"
void MainWindow::LoadEditHistory()
{
Contact& dr = db.getSelected() ;
ui->editHistory->setPlainText("") ;
if (dr.isNull() || dr.isEmpty()) return ;
History& h = dr.getHistory() ;
ui->editHistory->setPlainText(h.getHistory()) ;
}
void MainWindow::SaveEditHistory()
{
Contact& dr = db.getSelected() ;
if (dr.isNull() || dr.isEmpty()) return ;
History& h = dr.getHistory() ;
h.updateHistory(ui->editHistory->toPlainText()) ;
}
// Append to history, updating ui if necessary
void MainWindow::appendHistory(Contact& contact, QString msg)
{
if (contact.isNull() || contact.isEmpty()) return ;
if (contact.getField(Contact::ID).compare(db.getSelected().getField(Contact::ID))==0) {
SaveEditHistory() ;
contact.getHistory().addEntry(msg) ;
LoadEditHistory() ;
LoadOverviewTab() ;
} else {
contact.getHistory().addEntry(msg) ;
}
}
//
// on_actionEnableJournalHistoryEdit_triggered
//
//
void MainWindow::on_actionEnableEditHistoryEdit_triggered()
{
if (db.getSelected().isNull()) {
play(Disabled) ;
} else {
ui->editHistory->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable) ;
if (ui->tabBar->currentIndex()!=HISTORYTABPOS) {
dbg("tabBar->setCurrentIndex(HISTORYTABPOS)") ;
ui->tabBar->setCurrentIndex(HISTORYTABPOS);
}
dbg("editHistory->setFocus()") ;
ui->editHistory->setFocus() ;
}
}