Mercurial > retraceit
diff src/mainwindow.cpp @ 2:97d2c8869c39
First prototype implementation of table view and player
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 23 Mar 2015 16:34:42 +0100 |
parents | 147b08bc7d64 |
children | 248d5d1cdb38 |
line wrap: on
line diff
--- a/src/mainwindow.cpp Mon Mar 23 16:33:26 2015 +0100 +++ b/src/mainwindow.cpp Mon Mar 23 16:34:42 2015 +0100 @@ -9,6 +9,8 @@ #include "mainwindow.h" #include "constants.h" +#include "metadataview.h" +#include "pngplayer.h" #include <QDebug> #include <QDialog> @@ -28,11 +30,13 @@ #include <QStandardPaths> #include <QStyle> #include <QStatusBar> +#include <QTabWidget> +#include <QVBoxLayout> MainWindow::MainWindow() : - mHasValidFolder(false) -{ + mDataView(NULL) { setStatusBar(new QStatusBar()); + resize(1190, 500); setupGUI(); readSettings(); @@ -42,8 +46,21 @@ } -void MainWindow::setupGUI() -{ +void MainWindow::setupGUI() { + QTabWidget *tabWidget = new QTabWidget; + mDataView = new MetaDataView(this); + mPlayer = new PNGPlayer(this); + + tabWidget->addTab(mPlayer, tr("Player")); + tabWidget->addTab(mDataView, tr("Filter/Details")); + tabWidget->setMovable(true); + + setCentralWidget(tabWidget); + + connect (mPlayer, &PNGPlayer::error, this, &MainWindow::showErrorMessage); + connect (mPlayer, &PNGPlayer::advance, mDataView, &MetaDataView::selectNextRow); + connect (mDataView, &MetaDataView::selectionChanged, mPlayer, + &PNGPlayer::showPicture); } void MainWindow::showErrorMessage(const QString& errMsg) { @@ -61,7 +78,7 @@ restoreGeometry(mSettings.value("geometry").toByteArray()); restoreState(mSettings.value("windowState").toByteArray()); } - +/* void MainWindow::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasUrls()) { @@ -104,7 +121,7 @@ { event->accept(); } - +*/ void MainWindow::setFolder(const QString& folder) { QFileInfo fi(folder); @@ -112,6 +129,19 @@ showErrorMessage(tr("Failed to access directory: '%1'").arg(folder)); } QDir dir = QDir(folder); + QFileInfo metaData = dir.absoluteFilePath("metadata.csv"); + if (!metaData.exists() || !metaData.isReadable()) { + showErrorMessage(tr("Failed to access meta data file: '%1'").arg( + metaData.filePath())); - // TODO; + } + QString errorMsg = mDataView->parseMetaData(metaData.filePath()); + if (!errorMsg.isEmpty()) { + showErrorMessage(errorMsg); + return; + } + statusBar()->showMessage(tr("Parsed: '%1'").arg(metaData.filePath())); + qDebug() << "Parsed: " << metaData.filePath(); + mCurFolder = folder; + mPlayer->setBaseDir(folder); }