UIPF SDK manual

Introduction

WIP Notes

The main

The “main” is launched from file uipf.cc. @line 109, and follow these steps:

Main window

The WindowMain class actually manage the application. When created from the main (uipf.cc) it launch the constructor with he following steps (NOTE: order things get done is important):

Persistency

The persistency database is queried in different place:

  1. Population of tables in the detail view panel tabs (WindowsMain.cc @line 495-502)

         #if defined(Q_OS_WIN) && (!defined(SQLITE))
           tablewInput_ = new WidgetTableDouble(" AND QTBL.input = true", undoStack_);
         intTablewInput_ = new WidgetTableIntegers(" AND ITBL.tag like '%enableAssignment%'", undoStack_);
         tablewOutput_ = new WidgetTableDouble(" AND QTBL.output = true", undoStack_);
        #else
         tablewInput_ = new WidgetTableDouble(" AND QTBL.input = \'1\'", undoStack_);
         intTablewInput_ = new WidgetTableIntegers(" AND ITBL.tag like '%enableAssignment%'", undoStack_);
         tablewOutput_ = new WidgetTableDouble(" AND QTBL.output = \'1\'", undoStack_);
        #endif
    
  2. In DialogOpen::addItem

         QSqlDatabase db = QSqlDatabase::database("persistency");
         QSqlQuery query(db);
     QString querystring = QString("select tag, description, id from N where type = \'%1\'").arg(type);
     query.exec(querystring);
    
  3. In void ActionLibpf::getErrorsWarnings to get warnings and errors after kernel computation:

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
    
           QString querystring;
         #if defined SQLITE
           querystring = "SELECT warn.warnings, err.errors FROM (select ITBL.catalogid as catalogid, ITBL.i as warnings from ITBL where tag = \'nWarnings\') as warn join (select ITBL.catalogid as catalogid, ITBL.i as errors from ITBL where tag = \'nErrors\') as err join CATALOG on CATALOG.id = warn.catalogid and CATALOG.id = err.catalogid and CATALOG.id = ?";
         #else
           querystring = "SELECT distinct ITBL.I as warnings, itbl2.I as errors FROM ((CATALOG inner join ITBL on CATALOG.id = ITBL.catalogid) inner join ITBL as itbl2 on CATALOG.id = itbl2.catalogid) WHERE CATALOG.id = ? and ITBL.tag = \'nWarnings\' and itbl2.tag = \'nErrors\'";
         #endif
    
  4. In ModelIntegerEditable::go used by CommandDataSetInteger and WidgetTableIntegers to set and update integer table in the detail view panel

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
         #if defined(Q_OS_WIN) && (!defined(SQLITE))
           query.exec(QString("select completetag from CATALOG where id = %1").arg(node));
         #else
           query.exec(QString("select trim(completetag) from CATALOG where id = %1").arg(node));
         #endif
           query.next();
           prefix_ = query.value(0).toString().toStdString();
           strip_ = prefix_.length();
           // qDebug() << strip_;
    
           QString qs;
           if (child_) {
         #if defined SQLITE
             qs = "SELECT distinct substr(CATALOG.completetag||\'.\'||ITBL.tag,%3+2), ITBL.i, ITBL.DESCRIPTION, ITBL.ID FROM "
                  "ITBL join (select TC.finish as finish, TC.start as start from TC where TC.start = %1 or TC.finish = %1) as mytc join CATALOG on CATALOG.id = ITBL.catalogid and (CATALOG.id = mytc.finish or CATALOG.id = mytc.start) %2 order by ITBL.ID";
         #elif defined Q_OS_WIN
             qs = "select distinct right(CATALOG.completetag+\'.\'+ITBL.tag, len(CATALOG.completetag)+1+len(ITBL.tag)-%3-1), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(TC inner join (ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by ITBL.ID";
         #elif defined MYSQL
             qs = "select distinct substring(concat(CATALOG.completetag,\'.\',ITBL.tag) from (%3+2)), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(TC inner join (ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by ITBL.ID";
         #elif defined POSTGRESQL
             // Added by StoianE postgres+linux
             qs = "select distinct substring(CATALOG.completetag||\'.\'||ITBL.tag from (%3+2)), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(TC inner join (ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by ITBL.ID";
         #endif
           } else {
         #if defined SQLITE
             qs = "SELECT substr(CATALOG.completetag||\'.\'||ITBL.tag,%3+2), ITBL.i, ITBL.DESCRIPTION, ITBL.ID FROM "
                  "ITBL join CATALOG on CATALOG.id = ITBL.catalogid where (CATALOG.id = %1) %2 order by ITBL.ID";
         #elif defined Q_OS_WIN
             qs = "select distinct right(CATALOG.completetag+\'.\'+ITBL.tag, len(CATALOG.completetag)+1+len(ITBL.tag)-%3-1), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by ITBL.ID";
         #elif defined MYSQL
             qs = "select distinct substring(concat(CATALOG.completetag,\'.\',ITBL.tag) from (%3+2)), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by ITBL.ID";
         #elif defined POSTGRESQL
             // Added by StoianE postgres+linux
             qs = "select distinct substring(CATALOG.completetag||\'.\'||ITBL.tag from (%3+2)), ITBL.i, ITBL.DESCRIPTION, ITBL.ID from "
                  "(ITBL inner join CATALOG on (ITBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by ITBL.ID";
         #endif
           }
    
  5. In ModelQuantityEditable::go used by CommandDataSetDouble and WidgetTableDouble to set and update double table in the detail view panel. The usage is for both input and output table: see point 1 (WindowsMain.cc @line 495-502) for the queries modifications.

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
           if (currentNode_ != node) {
             qDebug() << "ModelQuantityEditable::go" << node;
             qValue_.clear();
             uValue_.clear();
           }
           query.setNumericalPrecisionPolicy(QSql::LowPrecisionDouble);
         #if defined SQLITE
           query.exec(QString("select completetag from CATALOG where id = %1").arg(node));
         #else
           query.exec(QString("select trim(completetag) from CATALOG where id = %1").arg(node));
         #endif
           query.next();
           prefix_ = query.value(0).toString().toStdString();
           strip_ = prefix_.length();
           qDebug() << "complete tag = " << prefix_.c_str();
           // qDebug() << strip_;
    
           QString qs;
           if (child_) {
         #if defined SQLITE
             qs = "SELECT distinct substr(CATALOG.completetag||\'.\'||QTBL.tag,%3+2), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID FROM "
                  "QTBL join (select TC.finish as finish, TC.start as start from TC where TC.start = %1 or TC.finish = %1) as mytc join CATALOG on CATALOG.id = QTBL.catalogid and (CATALOG.id = mytc.finish or CATALOG.id = mytc.start) %2 order by QTBL.ID";
         #elif defined Q_OS_WIN
             qs = "select distinct right(CATALOG.completetag+\'.\'+QTBL.tag, len(CATALOG.completetag)+1+len(QTBL.tag)-%3-1), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(TC inner join (QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by QTBL.ID";
         #elif defined MYSQL
             qs = "select distinct substring(concat(CATALOG.completetag,\'.\',QTBL.tag) from (%3+2) ), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(TC inner join (QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by QTBL.ID";
         #elif defined POSTGRESQL
             // Added by StoianE postgres + linux
             qs = "select distinct substring(CATALOG.completetag||\'.\'||QTBL.tag from (%3+2)), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(TC inner join (QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) on ((TC.finish = CATALOG.id) or (CATALOG.id = %1))) "
                  "where ((TC.start = %1) or (CATALOG.id = %1)) %2 order by QTBL.ID";
         #endif
           } else {
         #if defined SQLITE
             qs = "SELECT substr(CATALOG.completetag||\'.\'||QTBL.tag, %3+2), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID FROM "
                  "QTBL join CATALOG on CATALOG.id = QTBL.catalogid where (CATALOG.id = %1) %2 order by QTBL.ID";
         #elif defined Q_OS_WIN
             qs = "select distinct right(CATALOG.completetag+\'.\'+QTBL.tag, len(CATALOG.completetag)+1+len(QTBL.tag)-%3-1), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by QTBL.ID";
         #elif defined MYSQL
             qs = "select distinct substring(concat(CATALOG.completetag,\'.\',QTBL.tag) from (%3+2)), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by QTBL.ID";
         #elif defined POSTGRESQL
             // Added by StoianE postgres + linux
             qs = "select distinct substring(CATALOG.completetag||\'.\'||QTBL.tag from (%3+2)), QTBL.Q, QTBL.UOM, QTBL.DESCRIPTION, QTBL.ID from "
                  "(QTBL inner join CATALOG on (QTBL.catalogid = CATALOG.id)) where (CATALOG.id = %1) %2 order by QTBL.ID";
         #endif
           }
           qs = qs.arg(node).arg(extraFilter_.c_str()).arg(strip_);
           // qDebug() << "Query in ModelQuantityEditable::go = " << qs;
           setQuery(qs, db);
           if (lastError().isValid())
             qDebug() << "Error while executing query in ModelQuantityEditable::go: " << lastError();
    
  6. In WidgetTableMessages::go used to set and update message table in the detail view panel

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
    
         #if defined(Q_OS_WIN) && (!defined(SQLITE))
           QString qs("select STBL.tag+\' \'+STBL.s from (STBL inner join CATALOG on (STBL.catalogid = CATALOG.id)) where ((CATALOG.id = %1) and ((STBL.tag like \'errorMsg%\') or (STBL.tag like \'warningMsg%\')))");
         #elif !defined(POSTGRESQL)
           QString qs("SELECT CONCAT(smsg.tag,\' \',smsg.s) FROM (select STBL.tag as tag, STBL.s as s, STBL.catalogid as catalogid from STBL where tag like \'errorMsg%\' or tag like \'warningMsg%\') as smsg join CATALOG on CATALOG.id = smsg.catalogid and CATALOG.id = %1");
         #else
           QString qs("SELECT smsg.tag||\' \'||smsg.s FROM (select STBL.tag as tag, STBL.s as s, STBL.catalogid as catalogid from STBL where tag like \'errorMsg%\' or tag like \'warningMsg%\') as smsg join CATALOG on CATALOG.id = smsg.catalogid and CATALOG.id = %1");
         #endif
    
           qs = qs.arg(node);
           model_->setQuery(qs, db);
           if (model_->lastError().isValid())
             qDebug() << "Error while executing query in WidgetTableMessages::go: " << model_->lastError();
           model_->setHeaderData(0, Qt::Horizontal, tr("Error/Warning message"));
    
  7. In WidgetTree::forceGo

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery queryItem(db);
    
           QString queryString;
         #if defined SQLITE
           queryString = "SELECT CATALOG.tag, CATALOG.type, CATALOG.description, CATALOG.parent, CATALOG.completetag, warn.warnings, err.errors FROM (select ITBL.catalogid as catalogid, ITBL.i as warnings from ITBL where tag = \'nWarnings\') as warn join (select ITBL.catalogid as catalogid, ITBL.i as errors from ITBL where tag = \'nErrors\') as err join CATALOG on CATALOG.id = warn.catalogid and CATALOG.id = err.catalogid and CATALOG.id = ?";
         #else
           queryString = "SELECT distinct CATALOG.tag, CATALOG.type, CATALOG.description, CATALOG.parent, CATALOG.completetag, ITBL.I as warnings, itbl2.I as errors FROM ((CATALOG inner join ITBL on CATALOG.id = ITBL.catalogid) inner join ITBL as itbl2 on CATALOG.id = itbl2.catalogid) WHERE CATALOG.id = ? and ITBL.tag = \'nWarnings\' and itbl2.tag = \'nErrors\'";
         #endif
           queryItem.prepare(queryString);
           queryItem.addBindValue(node);
           queryItem.exec();
    
  8. In WidgetTree::addChilds

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery queryChilds(db);
    
           QTreeWidgetItem* itemChild;
           queryChilds.prepare("SELECT i FROM ITBL WHERE tag like \'embedded%\' AND catalogid = ? ORDER BY id");
           queryChilds.addBindValue(cid);
           queryChilds.exec();
    
          ...
    
    
        #if defined SQLITE
              QString queryString("SELECT CATALOG.tag, CATALOG.type, CATALOG.description, warn.warnings, err.errors FROM (select ITBL.catalogid as catalogid, ITBL.i as warnings from ITBL where tag = \'nWarnings\') as warn join (select ITBL.catalogid as catalogid, ITBL.i as errors from ITBL where tag = \'nErrors\') as err join CATALOG on CATALOG.id = warn.catalogid and CATALOG.id = err.catalogid and CATALOG.id = ");
        #else
              QString queryString("SELECT distinct CATALOG.tag, CATALOG.type, CATALOG.description, ITBL.I as warnings, itbl2.I as errors FROM ((CATALOG inner join ITBL on CATALOG.id = ITBL.catalogid) inner join ITBL as itbl2 on CATALOG.id = itbl2.catalogid) WHERE ITBL.tag = \'nWarnings\' and itbl2.tag = \'nErrors\' and CATALOG.id = ");
        #endif
    
              queryString += QVariant(i).toString();
              query.exec(queryString);
    
  9. in DelegateControl constructor (DelegateControl.cc) used in WidgetTableControl for DialogSensitivity:

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
         #if defined SQLITE
           query.prepare("SELECT distinct QTBL.ID, CATALOG.completetag||\'.\'||QTBL.tag, QTBL.UOM, QTBL.DESCRIPTION, QTBL.tag, QTBL.Q FROM" \
                         " QTBL join (select TC.finish as finish, TC.start as start from TC where TC.start = ? or TC.finish = ?) as mytc" \
                         " join CATALOG on CATALOG.id = QTBL.catalogid and (CATALOG.id = mytc.finish or CATALOG.id = mytc.start) AND QTBL.input = 1");
         #elif defined Q_OS_WIN
           query.prepare("SELECT DISTINCT qtbl.id, catalog.completetag+\'.\'+QTBL.tag, qtbl.uom, qtbl.description, qtbl.tag, qtbl.q FROM" \
                         " ((SELECT finish, start FROM tc WHERE tc.start = ? OR tc.finish = ?) AS mytc INNER JOIN" \
                         " (qtbl INNER JOIN catalog ON (qtbl.catalogid = catalog.id AND qtbl.input = true)) on ((mytc.finish = catalog.id) or (mytc.start = catalog.id))) ORDER BY qtbl.id;");
    
         #else // postgres
           query.prepare("SELECT DISTINCT qtbl.id, catalog.completetag||\'.\'||qtbl.tag, qtbl.uom, qtbl.description, qtbl.tag, qtbl.q FROM " \
                         " ((SELECT finish, start FROM tc WHERE tc.start = ? OR tc.finish = ?) AS mytc INNER JOIN" \
                         "  (qtbl INNER JOIN catalog ON (qtbl.catalogid = catalog.id AND qtbl.input = true)) on ((mytc.finish = catalog.id) or (mytc.start = catalog.id))) ORDER BY qtbl.id;");
    
         #endif
    
  10. In DelegateMonitor constructor (DelegateMonitor.cc) used in WidgetTableMonitor for DialogSensitivity:

           QSqlDatabase db = QSqlDatabase::database("persistency");
           QSqlQuery query(db);
         #if defined SQLITE
           query.prepare("SELECT distinct qtbl.id, CATALOG.completetag||\'.\'||QTBL.tag, QTBL.UOM, QTBL.DESCRIPTION, QTBL.tag FROM " \
                         " QTBL join (select TC.finish as finish, TC.start as start from TC where TC.start = ? or TC.finish = ?) as mytc" \
                         " join CATALOG on CATALOG.id = QTBL.catalogid and (CATALOG.id = mytc.finish or CATALOG.id = mytc.start) and qtbl.output = 1");
         #elif defined Q_OS_WIN
           query.prepare("SELECT DISTINCT qtbl.id, catalog.completetag+\'.\'+qtbl.tag, qtbl.uom, qtbl.description, qtbl.tag FROM" \
                         " ((SELECT finish, start FROM tc WHERE tc.start = ? OR tc.finish = ?) AS mytc INNER JOIN (qtbl INNER JOIN catalog ON (qtbl.catalogid = catalog.id AND qtbl.output = true)) on ((mytc.finish = catalog.id) or (mytc.start = catalog.id))) ORDER BY qtbl.id;");
         #else // postgres
           query.prepare("SELECT DISTINCT qtbl.id, catalog.completetag||\'.\'||qtbl.tag, qtbl.uom, qtbl.description, qtbl.tag FROM" \
                         " ((SELECT finish, start FROM tc WHERE tc.start = ? OR tc.finish = ?) AS mytc INNER JOIN (qtbl INNER JOIN catalog ON (qtbl.catalogid = catalog.id AND qtbl.output = true)) on ((mytc.finish = catalog.id) or (mytc.start = catalog.id))) ORDER BY qtbl.id;");
         #endif