QTfrontend/model/hats.cpp
changeset 6167 728cabee2c9f
parent 6160 863d3edf5690
child 6196 c16e84558f71
equal deleted inserted replaced
6166:701c5b8fac56 6167:728cabee2c9f
    26 #include "HWDataManager.h"
    26 #include "HWDataManager.h"
    27 
    27 
    28 HatsModel::HatsModel(QObject* parent) :
    28 HatsModel::HatsModel(QObject* parent) :
    29   QAbstractListModel(parent)
    29   QAbstractListModel(parent)
    30 {
    30 {
    31     QFile * hhfile =
    31     QPixmap hhpix = QPixmap(
    32         HWDataManager::instance().findFileForRead("Graphics/Hedgehog/Idle.png");
    32         HWDataManager::instance().findFileForRead("Graphics/Hedgehog/Idle.png")
    33     QPixmap hhpix = QPixmap(hhfile->fileName()).copy(0, 0, 32, 32);
    33     ).copy(0, 0, 32, 32);
    34 
       
    35     // this QFile is not needed any further
       
    36     delete hhfile;
       
    37 
    34 
    38     // my reserved hats
    35     // my reserved hats
    39     QStringList hatsList = HWDataManager::instance().entryList(
    36     QStringList hatsList = HWDataManager::instance().entryList(
    40                                    "Graphics/Hats/Reserved",
    37                                    "Graphics/Hats/Reserved",
    41                                    QDir::Files,
    38                                    QDir::Files,
    59     {
    56     {
    60         bool isReserved = (i < nReserved);
    57         bool isReserved = (i < nReserved);
    61 
    58 
    62         QString str = hatsList.at(i);
    59         QString str = hatsList.at(i);
    63         str = str.remove(QRegExp("\\.png$"));
    60         str = str.remove(QRegExp("\\.png$"));
    64         QFile * hatFile = HWDataManager::instance().findFileForRead(
    61         QPixmap pix(
    65                                             "Graphics/Hats/" + 
    62             HWDataManager::instance().findFileForRead(
    66                                             QString(isReserved?"Reserved/":"") +
    63                 "Graphics/Hats/" + QString(isReserved?"Reserved/":"") + str + 
    67                                             str + ".png"
    64                 ".png"
    68                                         );
    65             )
    69         QPixmap pix(hatFile->fileName());
    66         );
    70 
       
    71         // this QFile isn't needed any further
       
    72         delete hatFile;
       
    73 
    67 
    74         // rename properly
    68         // rename properly
    75         if (isReserved)
    69         if (isReserved)
    76             str = "Reserved "+str.remove(0,32);
    70             str = "Reserved "+str.remove(0,32);
    77 
    71