-
Notifications
You must be signed in to change notification settings - Fork 0
/
toollist.cpp
117 lines (104 loc) · 2.62 KB
/
toollist.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
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
#include "toollist.h"
#include <QDebug>
ToolList::ToolList(QObject *parent)
: QObject{parent}
{
}
void ToolList::insert_Tool(Tool* tool, bool check)
{
bool match = false;
int i = 0;
Tool* t;
/* Wenn eine Überprüfung stattfinden soll
* Überprüfe in der Liste ob es das Tool schon gibt*/
if(check)
{
while(i<list.size() && !match)
{
if(list.at(i)->get_Number() == tool->get_Number())
{
match = true;
}
i++;
}
}
if(!match)
{
t = new Tool(this);
t->set_Number(tool->get_Number());
t->set_Description(tool->get_Description());
t->set_ToolGL(tool->get_ToolGL());
t->set_ToolAL(tool->get_ToolAL());
t->set_ToolFL(tool->get_ToolFL());
t->set_HalterName(tool->get_HalterName());
t->set_counter(tool->get_counter());
t->set_State(tool->get_State());
t->set_SchneidLange(tool->get_SchneidLange());
list.append(t);
}
return;
}
void ToolList::prepend(Tool* tool)
{
Tool* t = new Tool(this);
t->set_Number(tool->get_Number());
t->set_Description(tool->get_Description());
t->set_ToolGL(tool->get_ToolGL());
t->set_ToolAL(tool->get_ToolAL());
t->set_ToolFL(tool->get_ToolFL());
list.prepend(t);
}
void ToolList::sort_ID()
{
for (int i = 0; i<list.size(); i++)
{
for(int j = 0; j<i; j++)
{
if(list.at(i)->get_Number() < list.at(j)->get_Number())
{
list.move(i,j);
break;
}
}
}
}
void ToolList::sort_Counter()
{
for (int i = 0; i<list.size(); i++)
{
for(int j = 0; j<i; j++)
{
if(list.at(i)->get_counter() < list.at(j)->get_counter())
{
list.move(i,j);
break;
}
}
}
}
bool ToolList::contains(Tool* t)
{
//qDebug() << "ToolList::contains: " + t->get_Number();
foreach(Tool* tool, list)
{
if(tool->get_Number() == t->get_Number())
{
//qDebug() << "Tool: " + t->get_Number() + " = " + tool->get_Number();
return true;
}
}
//qDebug() << "Tool: " + t->get_Number();
return false;
}
void ToolList::set_Description(ToolList* tl)
{
QList<Tool*> list_Source = tl->getList();
for(int i = 0; i < list.size(); i++)
{
for(int j = 0; j< list_Source.size(); j++)
{
if(list.at(i)->get_Number() == list_Source.at(j)->get_Number())
list.at(i)->set_Description(list_Source.at(j)->get_Description());
}
}
}