122 |
115 |
123 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
124 // connectSignals() |
117 // connectSignals() |
125 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
126 // |
119 // |
127 int VideoListDataModel::connectSignals() |
120 void VideoListDataModel::connectSignals() |
128 { |
121 { |
129 FUNC_LOG; |
122 FUNC_LOG; |
130 if(!connect(d_ptr, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
123 |
131 this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)))) |
124 connect(this, SIGNAL(modelChanged()), mDeleteWorker, SLOT(continueSlot()), Qt::UniqueConnection); |
132 { |
125 |
133 return -1; |
126 connect(this, SIGNAL(modelReady()), mDeleteWorker, SLOT(continueSlot()), Qt::UniqueConnection); |
134 } |
127 |
135 if(!connect(d_ptr, SIGNAL(videoDetailsReady(QVariant&)), |
128 connect(mDeleteWorker, SIGNAL(deleteStartupFailed(QList<TMPXItemId>&)), |
136 this, SIGNAL(fullVideoDetailsReady(QVariant&)))) |
129 this, SLOT(deleteStartingFailsSlot(QList<TMPXItemId>&)), Qt::UniqueConnection); |
137 { |
|
138 return -1; |
|
139 } |
|
140 if(!connect(this, SIGNAL(modelChanged()), mDeleteWorker, SLOT(continueSlot()))) |
|
141 { |
|
142 return -1; |
|
143 } |
|
144 if(!connect(this, SIGNAL(modelReady()), mDeleteWorker, SLOT(continueSlot()))) |
|
145 { |
|
146 return -1; |
|
147 } |
|
148 if(!connect(mDeleteWorker, SIGNAL(deleteStartupFailed(QList<TMPXItemId>)), |
|
149 this, SLOT(deleteStartingFailsSlot(QList<TMPXItemId>)))) |
|
150 { |
|
151 return -1; |
|
152 } |
|
153 |
|
154 return 0; |
|
155 } |
130 } |
156 |
131 |
157 // ----------------------------------------------------------------------------- |
132 // ----------------------------------------------------------------------------- |
158 // disconnectSignals() |
133 // disconnectSignals() |
159 // ----------------------------------------------------------------------------- |
134 // ----------------------------------------------------------------------------- |
160 // |
135 // |
161 void VideoListDataModel::disconnectSignals() |
136 void VideoListDataModel::disconnectSignals() |
162 { |
137 { |
163 FUNC_LOG; |
138 FUNC_LOG; |
164 disconnect(d_ptr, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), |
|
165 this, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
|
166 disconnect(d_ptr, SIGNAL(videoDetailsReady(QVariant&)), |
|
167 this, SIGNAL(fullVideoDetailsReady(QVariant&))); |
|
168 disconnect(this, SIGNAL(modelChanged()), mDeleteWorker, SLOT(continueSlot())); |
139 disconnect(this, SIGNAL(modelChanged()), mDeleteWorker, SLOT(continueSlot())); |
169 disconnect(this, SIGNAL(modelReady()), mDeleteWorker, SLOT(continueSlot())); |
140 disconnect(this, SIGNAL(modelReady()), mDeleteWorker, SLOT(continueSlot())); |
170 disconnect(mDeleteWorker, SIGNAL(deleteStartupFailed(QList<TMPXItemId>)), |
141 disconnect(mDeleteWorker, SIGNAL(deleteStartupFailed(QList<TMPXItemId>&)), |
171 this, SLOT(deleteStartingFailsSlot(QList<TMPXItemId>))); |
142 this, SLOT(deleteStartingFailsSlot(QList<TMPXItemId>&))); |
172 } |
143 } |
173 |
144 |
174 // ----------------------------------------------------------------------------- |
145 // ----------------------------------------------------------------------------- |
175 // mediaIdAtIndex() |
146 // mediaIdAtIndex() |
176 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
177 // |
148 // |
178 TMPXItemId VideoListDataModel::mediaIdAtIndex(int index) const |
149 const TMPXItemId& VideoListDataModel::mediaIdAtIndex(const int &index) const |
179 { |
150 { |
180 TMPXItemId mpxId =TMPXItemId::InvalidId(); |
151 return d_ptr->getMediaIdFromIndex(index); |
181 |
|
182 if(index >= 0 && index < d_ptr->getVideoCount()) |
|
183 { |
|
184 mpxId = d_ptr->getMediaIdFromIndex(index); |
|
185 } |
|
186 |
|
187 return mpxId; |
|
188 } |
152 } |
189 |
153 |
190 // ----------------------------------------------------------------------------- |
154 // ----------------------------------------------------------------------------- |
191 // indexOfId() |
155 // indexOfId() |
192 // ----------------------------------------------------------------------------- |
156 // ----------------------------------------------------------------------------- |
193 // |
157 // |
194 QModelIndex VideoListDataModel::indexOfId(TMPXItemId id) |
158 QModelIndex VideoListDataModel::indexOfId(const TMPXItemId &id) |
195 { |
159 { |
196 int rowIndex = d_ptr->mMediaData.indexOfId(id); |
160 int rowIndex = d_ptr->mMediaData.indexOfId(id); |
197 return index(rowIndex, 0, QModelIndex()); |
161 return index(rowIndex, 0, QModelIndex()); |
198 } |
162 } |
199 |
163 |
200 // ----------------------------------------------------------------------------- |
164 // ----------------------------------------------------------------------------- |
201 // mediaFilePathForId() |
165 // mediaFilePathForId() |
202 // ----------------------------------------------------------------------------- |
166 // ----------------------------------------------------------------------------- |
203 // |
167 // |
204 QString VideoListDataModel::mediaFilePathForId(TMPXItemId mediaId) const |
168 QString VideoListDataModel::mediaFilePathForId(const TMPXItemId &mediaId) const |
205 { |
169 { |
206 QString filePath; |
170 return d_ptr->getFilePathForId(mediaId);; |
207 filePath = d_ptr->getFilePathForId(mediaId); |
|
208 |
|
209 return filePath; |
|
210 } |
171 } |
211 |
172 |
212 // ----------------------------------------------------------------------------- |
173 // ----------------------------------------------------------------------------- |
213 // rowCount() |
174 // rowCount() |
214 // ----------------------------------------------------------------------------- |
175 // ----------------------------------------------------------------------------- |
531 |
493 |
532 // ----------------------------------------------------------------------------- |
494 // ----------------------------------------------------------------------------- |
533 // setAlbumInUse() |
495 // setAlbumInUse() |
534 // ----------------------------------------------------------------------------- |
496 // ----------------------------------------------------------------------------- |
535 // |
497 // |
536 void VideoListDataModel::setAlbumInUse(TMPXItemId albumId) |
498 void VideoListDataModel::setAlbumInUse(const TMPXItemId &albumId) |
537 { |
499 { |
538 FUNC_LOG; |
500 FUNC_LOG; |
539 d_ptr->setAlbumInUse(albumId); |
501 d_ptr->setAlbumInUse(albumId); |
540 } |
502 } |
541 |
503 |
542 // ----------------------------------------------------------------------------- |
504 // ----------------------------------------------------------------------------- |
543 // albumInUse() |
505 // albumInUse() |
544 // ----------------------------------------------------------------------------- |
506 // ----------------------------------------------------------------------------- |
545 // |
507 // |
546 TMPXItemId VideoListDataModel::albumInUse() |
508 const TMPXItemId& VideoListDataModel::albumInUse() const |
547 { |
509 { |
548 FUNC_LOG; |
510 FUNC_LOG; |
549 return d_ptr->mCurrentAlbum; |
511 return d_ptr->mCurrentAlbum; |
550 } |
512 } |
551 |
513 |
552 // ----------------------------------------------------------------------------- |
514 // ----------------------------------------------------------------------------- |
553 // removeItemsFromAlbum() |
515 // removeItemsFromAlbum() |
554 // ----------------------------------------------------------------------------- |
516 // ----------------------------------------------------------------------------- |
555 // |
517 // |
556 int VideoListDataModel::removeItemsFromAlbum(TMPXItemId &albumId, const QList<TMPXItemId> &items) |
518 int VideoListDataModel::removeItemsFromAlbum(const TMPXItemId &albumId, const QList<TMPXItemId> &items) |
557 { |
519 { |
558 FUNC_LOG; |
520 FUNC_LOG; |
559 int removeCount = d_ptr->removeItemsFromAlbum(albumId, items); |
521 int removeCount = d_ptr->removeItemsFromAlbum(albumId, items); |
560 if(removeCount) |
522 if(removeCount) |
561 { |
523 { |