Skip to content

Commit

Permalink
kfm load and save
Browse files Browse the repository at this point in the history
  • Loading branch information
m4444x committed Mar 24, 2006
1 parent c5dff16 commit 8678b43
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
8 changes: 8 additions & 0 deletions kfmmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ KfmModel::KfmModel( QObject * parent ) : BaseModel( parent )
clear();
}

QModelIndex KfmModel::getKFMroot() const
{
if ( kfmroot )
return createIndex( 0, 0, kfmroot );
else
return QModelIndex();
}

QString KfmModel::version2string( quint32 v )
{
if ( v == 0 ) return QString();
Expand Down
2 changes: 2 additions & 0 deletions kfmmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Q_OBJECT
// is it a compound type?
static bool isCompound( const QString & name );

QModelIndex getKFMroot() const;

// is this version supported ?
static bool isVersionSupported( quint32 );

Expand Down
68 changes: 41 additions & 27 deletions nifskope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,46 +519,49 @@ void NifSkope::load( const QString & filepath )

void NifSkope::load()
{
// open file
if ( lineLoad->text().isEmpty() )
{
nif->clear();
return;
}
if ( lineLoad->text().endsWith( ".KFM", Qt::CaseInsensitive ) )
setEnabled( false );

QString nifname = lineLoad->text();

if ( nifname.endsWith( ".KFM", Qt::CaseInsensitive ) )
{
loadKfm();
return;
if ( ! kfm->loadFromFile( nifname ) )
qWarning() << "failed to load kfm from file" << nifname;
nifname = kfm->get<QString>( kfm->getKFMroot(), "NIF File Name" );
if ( ! nifname.isEmpty() )
nifname.prepend( kfm->getFolder() + "/" );
}

setEnabled( false );
bool a = ogl->aAnimate->isChecked();
bool r = ogl->aRotate->isChecked();
ogl->aAnimate->setChecked( false );
ogl->aRotate->setChecked( false );

ProgDlg prog;
prog.setLabelText( "loading nif..." );
prog.setRange( 0, 1 );
prog.setValue( 0 );
prog.setMinimumDuration( 2100 );
connect( nif, SIGNAL( sigProgress( int, int ) ), & prog, SLOT( sltProgress( int, int ) ) );

if ( ! nif->loadFromFile( lineLoad->text() ) )
qWarning() << "failed to load nif from file " << lineLoad->text();
if ( nifname.isEmpty() )
{
nif->clear();
}
else
{
ProgDlg prog;
prog.setLabelText( "loading nif..." );
prog.setRange( 0, 1 );
prog.setValue( 0 );
prog.setMinimumDuration( 2100 );
connect( nif, SIGNAL( sigProgress( int, int ) ), & prog, SLOT( sltProgress( int, int ) ) );

if ( ! nif->loadFromFile( nifname ) )
qWarning() << "failed to load nif from file " << nifname;

}

ogl->aAnimate->setChecked( a );
ogl->aRotate->setChecked( r );
ogl->center();

setEnabled( true );
}

void NifSkope::loadKfm()
{
if ( ! kfm->loadFromFile( lineLoad->text() ) )
qWarning() << "failed to load kfm from file" << lineLoad->text();
}

void ProgDlg::sltProgress( int x, int y )
{
setRange( 0, y );
Expand All @@ -570,8 +573,19 @@ void NifSkope::save()
{
// write to file
setEnabled( false );
if ( ! nif->saveToFile( lineSave->text() ) )
qWarning() << "could not write file " << lineSave->text();

QString nifname = lineSave->text();

if ( nifname.endsWith( ".KFM", Qt::CaseInsensitive ) )
{
if ( ! kfm->saveToFile( nifname ) )
qWarning() << "failed to write kfm file" << nifname;
}
else
{
if ( ! nif->saveToFile( nifname ) )
qWarning() << "failed to write nif file " << nifname;
}
setEnabled( true );
}

Expand Down
2 changes: 0 additions & 2 deletions nifskope.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public slots:
void load();
void save();

void loadKfm();

void loadBrowse();
void saveBrowse();

Expand Down

0 comments on commit 8678b43

Please sign in to comment.