Repository navigation
Expand file tree
/
Copy pathglobalfunctions.cpp
More file actions
98 lines (77 loc) · 2.17 KB
/
Copy pathglobalfunctions.cpp
File metadata and controls
98 lines (77 loc) · 2.17 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
#include "globalfunctions.h"
#include "calculator/calculator.h"
void GetMatrixToTableWidget(Matrix &matrix, QTableWidget &tableWidgetMatrix)
{
int NumberRows = matrix.lineCount();
int NumberColumns = matrix.columnCount();
tableWidgetMatrix.setRowCount(NumberRows);
tableWidgetMatrix.setColumnCount(NumberColumns);
for (int l=0;l<NumberRows;l++)
{
for(int c=0;c<NumberColumns;c++)
{
if (tableWidgetMatrix.item(l,c) == 0)
{
QTableWidgetItem *newItem = new QTableWidgetItem(matrix.GetLineColText(l,c));
//QString str = matrix.GetLineColText(l,c);
tableWidgetMatrix.setItem(l,c, newItem);
}
else
{
tableWidgetMatrix.item(l, c)->setText(matrix.GetLineColText(l,c));
}
}
}
}
bool GetTableWidgetToMatrix(QTableWidget &tableWidgetMatrix, Matrix &matrix)
{
int NumberRows = tableWidgetMatrix.rowCount();
int NumberColumns = tableWidgetMatrix.columnCount();
Calculator calc;
Complexo z;
bool flagTableMatrixError=false;
matrix.SetLinesCols(NumberRows,NumberColumns);
for(int i=0;i<NumberRows;i++)
{
for(int l=0;l<NumberColumns;l++)
{
if (tableWidgetMatrix.item(i,l) == 0)
{
flagTableMatrixError = true;
return flagTableMatrixError;
}
matrix.SetLineColText(i,l,tableWidgetMatrix.item(i,l)->text());
}
}
return flagTableMatrixError;
}
void QStringListToTableWidget(QStringList &list, QTableWidget &tableWidget)
{
tableWidget.setRowCount(list.size());
for(int i = 0; i < list.size(); i++)
{
if (tableWidget.item(i,0) == 0)
{
QTableWidgetItem *newItem = new QTableWidgetItem(list.at(i));
tableWidget.setItem(i,0, newItem);
}
else
{
tableWidget.item(i,0)->setText(list.at(i));
}
}
}
int min(const int &a, const int &b)
{
if (a <= b)
return a;
else
return b;
}
int max(const int &a, const int &b)
{
if (a >= b)
return a;
else
return b;
}