equal
deleted
inserted
replaced
27 |
27 |
28 // User includes |
28 // User includes |
29 #include "radiohistorydatabase.h" |
29 #include "radiohistorydatabase.h" |
30 #include "radiologger.h" |
30 #include "radiologger.h" |
31 |
31 |
32 static const QLatin1String DATABASE_NAME ( "c:\\radioplayhistory.db" ); |
32 static const QLatin1String DATABASE_NAME ( "radioplayhistory.db" ); |
33 static const QLatin1String DATABASE_DRIVER ( "QSQLITE" ); |
33 static const QLatin1String DATABASE_DRIVER ( "QSQLITE" ); |
34 static const QLatin1String HISTORY_TABLE ( "history" ); |
34 static const QLatin1String HISTORY_TABLE ( "history" ); |
35 static const QLatin1String SQL_CREATE_TABLE ( "CREATE TABLE history (" |
35 static const QLatin1String SQL_CREATE_TABLE ( "CREATE TABLE history (" |
36 "id INTEGER PRIMARY KEY AUTOINCREMENT, " |
36 "id INTEGER PRIMARY KEY AUTOINCREMENT, " |
37 "artist TEXT NOT NULL, " |
37 "artist TEXT NOT NULL, " |
53 //static const QLatin1String SQL_DELETE_TAGGED = "DELETE FROM history WHERE tagged=1"; |
53 //static const QLatin1String SQL_DELETE_TAGGED = "DELETE FROM history WHERE tagged=1"; |
54 static const QLatin1String SQL_CLEAR_TAGS ( "UPDATE history SET tagged = 0 WHERE tagged = 1" ); |
54 static const QLatin1String SQL_CLEAR_TAGS ( "UPDATE history SET tagged = 0 WHERE tagged = 1" ); |
55 |
55 |
56 //static static const QLatin1String SQL_FIND_ITEM_BY_ID( "SELECT * FROM history WHERE id = ?" ); |
56 //static static const QLatin1String SQL_FIND_ITEM_BY_ID( "SELECT * FROM history WHERE id = ?" ); |
57 static const QLatin1String SQL_TOGGLE_TAG ( "UPDATE history SET tagged = ? WHERE id = ?" ); |
57 static const QLatin1String SQL_TOGGLE_TAG ( "UPDATE history SET tagged = ? WHERE id = ?" ); |
|
58 |
|
59 const int THOUSAND_HERTZ = 1000; |
58 |
60 |
59 #ifdef LOGGING_ENABLED |
61 #ifdef LOGGING_ENABLED |
60 # define GET_ERR( param ) GETSTRING( param.lastError().text() ) |
62 # define GET_ERR( param ) GETSTRING( param.lastError().text() ) |
61 # define GET_ERR_PTR( param ) GETSTRING( param->lastError().text() ) |
63 # define GET_ERR_PTR( param ) GETSTRING( param->lastError().text() ) |
62 #endif // LOGGING_ENABLED |
64 #endif // LOGGING_ENABLED |
95 |
97 |
96 query.prepare( SQL_ADD_ITEM ); |
98 query.prepare( SQL_ADD_ITEM ); |
97 query.addBindValue( artist ); |
99 query.addBindValue( artist ); |
98 query.addBindValue( title ); |
100 query.addBindValue( title ); |
99 query.addBindValue( stationName ); |
101 query.addBindValue( stationName ); |
100 query.addBindValue( static_cast<int>( frequency / 1000 ) ); |
102 query.addBindValue( static_cast<int>( frequency / THOUSAND_HERTZ ) ); |
101 query.addBindValue( fromRds ); |
103 query.addBindValue( fromRds ); |
102 query.addBindValue( QDateTime::currentDateTime().toTime_t() ); |
104 query.addBindValue( QDateTime::currentDateTime().toTime_t() ); |
103 |
105 |
104 commitTransaction( query ); |
106 commitTransaction( query ); |
105 } |
107 } |