Procházet zdrojové kódy

Update FirstRunDialog to use New JSON interface

FirstRunDialog now uses the new JSON-based functions for initial setup.
Felix Turo před 3 roky
rodič
revize
37666376db

+ 62 - 32
l10n/openpilotlog_de.ts

@@ -4,27 +4,27 @@
 <context>
     <name>ADatabase</name>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="768"/>
+        <location filename="../src/database/adatabase.cpp" line="767"/>
         <source>&lt;tr&gt;&lt;td&gt;Total Time: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="769"/>
+        <location filename="../src/database/adatabase.cpp" line="768"/>
         <source>&lt;tr&gt;&lt;td&gt;Last Flight: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="770"/>
+        <location filename="../src/database/adatabase.cpp" line="769"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of flights: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="771"/>
+        <location filename="../src/database/adatabase.cpp" line="770"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of aircraft: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="772"/>
+        <location filename="../src/database/adatabase.cpp" line="771"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of Pilots: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
@@ -362,12 +362,12 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="166"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
         <source>Open CSV File for import</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="170"/>
         <source>CSV files (*.csv)</source>
         <translation type="unfinished"></translation>
     </message>
@@ -386,7 +386,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="27"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="82"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="88"/>
         <source>Next</source>
         <translation type="unfinished"></translation>
     </message>
@@ -431,7 +431,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="136"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="392"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="464"/>
         <source>Import Database</source>
         <translation type="unfinished"></translation>
     </message>
@@ -649,101 +649,131 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="97"/>
+        <location filename="../src/gui/dialogues/firstrundialog.ui" line="845"/>
+        <source>main</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="103"/>
         <source>Error</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="98"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="104"/>
         <source>Please enter first and last name</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="105"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="111"/>
         <source>Done</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="125"/>
-        <source>Database found</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="132"/>
+        <source>Existing Database found</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="126"/>
-        <source>Warning.An existing database file has been detected on your system.&lt;br&gt;A backup copy of the existing database will be created at this location:&lt;br&gt;%1</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="133"/>
+        <source>An existing database file has been detected on your system.&lt;br&gt;Would you like to create a backup of the existing database?&lt;br&gt;&lt;br&gt;Note: if you select no, the existing database will be overwritten. Thisaction is irreversible.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="135"/>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="145"/>
+        <source>Unable to backup old database:&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="148"/>
+        <source>Backup successfully created.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="155"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="164"/>
+        <source>Unable to delete existing database file.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="161"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="171"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="181"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="190"/>
         <source>Database setup failed</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="136"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="162"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;Database: Unable to connect</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="146"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="172"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="156"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="165"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="182"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="191"/>
         <source>Unable to execute database query&lt;br&gt;The following error has occured:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="224"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="281"/>
         <source>Create Database</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="225"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="282"/>
         <source>We are now going to create the database.&lt;br&gt;Would you like to download the latest database information?&lt;br&gt;(Recommended, Internet connection required)</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="235"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="292"/>
         <source>Downloading latest data has failed.&lt;br&gt;&lt;br&gt;Using local data instead.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="296"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="301"/>
+        <source>Database creation has been unsuccessful. The following error has ocurred:&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="308"/>
+        <source>Database creation has been unsuccessful. Unable to fill template data.&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="358"/>
         <source>Setup incomplete</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="297"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="359"/>
         <source>Without completing the initial setup you cannot use the application.&lt;br&gt;&lt;br&gt;Quit anyway?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="378"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="450"/>
         <source>Choose backup file</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="384"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="456"/>
         <source>No Database has been selected.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="393"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="465"/>
         <source>The following database will be imported:&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;tt&gt;%1&lt;br&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br&gt;Is this correct?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="399"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="471"/>
         <source>Unable to import database file:</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="402"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="474"/>
         <source>Database successfully imported.</source>
         <translation type="unfinished"></translation>
     </message>

+ 62 - 32
l10n/openpilotlog_en.ts

@@ -4,27 +4,27 @@
 <context>
     <name>ADatabase</name>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="768"/>
