#pragma once
#include <QtWidgets/qwidget.h>
#include <qtablewidget.h>
#include "DatabaseConnection.h"
#pragma comment(lib,"Qt5Core.lib")
#pragma comment(lib,"Qt5Widgets.lib")
class MyWidget
{
public:
QWidget self;
QTableWidget tableworkers;
QTableWidget tabletasks;
MyWidget();
DatabaseConnection db;
void InitWidget();
void Tape(QTableWidget &table,bool t);
~MyWidget();
};
void MyWidget::Tape(QTableWidget &table,bool t)
void MyWidget::InitWidget()
{
// QTableWidget tableworkers;
//QTableWidget tabletasks;
// db.Connect();
QWidget self;
self.setWindowTitle("Task system");
self.setGeometry(0, 0, 1000, 700);
/*
db.StandartQuery();
tableworkers.setParent(&self);
tableworkers.setColumnCount(db.numCol);
tableworkers.setRowCount(db.numRow);
tableworkers.setGeometry(0, 0, 950, 300);
//Tape(tableworkers,false);
db.Query();
tabletasks.setParent(&self);
tabletasks.setColumnCount(db.numCol);
tabletasks.setRowCount(db.numRow);
tabletasks.setGeometry(0, 300, 950, 300);
//Tape(tabletasks, true);
*/
self.show();
}
Task* task_ = new Task();
for (int i = 0; i < nrows; i++)
{
task_->id = atoi(PQgetvalue(res, i, 0));
task_->task = PQgetvalue(res, i, 1);
task_->parentTask = atoi(PQgetvalue(res, i, 2));
task_->executor = PQgetvalue(res, i, 3);
char* ddl = PQgetvalue(res, i, 4);
ddl[4] = ddl[7] = '\0';
task_->dateDeathLine->tm_year = atoi(&ddl[0]) - 1900;
task_->dateDeathLine->tm_mon = atoi(&ddl[5]) - 1;
task_->dateDeathLine->tm_mday = atoi(&ddl[8]);
ddl = PQgetvalue(res, i, 5);
ddl[4] = ddl[7] = '\0';
task_->dateStart->tm_year = atoi(&ddl[0]) - 1900;
task_->dateStart->tm_mon = atoi(&ddl[5]) - 1;
task_->dateStart->tm_mday = atoi(&ddl[8]);
task_->status = PQgetvalue(res, i, 6);
task_->oldtask = PQgetvalue(res, i, 7);
cout << " Id: " << task_->id;
cout << " Task: " << task_->task;
cout << " Parent: " << task_->parentTask;
cout << " Executor: " << task_->executor;
char* date_string = new char[50];
strftime(date_string, 50, " %Y-%m-%d", task_->dateDeathLine);
cout << " DeathLine: " << date_string;
strftime(date_string, 50, "%Y-%m-%d", task_->dateStart);
cout << " Start: " << date_string;
cout << " Status: " << task_->status;
cout << " Oldtask: " << task_->oldtask << endl;
vTask.push_back(*task_);
}