Browse Source

Added StyledDelegate to BackupWidget

to properly display the JulianDay in the users format
Felix Turowsky 1 year ago
parent
commit
22c42b241f
2 changed files with 11 additions and 1 deletions
  1. 9 1
      src/gui/widgets/backupwidget.cpp
  2. 2 0
      src/gui/widgets/backupwidget.h

+ 9 - 1
src/gui/widgets/backupwidget.cpp

@@ -22,6 +22,8 @@
 #include "src/functions/datetime.h"
 #include "src/database/dbsummary.h"
 #include "src/gui/dialogues/firstrundialog.h"
+#include "src/classes/settings.h"
+#include "src/classes/styleddatedelegate.h"
 
 #include <QListView>
 #include <QStandardItemModel>
@@ -39,6 +41,12 @@ BackupWidget::BackupWidget(QWidget *parent) :
     model->setHorizontalHeaderLabels(QStringList{tr("Total Time"),tr("Flights"), tr("Aircraft"),
                                                  tr("Pilots"), tr("Last Flight"), tr("Backup File")});
     view = ui->tableView;
+
+
+    // julian day to Date Format
+    const auto dateDelegate = new StyledDateDelegate(Settings::getDisplayFormat(), model);
+    view->setItemDelegateForColumn(DATE_COLUMN, dateDelegate);
+
     refresh();
 }
 
@@ -86,7 +94,7 @@ const QString BackupWidget::absoluteBackupPath()
 const QString BackupWidget::backupName()
 {
     auto owner = DB->getPilotEntry(1);
-    return  QString("logbook_backup_%1_%2.db").arg(
+    return  QStringLiteral("logbook_backup_%1_%2.db").arg(
         OPL::DateTime::dateTimeToString(QDateTime::currentDateTime(), OPL::DateTimeFormat_deprecated::Backup),
                                                   owner.getLastName()
                 );

+ 2 - 0
src/gui/widgets/backupwidget.h

@@ -96,6 +96,8 @@ private:
     QList<int> selectedRows;
     void refresh();
 
+    static constexpr int DATE_COLUMN = 4;
+
 protected:
     /*!
      * \brief Handles change events, like updating the UI to new localisation