QML UI: get add dive closer to being useful

Now we at least start out with the corret date, time and number. This still
isn't functional as a lot of the data aren't used and the way you save the data
is completely silly, but it's another step in the right direction.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-12-26 21:37:18 -08:00
parent dc0be271bd
commit 0962b504ce
5 changed files with 9 additions and 6 deletions

View file

@ -49,8 +49,10 @@ MobileComponents.ApplicationWindow {
Action { Action {
text: "Add dive manually" text: "Add dive manually"
onTriggered: { onTriggered: {
manager.addDive();
detailsWindow.state = "edit" detailsWindow.state = "edit"
detailsWindow.dive_id = manager.addDive();
detailsWindow.number = manager.getNumber(detailsWindow.dive_id)
detailsWindow.date = manager.getDate(detailsWindow.dive_id)
stackView.push(detailsWindow) stackView.push(detailsWindow)
} }
} }

View file

@ -336,10 +336,10 @@ void QMLManager::saveChanges()
mark_divelist_changed(false); mark_divelist_changed(false);
} }
void QMLManager::addDive() QString QMLManager::addDive()
{ {
appendTextToLog("Adding new dive."); appendTextToLog("Adding new dive.");
DiveListModel::instance()->startAddDive(); return DiveListModel::instance()->startAddDive();
} }
void QMLManager::applyGpsData() void QMLManager::applyGpsData()

View file

@ -73,7 +73,7 @@ public slots:
void provideAuth(QNetworkReply *reply, QAuthenticator *auth); void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes); void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes);
void saveChanges(); void saveChanges();
void addDive(); QString addDive();
void applyGpsData(); void applyGpsData();
void sendGpsData(); void sendGpsData();
void clearGpsData(); void clearGpsData();

View file

@ -120,7 +120,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
} }
// create a new dive. set the current time and add it to the end of the dive list // create a new dive. set the current time and add it to the end of the dive list
void DiveListModel::startAddDive() QString DiveListModel::startAddDive()
{ {
struct dive *d; struct dive *d;
d = alloc_dive(); d = alloc_dive();
@ -132,6 +132,7 @@ void DiveListModel::startAddDive()
d->number = nr; d->number = nr;
add_single_dive(-1, d); add_single_dive(-1, d);
addDive(d); addDive(d);
return QString::number(d->id);
} }
DiveListModel *DiveListModel::instance() DiveListModel *DiveListModel::instance()

View file

@ -41,7 +41,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QHash<int, QByteArray> roleNames() const; QHash<int, QByteArray> roleNames() const;
void startAddDive(); QString startAddDive();
private: private:
QList<Dive> m_dives; QList<Dive> m_dives;
static DiveListModel *m_instance; static DiveListModel *m_instance;