9 #include "BundleObservationView.h"
13 #include <QFontDatabase>
14 #include <QHeaderView>
15 #include <QSizePolicy>
16 #include <QStandardItem>
17 #include <QStandardItemModel>
19 #include <QStringList>
22 #include <QTextStream>
23 #include <QVBoxLayout>
36 if (fileItem->fileName().contains(
".csv")) {
39 else if (fileItem->fileName().contains(
".txt")) {
53 if (!QFile::exists(fileItem->fileName())) {
57 QFile file(fileItem->fileName());
58 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
62 int numHeaderLines = 3;
63 if (fileItem->fileName().contains(
"images")) {
67 QTextStream in(&file);
77 header1 = in.readLine();
78 lineToken1 = header1.split(
",");
79 header2 = in.readLine();
80 lineToken2 = header2.split(
",");
82 if (numHeaderLines == 2) {
83 for (
int i = 0; i < lineToken1.size(); i++) {
84 QString t1 = lineToken1.at(i);
85 QString t2 = lineToken2.at(i);
86 QString head = t1 +
"\n" + t2;
88 model->setHorizontalHeaderItem(i,v1);
91 if (numHeaderLines == 3) {
92 header3 = in.readLine();
93 lineToken3 = header3.split(
",");
95 lineToken1.append(
"");
96 lineToken2.append(
"");
98 for (
int i = 0; i < lineToken3.size(); i++) {
99 QString t1 = lineToken1.at(i);
100 QString t2 = lineToken2.at(i);
101 QString t3 = lineToken3.at(i);
102 QString head = t1 +
"\n" + t2 +
"\n" + t3;
104 model->setHorizontalHeaderItem(i,v1);
110 while (!in.atEnd()) {
111 QString fileLine = in.readLine();
114 QStringList lineToken = fileLine.split(
",", QString::SkipEmptyParts);
116 bool rejected =
false;
117 if (lineToken.at(lineToken.size()-1) ==
"*") {
122 for (
int i = 0; i < lineToken.size(); i++) {
123 QString value = lineToken.at(i);
128 item->setData(QColor(200,0,0), Qt::BackgroundRole);
138 QTableView *qtable=
new QTableView();
139 qtable->setModel(
model);
140 qtable->setSortingEnabled(
true);
144 qtable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
146 setCentralWidget(qtable);
148 QSizePolicy policy = sizePolicy();
149 policy.setHorizontalPolicy(QSizePolicy::Expanding);
150 policy.setVerticalPolicy(QSizePolicy::Expanding);
151 setSizePolicy(policy);
162 if (!QFile::exists(fileItem->fileName())) {
166 QFile file(fileItem->fileName());
167 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
171 QTextStream in(&file);
172 QTextEdit *qText=
new QTextEdit();
177 const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
178 qText->setFontFamily(fixedFont.family());
180 while (!in.atEnd()) {
181 qText->append(in.readLine());
186 setCentralWidget(qText);
187 qText->moveCursor(QTextCursor::Start);
189 QSizePolicy policy = sizePolicy();
190 policy.setHorizontalPolicy(QSizePolicy::Expanding);
191 policy.setVerticalPolicy(QSizePolicy::Expanding);
192 setSizePolicy(policy);