--- a/igc.h Sun Jan 22 22:53:56 2012 +0100
+++ b/igc.h Tue Jan 24 01:38:43 2012 +0100
@@ -26,6 +26,7 @@
void read(QTextStream&);
QString device() const { return device_; }
QString pilot() const { return pilot_; }
+ QString glider() const { return glider_; }
QDate date() const { return date_; }
private:
QString device_, pilot_, glider_;
--- a/main.cc Sun Jan 22 22:53:56 2012 +0100
+++ b/main.cc Tue Jan 24 01:38:43 2012 +0100
@@ -8,5 +8,7 @@
MainWindow mw;
mw.show();
+ if (argc >= 2) mw.open(argv[1]);
+
return app.exec();
}
--- a/mainwindow.cc Sun Jan 22 22:53:56 2012 +0100
+++ b/mainwindow.cc Tue Jan 24 01:38:43 2012 +0100
@@ -9,6 +9,8 @@
connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
+
+
}
MainWindow::~MainWindow()
@@ -16,34 +18,71 @@
delete ui;
}
-void MainWindow::open()
+void MainWindow::open(const QString &s)
{
- QString fileName = QFileDialog::getOpenFileName(
- this,
- tr("Open IGC file"),
- "flights", tr("IGC files (*.igc);; All files (*)"));
- if (fileName.isEmpty()) return;
+ QString fileName;
+ if (s.isEmpty()) {
+ fileName = QFileDialog::getOpenFileName(
+ this,
+ tr("Open IGC file"),
+ "flights", tr("IGC files (*.igc);; All files (*)"));
+ if (fileName.isEmpty()) return;
+ }
+ else fileName = s;
- if(currentFile.isOpen())
- currentFile.close();
+
+ if(currentFile_.isOpen())
+ currentFile_.close();
- currentFile.setFileName(fileName);
+ currentFile_.setFileName(fileName);
- if (!currentFile.open(QFile::ReadOnly)) {
+ if (!currentFile_.open(QFile::ReadOnly)) {
QMessageBox::critical(this,
tr("Ooops!"),
- tr("The file %1 cannot be opened: %2!").arg(fileName).arg(currentFile.errorString()));
+ tr("The file %1 cannot be opened: %2!").arg(fileName).arg(currentFile_.errorString()));
return;
}
- input.setDevice(¤tFile);
+ input_.setDevice(¤tFile_);
setWindowTitle(QFileInfo(fileName).baseName());
statusBar()->showMessage(tr("opening %1").arg(fileName), 5000);
- igc.read(input);
+ igc_.read(input_);
+
+
+ // now let's fill the table
+ QTableWidget *t = ui->table;
+ int r = 0;
+ const int K = 0;
+ const int V = 1;
+
+ // cleanup
+ t->clearContents();
+ t->setRowCount(0);
+
+ // fill
+ t->setRowCount(t->rowCount() + 1);
+ t->setItem(r, K, new QTableWidgetItem(tr("Pilot")));
+ t->setItem(r, V, new QTableWidgetItem(igc_.pilot()));
+ ++r;
- qDebug() << igc.device();
- qDebug() << igc.pilot();
- qDebug() << igc.date();
+ t->setRowCount(t->rowCount() + 1);
+ t->setItem(r, K, new QTableWidgetItem(tr("Date")));
+ t->setItem(r, V, new QTableWidgetItem(igc_
+ .date()
+ .toString(tr("yyyy-MMM-dd (dddd)"))));
+ ++r;
+
+ t->setRowCount(t->rowCount() + 1);
+ t->setItem(r, K, new QTableWidgetItem(tr("Glider")));
+ t->setItem(r, V, new QTableWidgetItem(igc_.glider()));
+ ++r;
+
+
+// ui->table->setItem(0, 1, new QTableWidgetItem(igc_.pilot()));
+
+ qDebug() << igc_.device();
+ qDebug() << igc_.pilot();
+ qDebug() << igc_.date();
}
--- a/mainwindow.h Sun Jan 22 22:53:56 2012 +0100
+++ b/mainwindow.h Tue Jan 24 01:38:43 2012 +0100
@@ -12,15 +12,15 @@
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
- protected slots:
- void open();
+ public slots:
+ void open(const QString& = "");
private:
Ui::MainWindow *ui;
- QFile currentFile;
- QTextStream input;
+ QFile currentFile_;
+ QTextStream input_;
- IGC igc;
+ IGC igc_;
};
--- a/ui/mainwindow.ui Sun Jan 22 22:53:56 2012 +0100
+++ b/ui/mainwindow.ui Tue Jan 24 01:38:43 2012 +0100
@@ -13,7 +13,87 @@
<property name="windowTitle">
<string>MainWindow</string>
</property>
- <widget class="QWidget" name="centralwidget"/>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="info">
+ <attribute name="title">
+ <string>Info</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QTableWidget" name="table">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::NoSelection</enum>
+ </property>
+ <property name="showGrid">
+ <bool>false</bool>
+ </property>
+ <property name="cornerButtonEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <attribute name="horizontalHeaderVisible">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Attribute</string>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="altitude">
+ <attribute name="title">
+ <string>Altitude</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QGraphicsView" name="graphicsView"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>