Mercurial > retraceit
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:7a2637c3eb83 | 2:97d2c8869c39 |
---|---|
7 | 7 |
8 /** @file See mainwindow.h */ | 8 /** @file See mainwindow.h */ |
9 #include "mainwindow.h" | 9 #include "mainwindow.h" |
10 | 10 |
11 #include "constants.h" | 11 #include "constants.h" |
12 #include "metadataview.h" | |
13 #include "pngplayer.h" | |
12 | 14 |
13 #include <QDebug> | 15 #include <QDebug> |
14 #include <QDialog> | 16 #include <QDialog> |
15 #include <QWidget> | 17 #include <QWidget> |
16 #include <QHBoxLayout> | 18 #include <QHBoxLayout> |
26 #include <QDragMoveEvent> | 28 #include <QDragMoveEvent> |
27 #include <QMimeData> | 29 #include <QMimeData> |
28 #include <QStandardPaths> | 30 #include <QStandardPaths> |
29 #include <QStyle> | 31 #include <QStyle> |
30 #include <QStatusBar> | 32 #include <QStatusBar> |
33 #include <QTabWidget> | |
34 #include <QVBoxLayout> | |
31 | 35 |
32 MainWindow::MainWindow() : | 36 MainWindow::MainWindow() : |
33 mHasValidFolder(false) | 37 mDataView(NULL) { |
34 { | |
35 setStatusBar(new QStatusBar()); | 38 setStatusBar(new QStatusBar()); |
39 resize(1190, 500); | |
36 | 40 |
37 setupGUI(); | 41 setupGUI(); |
38 readSettings(); | 42 readSettings(); |
39 setAcceptDrops(true); | 43 setAcceptDrops(true); |
40 //QIcon windowIcon = QIcon(":/icon-64.png"); | 44 //QIcon windowIcon = QIcon(":/icon-64.png"); |
41 //setWindowIcon(windowIcon); | 45 //setWindowIcon(windowIcon); |
42 | 46 |
43 } | 47 } |
44 | 48 |
45 void MainWindow::setupGUI() | 49 void MainWindow::setupGUI() { |
46 { | 50 QTabWidget *tabWidget = new QTabWidget; |
51 mDataView = new MetaDataView(this); | |
52 mPlayer = new PNGPlayer(this); | |
53 | |
54 tabWidget->addTab(mPlayer, tr("Player")); | |
55 tabWidget->addTab(mDataView, tr("Filter/Details")); | |
56 tabWidget->setMovable(true); | |
57 | |
58 setCentralWidget(tabWidget); | |
59 | |
60 connect (mPlayer, &PNGPlayer::error, this, &MainWindow::showErrorMessage); | |
61 connect (mPlayer, &PNGPlayer::advance, mDataView, &MetaDataView::selectNextRow); | |
62 connect (mDataView, &MetaDataView::selectionChanged, mPlayer, | |
63 &PNGPlayer::showPicture); | |
47 } | 64 } |
48 | 65 |
49 void MainWindow::showErrorMessage(const QString& errMsg) { | 66 void MainWindow::showErrorMessage(const QString& errMsg) { |
50 QMessageBox::warning(this, tr("Error!"), errMsg); | 67 QMessageBox::warning(this, tr("Error!"), errMsg); |
51 statusBar()->showMessage(errMsg); | 68 statusBar()->showMessage(errMsg); |
59 | 76 |
60 void MainWindow::readSettings() { | 77 void MainWindow::readSettings() { |
61 restoreGeometry(mSettings.value("geometry").toByteArray()); | 78 restoreGeometry(mSettings.value("geometry").toByteArray()); |
62 restoreState(mSettings.value("windowState").toByteArray()); | 79 restoreState(mSettings.value("windowState").toByteArray()); |
63 } | 80 } |
64 | 81 /* |
65 void MainWindow::dragEnterEvent(QDragEnterEvent *event) | 82 void MainWindow::dragEnterEvent(QDragEnterEvent *event) |
66 { | 83 { |
67 if (event->mimeData()->hasUrls()) { | 84 if (event->mimeData()->hasUrls()) { |
68 foreach (const QUrl & url, event->mimeData()->urls()) { | 85 foreach (const QUrl & url, event->mimeData()->urls()) { |
69 if (url.isLocalFile()) { | 86 if (url.isLocalFile()) { |
102 | 119 |
103 void MainWindow::dragLeaveEvent(QDragLeaveEvent *event) | 120 void MainWindow::dragLeaveEvent(QDragLeaveEvent *event) |
104 { | 121 { |
105 event->accept(); | 122 event->accept(); |
106 } | 123 } |
107 | 124 */ |
108 void MainWindow::setFolder(const QString& folder) | 125 void MainWindow::setFolder(const QString& folder) |
109 { | 126 { |
110 QFileInfo fi(folder); | 127 QFileInfo fi(folder); |
111 if (!fi.isDir() || !fi.isReadable()) { | 128 if (!fi.isDir() || !fi.isReadable()) { |
112 showErrorMessage(tr("Failed to access directory: '%1'").arg(folder)); | 129 showErrorMessage(tr("Failed to access directory: '%1'").arg(folder)); |
113 } | 130 } |
114 QDir dir = QDir(folder); | 131 QDir dir = QDir(folder); |
132 QFileInfo metaData = dir.absoluteFilePath("metadata.csv"); | |
133 if (!metaData.exists() || !metaData.isReadable()) { | |
134 showErrorMessage(tr("Failed to access meta data file: '%1'").arg( | |
135 metaData.filePath())); | |
115 | 136 |
116 // TODO; | 137 } |
138 QString errorMsg = mDataView->parseMetaData(metaData.filePath()); | |
139 if (!errorMsg.isEmpty()) { | |
140 showErrorMessage(errorMsg); | |
141 return; | |
142 } | |
143 statusBar()->showMessage(tr("Parsed: '%1'").arg(metaData.filePath())); | |
144 qDebug() << "Parsed: " << metaData.filePath(); | |
145 mCurFolder = folder; | |
146 mPlayer->setBaseDir(folder); | |
117 } | 147 } |