-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestWindow.cpp
More file actions
141 lines (124 loc) · 4.72 KB
/
Copy pathTestWindow.cpp
File metadata and controls
141 lines (124 loc) · 4.72 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "TestWindow.h"
#include "Data/AllData.h"
#include <IniFiles.hpp> //Include the IniFiles header
#include "CarInfoInputForm.h" //Include for showing Form3
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
//make ListView columns have equally distributed width & fill entire space
if(ListView1->Columns->Count > 0)
{
int ColWidth = ListView1->ClientWidth / ListView1->Columns->Count;
for(int i = 0; i < ListView1->Columns->Count; i++)
ListView1->Columns->Items[i]->Width = ColWidth;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::LoadIni_testClick(TObject *Sender)
{
DataModule1->themeHelper.LoadSection("LIGHT THEME");
DataModule1->fontHelper.LoadSection("TEST FONT");
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
DataModule1->wrSettingsHelper.DeleteSettings();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
DataModule1->wrSettingsHelper.isRememberMe = true;
DataModule1->wrSettingsHelper.username = "test1";
DataModule1->wrSettingsHelper.password = "test2";
DataModule1->wrSettingsHelper.SaveSettings();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::SaveIni_TestClick(TObject *Sender)
{
DataModule1->themeHelper.SaveCurrent();
DataModule1->fontHelper.SaveCurrent();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::LoadWR_TestClick(TObject *Sender)
{
DataModule1->wrSettingsHelper.LoadSettings();
ShowMessage(DataModule1->wrSettingsHelper.username);
ShowMessage(DataModule1->wrSettingsHelper.password);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button3Click(TObject *Sender)
{
FillListView();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button4Click(TObject *Sender)
{
DataModule1->themeHelper.ResetToDefault();
DataModule1->fontHelper.ResetToDefault();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button5Click(TObject *Sender)
{
//open separate window for entering car info
Form3->AddCarMode();
Form3->ShowModal();
//get changes
FillListView();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button6Click(TObject *Sender)
{
//delete car based on index
DataModule1->companycars->Delete(ListView1->ItemIndex);
DataModule1->XmlDoc->SaveToFile(DataModule1->XmlDoc->FileName);
//avoid double click deleting next node in line
ListView1->ItemIndex = -1;
FillListView();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ListView1SelectItem(TObject *Sender, TListItem *Item, bool Selected)
{
//get the selected node from xml on selecting the listview item
if(ListView1->ItemIndex == -1){
return;
}
DataModule1->currentCar = DataModule1->companycars->car[ListView1->ItemIndex];
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button7Click(TObject *Sender)
{
//open separate window for entering car info with selected info
Form3->EditCarMode();
Form3->ShowModal();
FillListView();
}
//---------------------------------------------------------------------------
//update company cars and fill the list view with most recent info
void __fastcall TForm2::FillListView(){
DataModule1->companycars = Getcompanycars(DataModule1->XmlDoc);
ListView1->Items->Clear();
for(int i = 0; i < DataModule1->companycars->Count; i++){
ListView1->Items->Add();
ListView1->Items->Item[i]->Caption =
DataModule1->companycars->car[i]->licenseplate;
ListView1->Items->Item[i]->
Caption = DataModule1->companycars->car[i]->licenseplate;
ListView1->Items->Item[i]->SubItems->
Add(DataModule1->companycars->car[i]->internalmark);
ListView1->Items->Item[i]->SubItems->
Add(DataModule1->companycars->car[i]->assigned);
ListView1->Items->Item[i]->SubItems->
Add(DataModule1->companycars->car[i]->currentuser);
ListView1->Items->Item[i]->SubItems->
Add(DataModule1->companycars->car[i]->location);
}
}
//---------------------------------------------------------------------------