bool ExternalFile::idle( const QString& name, bool read ) { setFileName( name ); if( !TibiaFile::exists() ) { emit documentError( name, QObject::tr( "File does not exist." ), -1 ); return false; } if( !TibiaFile::open( QIODevice::ReadOnly ) ) { emit parseError( QObject::tr( "Open Error" ), TibiaFile::error() ); return false; } if( read ) { QDataStream in( this ); in.setByteOrder( QDataStream::LittleEndian ); in >> m_version; m_datFormat = g_formatHandler.getFormatByClient( m_version ); if( !m_datFormat ) { emit documentError( name, tr( "Unknown format: %1" ).arg( m_version ), -1 ); return false; } } m_idle = true; m_success = true; return m_success; }
void ItemEditor::onCurrentIndexChanged( int index ) { qint32 version = ui->comboVersions->itemData( index, Qt::UserRole ).toInt(); DatFormat *datFormat = g_formatHandler.getFormatByClient( version ); if( datFormat ) { ui->itemAttributes->setFormat( datFormat ); } }