-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectionlog.cpp
More file actions
75 lines (64 loc) · 2.31 KB
/
Copy pathconnectionlog.cpp
File metadata and controls
75 lines (64 loc) · 2.31 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
74
75
//---------------------------------------------------------------------------
#include <irspch.h>
#pragma hdrstop
#include "connectionlog.h"
#include <irsfinal.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TConnectionLogForm *ConnectionLogForm;
//---------------------------------------------------------------------------
__fastcall TConnectionLogForm::TConnectionLogForm(TComponent* Owner)
: TForm(Owner),
m_memo_error_string_list(),
m_error_string_list(),
m_update_timer(irs::make_cnt_s(1))
{
}
//---------------------------------------------------------------------------
void __fastcall TConnectionLogForm::CloseButtonClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TConnectionLogForm::ClearButtonClick(TObject *Sender)
{
m_memo_error_string_list.clear();
LogMemo->Lines->Clear();
}
void TConnectionLogForm::add_errors(
const error_string_list_type& a_error_string_list)
{
size_type start_index = 0;
if (a_error_string_list.size() > error_list_max_size) {
start_index = a_error_string_list.size() - error_list_max_size;
}
for (size_type i = start_index; i < a_error_string_list.size(); i++) {
m_error_string_list.push_back(a_error_string_list[i]);
if (m_error_string_list.size() > error_list_max_size) {
m_error_string_list.pop_front();
}
}
}
void TConnectionLogForm::update_error_list()
{
m_memo_error_string_list = m_error_string_list;
m_error_string_list.clear();
for (size_type i = 0; i < m_memo_error_string_list.size(); i++) {
string_type s = m_memo_error_string_list[i];
LogMemo->Lines->Add(irs::str_conv<String>(m_memo_error_string_list[i]));
}
}
//---------------------------------------------------------------------------
void __fastcall TConnectionLogForm::FormShow(TObject *Sender)
{
update_error_list();
}
//---------------------------------------------------------------------------
void __fastcall TConnectionLogForm::MainTimerTimer(TObject *Sender)
{
if (AutoUpdateCheckBox->Checked && m_update_timer.check()) {
update_error_list();
}
}
//---------------------------------------------------------------------------