Public Slots | Public Member Functions

SqlQueryModel Class Reference

Extension of QSqlQueryModel class and used throughout the application. More...

#include <Database.h>

Inheritance diagram for SqlQueryModel:
Inheritance graph
[legend]
Collaboration diagram for SqlQueryModel:
Collaboration graph
[legend]

List of all members.

Public Slots

virtual void clear ()
void reQuery ()

Public Member Functions

 SqlQueryModel (QObject *parent=0)
bool contains (const QString &value, const int column=0) const
bool contains (const QMap< int, QString > &columnToStringMap) const

Detailed Description

Extension of QSqlQueryModel class and used throughout the application.


Constructor & Destructor Documentation

SqlQueryModel::SqlQueryModel ( QObject parent = 0  ) 

                                                      : QSqlQueryModel(parent)
{
    // Required by QSqlHelper because it can not inherit QObject and connect in it's constructor.
    QObject::connect(Database::instance(), SIGNAL(tableChanged(QString)),
                     this, SLOT(onTableChange(QString)), Qt::QueuedConnection);
};


Member Function Documentation

void SqlQueryModel::clear (  )  [virtual, slot]
bool SqlQueryModel::contains ( const QMap< int, QString > &  columnToStringMap  )  const

{
    QMap<int, QString>::const_iterator i;
    if (!query().isActive()) return false ;
    Q_ASSERT(query().isSelect());
    query().first();
    if (!query().isValid()) return false; //betekent dat de query leeg is waarschijnlijk

    do {
        bool flag = true;
        for (i = columnToStringMap.constBegin(); i != columnToStringMap.constEnd(); i++){
            //qDebug() << "COMPARING: " << i.value() << " " << query().value(i.key()).toString();
            if (0 != QString::localeAwareCompare(i.value(), query().value(i.key()).toString()))
                flag = false;
        }
        if (flag == true) return true;
    } while (query().next());
    return false;
}

bool SqlQueryModel::contains ( const QString value,
const int  column = 0 
) const

Referenced by FileSelectionModel::data().

{
    QMap<int, QString> columnToStringMap;
    columnToStringMap.insert(column, value);
    return contains(columnToStringMap);
}

void SqlQueryModel::reQuery (  )  [slot]

Reimplemented in CalibrationsModel.

Referenced by SensorUnitEditor::onAddButtonPress().

{
    beginResetModel();//crash qlist assert !isempty() wanneer geen reset gebeurt: waarschijnlijk omdat selectie aanblijft en die gebruikmaakt van QList
    setQuery(query().lastQuery(), Database::staticCon());
    //setQuery(query()) werkt voor een of andere rede niet... er komt geen verandering in de view, nochtans lijkt het een betere manier
    //mischien nog eens executen???? query.exec en dan setQuery??
    endResetModel();
}


The documentation for this class was generated from the following files: