3
LogModel::LogModel(DataProxy_SQLite *dp, QObject *parent):QSqlRelationalTableModel(parent)
5
//qDebug() << "LogModel::LogModel " << endl;
6
//logModel = new QSqlRelationalTableModel(this);
9
setEditStrategy(QSqlTableModel::OnFieldChange);
10
//qDebug() << "LogModel::LogModel - END" << endl;
14
void LogModel::createlogModel(const int _i)
24
setRelation ( int column, const QSqlRelation & relation )
26
model->setTable("employee");
27
model->setRelation(2, QSqlRelation("city", "id", "name"));
29
The setRelation() call specifies that column 2 in table employee
30
is a foreign key that maps with field id of table city, and that
31
the view should present the city's name field to the user.
36
This should be coherent with the logview
39
//qDebug() << "LogModel::createlogModel: log: " << QString::number(_i) << endl;
41
//QString contestMode = dataProxy->getLogTypeOfUserLog(_i);
44
QString stringQuery = QString("lognumber='%1'").arg(_i);
45
QSqlQuery query(stringQuery);
46
setFilter(stringQuery);
51
//if (contestMode.compare("DX"))
52
if (contestMode == "DX")
54
//qDebug() << "LogModel::createlogModel: found type DX" << endl;
57
else if (contestMode == "CQ-WW-SSB")
59
//qDebug() << "LogModel::createlogModel: found type CQ-WW-SSB" << endl;
63
// THIS POINT SHOULD NOT BE REACHED. It means that there is a kind of contest not supported.
64
// Maybe the way should be to move ALL the actions from DX here.
65
//qDebug() << "LogModel::createlogModel: log type NOT found" << endl;
74
void LogModel::setColumnsToDX()
76
//qDebug() << "LogModel::setColumnsToDX" << endl;
79
QString stringQuery = QString("SELECT * from log LIMIT 1");
80
QSqlRecord rec; // = q.record();
84
bool sqlOK = q.exec(stringQuery);
87
emit queryError(Q_FUNC_INFO, q.lastError().databaseText(), q.lastError().number(), q.lastQuery());
91
rec = q.record(); // Number of columns
93
//qDebug() << "LogModel::createlogModel - columns: " << QString::number(rec.count()) << endl;
95
nameCol = rec.indexOf("bandid");
96
setRelation(nameCol, QSqlRelation("band", "id", "name"));
98
nameCol = rec.indexOf("modeid");
99
setRelation(nameCol, QSqlRelation("mode", "id", "submode"));
101
nameCol = rec.indexOf("id");
102
setSort(nameCol, Qt::AscendingOrder);
104
nameCol = rec.indexOf("qso_date");
105
setHeaderData(nameCol, Qt::Horizontal, tr("Date"));
107
nameCol = rec.indexOf("call");
108
setHeaderData(nameCol, Qt::Horizontal,tr("QRZ"));
110
nameCol = rec.indexOf("bandid");
111
setHeaderData(nameCol, Qt::Horizontal, tr("Band"));
113
nameCol = rec.indexOf("modeid");
114
setHeaderData(nameCol, Qt::Horizontal, tr("Mode"));
116
nameCol = rec.indexOf("rst_sent");
117
setHeaderData(nameCol, Qt::Horizontal, tr("RSTtx"));
119
nameCol = rec.indexOf("rst_rcvd");
120
setHeaderData(nameCol, Qt::Horizontal, tr("RSTrx"));
122
nameCol = rec.indexOf("comment");
123
setHeaderData(nameCol, Qt::Horizontal, tr("Comment"));