
void showRomList()
{
  // Create View
  QListView *lv = new QListView();
  lv->addColumn( i18n("Name") );
  lv->addColumn( i18n("Description") );

  // Load Data
  QString filename( locateLocal( "appdata", "roms.xmame" ) );
  if ( !fillRomList( lv, filename ) ) {
    (void) new QListViewItem( lv, i18n( "No ROMs Found" ),
			      i18n( "Could not load file '%1', %2" )
			        .arg( filename ).arg( errstring( errno ) ) );
  }


  lv->show();
}


bool fillRomList( QListView *lv, const QString &filename )
{
  // Load file
  QFile f( filename );
  if ( !f.open(IO_ReadOnly) ) {
    kdDebug() << "Could not open file '" << filename << "', "
	      << errstring( errno )
	      << endl;
    return false;
  }

  QByteArray raw = f.readAll();
  QString txt( QString::fromLocal8Bit( raw ) );
  kdDebug() << "Loaded " << txt.length() << " chars from " << filename << endl;

  // Parse contents
  QRegExp re( "^(\\w+)\\s+\"(.*)\".*$" );

  int pos = txt.find( re );
  while ( pos >= 0 ) {

    (void) new QListViewItem( lv, re.cap(1), re.cap(2) );

    pos += re.matchedLength();
    pos = txt.find( re, pos );
  }

  kdDebug() << "Matched " << lv.childCount() << " lines" << endl;
  return true;
}