+        <location filename="../src/database/adatabase.cpp" line="767"/>
         <source>&lt;tr&gt;&lt;td&gt;Total Time: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="769"/>
+        <location filename="../src/database/adatabase.cpp" line="768"/>
         <source>&lt;tr&gt;&lt;td&gt;Last Flight: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="770"/>
+        <location filename="../src/database/adatabase.cpp" line="769"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of flights: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="771"/>
+        <location filename="../src/database/adatabase.cpp" line="770"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of aircraft: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="772"/>
+        <location filename="../src/database/adatabase.cpp" line="771"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of Pilots: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
@@ -362,12 +362,12 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="166"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
         <source>Open CSV File for import</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="170"/>
         <source>CSV files (*.csv)</source>
         <translation type="unfinished"></translation>
     </message>
@@ -386,7 +386,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="27"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="82"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="88"/>
         <source>Next</source>
         <translation type="unfinished"></translation>
     </message>
@@ -431,7 +431,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="136"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="392"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="464"/>
         <source>Import Database</source>
         <translation type="unfinished"></translation>
     </message>
@@ -649,101 +649,131 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="97"/>
+        <location filename="../src/gui/dialogues/firstrundialog.ui" line="845"/>
+        <source>main</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="103"/>
         <source>Error</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="98"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="104"/>
         <source>Please enter first and last name</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="105"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="111"/>
         <source>Done</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="125"/>
-        <source>Database found</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="132"/>
+        <source>Existing Database found</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="126"/>
-        <source>Warning.An existing database file has been detected on your system.&lt;br&gt;A backup copy of the existing database will be created at this location:&lt;br&gt;%1</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="133"/>
+        <source>An existing database file has been detected on your system.&lt;br&gt;Would you like to create a backup of the existing database?&lt;br&gt;&lt;br&gt;Note: if you select no, the existing database will be overwritten. Thisaction is irreversible.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="135"/>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="145"/>
+        <source>Unable to backup old database:&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="148"/>
+        <source>Backup successfully created.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="155"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="164"/>
+        <source>Unable to delete existing database file.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="161"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="171"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="181"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="190"/>
         <source>Database setup failed</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="136"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="162"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;Database: Unable to connect</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="146"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="172"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="156"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="165"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="182"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="191"/>
         <source>Unable to execute database query&lt;br&gt;The following error has occured:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="224"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="281"/>
         <source>Create Database</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="225"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="282"/>
         <source>We are now going to create the database.&lt;br&gt;Would you like to download the latest database information?&lt;br&gt;(Recommended, Internet connection required)</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="235"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="292"/>
         <source>Downloading latest data has failed.&lt;br&gt;&lt;br&gt;Using local data instead.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="296"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="301"/>
+        <source>Database creation has been unsuccessful. The following error has ocurred:&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="308"/>
+        <source>Database creation has been unsuccessful. Unable to fill template data.&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="358"/>
         <source>Setup incomplete</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="297"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="359"/>
         <source>Without completing the initial setup you cannot use the application.&lt;br&gt;&lt;br&gt;Quit anyway?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="378"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="450"/>
         <source>Choose backup file</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="384"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="456"/>
         <source>No Database has been selected.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="393"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="465"/>
         <source>The following database will be imported:&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;tt&gt;%1&lt;br&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br&gt;Is this correct?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="399"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="471"/>
         <source>Unable to import database file:</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="402"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="474"/>
         <source>Database successfully imported.</source>
         <translation type="unfinished"></translation>
     </message>

+ 62 - 32
l10n/openpilotlog_es.ts

@@ -4,27 +4,27 @@
 <context>
     <name>ADatabase</name>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="768"/>
+        <location filename="../src/database/adatabase.cpp" line="767"/>
         <source>&lt;tr&gt;&lt;td&gt;Total Time: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="769"/>
+        <location filename="../src/database/adatabase.cpp" line="768"/>
         <source>&lt;tr&gt;&lt;td&gt;Last Flight: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="770"/>
+        <location filename="../src/database/adatabase.cpp" line="769"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of flights: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="771"/>
+        <location filename="../src/database/adatabase.cpp" line="770"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of aircraft: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/database/adatabase.cpp" line="772"/>
+        <location filename="../src/database/adatabase.cpp" line="771"/>
         <source>&lt;tr&gt;&lt;td&gt;Number of Pilots: &lt;/td&gt;&lt;td&gt;%1&lt;/td&gt;</source>
         <translation type="unfinished"></translation>
     </message>
@@ -362,12 +362,12 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="166"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
         <source>Open CSV File for import</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/widgets/debugwidget.cpp" line="168"/>
+        <location filename="../src/gui/widgets/debugwidget.cpp" line="170"/>
         <source>CSV files (*.csv)</source>
         <translation type="unfinished"></translation>
     </message>
@@ -386,7 +386,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="27"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="82"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="88"/>
         <source>Next</source>
         <translation type="unfinished"></translation>
     </message>
@@ -431,7 +431,7 @@ Error: %2</source>
     </message>
     <message>
         <location filename="../src/gui/dialogues/firstrundialog.ui" line="136"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="392"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="464"/>
         <source>Import Database</source>
         <translation type="unfinished"></translation>
     </message>
@@ -649,101 +649,131 @@ Error: %2</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="97"/>
+        <location filename="../src/gui/dialogues/firstrundialog.ui" line="845"/>
+        <source>main</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="103"/>
         <source>Error</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="98"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="104"/>
         <source>Please enter first and last name</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="105"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="111"/>
         <source>Done</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="125"/>
-        <source>Database found</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="132"/>
+        <source>Existing Database found</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="126"/>
-        <source>Warning.An existing database file has been detected on your system.&lt;br&gt;A backup copy of the existing database will be created at this location:&lt;br&gt;%1</source>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="133"/>
+        <source>An existing database file has been detected on your system.&lt;br&gt;Would you like to create a backup of the existing database?&lt;br&gt;&lt;br&gt;Note: if you select no, the existing database will be overwritten. Thisaction is irreversible.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="135"/>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="145"/>
+        <source>Unable to backup old database:&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="148"/>
+        <source>Backup successfully created.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <location filename="../src/gui/dialogues/firstrundialog.cpp" line="155"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="164"/>
+        <source>Unable to delete existing database file.</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="161"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="171"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="181"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="190"/>
         <source>Database setup failed</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="136"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="162"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;Database: Unable to connect</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="146"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="172"/>
         <source>Errors have ocurred creating the database.Without a working database The application will not be usable.&lt;br&gt;The following error has ocurred:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="156"/>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="165"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="182"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="191"/>
         <source>Unable to execute database query&lt;br&gt;The following error has occured:&lt;br&gt;%1</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="224"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="281"/>
         <source>Create Database</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="225"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="282"/>
         <source>We are now going to create the database.&lt;br&gt;Would you like to download the latest database information?&lt;br&gt;(Recommended, Internet connection required)</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="235"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="292"/>
         <source>Downloading latest data has failed.&lt;br&gt;&lt;br&gt;Using local data instead.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="296"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="301"/>
+        <source>Database creation has been unsuccessful. The following error has ocurred:&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="308"/>
+        <source>Database creation has been unsuccessful. Unable to fill template data.&lt;br&gt;&lt;br&gt;%1</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="358"/>
         <source>Setup incomplete</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="297"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="359"/>
         <source>Without completing the initial setup you cannot use the application.&lt;br&gt;&lt;br&gt;Quit anyway?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="378"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="450"/>
         <source>Choose backup file</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="384"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="456"/>
         <source>No Database has been selected.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="393"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="465"/>
         <source>The following database will be imported:&lt;br&gt;&lt;br&gt;&lt;b&gt;&lt;tt&gt;%1&lt;br&gt;&lt;/b&gt;&lt;/tt&gt;&lt;br&gt;Is this correct?</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="399"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="471"/>
         <source>Unable to import database file:</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="402"/>
