radioapp/radiouiengine/src/radiohistorymodel_p.cpp
changeset 51 bbebb0235466
parent 34 bc10a61bd7d3
child 54 a8ba0c289b44
equal deleted inserted replaced
47:74b7c6e79031 51:bbebb0235466
    31 #include "radiohistoryitem.h"
    31 #include "radiohistoryitem.h"
    32 #include "radiohistoryitem_p.h"
    32 #include "radiohistoryitem_p.h"
    33 #include "radiostation.h"
    33 #include "radiostation.h"
    34 #include "radiologger.h"
    34 #include "radiologger.h"
    35 
    35 
    36 static const QLatin1String DATABASE_NAME    ( "radioplayhistory.db" );
    36 static const QLatin1String DATABASE_NAME    ( "c:\\radioplayhistory.db" );
    37 static const QLatin1String DATABASE_DRIVER  ( "QSQLITE" );
    37 static const QLatin1String DATABASE_DRIVER  ( "QSQLITE" );
    38 static const QLatin1String HISTORY_TABLE    ( "history" );
    38 static const QLatin1String HISTORY_TABLE    ( "history" );
    39 static const QLatin1String SQL_CREATE_TABLE ( "CREATE TABLE history ("
    39 static const QLatin1String SQL_CREATE_TABLE ( "CREATE TABLE history ("
    40                                                 "id INTEGER PRIMARY KEY AUTOINCREMENT, "
    40                                                 "id INTEGER PRIMARY KEY AUTOINCREMENT, "
    41                                                 "artist TEXT NOT NULL, "
    41                                                 "artist TEXT NOT NULL, "
   185     if ( mQueryModel->lastError().type() == QSqlError::NoError ) {
   185     if ( mQueryModel->lastError().type() == QSqlError::NoError ) {
   186 
   186 
   187         QSqlRecord record = mQueryModel->record( row );
   187         QSqlRecord record = mQueryModel->record( row );
   188         if ( role == Qt::DisplayRole ) {
   188         if ( role == Qt::DisplayRole ) {
   189 
   189 
   190             const QString artist = record.value( RadioHistoryValue::Artist ).toString();
   190             QString artist = record.value( RadioHistoryValue::Artist ).toString();
       
   191             if ( artist.isEmpty() ) {
       
   192                 artist = qtTrId( "txt_rad_dblist_unknown" );
       
   193             }
       
   194 
   191             const QString title = record.value( RadioHistoryValue::Title ).toString();
   195             const QString title = record.value( RadioHistoryValue::Title ).toString();
   192             const QString station = record.value( RadioHistoryValue::Station ).toString();
   196             const QString station = record.value( RadioHistoryValue::Station ).toString();
   193             const uint frequency = record.value( RadioHistoryValue::Frequency ).toUInt() * 1000;
   197             const uint frequency = record.value( RadioHistoryValue::Frequency ).toUInt() * 1000;
   194 
   198 
   195             QStringList list;
   199             QStringList list;
   196             if ( mShowDetails ) {
   200             if ( mShowDetails ) {
   197                 QString formatter = qtTrId( "txt_rad_dblist_1_2" );
   201                 QString formatter = qtTrId( "txt_rad_dblist_1_2" );
   198                 LOG_FORMAT( "---formatter--- %s", GETSTRING( formatter ) );
   202                 LOG_FORMAT( "---formatter--- %s", GETSTRING( formatter ) );
   199                 formatter = "%1 - %2";  // TODO!
       
   200 
   203 
   201                 const QString firstRow = QString( formatter ).arg( artist ).arg( title );
   204                 const QString firstRow = QString( formatter ).arg( artist ).arg( title );
   202                 LOG_FORMAT( "---firstRow--- %s", GETSTRING( firstRow ) );
   205                 LOG_FORMAT( "---firstRow--- %s", GETSTRING( firstRow ) );
   203                 list.append( firstRow );
   206                 list.append( firstRow );
   204 
   207