aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--qt-ui/divelistview.cpp35
-rw-r--r--qt-ui/diveplanner.cpp4
-rw-r--r--qt-ui/mainwindow.cpp1
-rw-r--r--qt-ui/models.cpp7
-rw-r--r--qt-ui/printlayout.cpp1
-rw-r--r--qt-ui/simplewidgets.cpp1
-rw-r--r--qt-ui/subsurfacewebservices.cpp7
8 files changed, 44 insertions, 14 deletions
diff --git a/dive.h b/dive.h
index 62d57d6cc..12f190c41 100644
--- a/dive.h
+++ b/dive.h
@@ -846,7 +846,9 @@ struct diveplan {
struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he, int po2, bool entered);
void get_gas_string(int o2, int he, char *buf, int len);
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
+#if DEBUG_PLAN
void dump_plan(struct diveplan *diveplan);
+#endif
void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco);
void delete_single_dive(int idx);
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 6e2024a2d..b2bf7cfc6 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -242,6 +242,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
QItemSelection newDeselected = selectionModel()->selection();
QModelIndexList diveList;
+ //TODO: This should be called find_first_selected_dive and be ported to C code.
int firstSelectedDive = -1;
/* context for temp. variables. */ {
int i = 0;
@@ -250,6 +251,7 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
dive->selected = newDiveSelection.contains(i) == true;
if (firstSelectedDive == -1 && dive->selected) {
firstSelectedDive = i;
+ break;
}
}
}
@@ -444,6 +446,7 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
const QAbstractItemModel *model = index.model();
struct dive *dive = (struct dive *)model->data(index, DiveTripModel::DIVE_ROLE).value<void *>();
if (!dive) { // it's a trip!
+ //TODO: deselect_trip_dives on c-code?
if (model->rowCount(index)) {
struct dive *child = (struct dive *)model->data(index.child(0, 0), DiveTripModel::DIVE_ROLE).value<void *>();
while (child) {
@@ -462,6 +465,7 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
const QAbstractItemModel *model = index.model();
struct dive *dive = (struct dive *)model->data(index, DiveTripModel::DIVE_ROLE).value<void *>();
if (!dive) { // it's a trip!
+ //TODO: select_trip_dives on C code?
if (model->rowCount(index)) {
QItemSelection selection;
struct dive *child = (struct dive *)model->data(index.child(0, 0), DiveTripModel::DIVE_ROLE).value<void *>();
@@ -523,7 +527,8 @@ void DiveListView::merge_trip(const QModelIndex &a, int offset)
dive_trip_t *trip_a = (dive_trip_t *)a.data(DiveTripModel::TRIP_ROLE).value<void *>();
dive_trip_t *trip_b = (dive_trip_t *)b.data(DiveTripModel::TRIP_ROLE).value<void *>();
-
+ // TODO: merge_trip on the C code? some part of this needs to stay ( getting the trips from the model,
+ // but not the algorithm.
if (trip_a == trip_b || !trip_a || !trip_b)
return;
@@ -538,6 +543,7 @@ void DiveListView::merge_trip(const QModelIndex &a, int offset)
fixMessyQtModelBehaviour();
restoreSelection();
mark_divelist_changed(true);
+ //TODO: emit a signal to signalize that the divelist changed?
}
void DiveListView::mergeTripAbove()
@@ -552,6 +558,7 @@ void DiveListView::mergeTripBelow()
void DiveListView::removeFromTrip()
{
+ //TODO: move this to C-code.
int i;
struct dive *d;
for_each_dive(i, d) {
@@ -567,11 +574,12 @@ void DiveListView::removeFromTrip()
void DiveListView::newTripAbove()
{
- dive_trip_t *trip;
- int idx;
struct dive *d = (struct dive *)contextMenuIndex.data(DiveTripModel::DIVE_ROLE).value<void *>();
if (!d) // shouldn't happen as we only are setting up this action if this is a dive
return;
+ //TODO: port to c-code.
+ dive_trip_t *trip;
+ int idx;
rememberSelection();
trip = create_and_hookup_trip_from_dive(d);
for_each_dive(idx, d) {
@@ -597,15 +605,17 @@ void DiveListView::addToTripAbove()
void DiveListView::addToTrip(bool below)
{
- int idx, delta = (currentOrder == Qt::AscendingOrder) ? -1 : +1;
+ int delta = (currentOrder == Qt::AscendingOrder) ? -1 : +1;
+ struct dive *d = (struct dive *)contextMenuIndex.data(DiveTripModel::DIVE_ROLE).value<void *>();
+ rememberSelection();
+
+ //TODO: This part should be moved to C-code.
+ int idx;
dive_trip_t *trip = NULL;
struct dive *pd = NULL;
- struct dive *d = (struct dive *)contextMenuIndex.data(DiveTripModel::DIVE_ROLE).value<void *>();
- if (!d) // shouldn't happen as we only are setting up this action if this is a dive
- return;
if (below) // Should we add to the trip below instead?
delta *= -1;
- rememberSelection();
+
if (d->selected) { // we are right-clicking on one of possibly many selected dive(s)
// find the top selected dive, depending on the list order
if (delta == 1) {
@@ -637,6 +647,7 @@ void DiveListView::addToTrip(bool below)
}
trip->expanded = 1;
mark_divelist_changed(true);
+ //This part stays at C++ code.
reload(currentLayout, false);
restoreSelection();
fixMessyQtModelBehaviour();
@@ -651,6 +662,7 @@ void DiveListView::markDiveInvalid()
for_each_dive(i, d) {
if (!d->selected)
continue;
+ //TODO: this should be done in the future
// now mark the dive invalid... how do we do THAT?
// d->invalid = true;
}
@@ -669,10 +681,12 @@ void DiveListView::markDiveInvalid()
void DiveListView::deleteDive()
{
- int i;
struct dive *d = (struct dive *)contextMenuIndex.data(DiveTripModel::DIVE_ROLE).value<void *>();
if (!d)
return;
+
+ //TODO: port this to C-code.
+ int i;
// after a dive is deleted the ones following it move forward in the dive_table
// so instead of using the for_each_dive macro I'm using an explicit for loop
// to make this easier to understand
@@ -829,6 +843,7 @@ void DiveListView::loadImages()
for (int i = 0; i < fileNames.size(); ++i) {
if (readfile(fileNames.at(i).toUtf8().data(), &mem) <= 0)
continue;
+ //TODO: This inner code should be ported to C-Code.
retval = exif.parseFrom((const unsigned char *)mem.buffer, (unsigned)mem.size);
free(mem.buffer);
if (retval != PARSE_EXIF_SUCCESS)
@@ -836,7 +851,7 @@ void DiveListView::loadImages()
imagetime = shiftDialog.epochFromExiv(&exif);
if (!imagetime)
continue;
- imagetime += shiftDialog.amount();
+ imagetime += shiftDialog.amount(); // TODO: this should be cached and passed to the C-function
int j = 0;
struct dive *dive;
for_each_dive(j, dive) {
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index b5fd5d1a8..ac7a208ea 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -469,6 +469,7 @@ void DivePlannerGraphics::drawProfile()
plannerModel->deleteTemporaryPlan();
return;
}
+ //TODO: divedatapoint_list_get_max_depth on C - code?
while (dp->next) {
if (dp->time && dp->depth > max_depth)
max_depth = dp->depth;
@@ -1489,7 +1490,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
// We just start with a surface node at time = 0
if (!stagingDive)
return;
-
+ //TODO: this thingy looks like it could be a good C-based function
diveplan.dp = NULL;
int lastIndex = -1;
for (int i = 0; i < rowCount(); i++) {
@@ -1559,6 +1560,7 @@ void DivePlannerPointsModel::createPlan()
return cancelPlan();
createTemporaryPlan();
+ //TODO: C-based function here?
plan(&diveplan, &cache, &tempDive, isPlanner());
copy_cylinders(stagingDive, tempDive);
int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 0b00d4fd1..cd8e6d808 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -391,6 +391,7 @@ void MainWindow::on_actionAddDive_triggered()
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
// now cheat - create one dive that we use to store the info tab data in
+ //TODO: C-function create_temporary_dive ?
struct dive *dive = alloc_dive();
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset();
dive->dc.model = "manually added dive"; // don't translate! this is stored in the XML file
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 6d64da44b..0564add12 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -444,7 +444,7 @@ void WeightModel::passInData(const QModelIndex &index, const QVariant &value)
}
}
}
-
+//TODO: Move to C
weight_t string_to_weight(const char *str)
{
const char *end;
@@ -469,6 +469,7 @@ lbs:
return weight;
}
+//TODO: Move to C.
depth_t string_to_depth(const char *str)
{
const char *end;
@@ -492,6 +493,7 @@ ft:
return depth;
}
+//TODO: Move to C.
pressure_t string_to_pressure(const char *str)
{
const char *end;
@@ -515,6 +517,7 @@ psi:
return pressure;
}
+//TODO: Move to C.
/* Imperial cylinder volumes need working pressure to be meaningful */
volume_t string_to_volume(const char *str, pressure_t workp)
{
@@ -547,6 +550,7 @@ l:
return volume;
}
+//TODO: Move to C.
fraction_t string_to_fraction(const char *str)
{
const char *end;
@@ -564,6 +568,7 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r
switch (index.column()) {
case TYPE:
if (!value.isNull()) {
+ //TODO: C-function weigth_system_set_description ?
if (!ws->description || gettextFromC::instance()->tr(ws->description) != vString) {
// loop over translations to see if one matches
int i = -1;
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index d146ee063..c30ff9cd1 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -93,6 +93,7 @@ void PrintLayout::setup()
}
// go trought the dive table and find how many dives we are a going to print
+// TODO: C function: 'count_selected_dives' or something
int PrintLayout::estimateTotalDives() const
{
int total = 0, i = 0;
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index be3add815..d100eb762 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -224,6 +224,7 @@ void ShiftImageTimesDialog::syncCameraClicked()
connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &)));
}
+//TODO: This should be moved to C-Code.
time_t ShiftImageTimesDialog::epochFromExiv(EXIFInfo *exif)
{
struct tm tm;
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 1b8eab129..50f195635 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -40,7 +40,7 @@ static bool is_automatic_fix(struct dive *gpsfix)
}
#define SAME_GROUP 6 * 3600 // six hours
-
+//TODO: C Code. static functions are not good if we plan to have a test for them.
static bool merge_locations_into_dives(void)
{
int i, nr = 0, changed = 0;
@@ -94,7 +94,7 @@ static bool merge_locations_into_dives(void)
}
return changed > 0;
}
-
+//TODO: C-code.
static void clear_table(struct dive_table *table)
{
int i;
@@ -103,6 +103,7 @@ static void clear_table(struct dive_table *table)
table->nr = 0;
}
+// TODO: This looks like should be ported to C code. or a big part of it.
bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, const bool selected)
{
static const char errPrefix[] = "divelog.de-upload:";
@@ -451,6 +452,7 @@ void SubsurfaceWebServices::setStatusText(int status)
ui.status->setText(text);
}
+//TODO: C-Code.
/* requires that there is a <download> or <error> tag under the <root> tag */
void SubsurfaceWebServices::download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status)
{
@@ -467,6 +469,7 @@ void SubsurfaceWebServices::download_dialog_traverse_xml(xmlNodePtr node, unsign
}
}
+// TODO: C-Code
unsigned int SubsurfaceWebServices::download_dialog_parse_response(const QByteArray &xml)
{
xmlNodePtr root;