39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include "psxsavewidget.h"
|
|
#include <QVBoxLayout>
|
|
#include <QTextCodec>
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
PSXSaveWidget::PSXSaveWidget( MemoryCard *memCard, int block, QWidget *parent ) : QFrame( parent ) {
|
|
this->memCard = memCard;
|
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
Icon *icon = new Icon;
|
|
QFrame *iconContainer = new QFrame;
|
|
iconContainer->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
|
|
QVBoxLayout *iconLayout = new QVBoxLayout;
|
|
iconWidget = new PSXIcon( icon );
|
|
iconLayout->addWidget( iconWidget );
|
|
iconContainer->setLayout( iconLayout );
|
|
mainLayout->addWidget( iconContainer );
|
|
mainLayout->addStretch();
|
|
label = new QLabel(); mainLayout->addWidget( label );
|
|
this->setLayout( mainLayout );
|
|
this->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
|
|
this->setEnabled( false );
|
|
if( block != 0 ) { this->setBlock( block ); }
|
|
}
|
|
|
|
void PSXSaveWidget::setBlock( int id ) {
|
|
InitialBlock *block = (InitialBlock*)memCard->getBlock( id );
|
|
QTextCodec *codec = QTextCodec::codecForName("Shift-JIS");
|
|
QString saveTitle = codec->toUnicode( block->Header()->SJISSaveTitle() );
|
|
//this->label->setText( saveTitle );
|
|
this->iconWidget->setIcon( block->getIcon( 0 ) );
|
|
this->iconWidget->update();
|
|
this->setEnabled( true );
|
|
}
|
|
|
|
void PSXSaveWidget::setBlockFromModel( const QModelIndex &index ) {
|
|
this->setBlock( index.model()->index( index.row(), 0 ).data().toInt() );
|
|
}
|
|
|