~phablet-team/history-service/optimize_dbus_traffic

« back to all changes in this revision

Viewing changes to plugins/sqlite/sqlitehistorythreadview.cpp

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2017-02-07 18:09:16 UTC
  • Revision ID: renato.filho@canonical.com-20170207180916-2p4r0vge6740bnod
Create unit test for multiple fields sort query.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    QString condition = mPlugin->filterToString(filter, filterValues);
44
44
    QString order;
45
45
    if (!sort.sortField().isNull()) {
46
 
        order = QString("ORDER BY %1 %2").arg(sort.sortField(), sort.sortOrder() == Qt::AscendingOrder ? "ASC" : "DESC");
 
46
        // WORKAROUND: Supports multiple fields by split it using ','
 
47
        // The idea is to implement a list of sort from the top of the API
 
48
        Q_FOREACH(const QString& field, sort.sortField().split(",")) {
 
49
            order += QString("%1 %2, ")
 
50
                    .arg(field.trimmed())
 
51
                    .arg(sort.sortOrder() == Qt::AscendingOrder ? "ASC" : "DESC");
 
52
        }
 
53
 
 
54
        order = QString("ORDER BY %1").arg(order.mid(0, order.lastIndexOf(",")));
47
55
        // FIXME: check case sensitiviy
48
56
    }
49
57