| 1 |
/* |
|---|
| 2 |
* Copyright (C) 2005-2006 Alo Sarv <madcat_@users.sourceforge.net> |
|---|
| 3 |
* |
|---|
| 4 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 5 |
* it under the terms of the GNU General Public License as published by |
|---|
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 |
* (at your option) any later version. |
|---|
| 8 |
* |
|---|
| 9 |
* This program is distributed in the hope that it will be useful, |
|---|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
* GNU General Public License for more details. |
|---|
| 13 |
* |
|---|
| 14 |
* You should have received a copy of the GNU General Public License |
|---|
| 15 |
* along with this program; if not, write to the Free Software |
|---|
| 16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 17 |
*/ |
|---|
| 18 |
|
|---|
| 19 |
#include <hncore/metadb.h> |
|---|
| 20 |
#include <hncore/metadata.h> |
|---|
| 21 |
#include <QApplication> |
|---|
| 22 |
#include <QFileDialog> |
|---|
| 23 |
#include <QProgressDialog> |
|---|
| 24 |
#include <QHeaderView> |
|---|
| 25 |
#include "fileviewer.h" |
|---|
| 26 |
|
|---|
| 27 |
int main(int argc, char *argv[]) { |
|---|
| 28 |
QApplication app(argc, argv); |
|---|
| 29 |
QMainWindow *wnd = new QMainWindow; |
|---|
| 30 |
Ui::MainWindow *ui = new Ui::MainWindow; |
|---|
| 31 |
ui->setupUi(wnd); |
|---|
| 32 |
QStringList headerLabels; |
|---|
| 33 |
headerLabels << "File Name" << "File Size" << "Modification Date"; |
|---|
| 34 |
ui->outWnd->setHeaderLabels(headerLabels); |
|---|
| 35 |
ui->outWnd->header()->setStretchLastSection(false); |
|---|
| 36 |
ui->outWnd->header()->resizeSection(0, 400); |
|---|
| 37 |
#ifndef WIN32 |
|---|
| 38 |
wnd->show(); |
|---|
| 39 |
#endif |
|---|
| 40 |
|
|---|
| 41 |
QString s = QFileDialog::getOpenFileName( |
|---|
| 42 |
wnd, "Choose metadb.dat file to load", |
|---|
| 43 |
"", "metadb.dat" |
|---|
| 44 |
); |
|---|
| 45 |
if (!s.size()) { |
|---|
| 46 |
return 0; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
std::ifstream ifs(s.toStdString().c_str(), std::ios::binary); |
|---|
| 50 |
MetaDb::instance().load(ifs); |
|---|
| 51 |
MetaDb::CIter it = MetaDb::instance().begin(); |
|---|
| 52 |
while (it != MetaDb::instance().end()) { |
|---|
| 53 |
QTreeWidgetItem *item = new QTreeWidgetItem(ui->outWnd); |
|---|
| 54 |
item->setText(0, QString::fromStdString((*it)->getName())); |
|---|
| 55 |
item->setText(1, QString::number((*it)->getSize())); |
|---|
| 56 |
item->setText(2, QString::number((*it)->getModDate())); |
|---|
| 57 |
++it; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
#ifdef WIN32 |
|---|
| 61 |
wnd->show(); |
|---|
| 62 |
#endif |
|---|
| 63 |
|
|---|
| 64 |
return app.exec(); |
|---|
| 65 |
} |
|---|