Some bugs fixed.
[gpssportsniffer] / utils.cpp
index b48ffad..e2c0110 100755 (executable)
--- a/utils.cpp
+++ b/utils.cpp
@@ -1,3 +1,22 @@
+/****************************************************************************
+**
+**  Copyright (C) 2011  Tito Eritja Real <jtitoo@gmail.com>
+**
+**  This program is free software: you can redistribute it and/or modify
+**  it under the terms of the GNU General Public License as published by
+**  the Free Software Foundation, either version 3 of the License, or
+**  (at your option) any later version.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+**
+**  You should have received a copy of the GNU General Public License
+**  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+**
+****************************************************************************/
+
 #include "utils.h"
 #include "constants.h"
 #include "track.h"
@@ -56,7 +75,7 @@ Track* readFromXML(QString fileName){
 
     qDebug() << "going to read file:" << fileName;
 
-    Track* myTrack = new Track();
+    Track* myTrack = new Track(fileName);
     myTrack->addActivity("doesn'tmatter");
 
     if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -286,3 +305,16 @@ GpsPoint* parseTCXGpsPoint(QXmlStreamReader& xml){
     return point;
 }
 
+QString nameFromFile(QString fileName){
+
+    QString sep = "/";
+    int indexName = fileName.lastIndexOf(sep);
+    if(indexName<0){
+        return fileName;
+    }else{
+        int cont = fileName.length()-indexName-1;
+        QString stringName = fileName.right(cont);
+        return stringName;
+    }
+
+}