mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Update the picture model to use the new picture function calls.
Update the picture model to use the new picture function calls, wich made the code smaller and easyer to understand. AND as a plus, it doesn't use the magic 123 identifier for pictures. AND it correctly adds images without timestamp to the list. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d95d1735b5
commit
42f36d6315
1 changed files with 13 additions and 22 deletions
|
@ -25,39 +25,30 @@ SPixmap scaleImages(const QString& s){
|
||||||
|
|
||||||
void DivePictureModel::updateDivePictures(int divenr)
|
void DivePictureModel::updateDivePictures(int divenr)
|
||||||
{
|
{
|
||||||
qDebug() << "Updating dive pictures.";
|
if (numberOfPictures != 0) {
|
||||||
beginRemoveRows(QModelIndex(), 0, numberOfPictures-1);
|
beginRemoveRows(QModelIndex(), 0, numberOfPictures-1);
|
||||||
numberOfPictures = 0;
|
numberOfPictures = 0;
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList pictures;
|
|
||||||
struct dive *d = get_dive(divenr);
|
struct dive *d = get_dive(divenr);
|
||||||
if (!d){
|
int numberOfPictures = dive_get_picture_count(d);
|
||||||
qDebug() << "Got no dive, exiting.";
|
if (!d || numberOfPictures == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// All pictures are set in *all* divecomputers. ( waste of memory if > 100 pictures? )
|
|
||||||
// so just get from the first one.
|
QStringList pictures;
|
||||||
struct event *ev = d->dc.events;
|
FOR_EACH_PICTURE( d ) {
|
||||||
while(ev){
|
pictures.push_back(QString(picture->filename));
|
||||||
if(ev->type == 123){ // 123 means PICTURE.
|
|
||||||
numberOfPictures++;
|
|
||||||
pictures.push_back(QString(ev->name));
|
|
||||||
}
|
|
||||||
ev = ev->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stringPixmapCache.clear();
|
||||||
SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>( pictures, scaleImages);
|
SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>( pictures, scaleImages);
|
||||||
Q_FOREACH(const SPixmap & pixmap, retList)
|
Q_FOREACH(const SPixmap & pixmap, retList)
|
||||||
stringPixmapCache[pixmap.first] = pixmap.second;
|
stringPixmapCache[pixmap.first] = pixmap.second;
|
||||||
|
|
||||||
if (numberOfPictures == 0){
|
|
||||||
qDebug() << "Got no pictures, exiting.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
beginInsertRows(QModelIndex(), 0, numberOfPictures-1);
|
beginInsertRows(QModelIndex(), 0, numberOfPictures-1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
qDebug() << "Everything Ok.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue