void CVoxSQLite::InsertGroups( const char* username, Groups& rList ) { for ( Groups::iterator iter = rList.begin(); iter != rList.end(); iter++ ) { InsertGroup( username, (*iter) ); } }
void WorkSheetModel::generateData(const bool &cancelLoad) { static int numOfLineChecksCalled = 0; static int numOfLines = 250; QString name; QString mbName; QMessage *qmessage; Message *message; MessageBase *header; MessageBase *trailer; BaseField *baseField; QBaseEntry *tableHeader; GroupBase *groupBase; FieldTrait::FieldType ft; char c[60]; int fieldID; int rowPos = 0; int colPos = 0; quint32 sortRole = Qt::UserRole + 2; setSortRole(sortRole); setRowCount(0); if (!tableSchema) { qWarning() << "Unable to generate data - table schema is null" << __FILE__ << __LINE__; return; } if (!tableSchema->fieldList) { qWarning() << "Unable to generate data - field list is null" << __FILE__ << __LINE__; setColumnCount(0); return; } if (!messageList) { qWarning() << "Unable to generate data - message list is null" << __FILE__ << __LINE__; return; } setColumnCount(tableSchema->fieldList->count()); QColor modBGColor; // = QColor(255,214,79,100); // This is a list of messages read in from file QListIterator <QMessage *> mIter(*messageList); // this is the fields user selected that they want displayed QListIterator <QBaseEntry *> tableHeaderIter(*(tableSchema->fieldList)); bool modifyBackgroundColor; QElapsedTimer myTimer; myTimer.start(); int messageCount = messageList->count(); //setRowCount(messageCount); while(mIter.hasNext()) { if ((rowPos%numOfLines) == 0) { // every 100 iterations allow gui to process events numOfLineChecksCalled++; if (numOfLineChecksCalled > 5) numOfLines = 1000; if (cancelLoad) { qDebug() << "CANCEL LOAD IN GENERATE DATA " << __FILE__ << __LINE__; return; } /* WorkSheet *w = qobject_cast <WorkSheet *> (parent()); if (w) { w->setUpdatesEnabled(true); w->updateTable(); w->update(); qApp->processEvents(QEventLoop::WaitForMoreEvents,100); w->setUpdatesEnabled(false); } */ } qmessage = mIter.next(); QString senderID = qmessage->senderID; //qDebug() << ">>>>>>>>>>>>> MESSAGE LIST COUNT = " << messageList->count() << __FILE__ << __LINE__; // qDebug() << "Look for sender id = " << senderID << __FILE__ << __LINE__; if (messageList->senderColorMap.contains(qmessage->senderID) ) { modBGColor =messageList->senderColorMap.value(qmessage->senderID); modifyBackgroundColor = true; } else modifyBackgroundColor = false; QVariant var; var.setValue((void *) qmessage); message = qmessage->mesg; header = message->Header(); trailer = message->Trailer(); tableHeaderIter.toFront(); colPos = 0; bool found; QList <QStandardItem *>items; while(tableHeaderIter.hasNext()) { found = false; tableHeader = tableHeaderIter.next(); fieldID = tableHeader->ft->_fnum; if (header) { BaseField *bf = header->get_field(fieldID); if (bf) { ft = bf->get_underlying_type(); memset(c,'\0',60); bf->print(c); if (FieldTrait::is_int(ft)) { int ival(static_cast<Field<int, 0>*>(bf)->get()); //qDebug() << tableHeader->name << ", field id = " << fieldID << ", value = " << ival; IntItem *intItem = new IntItem(ival); //QStandardItem *intItem = new QStandardItem(QString::number(ival)); //intItem->setData(ival,Qt::UserRole); intItem->setData(senderID,senderIDRole); intItem->setData(var); intItem->setData(ival,sortRole); if (modifyBackgroundColor) intItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,intItem); items.append(intItem); found = true; } else if (FieldTrait::is_float(ft)) { qDebug() << "WORK WITH FLOAT" << __FILE__ << __LINE__; double fval(static_cast<Field<double, 0>*>(bf)->get()); found = true; } else if (FieldTrait::is_string(ft)) { memset(c,'\0',60); bf->print(c); QLatin1Literal ll(c); QStandardItem *strItem = new QStandardItem(QString(ll)); strItem->setData(senderID,senderIDRole); strItem->setData(var); strItem->setData(ll,sortRole); if (modifyBackgroundColor) strItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,strItem); items.append(strItem); found = true; } else if (FieldTrait::is_char(ft)) { QChar ch(static_cast<Field<char, 0>*>(bf)->get()); QString cstr = ch.decomposition(); QStandardItem *charItem = new QStandardItem(cstr); charItem->setData(senderID,senderIDRole); charItem->setData(var); charItem->setData(cstr,sortRole); if (modifyBackgroundColor) charItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,charItem); items.append(charItem); found = true; } } } if (message) { BaseField *bfm = message->get_field(fieldID); if (bfm) { ft = bfm->get_underlying_type(); memset(c,'\0',60); bfm->print(c); if (FieldTrait::is_int(ft)) { int ival(static_cast<Field<int, 0>*>(bfm)->get()); //qDebug() << tableHeader->name << ", field id = " << fieldID << ", value = " << ival; IntItem *intItem = new IntItem(ival); intItem->setData(senderID,senderIDRole); intItem->setData(var); intItem->setData(ival,sortRole); if (modifyBackgroundColor) intItem->setData(modBGColor, Qt::BackgroundRole); // setItem(rowPos,colPos,intItem); items.append(intItem); found = true; } else if (FieldTrait::is_float(ft)) { qDebug() << "WORK WITH FLOAT" << __FILE__ << __LINE__; double fval(static_cast<Field<double, 0>*>(bfm)->get()); found = true; } else if (FieldTrait::is_string(ft)) { memset(c,'\0',60); bfm->print(c); QStandardItem *strItem = new QStandardItem(QLatin1Literal(c)); strItem->setData(senderID,senderIDRole); strItem->setData(QLatin1Literal(c),sortRole); strItem->setData(var); if (modifyBackgroundColor) strItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,strItem); items.append(strItem); found = true; } else if (FieldTrait::is_char(ft)) { QChar ch(static_cast<Field<char, 0>*>(bfm)->get()); QString cstr = ch.decomposition(); QStandardItem *charItem = new QStandardItem(cstr); charItem->setData(senderID,senderIDRole); charItem->setData(cstr,sortRole); charItem->setData(var); if (modifyBackgroundColor) charItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,charItem); items.append(charItem); found = true; } } //else // qWarning() << "BASE FIELD = NULL FOR HEADER" << __FILE__ << __LINE__; Groups groups = message->get_groups(); std::map<unsigned short,GroupBase *>::iterator iterGrps; for(iterGrps = groups.begin(); iterGrps != groups.end(); iterGrps++) { groupBase = iterGrps->second; int size = groupBase->size(); for(int i=0;i<size;i++) { MessageBase *mb = groupBase->get_element(i); mbName = QString::fromStdString(mb->get_msgtype()); BaseField *bfg = mb->get_field(fieldID); if (bfg) { ft = bfg->get_underlying_type(); memset(c,'\0',60); bfg->print(c); if (FieldTrait::is_int(ft)) { int ival(static_cast<Field<int, 0>*>(bfg)->get()); //qDebug() << tableHeader->name << ", field id = " << fieldID << ", value = " << ival; IntItem *intItem = new IntItem(ival); intItem->setData(senderID,senderIDRole); intItem->setData(ival,sortRole); intItem->setData(var); if (modifyBackgroundColor) intItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,intItem); items.append(intItem); found = true; } else if (FieldTrait::is_float(ft)) { qDebug() << "WORK WITH FLOAT" << __FILE__ << __LINE__; double fval(static_cast<Field<double, 0>*>(bfg)->get()); found = true; } else if (FieldTrait::is_string(ft)) { memset(c,'\0',60); bfg->print(c); QStandardItem *strItem = new QStandardItem(QLatin1Literal(c)); strItem->setData(senderID,senderIDRole); strItem->setData(QLatin1Literal(c),sortRole); strItem->setData(var); if (modifyBackgroundColor) strItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,strItem); items.append(strItem); found = true; } else if (FieldTrait::is_char(ft)) { QChar ch(static_cast<Field<char, 0>*>(bfm)->get()); QString cstr = ch.decomposition(); QStandardItem *charItem = new QStandardItem(cstr); charItem->setData(senderID,senderIDRole); charItem->setData(cstr,sortRole); charItem->setData(var); if (modifyBackgroundColor) charItem->setData(modBGColor, Qt::BackgroundRole); // setItem(rowPos,colPos,charItem); items.append(charItem); found = true; } } // else // qWarning() << "BASE FIELD = NULL FOR GROUP" << __FILE__ << __LINE__; // qDebug() << "\t\tHave Message Named: " + mbName; } } } if (trailer) { BaseField *bft = trailer->get_field(fieldID); if (bft) { ft = bft->get_underlying_type(); memset(c,'\0',60); bft->print(c); if (FieldTrait::is_int(ft)) { int ival(static_cast<Field<int, 0>*>(bft)->get()); IntItem *intItem = new IntItem(ival); intItem->setData(senderID,senderIDRole); intItem->setData(ival,sortRole); intItem->setData(var); if (modifyBackgroundColor) intItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,intItem); items.append(intItem); found = true; } else if (FieldTrait::is_float(ft)) { qDebug() << "WORK WITH FLOAT" << __FILE__ << __LINE__; double fval(static_cast<Field<double, 0>*>(bft)->get()); found = true; } else if (FieldTrait::is_string(ft)) { memset(c,'\0',60); bft->print(c); QStandardItem *strItem = new QStandardItem(QLatin1Literal(c)); strItem->setData(senderID,senderIDRole); strItem->setData(var); strItem->setData(QLatin1Literal(c),sortRole); if (modifyBackgroundColor) strItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,strItem); items.append(strItem); found = true; } else if (FieldTrait::is_char(ft)) { QChar ch(static_cast<Field<char, 0>*>(bft)->get()); QString cstr = ch.decomposition(); QStandardItem *charItem = new QStandardItem(cstr); charItem->setData(senderID,senderIDRole); charItem->setData(var); charItem->setData(cstr,sortRole); if (modifyBackgroundColor) charItem->setData(modBGColor, Qt::BackgroundRole); // setItem(rowPos,colPos,charItem); items.append(charItem); found = true; } } //else // qWarning() << "BASE FIELD = NULL FOR TRAILER" << __FILE__ << __LINE__; } if (!found) { //qDebug() << "**************** NOT FOUND **********************" << colPos << __FILE__ << __LINE__; // create a dummmy item, so color of row can be uniform across; QStandardItem *dummyItem = new QStandardItem(""); dummyItem->setData(senderID,senderIDRole); dummyItem->setData(var); if (modifyBackgroundColor) dummyItem->setData(modBGColor, Qt::BackgroundRole); //setItem(rowPos,colPos,dummyItem); items.append(dummyItem); } colPos++; } appendRow(items); rowPos++; } int nMilliseconds = myTimer.elapsed(); //qDebug() << "TIME TO LOAD = " << nMilliseconds; }
actor spawn_in_groups(const Groups& gs, F fun, Ts&&... xs) { actor_config cfg{context()}; return eval_opts(Os, system().spawn_in_groups_impl<make_unbound(Os)>(cfg, gs.begin(), gs.end(), fun, std::forward<Ts>(xs)...)); }