…
//CREATE & EXECUTE QUERY
queryAlarms.exec(“SELECT …â€);
//FULFIL TEXT TABLE WITH RECORDS
FulfilTableWithRecords (queryAlarms, cursor, texttableTable, formatCellFormat2);
…
{
double doubleValue;
while(queryAlarms.next())
{
//INSERT ROW IN THE TABLE
texttableTable->appendRows(1);
//GET ONE RECORD
record = queryAlarms.record();
//GET FIELDS FROM THE RECORD
strAlarmTime = record.value(0).toString();
strAckTime = record.value(1).toString();
strReturnTime = record.value(2).toString();
strTagName = record.value(3).toString();
doubleValue = record.value(4).toDouble();
strLimit = record.value(5).toString();
strKomentar1 = record.value(6).toString();
strAckOperatorName = record.value(7).toString();
strKomentar2 = record.value(8).toString();
//CHANGE TIME FORMAT. "2010-07-27T07:27:27" to "2010-07-27 07:27:27"
strAlarmTime.replace("T", " ");
strAckTime.replace("T", " ");
strReturnTime.replace("T", " ");
//FULFIL ONE ROW IN THE TABLE
cursor.insertText(strAlarmTime, formatCellFormat2);
cursor.insertText(strAckTime, formatCellFormat2);
cursor.insertText(strReturnTime, formatCellFormat2);
cursor.insertText(strTagName, formatCellFormat2);
cursor.insertText(tr("%1").arg(doubleValue), formatCellFormat2);
cursor.insertText(strLimit, formatCellFormat2);
cursor.insertText(strKomentar1, formatCellFormat2);
cursor.insertText(strAckOperatorName, formatCellFormat2);
cursor.insertText(strKomentar2, formatCellFormat2);
}
}
…
//CREATE & EXECUTE QUERY
QSqlQuery queryAlarms;
queryAlarms.exec(“SELECT …â€);
//FULFIL TEXT TABLE WITH RECORDS
FulfilTableWithRecords (queryAlarms, cursor, texttableTable, formatCellFormat2);
…
void AlarmsEditor::FulfilTableWithRecords (QSqlQuery queryAlarms, QTextCursor cursor, QTextTable* texttableTable, QTextCharFormat formatCellFormat2)
{
QSqlRecord record;
QString strAlarmTime;
QString strAckTime;
QString strReturnTime;
QString strTagName;
double doubleValue;
QString strLimit;
QString strKomentar1;
QString strAckOperatorName;
QString strKomentar2;
while(queryAlarms.next())
{
//INSERT ROW IN THE TABLE
texttableTable->appendRows(1);
//GET ONE RECORD
record = queryAlarms.record();
//GET FIELDS FROM THE RECORD
strAlarmTime = record.value(0).toString();
strAckTime = record.value(1).toString();
strReturnTime = record.value(2).toString();
strTagName = record.value(3).toString();
doubleValue = record.value(4).toDouble();
strLimit = record.value(5).toString();
strKomentar1 = record.value(6).toString();
strAckOperatorName = record.value(7).toString();
strKomentar2 = record.value(8).toString();
//CHANGE TIME FORMAT. "2010-07-27T07:27:27" to "2010-07-27 07:27:27"
strAlarmTime.replace("T", " ");
strAckTime.replace("T", " ");
strReturnTime.replace("T", " ");
//FULFIL ONE ROW IN THE TABLE
cursor.insertText(strAlarmTime, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strAckTime, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strReturnTime, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strTagName, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("%1").arg(doubleValue), formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strLimit, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strKomentar1, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strAckOperatorName, formatCellFormat2);
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(strKomentar2, formatCellFormat2);
cursor.movePosition(QTextCursor::NextRow);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks