core: turn picture-table into std::vector<>

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-30 15:00:28 +02:00 committed by bstoeger
parent 3cb04d230b
commit 9e3e0a5a05
29 changed files with 170 additions and 316 deletions

View file

@ -835,18 +835,15 @@ void DiveListView::matchImagesToDives(const QStringList &fileNames)
// Create the data structure of pictures to be added: a list of pictures per dive.
std::vector<Command::PictureListForAddition> pics;
for (const QString &fileName: fileNames) {
struct dive *d;
picture *pic = create_picture(qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll(), &d);
auto [pic, d] = create_picture(fileName.toStdString(), shiftDialog.amount(), shiftDialog.matchAll());
if (!pic)
continue;
PictureObj pObj(*pic);
free(pic);
auto it = std::find_if(pics.begin(), pics.end(), [d](const Command::PictureListForAddition &l) { return l.d == d; });
auto it = std::find_if(pics.begin(), pics.end(), [dive=d](const Command::PictureListForAddition &l) { return l.d == dive; });
if (it == pics.end())
pics.push_back(Command::PictureListForAddition { d, { std::move(pObj) } });
pics.push_back(Command::PictureListForAddition { d, { std::move(*pic) } });
else
it->pics.push_back(std::move(pObj));
it->pics.push_back(std::move(*pic));
}
if (pics.empty())

View file

@ -188,8 +188,8 @@ void FindMovedImagesDialog::on_scanButton_clicked()
struct dive *dive;
for_each_dive (i, dive)
if (!onlySelected || dive->selected)
FOR_EACH_PICTURE(dive)
imagePaths.append(QString(picture->filename));
for (auto &picture: dive->pictures)
imagePaths.append(QString::fromStdString(picture.filename));
stopScanning = 0;
QFuture<QVector<Match>> future = QtConcurrent::run(
// Note that we capture everything but "this" by copy to avoid dangling references.