+        <location filename="../src/gui/dialogues/firstrundialog.cpp" line="474"/>
         <source>Database successfully imported.</source>
         <translation type="unfinished"></translation>
     </message>

+ 1 - 1
src/database/adatabase.cpp

@@ -385,7 +385,7 @@ bool ADatabase::insert(AEntry new_entry)
     }
 
     //check result.
-    if (!query.exec())
+    if (query.exec())
     {
         DEB << "Entry successfully committed.";
         emit dataBaseUpdated();

+ 10 - 0
src/database/adatabase.h

@@ -345,8 +345,18 @@ public:
      */
     QVector<RowData_T> getTable(ADatabaseTable table_name);
 
+    /*!
+     * \brief getUserTableNames returns a list of the table names of tables that contain user-created data
+     * (flights, pilots,..)
+     * \return
+     */
     QStringList getUserTableNames();
 
+    /*!
+     * \brief getTemplateTableNames returns a list of the table names of tables that contain template data
+     * (aiports, aircraft,..)
+     * \return
+     */
     QStringList getTemplateTableNames();
 
 signals:

+ 1 - 0
src/database/adatabasesetup.cpp

@@ -290,6 +290,7 @@ bool ADataBaseSetup::createDatabase()
     return true;
 }
 
+QT_DEPRECATED
 bool ADataBaseSetup::downloadTemplates()
 {
     QDir template_dir(AStandardPaths::directory(AStandardPaths::Templates));

+ 1 - 1
src/database/adbsetup.cpp

@@ -349,7 +349,7 @@ bool importTemplateData(bool use_local_ressources)
             return false;
         }
     } // for table_name
-    return false;
+    return true;
 }
 
 } // namespace aDbSetup

+ 87 - 15
src/gui/dialogues/firstrundialog.cpp

@@ -19,7 +19,9 @@
 #include "ui_firstrundialog.h"
 #include "src/functions/alog.h"
 #include "src/database/adatabase.h"
-#include "src/database/adatabasesetup.h"
+#include "src/gui/widgets/backupwidget.h"
+//#include "src/database/adatabasesetup.h"
+#include "src/database/adbsetup.h"
 #include "src/classes/apilotentry.h"
 #include "src/classes/adownload.h"
 #include "src/classes/asettings.h"
@@ -27,7 +29,9 @@
 #include "src/functions/adate.h"
 #include <QErrorMessage>
 #include <QFileDialog>
+#include <QKeyEvent>
 #include "src/classes/astyle.h"
+#include "src/functions/adatetime.h"
 
 FirstRunDialog::FirstRunDialog(QWidget *parent) :
     QDialog(parent),
@@ -62,6 +66,8 @@ FirstRunDialog::FirstRunDialog(QWidget *parent) :
                     ADate::getFormatString(Opl::Date::ADateFormat::ISODate));
         date_edit->setDate(QDate::currentDate());
     }
+    // Debug - use ctrl + t to enable branchLineEdit to select from which git branch the templates are pulled
+    ui->branchLineEdit->setVisible(false);
 }
 
 FirstRunDialog::~FirstRunDialog()
