add newItem function to interface with QML

In order to make sure QML can properly interact with Rust I'll use a
function in the proxy model to interact with the actual model
underneath in Rust.
This commit is contained in:
Chris Cochrun 2023-04-12 19:00:31 -05:00
parent b2a87b76b6
commit 85285b7d02
3 changed files with 7 additions and 1 deletions

View file

@ -226,6 +226,11 @@ QModelIndex ImageProxyModel::idx(int row) {
return idx;
}
void ImageProxyModel::newItem(const QUrl &url) {
auto model = qobject_cast<ImageModel *>(sourceModel());
model->newItem(url);
}
QVariantMap ImageProxyModel::getImage(const int &row) {
auto model = qobject_cast<ImageModel *>(sourceModel());
QVariantMap image = model->getItem(mapToSource(index(row, 0)).row());

View file

@ -62,6 +62,7 @@ public:
public slots:
Q_INVOKABLE QVariantMap getImage(const int &row);
Q_INVOKABLE void newItem(const QUrl &url);
Q_INVOKABLE void deleteImage(const int &row);
Q_INVOKABLE void deleteImages(const QVector<int> &rows);