Subversion Repositories public

Rev

Rev 132 | Rev 143 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 132 Rev 137
Line 25... Line 25...
25
#include <ksimpleconfig.h>
25
#include <ksimpleconfig.h>
26
#include <klocale.h>
26
#include <klocale.h>
27
#include <qlabel.h>
27
#include <qlabel.h>
28
#include "garmin.h"
28
#include "garmin.h"
29
 
29
 
30
#include <iostream.h>
30
#include <iostream>
-
 
31
 
-
 
32
using std::cout;
-
 
33
using std::endl;
31
 
34
 
32
extern KApplication *mapp;
35
extern KApplication *mapp;
33
 
36
 
34
progressWidget::progressWidget ( QWidget* parent, const char* name, bool modal, WFlags fl )
37
progressWidget::progressWidget ( QWidget* parent, const char* name, bool modal, WFlags fl )
35
		: progressWidgetBase ( parent,name, modal,fl )
38
		: progressWidgetBase ( parent,name, modal,fl )
Line 38... Line 41...
38
 
41
 
39
progressWidget::~progressWidget()
42
progressWidget::~progressWidget()
40
{
43
{
41
}
44
}
42
 
45
 
-
 
46
void progressWidget::CallBack(char *str)
-
 
47
{
-
 
48
cout << "I'm here :-) <" << str << ">" << endl;
-
 
49
}
-
 
50
 
43
/*$SPECIALIZATION$*/
51
/*$SPECIALIZATION$*/
44
void progressWidget::Download()
52
bool progressWidget::Download()
45
{
53
{
46
QString Data, filepath, device;
54
QString Data, filepath, device;
47
int step, psteps = 4;
55
int step, psteps = 4;
48
garmin_unit         garmin;
56
garmin_unit         garmin;
49
garmin_data *       data;
57
garmin_data *       data;
Line 75... Line 83...
75
	delete cfg;
83
	delete cfg;
76
 
84
 
77
	if (Data.isEmpty())
85
	if (Data.isEmpty())
78
	{
86
	{
79
	   KMessageBox::error(this, i18n("No data path was set in the settings!"));
87
	   KMessageBox::error(this, i18n("No data path was set in the settings!"));
80
	   done(QDialog::Rejected);
88
//	   done(QDialog::Rejected);
81
	   return;
89
	   return false;
82
	}
90
	}
83
 
91
 
84
	if (!isVisible())
92
	if (!isVisible())
85
	   setShown(true);
93
	   setShown(true);
86
 
94
 
87
	garmin_set_device(device.ascii());
95
	garmin_set_device(device.ascii());
88
	garmin_set_method(0);		// read from a special device produced by "gamin_gps"
96
	garmin_set_method(0);		// Setting to 1 doesn't work!!
-
 
97
	// Initialize a callback function to have a real progress
-
 
98
	garmin_set_hook(&progressWidget::CallBack);
89
 
99
 
90
	if (garmin_init(&garmin, 0) == 0)
100
	if (garmin_init(&garmin, 0) == 0)
91
	{
101
	{
92
	   KMessageBox::error(this, i18n("Error initializing a garmin device!"));
-
 
93
	   garmin_close(&garmin);
102
	   garmin_close(&garmin);
-
 
103
	   garmin_clear_hook();
94
	   done(QDialog::Rejected);
104
//	   done(QDialog::Rejected);
95
	   return;
105
	   return false;
96
	}
106
	}
97
 
107
 
98
	barProgress->setTotalSteps(5);
108
	barProgress->setTotalSteps(5);
99
	step = 0;
109
	step = 0;
100
	barProgress->setProgress(step++);
110
	barProgress->setProgress(step++);
Line 260... Line 270...
260
	else
270
	else
261
	   KMessageBox::error(this, i18n("Unable to extract any data!"));
271
	   KMessageBox::error(this, i18n("Unable to extract any data!"));
262
 
272
 
263
	mapp->processEvents();
273
	mapp->processEvents();
264
	garmin_close(&garmin);
274
	garmin_close(&garmin);
-
 
275
	garmin_clear_hook();
265
	done(QDialog::Accepted);
276
//	done(QDialog::Accepted);
-
 
277
 
-
 
278
	if (garmin_count_error() > 0)
-
 
279
	   return false;
-
 
280
 
-
 
281
	return true;
266
}
282
}
267
 
283
 
268
int progressWidget::get_run_track_lap_info ( garmin_data * run,
284
int progressWidget::get_run_track_lap_info ( garmin_data * run,
269
			 uint32 *      track_index,
285
			 uint32 *      track_index,
270
			 uint32 *      first_lap_index,
286
			 uint32 *      first_lap_index,