QTfrontend/ammoSchemeModel.cpp
branchexperimental3D
changeset 4812 f924be23ffb4
parent 4600 5a3b1dbdd4c9
child 4820 4dcfbf9f7910
equal deleted inserted replaced
4347:0ddb100fea61 4812:f924be23ffb4
    58         << QVariant(2)             // explosives     32
    58         << QVariant(2)             // explosives     32
    59         << QVariant(35)            // health case pct 33
    59         << QVariant(35)            // health case pct 33
    60         << QVariant(25)            // health case amt 34
    60         << QVariant(25)            // health case amt 34
    61         << QVariant(47)            // water rise amt 35
    61         << QVariant(47)            // water rise amt 35
    62         << QVariant(5)             // health dec amt 36
    62         << QVariant(5)             // health dec amt 36
       
    63         << QVariant(100)           // rope modfier   37
    63         ;
    64         ;
    64 
    65 
    65 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
    66 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
    66     QAbstractTableModel(parent),
    67     QAbstractTableModel(parent),
    67     fileConfig(fileName, QSettings::IniFormat)
    68     fileConfig(fileName, QSettings::IniFormat)
   118         << "explosives"       // 32
   119         << "explosives"       // 32
   119         << "healthprobability" // 33
   120         << "healthprobability" // 33
   120         << "healthcaseamount" // 34
   121         << "healthcaseamount" // 34
   121         << "waterrise"        // 35
   122         << "waterrise"        // 35
   122         << "healthdecrease"   // 36
   123         << "healthdecrease"   // 36
       
   124         << "ropepct"          // 37
   123         ;
   125         ;
   124 
   126 
   125     QList<QVariant> proMode;
   127     QList<QVariant> proMode;
   126     proMode
   128     proMode
   127         << predefSchemesNames[1]   // name           0
   129         << predefSchemesNames[1]   // name           0
   159         << QVariant(2)             // explosives     32
   161         << QVariant(2)             // explosives     32
   160         << QVariant(35)            // health case pct 33
   162         << QVariant(35)            // health case pct 33
   161         << QVariant(25)            // health case amt 34
   163         << QVariant(25)            // health case amt 34
   162         << QVariant(47)            // water rise amt 35
   164         << QVariant(47)            // water rise amt 35
   163         << QVariant(5)             // health dec amt 36
   165         << QVariant(5)             // health dec amt 36
       
   166         << QVariant(100)           // rope modfier   37
   164         ;
   167         ;
   165 
   168 
   166     QList<QVariant> shoppa;
   169     QList<QVariant> shoppa;
   167     shoppa
   170     shoppa
   168         << predefSchemesNames[2]   // name           0
   171         << predefSchemesNames[2]   // name           0
   200         << QVariant(0)             // explosives     32
   203         << QVariant(0)             // explosives     32
   201         << QVariant(0)             // health case pct 33
   204         << QVariant(0)             // health case pct 33
   202         << QVariant(25)            // health case amt 34
   205         << QVariant(25)            // health case amt 34
   203         << QVariant(47)            // water rise amt 35
   206         << QVariant(47)            // water rise amt 35
   204         << QVariant(5)             // health dec amt 36
   207         << QVariant(5)             // health dec amt 36
       
   208         << QVariant(100)           // rope modfier   37
   205         ;
   209         ;
   206 
   210 
   207     QList<QVariant> cleanslate;
   211     QList<QVariant> cleanslate;
   208     cleanslate
   212     cleanslate
   209         << predefSchemesNames[3]   // name           0
   213         << predefSchemesNames[3]   // name           0
   241         << QVariant(2)             // explosives     32
   245         << QVariant(2)             // explosives     32
   242         << QVariant(35)            // health case pct 33
   246         << QVariant(35)            // health case pct 33
   243         << QVariant(25)            // health case amt 34
   247         << QVariant(25)            // health case amt 34
   244         << QVariant(47)            // water rise amt 35
   248         << QVariant(47)            // water rise amt 35
   245         << QVariant(5)             // health dec amt 36
   249         << QVariant(5)             // health dec amt 36
       
   250         << QVariant(100)           // rope modfier   37
   246         ;
   251         ;
   247 
   252 
   248     QList<QVariant> minefield;
   253     QList<QVariant> minefield;
   249     minefield
   254     minefield
   250         << predefSchemesNames[4]   // name           0
   255         << predefSchemesNames[4]   // name           0
   282         << QVariant(0)             // explosives     32
   287         << QVariant(0)             // explosives     32
   283         << QVariant(35)            // health case pct 33
   288         << QVariant(35)            // health case pct 33
   284         << QVariant(25)            // health case amt 34
   289         << QVariant(25)            // health case amt 34
   285         << QVariant(47)            // water rise amt 35
   290         << QVariant(47)            // water rise amt 35
   286         << QVariant(5)             // health dec amt 36
   291         << QVariant(5)             // health dec amt 36
       
   292         << QVariant(100)           // rope modfier   37
   287         ;
   293         ;
   288 
   294 
   289     QList<QVariant> barrelmayhem;
   295     QList<QVariant> barrelmayhem;
   290     barrelmayhem
   296     barrelmayhem
   291         << predefSchemesNames[5]   // name           0
   297         << predefSchemesNames[5]   // name           0
   323         << QVariant(80)            // explosives     32
   329         << QVariant(80)            // explosives     32
   324         << QVariant(35)            // health case pct 33
   330         << QVariant(35)            // health case pct 33
   325         << QVariant(25)            // health case amt 34
   331         << QVariant(25)            // health case amt 34
   326         << QVariant(47)            // water rise amt 35
   332         << QVariant(47)            // water rise amt 35
   327         << QVariant(5)             // health dec amt 36
   333         << QVariant(5)             // health dec amt 36
       
   334         << QVariant(100)           // rope modfier   37
   328         ;
   335         ;
   329 
   336 
   330     QList<QVariant> tunnelhogs;
   337     QList<QVariant> tunnelhogs;
   331     tunnelhogs
   338     tunnelhogs
   332         << predefSchemesNames[6]   // name           0
   339         << predefSchemesNames[6]   // name           0
   364         << QVariant(10)            // explosives     32
   371         << QVariant(10)            // explosives     32
   365         << QVariant(35)            // health case pct 33
   372         << QVariant(35)            // health case pct 33
   366         << QVariant(25)            // health case amt 34
   373         << QVariant(25)            // health case amt 34
   367         << QVariant(47)            // water rise amt 35
   374         << QVariant(47)            // water rise amt 35
   368         << QVariant(5)             // health dec amt 36
   375         << QVariant(5)             // health dec amt 36
       
   376         << QVariant(100)           // rope modfier   37
   369         ;
   377         ;
   370 
   378 
   371     QList<QVariant> forts;
   379     QList<QVariant> forts;
   372     forts
   380     forts
   373         << predefSchemesNames[7]   // name           0
   381         << predefSchemesNames[7]   // name           0
   405         << QVariant(0)             // explosives     32
   413         << QVariant(0)             // explosives     32
   406         << QVariant(35)            // health case pct 33
   414         << QVariant(35)            // health case pct 33
   407         << QVariant(25)            // health case amt 34
   415         << QVariant(25)            // health case amt 34
   408         << QVariant(47)            // water rise amt 35
   416         << QVariant(47)            // water rise amt 35
   409         << QVariant(5)             // health dec amt 36
   417         << QVariant(5)             // health dec amt 36
       
   418         << QVariant(100)           // rope modfier   37
   410         ;
   419         ;
   411 
   420 
   412     QList<QVariant> timeless;
   421     QList<QVariant> timeless;
   413     timeless
   422     timeless
   414         << predefSchemesNames[8]   // name           0
   423         << predefSchemesNames[8]   // name           0
   446         << QVariant(2)             // explosives     32
   455         << QVariant(2)             // explosives     32
   447         << QVariant(35)            // health case pct 33
   456         << QVariant(35)            // health case pct 33
   448         << QVariant(30)            // health case amt 34
   457         << QVariant(30)            // health case amt 34
   449         << QVariant(0)             // water rise amt 35
   458         << QVariant(0)             // water rise amt 35
   450         << QVariant(0)             // health dec amt 36
   459         << QVariant(0)             // health dec amt 36
       
   460         << QVariant(100)           // rope modfier   37
   451         ;
   461         ;
   452 
   462 
   453     QList<QVariant> thinkingportals;
   463     QList<QVariant> thinkingportals;
   454     thinkingportals
   464     thinkingportals
   455         << predefSchemesNames[9]   // name           0
   465         << predefSchemesNames[9]   // name           0
   487         << QVariant(5)             // explosives     32
   497         << QVariant(5)             // explosives     32
   488         << QVariant(25)            // health case pct 33
   498         << QVariant(25)            // health case pct 33
   489         << QVariant(25)            // health case amt 34
   499         << QVariant(25)            // health case amt 34
   490         << QVariant(47)            // water rise amt 35
   500         << QVariant(47)            // water rise amt 35
   491         << QVariant(5)             // health dec amt 36
   501         << QVariant(5)             // health dec amt 36
       
   502         << QVariant(100)           // rope modfier   37
   492         ;
   503         ;
   493 
   504 
   494     QList<QVariant> kingmode;
   505     QList<QVariant> kingmode;
   495     kingmode
   506     kingmode
   496         << predefSchemesNames[10]  // name           0
   507         << predefSchemesNames[10]  // name           0
   505         << QVariant(false)         // vampiric       9
   516         << QVariant(false)         // vampiric       9
   506         << QVariant(false)         // karma          10
   517         << QVariant(false)         // karma          10
   507         << QVariant(false)         // artillery      11
   518         << QVariant(false)         // artillery      11
   508         << QVariant(true)          // random order   12
   519         << QVariant(true)          // random order   12
   509         << QVariant(true)          // king           13
   520         << QVariant(true)          // king           13
   510         << QVariant(true)          // place hog      14
   521         << QVariant(false)         // place hog      14
   511         << QVariant(true)          // shared ammo    15
   522         << QVariant(false)         // shared ammo    15
   512         << QVariant(false)         // disable girders 16
   523         << QVariant(false)         // disable girders 16
   513         << QVariant(false)         // disable land objects 17
   524         << QVariant(false)         // disable land objects 17
   514         << QVariant(false)         // AI survival    18
   525         << QVariant(false)         // AI survival    18
   515         << QVariant(false)         // inf. attack    19
   526         << QVariant(false)         // inf. attack    19
   516         << QVariant(false)         // reset weps     20
   527         << QVariant(false)         // reset weps     20
   521         << QVariant(45)            // turn time      25
   532         << QVariant(45)            // turn time      25
   522         << QVariant(100)           // init health    26
   533         << QVariant(100)           // init health    26
   523         << QVariant(15)            // sudden death   27
   534         << QVariant(15)            // sudden death   27
   524         << QVariant(5)             // case prob      28
   535         << QVariant(5)             // case prob      28
   525         << QVariant(3)             // mines time     29
   536         << QVariant(3)             // mines time     29
   526         << QVariant(3)             // mines number   30
   537         << QVariant(4)             // mines number   30
   527         << QVariant(20)            // mine dud pct   31
   538         << QVariant(0)             // mine dud pct   31
   528         << QVariant(3)             // explosives     32
   539         << QVariant(2)             // explosives     32
   529         << QVariant(35)            // health case pct 33
   540         << QVariant(35)            // health case pct 33
   530         << QVariant(30)            // health case amt 34
   541         << QVariant(25)            // health case amt 34
   531         << QVariant(30)            // water rise amt 35
   542         << QVariant(47)            // water rise amt 35
   532         << QVariant(5)             // health dec amt 36
   543         << QVariant(5)             // health dec amt 36
       
   544         << QVariant(100)           // rope modfier   37
   533         ;
   545         ;
   534 
   546 
   535 
   547 
   536     schemes.append(defaultScheme);
   548     schemes.append(defaultScheme);
   537     schemes.append(proMode);
   549     schemes.append(proMode);
   563     fileConfig.endArray();
   575     fileConfig.endArray();
   564 }
   576 }
   565 
   577 
   566 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   578 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   567 {
   579 {
       
   580     Q_UNUSED(section);
       
   581     Q_UNUSED(orientation);
       
   582     Q_UNUSED(role);
       
   583 
   568     return QVariant();
   584     return QVariant();
   569 }
   585 }
   570 
   586 
   571 int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
   587 int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
   572 {
   588 {
   584         return defaultScheme.size();
   600         return defaultScheme.size();
   585 }
   601 }
   586 
   602 
   587 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   603 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   588 {
   604 {
       
   605     Q_UNUSED(index);
       
   606 
   589     return
   607     return
   590         Qt::ItemIsEnabled
   608         Qt::ItemIsEnabled
   591         | Qt::ItemIsSelectable
   609         | Qt::ItemIsSelectable
   592         | Qt::ItemIsEditable;
   610         | Qt::ItemIsEditable;
   593 }
   611 }
   606     return true;
   624     return true;
   607 }
   625 }
   608 
   626 
   609 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
   627 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
   610 {
   628 {
   611     beginInsertRows(parent, row, row);
   629     Q_UNUSED(count);
   612 
   630 
   613     QList<QVariant> newScheme = defaultScheme;
   631     beginInsertRows(parent, schemes.size(), schemes.size());
   614     newScheme[0] = QVariant(tr("new"));
   632 
   615 
   633     if (row == -1)
   616     schemes.insert(row, newScheme);
   634     {
       
   635         QList<QVariant> newScheme = defaultScheme;
       
   636         newScheme[0] = QVariant(tr("new"));
       
   637         schemes.insert(schemes.size(), newScheme);
       
   638     }
       
   639     else
       
   640     {
       
   641         QList<QVariant> newScheme = schemes[row];
       
   642         newScheme[0] = QVariant(tr("copy of") + " " + newScheme[0].toString());
       
   643         schemes.insert(schemes.size(), newScheme);
       
   644     }
   617 
   645 
   618     endInsertRows();
   646     endInsertRows();
   619 
   647 
   620     return true;
   648     return true;
   621 }
   649 }
   670     netScheme = defaultScheme;
   698     netScheme = defaultScheme;
   671 }
   699 }
   672 
   700 
   673 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   701 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   674 {
   702 {
       
   703     Q_UNUSED(section);
       
   704     Q_UNUSED(orientation);
       
   705     Q_UNUSED(role);
       
   706 
   675     return QVariant();
   707     return QVariant();
   676 }
   708 }
   677 
   709 
   678 int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
   710 int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
   679 {
   711 {