mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add DiveListModel
This model will be used to show the dives in QML. This commit adds the model, and the means to link it to QML. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bf882416f9
commit
b7e4b35cde
6 changed files with 392 additions and 4 deletions
|
@ -1,15 +1,15 @@
|
|||
#include "qmlmanager.h"
|
||||
#include <QUrl>
|
||||
|
||||
#include "../qt-models/divelistmodel.h"
|
||||
|
||||
QMLManager::QMLManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QMLManager::~QMLManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString QMLManager::filename()
|
||||
|
@ -20,12 +20,21 @@ QString QMLManager::filename()
|
|||
void QMLManager::setFilename(const QString &f)
|
||||
{
|
||||
m_fileName = f;
|
||||
emit filenameChanged();
|
||||
loadFile();
|
||||
emit filenameChanged();
|
||||
}
|
||||
|
||||
void QMLManager::loadFile()
|
||||
{
|
||||
QUrl url(m_fileName);
|
||||
QString strippedFileName = url.toLocalFile();
|
||||
|
||||
parse_file(strippedFileName.toUtf8().data());
|
||||
|
||||
int i;
|
||||
struct dive *d;
|
||||
|
||||
for_each_dive(i, d) {
|
||||
DiveListModel::instance()->addDive(d);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue