Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- QList<QTreeWidgetItem *> WitHandler::StringListToGameList( const QStringList &list, bool *okRet )
- {
- int lines = list.size();
- bool ok = false;
- int gameCnt = -1;
- QString used;
- qint64 totalHddUsed = 0;
- int mode = 0;// 0 = hdd info, 1 = game info
- QList<QTreeWidgetItem *> games;
- QString id;
- QString name;
- QString sizeStr;
- QString region;
- QString type;
- QString partitionInfo;
- QString path;
- int currentGame = 0;
- for( int j = 0; j < lines; j++ )
- {
- QString p = list.at( j );
- switch( mode )
- {
- case 0://get partition info
- {
- if( p.startsWith( "total-discs=" ) )//gamecount
- {
- p.remove( 0, p.indexOf( "=" ) + 1 );
- gameCnt = p.toInt( &ok );
- if( !ok || gameCnt < 0 )
- {
- qDebug() << "count" << p;
- goto abort;
- }
- if( !gameCnt )//just a HDD with no games
- {
- QTreeWidgetItem *size = new QTreeWidgetItem();//just tack the size onto the end of the list for now
- size->setText( 0, "0" );
- games << size;
- *okRet = true;
- return games;
- }
- continue;
- }
- if( p.startsWith( "total-size=" ) )//total size
- {
- p.remove( 0, p.indexOf( "=" ) + 1 );
- totalHddUsed = p.toDouble( &ok );
- if( !ok )
- {
- qDebug() << "size";
- goto abort;
- }
- used = p;
- if( gameCnt >= 0 )
- mode = 1;
- qdebug() << "got teh partition info, gameCnt" << gameCnt << "totalHddUsed:" << totalHddUsed;
- continue;
- }
- }
- break;
- case 1://game info
- {
- if( p.startsWith( "id=" ) )
- {
- currentGame++;
- id = p;
- id.remove( 0, 3 );
- if( namesFromWiiTDB )name = wiiTDB->NameFromID( id );//get the title from the wiitdb.zip
- continue;
- }
- if( p.startsWith( "name=" ) && ( !namesFromWiiTDB || name.isEmpty() ) )
- {
- name = p;
- name.remove( 0, 5 );
- continue;
- }
- if( p.startsWith( "title=" ) )//overwrite the title from the disc header with the one from titles.txt
- {
- QString title = p;
- title.remove( 0, 6 );
- if( title == "(null)" )
- continue;
- name = title;
- continue;
- }
- if( p.startsWith( "region=" ) )
- {
- p.remove( 0, 7 );
- region = p;
- continue;
- }
- if( p.startsWith( "size=" ) )
- {
- p.remove( 0, 5 );
- sizeStr = p;
- //qDebug() << "list-lll" << sizeStr << name;
- continue;
- }
- if( p.startsWith( "filetype=" ) )
- {
- p.remove( 0, 9 );
- type = p;
- continue;
- }
- if( p.startsWith( "partition-info=" ) )
- {
- p.remove( 0, 15 );
- partitionInfo = p;
- continue;
- }
- if( p.startsWith( "source=" ) )
- {
- p.remove( 0, 7 );
- path = p;
- if( !id.isEmpty() && !name.isEmpty() && !sizeStr.isEmpty() && !region.isEmpty() && !type.isEmpty() && !partitionInfo.isEmpty() && !path.isEmpty() )
- {
- QTreeWidgetItem *item = new QTreeWidgetItem();
- SetGameID( item, id );
- SetGameName( item, name );
- SetGameSize( item, sizeStr );
- SetGameRegion( item, region );
- SetGameType( item, type );
- SetGamePartitions( item, partitionInfo );
- SetGamePath( item, path );
- games << item;
- id.clear();
- name.clear();
- sizeStr.clear();
- region.clear();
- type.clear();
- partitionInfo.clear();
- path.clear();
- if( games.size() == gameCnt )
- {
- QTreeWidgetItem *size = new QTreeWidgetItem();//just tack the size onto the end of the list for now
- size->setText( 0, used );
- games << size;
- *okRet = true;
- return games;
- }
- }
- else
- {
- qDebug() << "error parsing game" << currentGame;
- qDebug() << id << name << sizeStr << region << type << partitionInfo << path;
- }
- }
- }
- break;
- default:
- qDebug() << "list-lll case";
- goto abort;
- break;
- }
- }
- qDebug() << "list-lll wtf";
- abort:
- while( !games.isEmpty() )
- {
- QTreeWidgetItem *shit = games.takeFirst();
- delete shit;
- }
- *okRet = false;
- emit SendFatalErr( tr( "wit LIST-LLL returned invalid list of games" ), witListLLLHDD );
- return games;
- }
Add Comment
Please, Sign In to add comment