Subversion Repositories public

Rev

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

Rev 225 Rev 230
Line 87... Line 87...
87
	mapLap = 0;
87
	mapLap = 0;
88
	mapPan = QRect(0, 0, 0, 0);
88
	mapPan = QRect(0, 0, 0, 0);
89
	stateHand = stateFlag = stateGlas = false;
89
	stateHand = stateFlag = stateGlas = false;
90
	oldTransX = oldTransY = 0.0;
90
	oldTransX = oldTransY = 0.0;
91
	lmbPressed = 0;
91
	lmbPressed = 0;
-
 
92
	kl = new KLocale(QString("kdesktop"), 0);
92
 
93
 
93
	// Load the config parameters
94
	// Load the config parameters
94
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"), true);
95
	KSimpleConfig *cfg = new KSimpleConfig(QString("sportwatcher.rc"), true);
95
	cfg->setGroup(QString("SportWatcher"));
96
	cfg->setGroup(QString("SportWatcher"));
96
	lower1 = cfg->readNumEntry("lower1", 0);
97
	lower1 = cfg->readNumEntry("lower1", 0);
Line 103... Line 104...
103
	restHr = cfg->readNumEntry("restHr", 60);
104
	restHr = cfg->readNumEntry("restHr", 60);
104
	vo2max = cfg->readNumEntry("vo2max", 50);
105
	vo2max = cfg->readNumEntry("vo2max", 50);
105
	weight = cfg->readNumEntry("weight", 70);
106
	weight = cfg->readNumEntry("weight", 70);
106
	sampleTime = cfg->readNumEntry("seconds", 15);
107
	sampleTime = cfg->readNumEntry("seconds", 15);
107
	Serial = cfg->readBoolEntry("Serial", false);
108
	Serial = cfg->readBoolEntry("Serial", false);
-
 
109
	Forerunner = cfg->readBoolEntry("Forerunner", false);
108
	Contour = cfg->readBoolEntry("Contour", false);
110
	Contour = cfg->readBoolEntry("Contour", false);
109
	Device = cfg->readEntry("Device", "/dev/ttyUSB0");
111
	Device = cfg->readEntry("Device", "/dev/ttyUSB0");
110
	Data = cfg->readEntry("Data", QDir::home().absPath() + "/.sportwatcher");
112
	Data = cfg->readEntry("Data", QDir::home().absPath() + "/.sportwatcher");
111
	HRM = cfg->readEntry("HRM", QDir::home().absPath() + "/polar");
113
	HRM = cfg->readEntry("HRM", QDir::home().absPath() + "/polar");
112
	MAP = cfg->readEntry("MAP", QDir::home().absPath() + "/.sportwatcher/track.wms");
114
	MAP = cfg->readEntry("MAP", QDir::home().absPath() + "/.sportwatcher/track.wms");
Line 126... Line 128...
126
}
128
}
127
 
129
 
128
sportwatcherWidget::~sportwatcherWidget()
130
sportwatcherWidget::~sportwatcherWidget()
129
{
131
{
130
	destroy();
132
	destroy();
-
 
133
	delete kl;
131
}
134
}
132
 
135
 
133
void sportwatcherWidget::destroy()
136
void sportwatcherWidget::destroy()
134
{
137
{
135
	if (gmn)
138
	if (gmn)
Line 312... Line 315...
312
	   ds.garmin_print_data(gmn);
315
	   ds.garmin_print_data(gmn);
313
	   rn = ds.getRunNode();
316
	   rn = ds.getRunNode();
314
 
317
 
315
	   lap = ds.getLap(rn->run->first_lap_index);
318
	   lap = ds.getLap(rn->run->first_lap_index);
316
	   const QDateTime *qt = garmin_dtime (lap->start_time);
319
	   const QDateTime *qt = garmin_dtime (lap->start_time);
317
	   QString idx = qt->toString("dd.MM.yyyy hh:mm.ss");
320
//	   QString idx = qt->toString("dd.MM.yyyy hh:mm.ss");
-
 
321
	   QString idx = kl->formatDateTime (*qt, true, true);
318
 
322
 
319
	   if (strlen (rn->run->workout.name) > 1 && strlen (rn->run->workout.name) < 16 && isalpha (rn->run->workout.name[0]))
323
	   if (strlen (rn->run->workout.name) > 1 && strlen (rn->run->workout.name) < 16 && isalpha (rn->run->workout.name[0]))
320
	      idx.setAscii (rn->run->workout.name);
324
	      idx.setAscii (rn->run->workout.name);
321
 
325
 
322
	   if (!index)
326
	   if (!index)
Line 537... Line 541...
537
	delete info;
541
	delete info;
538
}
542
}
539
 
543
 
