Commit 76041d45 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

introduced historical view

parent 56f5cd79
...@@ -316,7 +316,7 @@ void Alarm::onItemDoubleClicked(const QModelIndex &mi) { ...@@ -316,7 +316,7 @@ void Alarm::onItemDoubleClicked(const QModelIndex &mi) {
} }
void Alarm::tabChanged(int t) { void Alarm::tabChanged(int t) {
if(t == 2 && ui->twHistory->model()->rowCount() == 0) if(t == 2)
queryDB(); queryDB();
if(t > 1) { if(t > 1) {
ui->pBAckAll->setHidden(true); ui->pBAckAll->setHidden(true);
...@@ -386,8 +386,8 @@ void Alarm::queryDB() ...@@ -386,8 +386,8 @@ void Alarm::queryDB()
for(i = 1; i < m_handlers.size(); i++) for(i = 1; i < m_handlers.size(); i++)
ored_handlers += " OR att_name LIKE '%" + m_handlers[i] + "%' "; ored_handlers += " OR att_name LIKE '%" + m_handlers[i] + "%' ";
if(startSearch.isValid()) { if(startSearch.isValid()) {
query = QString("SELECT asd.data_time,ac.att_name, " query = QString("SELECT asd.data_time AS 'Date/Time',ac.att_name AS 'Alarm', "
"COALESCE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(asd.value_r,'0','NORMAL'),'1','ALARM UNACK'),'2','ALARM ACKED'),'3','RETURNED NORMAL'),'4','SHELVED'),'6','DISABLED'),aed.error_desc) as value_r " "COALESCE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(asd.value_r,'0','NORMAL'),'1','ALARM UNACK'),'2','ALARM ACKED'),'3','RETURNED NORMAL'),'4','SHELVED'),'6','DISABLED'),aed.error_desc) AS 'Status' "
"FROM att_scalar_devenum_ro asd " "FROM att_scalar_devenum_ro asd "
"JOIN att_conf ac ON asd.att_conf_id=ac.att_conf_id " "JOIN att_conf ac ON asd.att_conf_id=ac.att_conf_id "
"LEFT OUTER JOIN att_error_desc aed ON aed.att_error_desc_id=asd.att_error_desc_id " "LEFT OUTER JOIN att_error_desc aed ON aed.att_error_desc_id=asd.att_error_desc_id "
...@@ -395,8 +395,8 @@ void Alarm::queryDB() ...@@ -395,8 +395,8 @@ void Alarm::queryDB()
"AND asd.data_time > '%2' ORDER BY asd.data_time DESC;").arg(ored_handlers).arg(startSearch.toString("yyyy-MM-dd hh:mm:ss.zzz")); "AND asd.data_time > '%2' ORDER BY asd.data_time DESC;").arg(ored_handlers).arg(startSearch.toString("yyyy-MM-dd hh:mm:ss.zzz"));
} }
else if(dts.isValid() && dte.isValid() && dts < dte) { else if(dts.isValid() && dte.isValid() && dts < dte) {
query = QString("SELECT asd.data_time,ac.att_name, " query = QString("SELECT asd.data_time AS 'Date/Time',ac.att_name AS 'Alarm', "
"COALESCE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(asd.value_r,'0','NORMAL'),'1','ALARM UNACK'),'2','ALARM ACKED'),'3','RETURNED NORMAL'),'4','SHELVED'),'6','DISABLED'),aed.error_desc) as value_r " "COALESCE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(asd.value_r,'0','NORMAL'),'1','ALARM UNACK'),'2','ALARM ACKED'),'3','RETURNED NORMAL'),'4','SHELVED'),'6','DISABLED'),aed.error_desc) as AS 'Status' "
"FROM att_scalar_devenum_ro asd " "FROM att_scalar_devenum_ro asd "
"JOIN att_conf ac ON asd.att_conf_id=ac.att_conf_id " "JOIN att_conf ac ON asd.att_conf_id=ac.att_conf_id "
"LEFT OUTER JOIN att_error_desc aed ON aed.att_error_desc_id=asd.att_error_desc_id " "LEFT OUTER JOIN att_error_desc aed ON aed.att_error_desc_id=asd.att_error_desc_id "
......
...@@ -32,15 +32,21 @@ MySqlModel::MySqlModel(QObject *parent) : QSqlQueryModel(parent) ...@@ -32,15 +32,21 @@ MySqlModel::MySqlModel(QObject *parent) : QSqlQueryModel(parent)
QVariant MySqlModel::data(const QModelIndex &index, int role) const QVariant MySqlModel::data(const QModelIndex &index, int role) const
{ {
QVariant value = QSqlQueryModel::data(index, role); QVariant value = QSqlQueryModel::data(index, role);
// if (value.isValid() && role == Qt::DisplayRole) { if (value.isValid() && role == Qt::DisplayRole) {
// if (index.column() == 0) if (index.column() == 0) {
// { QDateTime data = value.toDateTime();
// QDateTime data; return data.toString("yyyy-MM-dd hh:mm:ss.zzz");
// double v = value.toDouble(); }
// data.setTime_t((int) v); else if(index.column() == 1) {
// data = data.addMSecs(1000 *(v - (int) v)); // remove long fully qualified name
// return data.toString("d MMM yyyy hh:mm:ss.zzz"); QRegularExpression re("[tango://]*(.*):\\d+/(.*)");
// } QString s = value.toString();
// } QRegularExpressionMatch ma = re.match(s);
if(ma.capturedTexts().size() > 2) {
s = "[" + ma.capturedTexts().at(1).section('.', 0, 0) + "] " + ma.capturedTexts()[2];
return s;
}
}
}
return value; return value;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment