/*! * \brief DBthread::newDB * \param query * \param DBname * * Slot for creating a new db and all the tables needed inside it. */ void DBthread::newDB(QString query, QString DBname){ QSqlQuery query1(query); if(query1.isActive()) qDebug()<<"Base de Datos Creada"; else{ if(result){ result = false; emit querResult(result,query1.lastError().text()); qDebug()<<"Base de Datos no Creada"; } } QSqlQuery query2("use " + DBname); if(query2.isActive()) qDebug()<<"Colocado en la base de datos " << DBname; else{ if(result){ result = false; emit querResult(result,query2.lastError().text()); qDebug() << query2.lastError(); } } QSqlQuery PlayTab("create table if not exists players(id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, player_label VARCHAR(10) NOT NULL, PRIMARY KEY(id))"); if(PlayTab.isActive()) qDebug()<<"Tabla de jugadores creada"; else{ if(result){ result = false; emit querResult(result,PlayTab.lastError().text()); qDebug()<<"Tabla de jugadores no creada"; } } QSqlQuery FrameTab("create table if not exists data(id INT UNSIGNED NOT NULL AUTO_INCREMENT,frame BIGINT UNSIGNED NOT NULL, player_id TINYINT UNSIGNED NOT NULL, xpos DOUBLE PRECISION UNSIGNED NOT NULL, ypos DOUBLE PRECISION UNSIGNED NOT NULL, FOREIGN KEY (player_id) REFERENCES players(id) ON DELETE CASCADE, PRIMARY KEY (id))"); if(FrameTab.isActive()) qDebug()<<"Tabla de datos creada"; else{ if(result){ result = false; emit querResult(result,FrameTab.lastError().text()); qDebug()<<"Tabla de datos no creada"; } } if(result){ qDebug() << result; emit querResult(result,QString()); } }
bool Table::Paint(int zoom, Draw& w, int x, int y, int cx, int ymax, PaintInfo& pi) const { int j; Vector<Line> header; int zfw = DocZoomLn(zoom, GetFrameWidth()); int tcx = cx - 2 * zfw - DocZoom(zoom, GetLm()) - DocZoom(zoom, GetRm()); bool breakpage = pi.line != pi.oline; int pgcy = ymax - y; pi.oline = pi.line; if(pi.line) { int m = min(GetHeaderRows(), cell.GetCount()); for(j = 0; j < m; j++) header.Add() = GetLine(zoom, j, tcx, NULL); } int hdrcy = Span(header); if(hdrcy > ymax - y) { header.Clear(); hdrcy = 0; } int hg = hdrcy; int yp = y; y += zfw; bool was = false; if(y >= ymax) { pi.ypos = y; return true; } while(pi.line < GetRows() && y < ymax) { Vector<Line> line; Vector<int> *yl = &pi.yl; int span = 0; bool nospan = true; for(;;) { int k = pi.line + line.GetCount(); if(k >= GetRows() || line.GetCount() && !KeepLine(k) && span <= 0) break; span = max((line.Add() = GetLine(zoom, k, tcx, yl)).span, span); if(span) nospan = false; yl = NULL; span--; } hg += Span(line); int lhg = line.Top().height; if(hg + y + zfw > ymax) { if((!breakpage || lhg > style.breakcy && ymax - (y + hg - lhg) - zfw > style.breakpgcy) && nospan && line.GetCount() && hg + y + zfw - lhg <= ymax) { int yy = y + hdrcy; PaintLines(zoom, w, x, yy, 0, header, 0); yy = y + hdrcy; int i; for(i = 0; i < line.GetCount() - 1; i++) { DrawLine(zoom, w, x, yy, pi.line++, line[i], ymax, NULL); yy += line[i].height; } DrawLine(zoom, w, x, yy, pi.line, line[i], ymax, &pi.yl); breakpage = was = true; y = ymax; } if(breakpage) { FrameTab(zoom, w, was, x, y, yp, cx); pi.ypos = y; return true; } } y += hg; int yy = y; PaintLines(zoom, w, x, yy, pi.line, line, &pi.yl); PaintLines(zoom, w, x, yy, 0, header, 0); pi.yl.Clear(); header.Clear(); hg = 0; breakpage = was = true; pi.line += line.GetCount(); } FrameTab(zoom, w, was, x, y, yp, cx); pi.ypos = y + zfw; return false; }