540
void sportwatcherWidget::helpContents()
544
void sportwatcherWidget::helpContents()
541
{
545
{
-
 
546
	KMessageBox::information(this, i18n("This function is currently not implemented!"));
542
}
547
}
543
 
548
 
544
void sportwatcherWidget::helpIndex()
549
void sportwatcherWidget::helpIndex()
545
{
550
{
-
 
551
	KMessageBox::information(this, i18n("This function is currently not implemented!"));
546
}
552
}
547
 
553
 
548
void sportwatcherWidget::fileExit()
554
void sportwatcherWidget::fileExit()
549
{
555
{
550
	if (mama)
556
	if (mama)
551
	   mama->close();
557
	   mama->close();
552
}
558
}
553
 
559
 
554
void sportwatcherWidget::filePrint()
560
void sportwatcherWidget::filePrint()
555
{
561
{
-
 
562
	KMessageBox::information(this, i18n("This function is currently not implemented!"));
556
}
563
}
557
 
564
 
558
/*
565
/*
559
 * This function allows the user to choose a file name, where we save the
566
 * This function allows the user to choose a file name, where we save the
560
 * actual lap in Garmins own TCX format. This format is simply a XML-file.
567
 * actual lap in Garmins own TCX format. This format is simply a XML-file.
Line 1199... Line 1206...
1199
	}
1206
	}
1200
 
1207
 
1201
	// Do we have allready so items in the list?
1208
	// Do we have allready so items in the list?
1202
	if ((item = liActivities->findItem (fld, 0, Qt::ExactMatch)) != 0)
1209
	if ((item = liActivities->findItem (fld, 0, Qt::ExactMatch)) != 0)
1203
	{
1210
	{
1204
	   el = new KListViewItem(item, qt->toString("dd.MM.yyyy hh:mm:ss"));
1211
//	   el = new KListViewItem(item, qt->toString("dd.MM.yyyy hh:mm:ss"));
-
 
1212
	   el = new KListViewItem(item, kl->formatDateTime(*qt, true, true));
1205
	   el->setText(1, tgfile);
1213
	   el->setText(1, tgfile);
1206
	   el->setPixmap(0, QPixmap::fromMimeSource(px));
1214
	   el->setPixmap(0, QPixmap::fromMimeSource(px));
1207
	   item->insertItem(el);
1215
	   item->insertItem(el);
1208
	}
1216
	}
1209
	else	// no, this is the first item. (shouldn't be!)
1217
	else	// no, this is the first item. (shouldn't be!)
1210
	{
1218
	{
1211
	   it = new KListViewItem(liActivities, fld);
1219
	   it = new KListViewItem(liActivities, fld);
1212
	   it->setPixmap(0, QPixmap::fromMimeSource(QString("history.png")));
1220
	   it->setPixmap(0, QPixmap::fromMimeSource(QString("history.png")));
1213
	   liActivities->insertItem(it);
1221
	   liActivities->insertItem(it);
1214
	   el = new KListViewItem(item, qt->toString("dd.MM.yyyy hh:mm:ss"));
1222
//	   el = new KListViewItem(item, qt->toString("dd.MM.yyyy hh:mm:ss"));
-
 
1223
	   el = new KListViewItem(item, kl->formatDateTime(*qt, true, true));
1215
	   el->setText(1, tgfile);
1224
	   el->setText(1, tgfile);
1216
	   el->setPixmap(0, QPixmap::fromMimeSource(px));
1225
	   el->setPixmap(0, QPixmap::fromMimeSource(px));
1217
	   it->insertItem(el);
1226
	   it->insertItem(el);
1218
	}
1227
	}
1219
}
1228
}
Line 1257... Line 1266...
1257
 
1266
 
1258
	if (name.length() <= 1)
1267
	if (name.length() <= 1)
1259
	{
1268
	{
1260
	   lap = ds.getLap(rn->run->first_lap_index);
1269
	   lap = ds.getLap(rn->run->first_lap_index);
1261
	   const QDateTime *qt = garmin_dtime (lap->start_time);
1270
	   const QDateTime *qt = garmin_dtime (lap->start_time);
1262
	   QString idx = qt->toString("dd.MM.yyyy hh:mm.ss");
1271
//	   QString idx = qt->toString("dd.MM.yyyy hh:mm.ss");
-
 
1272
	   QString idx = kl->formatDateTime(*qt, true, true);
1263
	   lvItem->setText (0, idx);
1273
	   lvItem->setText (0, idx);
1264
	   datei.setFile (lvItem->text(1));
1274
	   datei.setFile (lvItem->text(1));
1265
	   garmin_save_all (gmn, datei.fileName().ascii(), datei.dirPath(true).ascii(), 1);
1275
	   garmin_save_all (gmn, datei.fileName().ascii(), datei.dirPath(true).ascii(), 1);
1266
	   delete qt;
1276
	   delete qt;
1267
	   return;
1277
	   return;
Line 1609... Line 1619...
1609
	   weight = cfg->readNumEntry("weight");
1619
	   weight = cfg->readNumEntry("weight");
1610
	   sampleTime = cfg->readNumEntry("seconds");
1620
	   sampleTime = cfg->readNumEntry("seconds");
1611
	   Serial = cfg->readBoolEntry("Serial");
1621
	   Serial = cfg->readBoolEntry("Serial");
1612
	   Contour = cfg->readBoolEntry("Contour");
1622
	   Contour = cfg->readBoolEntry("Contour");
1613
	   Device = cfg->readEntry("Device");
1623
	   Device = cfg->readEntry("Device");
-
 
1624
	   Forerunner = cfg->readBoolEntry("Forerunner", false);
1614
	   Data = cfg->readEntry("Data");
1625
	   Data = cfg->readEntry("Data");
1615
	   HRM = cfg->readEntry("HRM");
1626
	   HRM = cfg->readEntry("HRM");
1616
	   MAP = cfg->readEntry("MAP");
1627
	   MAP = cfg->readEntry("MAP");
1617
	   Units = cfg->readNumEntry("Units");
1628
	   Units = cfg->readNumEntry("Units");
1618
	   MapType = cfg->readNumEntry("MapType");
1629
	   MapType = cfg->readNumEntry("MapType");
Line 1846... Line 1857...
1846
	      lt = st.secsTo(t);
1857
	      lt = st.secsTo(t);
1847
	      t.setHMS(0, 0, 0);
1858
	      t.setHMS(0, 0, 0);
1848
	      t = t.addSecs(lt - secs);
1859
	      t = t.addSecs(lt - secs);
1849
	      qt->setDate(dat);
1860
	      qt->setDate(dat);
1850
	      qt->setTime(t);
1861
	      qt->setTime(t);
1851
	      qs_name.append(dat.toString("dd.MM.yyyy"));
1862
//	      qs_name.append(dat.toString("dd.MM.yyyy"));
-
 
1863
	      qs_name.append(kl->formatDate(dat, true));
1852
	      qs_name.append(" ");
1864
	      qs_name.append(" ");
1853
	      qs_name.append(st.toString("hh:mm:ss"));
1865
//	      qs_name.append(st.toString("hh:mm:ss"));
-
 
1866
	      qs_name.append(kl->formatTime(st, true));
1854
	      max_time = lt;
1867
	      max_time = lt;
1855
	      qs_etime = QString(qt->toString("hh:mm:ss.zzz"));
1868
	      qs_etime = QString(qt->toString("hh:mm:ss.zzz"));
1856
 
1869
 
1857
	      distance = 0.0;
1870
	      distance = 0.0;
1858
	      cal = 0;
1871
	      cal = 0;
Line 1908... Line 1921...
1908
 
1921
 
1909
		 int h = secs / 3600;
1922
		 int h = secs / 3600;
1910
		 int m = (secs - (h * 3600)) / 60;
1923
		 int m = (secs - (h * 3600)) / 60;
1911
		 int s = secs - ((h * 3600) + (m * 60));
1924
		 int s = secs - ((h * 3600) + (m * 60));
1912
		 t = QTime(h, m, s, 0);
1925
		 t = QTime(h, m, s, 0);
1913
		 qs_avgpace = t.toString("  hh:mm:ss");
1926
		 qs_avgpace = QString("  ") + kl->formatTime(t, true);
1914
 
1927
 
1915
		 if (Units == 0)
1928
		 if (Units == 0)
1916
		    qs_avgpace.append(QString(" /km"));
1929
		    qs_avgpace.append(QString(" /km"));
1917
		 else
1930
		 else
1918
		    qs_avgpace.append(QString(" /mi"));
1931
		    qs_avgpace.append(QString(" /mi"));
Line 1954... Line 1967...
1954
		 if ((lap = ds.getLap(i)) == NULL)
1967
		 if ((lap = ds.getLap(i)) == NULL)
1955
		    continue;
1968
		    continue;
1956
 
1969
 
1957
		 qt = garmin_dtime (lap->start_time);
1970
		 qt = garmin_dtime (lap->start_time);
1958
		 qs_name.sprintf("Lap %03d - ", laps);
1971
		 qs_name.sprintf("Lap %03d - ", laps);
1959
		 qs_name.append(qt->toString("hh:mm:ss"));
1972
//		 qs_name.append(qt->toString("hh:mm:ss"));
-
 
1973
		 qs_name.append(kl->formatTime(qt->time(), true));
1960
		 qs_distance.sprintf("%.2f %s", (Units == 1) ? lap->total_distance / 0.304 : lap->total_distance, (Units == 1) ? "ft" : "m");
1974
		 qs_distance.sprintf("%.2f %s", (Units == 1) ? lap->total_distance / 0.304 : lap->total_distance, (Units == 1) ? "ft" : "m");
1961
		 t = QTime(0, 0, 0, 0);
1975
		 t = QTime(0, 0, 0, 0);
1962
		 t = t.addMSecs(lap->total_time * 10);
1976
		 t = t.addMSecs(lap->total_time * 10);
1963
		 qs_etime = t.toString("hh:mm:ss.zzz");
1977
		 qs_etime = t.toString("hh:mm:ss.zzz");
1964
		 spd = lap->total_distance / (lap->total_time / 100.0);
1978
		 spd = lap->total_distance / (lap->total_time / 100.0);
Line 1990... Line 2004...
1990
		    long secs = (double)lap->total_time / 10000.0 * (fact / lap->total_distance * 100.0);
2004
		    long secs = (double)lap->total_time / 10000.0 * (fact / lap->total_distance * 100.0);
1991
		    int h = secs / 3600;
2005
		    int h = secs / 3600;
1992
		    int m = (secs - (h * 3600)) / 60;
2006
		    int m = (secs - (h * 3600)) / 60;
1993
		    int s = secs - ((h * 3600) + (m * 60));
2007
		    int s = secs - ((h * 3600) + (m * 60));
1994
		    t = QTime(h, m, s, 0);
2008
		    t = QTime(h, m, s, 0);
1995
		    qs_avgpace = t.toString("hh:mm:ss");
2009
//		    qs_avgpace = t.toString("hh:mm:ss");
-
 
2010
		    qs_avgpace = kl->formatTime(t, true);
1996
 
2011
 
1997
		    if (Units == 0)
2012
		    if (Units == 0)
1998
		       qs_avgpace.append(QString(" /km"));
2013
		       qs_avgpace.append(QString(" /km"));
1999
		    else
2014
		    else
2000
		       qs_avgpace.append(QString(" /mi"));
2015
		       qs_avgpace.append(QString(" /mi"));
Line 3035... Line 3050...
3035
	      y2 = height - margin_bottom;
3050
	      y2 = height - margin_bottom;
3036
	      paint.drawLine(x1, y1, x2, y2);
3051
	      paint.drawLine(x1, y1, x2, y2);
3037
	      QTime tm(0, 0, 0);
3052
	      QTime tm(0, 0, 0);
3038
	      tm = tm.addSecs(i);
3053
	      tm = tm.addSecs(i);
3039
	      paint.setPen(QPen(frame, 1, QPen::SolidLine));
3054
	      paint.setPen(QPen(frame, 1, QPen::SolidLine));
3040
	      paint.drawText(x1 - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((i >= 3600) ? "hh:mm:ss" : "mm:ss"));
3055
//	      paint.drawText(x1 - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((i >= 3600) ? "hh:mm:ss" : "mm:ss"));
-
 
3056
	      paint.drawText(x1 - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, kl->formatTime (tm, (i >= 3600) ? true : false));
3041
	      paint.setPen(QPen(mark, 1, QPen::SolidLine));
3057
	      paint.setPen(QPen(mark, 1, QPen::SolidLine));
3042
	   }
3058
	   }
3043
	}
3059
	}
3044
 
3060
 
3045
	// This is the total time, with pauses included, at the lower right
3061
	// This is the total time, with pauses included, at the lower right
3046
	// corner of the graphic.
3062
	// corner of the graphic.
3047
	QTime tm(0, 0, 0);
3063
	QTime tm(0, 0, 0);
3048
	QString qs;
3064
	QString qs;
3049
	tm = tm.addSecs(max_time);
3065
	tm = tm.addSecs(max_time);
3050
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
3066
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
3051
	paint.drawText(width - margin_right - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((max_time >= 3600) ? "hh:mm:ss" : "mm:ss"));
3067
//	paint.drawText(width - margin_right - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((max_time >= 3600) ? "hh:mm:ss" : "mm:ss"));
-
 
3068
	paint.drawText(width - margin_right - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, kl->formatTime(tm, (max_time >= 3600) ? true : false));
3052
 
3069
 
3053
	// Draw the minimal elevation, speed and/or heart rate
3070
	// Draw the minimal elevation, speed and/or heart rate
3054
	if (max_height > 0.0 || max_speed > 0.0)
3071
	if (max_height > 0.0 || max_speed > 0.0)
3055
	{
3072
	{
3056
	   // left side
3073
	   // left side