so this piece of code
QFile file1( rootDir + "/song.properties" );
QString line;
if ( file1.open( IO_ReadOnly ) )
{
QTextStream stream( &file1 );
while (!stream.eof())
{
QString line = stream.readLine();
line = line.stripWhiteSpace();
if (line.find("title=")>=0)
title=line.mid(line.find("title=")+6);
if (line.find("artists=")>=0)
artists=line.mid(line.find("artists=")+8);
if (line.find("rate=")>=0)
rate=line.mid(line.find("rate=")+5).toInt();
if (line.find("bitDepth=")>=0)
bitDepth=line.mid(line.find("bitDepth=")+9).toInt();
if (line.find("activeTrackNumber=")>=0)
activeTrackNumber=line.mid(line.find("activeTrackNumber=")+18).toInt();
if (line.find("firstBlock=")>=0)
firstBlock=(long
long)line.mid(line.find("firstBlock=")+11).toDouble();
if (line.find("workingBlock=")>=0)
workingBlock=(long
long)line.mid(line.find("workingBlock=")+13).toDouble();
if (line.find("hzoom=")>=0)
hzoom=line.mid(line.find("hzoom=")+6).toInt();
if (line.find("editingMode=")>=0)
editingMode=line.mid(line.find("editingMode=")+12).toInt();
}
PMESG("Reading Song Properties : title=%s rate=%d
bitDepth=%d",title.ascii(),rate,bitDepth);
file1.close();
}
would become
MustuxProperties mp = new MustuxProperties( rootDir +
"/song.properties" );
title=mp->getString("title");
artists=mp->getString("artists");
rate=mp->getInt("rate");
bitDepth=mp->getInt("bitDepth");
activeTrackNumber=mp->getInt("activeTrackNumber");
firstBlock=mp->getLongLong("firstBlock");
workingBlock=mp->getLongLong("workingBlock");
hzoom=mp->getInt("hzoom");
editingMode=mp->getInt("editingMode");
delete mp; // it will close the file
PMESG("Reading Song Properties : title=%s rate=%d
bitDepth=%d",title.ascii(),rate,bitDepth);
it could be used in many places in the code
If you are able to implement such a class, please let me know so I can keep
working on code cleaning. Otherwise it is nor urgent, so we cant wait for that.
Thanks alot