equal
deleted
inserted
replaced
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 ( "c:\\radioplayhistory.db" ); |
36 static const QLatin1String DATABASE_NAME ( "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, " |
63 static const QLatin1String SQL_DELETE_ITEM_FORMAT_STR ( "DELETE FROM history WHERE id = %1" ); |
63 static const QLatin1String SQL_DELETE_ITEM_FORMAT_STR ( "DELETE FROM history WHERE id = %1" ); |
64 static const QLatin1String SQL_REMOVE_TAG_FORMAT_STR ( "UPDATE history SET tagged = 0 WHERE id = %1" ); |
64 static const QLatin1String SQL_REMOVE_TAG_FORMAT_STR ( "UPDATE history SET tagged = 0 WHERE id = %1" ); |
65 static const QLatin1String OR_ID_IS_FORMAT_STR (" OR id = %1"); |
65 static const QLatin1String OR_ID_IS_FORMAT_STR (" OR id = %1"); |
66 |
66 |
67 static const int MAX_ID_COUNT_IN_QUERY = 5; |
67 static const int MAX_ID_COUNT_IN_QUERY = 5; |
|
68 const int THOUSAND_HERTZ = 1000; |
68 |
69 |
69 #ifdef LOGGING_ENABLED |
70 #ifdef LOGGING_ENABLED |
70 # define GET_ERR( param ) GETSTRING( param.lastError().text() ) |
71 # define GET_ERR( param ) GETSTRING( param.lastError().text() ) |
71 # define GET_ERR_PTR( param ) GETSTRING( param->lastError().text() ) |
72 # define GET_ERR_PTR( param ) GETSTRING( param->lastError().text() ) |
72 #endif // LOGGING_ENABLED |
73 #endif // LOGGING_ENABLED |
85 */ |
86 */ |
86 RadioHistoryModelPrivate::RadioHistoryModelPrivate( RadioHistoryModel* model, |
87 RadioHistoryModelPrivate::RadioHistoryModelPrivate( RadioHistoryModel* model, |
87 RadioUiEngine& uiEngine ) : |
88 RadioUiEngine& uiEngine ) : |
88 q_ptr( model ), |
89 q_ptr( model ), |
89 mUiEngine( uiEngine ), |
90 mUiEngine( uiEngine ), |
90 mRtItemClass( -1 ), |
|
91 mTopItemIsPlaying( false ), |
91 mTopItemIsPlaying( false ), |
92 mShowDetails( true ), |
92 mShowDetails( true ), |
93 mViewMode( ShowAll ) |
93 mViewMode( ShowAll ) |
94 { |
94 { |
95 } |
95 } |
151 const RadioStation& station, |
151 const RadioStation& station, |
152 bool fromRds ) |
152 bool fromRds ) |
153 { |
153 { |
154 LOG_FORMAT( "RadioHistoryModelPrivate::addItem. Artist: %s, Title: %s", GETSTRING( artist ), GETSTRING( title ) ); |
154 LOG_FORMAT( "RadioHistoryModelPrivate::addItem. Artist: %s, Title: %s", GETSTRING( artist ), GETSTRING( title ) ); |
155 |
155 |
156 if ( !mQueryModel ) { |
156 if ( !mQueryModel || title.isEmpty() ) { |
157 return; |
157 return; |
158 } |
158 } |
159 |
159 |
160 mTopItemIsPlaying = true; |
160 mTopItemIsPlaying = true; |
161 |
161 |
163 |
163 |
164 query.prepare( SQL_ADD_ITEM ); |
164 query.prepare( SQL_ADD_ITEM ); |
165 query.addBindValue( artist ); |
165 query.addBindValue( artist ); |
166 query.addBindValue( title ); |
166 query.addBindValue( title ); |
167 query.addBindValue( station.name() ); |
167 query.addBindValue( station.name() ); |
168 query.addBindValue( static_cast<int>( station.frequency() / 1000 ) ); |
168 query.addBindValue( static_cast<int>( station.frequency() / THOUSAND_HERTZ ) ); |
169 query.addBindValue( fromRds ); |
169 query.addBindValue( fromRds ); |
170 query.addBindValue( QDateTime::currentDateTime().toTime_t() ); |
170 query.addBindValue( QDateTime::currentDateTime().toTime_t() ); |
171 |
171 |
172 commitTransaction( query, InsertRows, 0 ); |
172 commitTransaction( query, InsertRows, 0 ); |
173 } |
173 } |
198 artist = qtTrId( "txt_rad_dblist_unknown" ); |
198 artist = qtTrId( "txt_rad_dblist_unknown" ); |
199 } |
199 } |
200 |
200 |
201 const QString title = record.value( RadioHistoryValue::Title ).toString(); |
201 const QString title = record.value( RadioHistoryValue::Title ).toString(); |
202 const QString station = record.value( RadioHistoryValue::Station ).toString(); |
202 const QString station = record.value( RadioHistoryValue::Station ).toString(); |
203 const uint frequency = record.value( RadioHistoryValue::Frequency ).toUInt() * 1000; |
203 const uint frequency = record.value( RadioHistoryValue::Frequency ).toUInt() * THOUSAND_HERTZ; |
204 |
204 |
205 QStringList list; |
205 QStringList list; |
206 if ( mShowDetails ) { |
206 if ( mShowDetails ) { |
207 QString formatter = qtTrId( "txt_rad_dblist_1_2" ); |
207 QString formatter = qtTrId( "txt_rad_dblist_1_2" ); |
208 LOG_FORMAT( "---formatter--- %s", GETSTRING( formatter ) ); |
208 LOG_FORMAT( "---formatter--- %s", GETSTRING( formatter ) ); |