libpsxsave/qt-gui/main.cpp
2010-08-10 09:40:01 -04:00

50 lines
1.3 KiB
C++

#include <QtGui>
#include <iostream>
#include "psxsavewidget.h"
#include "memcard.h"
#include "psxmemcard.h"
int main( int argc, char *argv[] ) {
QApplication app( argc, argv );
MemoryCard *memCard = new MemoryCard();
if( argc > 1 ) {
memCard->loadFile( argv[1] );
if( argc > 2 ) {
for( int i = 2; i < argc; i++ ) {
memCard->loadMCS( argv[i] );
}
}
} else {
std::cout << "No filename provided, exiting.\n";
return 1;
}
QMap<QString, QString> games;
QWidget *mainWidget = new QWidget;
QVBoxLayout *vlayout = new QVBoxLayout;
QHBoxLayout *hlayout = new QHBoxLayout;
PSXMemoryCardModel *memCardModel = new PSXMemoryCardModel( memCard );
QTreeView *tv = new QTreeView();
tv->setModel( memCardModel );
tv->setColumnHidden( 0, true );
for( int i = 1; i < 5; i++ ) tv->resizeColumnToContents( i );
vlayout->addWidget( tv );
QWidget *listContainer = new QWidget;
listContainer->setLayout( vlayout );
hlayout->addWidget( listContainer );
PSXSaveWidget *saveWidget = new PSXSaveWidget( memCard );
hlayout->addWidget( saveWidget );
QObject::connect(
tv, SIGNAL( clicked( const QModelIndex & ) ),
saveWidget, SLOT( setBlockFromModel( const QModelIndex & ) ) );
mainWidget->setLayout( hlayout );
mainWidget->resize( 900, 400 );
mainWidget->show();
return app.exec();
}