@@ -122,15 +128,35 @@ bool FirstRunDialog::finishSetup()
     QFileInfo database_file(AStandardPaths::directory(AStandardPaths::Database).
                                  absoluteFilePath(QStringLiteral("logbook.db")));
     if (database_file.exists()) {
-        QMessageBox message_box(QMessageBox::Critical, tr("Database found"),
-                                tr("Warning."
-                                   "An existing database file has been detected on your system.<br>"
-                                   "A backup copy of the existing database will be created at this location:<br>"
-                                   "%1").arg(
-                                    QDir::cleanPath(AStandardPaths::directory(AStandardPaths::Backup).canonicalPath())));
-        message_box.exec();
-        ADataBaseSetup::backupOldData();
-    }
+
+        QMessageBox message_box(QMessageBox::Question, tr("Existing Database found"),
+                                   tr("An existing database file has been detected on your system.<br>"
+                                   "Would you like to create a backup of the existing database?<br><br>"
+                                   "Note: if you select no, the existing database will be overwritten. This"
+                                   "action is irreversible."),
+                                   QMessageBox::Yes | QMessageBox::No, this);
+        message_box.setDefaultButton(QMessageBox::Yes);
+
+        if(message_box.exec() == QMessageBox::Yes) {
+            // Create Backup
+            const QString backup_name = BackupWidget::absoluteBackupPath();
+            QFile old_db_file(database_file.absoluteFilePath());
+            if (!old_db_file.copy(backup_name)) {
+                WARN(tr("Unable to backup old database:<br>%1").arg(old_db_file.errorString()));
+                return false;
+            } else {
+                INFO(tr("Backup successfully created."));
+            }
+        }
+
+        //delete existing DB file
+        QFile db_file(database_file.absoluteFilePath());
+        if (!db_file.remove()) {
+            WARN(tr("Unable to delete existing database file."));
+            return false;
+        }
+    } // if database file exists
+
     if (!aDB->connect()) {
         QMessageBox message_box(QMessageBox::Critical, tr("Database setup failed"),
                                 tr("Errors have ocurred creating the database."
@@ -172,6 +198,37 @@ bool FirstRunDialog::finishSetup()
     return true;
 }
 
+bool FirstRunDialog::downloadTemplates(QString branch_name)
+{
+    // Create url string
+    auto template_url_string = QStringLiteral("https://raw.githubusercontent.com/fiffty-50/openpilotlog/");
+    template_url_string.append(branch_name);
+    template_url_string.append(QLatin1String("/assets/database/templates/"));
+
+    QDir template_dir(AStandardPaths::directory(AStandardPaths::Templates));
+
+    const auto template_tables = aDB->getTemplateTableNames();
+    for (const auto& table : template_tables) {
+        QEventLoop loop;
+        ADownload* dl = new ADownload;
+        QObject::connect(dl, &ADownload::done, &loop, &QEventLoop::quit );
+        dl->setTarget(QUrl(template_url_string + table + QLatin1String(".json")));
+        dl->setFileName(template_dir.absoluteFilePath(table + QLatin1String(".json")));
+
+        DEB << "Downloading: " << template_url_string + table + QLatin1String(".json");
+        DEB << "To:" << AStandardPaths::directory(AStandardPaths::Templates);
+
+        dl->download();
+        dl->deleteLater();
+        loop.exec(); // event loop waits for download done signal before allowing loop to continue
+
+        QFileInfo downloaded_file(template_dir.filePath(table + QLatin1String(".json")));
+        if (downloaded_file.size() == 0)
+            return false; // ssl/network error
+    }
+    return true;
+}
+
 void FirstRunDialog::writeSettings()
 {
     ASettings::resetToDefaults();
@@ -230,7 +287,7 @@ bool FirstRunDialog::setupDatabase()
 
     if (confirm.exec() == QMessageBox::Yes) {
         useRessourceData = false;
-        if (!ADataBaseSetup::downloadTemplates()) {
+        if (!downloadTemplates(ui->branchLineEdit->text())) {
             QMessageBox message_box(this);
             message_box.setText(tr("Downloading latest data has failed.<br><br>Using local data instead."));
             message_box.exec();
@@ -240,14 +297,19 @@ bool FirstRunDialog::setupDatabase()
         useRessourceData = true;
     }
 
-    if(!ADataBaseSetup::createDatabase())
+    if(!aDbSetup::createDatabase()) {
+        WARN(tr("Database creation has been unsuccessful. The following error has ocurred:<br><br>%1")
+             .arg(aDB->lastError.text()));
         return false;
+    }
 
-    aDB->updateLayout();
 
-    if(!ADataBaseSetup::importDefaultData(useRessourceData))
+    if(!aDbSetup::importTemplateData(useRessourceData)) {
+        WARN(tr("Database creation has been unsuccessful. Unable to fill template data.<br><br>%1")
+             .arg(aDB->lastError.text()));
         return false;
-    aDB->updateLayout();
+    }
+
     return true;
 }
 
@@ -306,6 +368,16 @@ void FirstRunDialog::reject()
     }
 }
 
+void FirstRunDialog::keyPressEvent(QKeyEvent *keyEvent)
+{
+    if(keyEvent->type() == QKeyEvent::KeyPress) {
+        if(keyEvent->matches(QKeySequence::AddTab)) {
+            ui->branchLineEdit->setVisible(true);
+            ui->branchLineEdit->setEnabled(true);
+        }
+    }
+}
+
 void FirstRunDialog::on_styleComboBox_currentTextChanged(const QString &new_style_setting)
 {
     DEB << "style selected:"<<new_style_setting;

+ 12 - 0
src/gui/dialogues/firstrundialog.h

@@ -68,10 +68,22 @@ private:
     bool createUserEntry();
     bool writeCurrencies();
     bool finishSetup();
+    bool downloadTemplates(QString branch_name);
 
     QList<QDateEdit*> dateEdits;
 
+protected:
     void reject() override;
+    /*!
+     * \brief Shows the debug widget by pressing <ctrl + t>
+     */
+
+    /*!
+     * \brief keyPressEvent ctrl + t enables debug mode, showing the branch selector
+     * which is used to select a git branch other than main for downloading the templates
+     * \param keyEvent
+     */
+    void keyPressEvent(QKeyEvent* keyEvent) override;
 };
 
 #endif // FIRSTRUNDIALOG_H

+ 11 - 1
src/gui/dialogues/firstrundialog.ui

@@ -31,7 +31,7 @@
    <item row="1" column="0" colspan="2">
     <widget class="QStackedWidget" name="stackedWidget">
      <property name="currentIndex">
-      <number>0</number>
+      <number>4</number>
      </property>
      <widget class="QWidget" name="personalDataPage">
       <layout class="QGridLayout" name="gridLayout_9">
@@ -836,6 +836,16 @@
          </property>
         </widget>
        </item>
+       <item row="2" column="0">
+        <widget class="QLineEdit" name="branchLineEdit">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="text">
+          <string>main</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>

+ 10 - 10
src/gui/widgets/backupwidget.h

@@ -74,6 +74,16 @@ public:
     explicit BackupWidget(QWidget *parent = nullptr);
     ~BackupWidget();
 
+    /*!
+     * \brief Generates a filename for creating a backup
+     */
+    static const QString backupName();
+
+    /*!
+     * \brief Generates the absolute path for a new local backup file.
+     */
+    static const QString absoluteBackupPath();
+
 private slots:
     void on_tableView_clicked(const QModelIndex &index);
 
@@ -117,16 +127,6 @@ private:
                                                     // AFileStandardItem class
     void refresh();
 
-    /*!
-     * \brief Generates a filename for creating a backup
-     */
-    const QString backupName();
-
-    /*!
-     * \brief Generates the absolute path for a new backup file.
-     */
-    const QString absoluteBackupPath();
-
 protected:
     /*!
      * \brief Handles change events, like updating the UI to new localisation

+ 3 - 7
src/gui/widgets/debugwidget.cpp

@@ -22,6 +22,7 @@
 #include "src/gui/widgets/pilotswidget.h"
 #include "src/gui/widgets/aircraftwidget.h"
 #include "src/gui/dialogues/firstrundialog.h"
+#include "src/gui/widgets/backupwidget.h"
 #include <QtGlobal>
 #include "src/functions/atime.h"
 #include "src/functions/astat.h"
@@ -32,13 +33,8 @@
 void DebugWidget::on_debugPushButton_clicked()
 {
     // Debug
-    QString query = "Invalid";
-    aDB->getAircraftEntry(4444);
-    DEB << aDB->lastError.type();
-    aDB->customQuery(query, 3);
-    DEB << aDB->lastError.type();
-    aDB->customQuery("SELECT * FROM FLIGHTS", 1);
-    DEB << aDB->lastError.type();
+    auto frd = new FirstRunDialog(this);
+    frd->exec();
 
 }