void LAP_SQLModel::fetchMore ( const QModelIndex &) { QVector <QVariant> _temp(header.count()); int lump = 0; do { _temp.clear(); for (int i=0; i< header.count(); ++i) _temp.push_back(_query.value(i)); _data.push_back(_temp); lump++; }while ( lump < max_lump && _query.next() ); _isall = _query.next(); _row_count = _data.size(); //maybe we need to recalculate sums? if (!_isall && this->_totals) { if (_data.size()>0) { QVector < double > sums(_column_count,0); for (int j=0; j< _data.size(); ++j) for (int i=1; i< _column_count; ++i) if (_isCalc[i]) { if (!_neg) sums[i] += _data[j][i].toDouble(); else { if (_data[j][i].toDouble()>=0 && _neg == 1) sums[i] += _data[j][i].toDouble(); if (_data[j][i].toDouble()<0 && _neg == 2) sums[i] += _data[j][i].toDouble(); } } _temp[0]=""; for (int i=1; i< _column_count; ++i) { if (_isCalc[i]) _temp[i] = sums[i]; else _temp[i] = ""; } _data.push_back(_temp); _row_count++; } } // if (_grid->isAuto) emit layoutChanged(); //_grid->resizeRowsToContents(); }
Matrix4f CMatrixFactory::CreateTranslateMatrixZ( float dz ) { Matrix4f _temp = Matrix4f::Identity(); _temp(2,3) = dz; return _temp; }
Matrix4f CMatrixFactory::CreateTranslateMatrixY( float dy ) { Matrix4f _temp = Matrix4f::Identity(); _temp(1,3) = dy; return _temp; }
Matrix4f CMatrixFactory::CreateTranslateMatrixX( float dx ) { Matrix4f _temp = Matrix4f::Identity(); _temp(0,3) = dx; return _temp; }
HijriDate::HijriDate(uint32_t _date_abs) { this->date_abs = _date_abs; if (_date_abs >= __hijri_epoch) { HijriDate _temp(absolute_to_hijri(_date_abs)); this->date_y = _temp.date_y; this->date_m = _temp.date_m; this->date_d = _temp.date_d; } else { this->date_y = 0; this->date_m = 0; this->date_d = 0; } }
void Server::AcceptNuovoClient(void) throw(const char*){ TCPsocket new_client=SDLNet_TCP_Accept(this->server); if(new_client==NULL){ return; } if(this->connessioni.size()>MAX_CLIENT_ACTIVE){ //busy const char mess_busy[]="BUSY"; SDLNet_TCP_Send(new_client,mess_busy,strlen(mess_busy)); SDLNet_TCP_Close(new_client); new_client=NULL; }else{ //TODO: rivedere l'algoritmo! std::cout << "Nuova connessione accettata!\n"; std::cout << "\tID CLIENT: "<<this->count_id<<"\n\n"; Data_scriptClient _temp(this->count_id,NULL,new_client); this->connessioni.insert(std::pair<ID_Host,Data_scriptClient>(this->count_id,_temp)); this->connessioni[this->count_id].id_thread=SDL_CreateThread(Server::script_client, &this->connessioni[this->count_id]); this->count_id++; } }
Resolution loadResFromFile(const std::string& __str) { std::ifstream _file; _file.open(__str); if (!_file.is_open()) throw std::string("blad!"); std::string _temp(""); std::getline(_file, _temp); std::string _n1; std::string _n2; bool first = true; for (char c : _temp) { if (c == ' ') { first = false; continue; } if (first) _n1 += c; else _n2 += c; } uint _n1_i, _n2_i; std::istringstream iss(_n1); iss >> _n1_i; std::istringstream iss_2(_n2); iss_2 >> _n2_i; Resolution r; r.w = _n1_i; r.h = _n2_i; return r; }
bool LAP_SQLModel::setQuery(QString sqlQuery, bool totals, int neg, int colr) { _query.clear(); //_query.setForwardOnly(true); for (int i=0; i< _data.size(); ++i) _data[i].clear(); _data.clear(); _row_count = _column_count = 0; mhead.clear(); bool ok = _query.exec(sqlQuery); if (!ok) { error = _query.lastError(); return false; } QSqlRecord _record = _query.record(); header.clear(); _isCalc.clear(); _isCalc.resize(_record.count()); _neg = neg; _colr = colr; for (int i=0; i< _record.count(); ++i) { header << _grid->LAP_Columns[i].caption; mhead[_grid->LAP_Columns[i].name] = i; if (_grid->LAP_Columns[i].isc && (_record.field(i).type() == QVariant::Int || _record.field(i).type() == QVariant::Double)) _isCalc[i] = true; } QVector <QVariant> _temp(_record.count()); int lump = 0; while ( lump < max_lump && _query.next() ) { for (int i=0; i< header.count(); ++i) _temp[i] = _query.value(i); _data.push_back(_temp); lump++; } _isall = _query.next(); _column_count = _record.count(); _totals=totals; if (totals && !_isall) { if (_data.size()>0) { QVector < double > sums(_column_count,0); for (int j=0; j< _data.size(); ++j) for (int i=1; i< _column_count; ++i) if (_isCalc[i]) { if (_neg == 0) sums[i] += _data[j][i].toDouble(); else { if (_data[j][i].toDouble()>=0 && _neg == 1) sums[i] += _data[j][i].toDouble(); if (_data[j][i].toDouble()<0 && _neg == 2) sums[i] += _data[j][i].toDouble(); } } _temp[0]=""; for (int i=1; i< _column_count; ++i) { if (_isCalc[i]) _temp[i] = sums[i]; else _temp[i] = ""; } _data.push_back(_temp); } } _row_count = _data.size(); reset(); return true; }