QTfrontend/model/ammoSchemeModel.cpp
branchqmlfrontend
changeset 12855 1b2b84315d27
parent 12666 1d25f5555c38
child 12897 fc47fc4af6bd
child 12922 c0320d66310d
equal deleted inserted replaced
11843:01f88c3b7b66 12855:1b2b84315d27
    79                          << "Shoppa"
    79                          << "Shoppa"
    80                          << "Clean Slate"
    80                          << "Clean Slate"
    81                          << "Minefield"
    81                          << "Minefield"
    82                          << "Barrel Mayhem"
    82                          << "Barrel Mayhem"
    83                          << "Tunnel Hogs"
    83                          << "Tunnel Hogs"
    84                          << "Fort Mode"
       
    85                          << "Timeless"
    84                          << "Timeless"
    86                          << "Thinking with Portals"
    85                          << "Thinking with Portals"
    87                          << "King Mode"
    86                          << "King Mode"
    88 						 << "Construction Mode"
    87                          << "Construction Mode"
       
    88                          << "HedgeEditor"
    89                          ;
    89                          ;
    90 
    90 
    91     numberOfDefaultSchemes = predefSchemesNames.size();
    91     numberOfDefaultSchemes = predefSchemesNames.size();
    92 
    92 
    93     spNames = QStringList()
    93     spNames = QStringList()
   220             << QVariant(1)             // case prob      30
   220             << QVariant(1)             // case prob      30
   221             << QVariant(0)             // mines time     31
   221             << QVariant(0)             // mines time     31
   222             << QVariant(0)             // mines number   32
   222             << QVariant(0)             // mines number   32
   223             << QVariant(0)             // mine dud pct   33
   223             << QVariant(0)             // mine dud pct   33
   224             << QVariant(0)             // explosives     34
   224             << QVariant(0)             // explosives     34
   225             << QVariant(8)             // air mines      35
   225             << QVariant(0)             // air mines      35
   226             << QVariant(0)             // health case pct 36
   226             << QVariant(0)             // health case pct 36
   227             << QVariant(25)            // health case amt 37
   227             << QVariant(25)            // health case amt 37
   228             << QVariant(47)            // water rise amt 38
   228             << QVariant(0)             // water rise amt 38
   229             << QVariant(5)             // health dec amt 39
   229             << QVariant(0)             // health dec amt 39
   230             << QVariant(100)           // rope modfier   40
   230             << QVariant(100)           // rope modfier   40
   231             << QVariant(100)           // get away time  41
   231             << QVariant(100)           // get away time  41
   232             << QVariant(0)             // world edge     42
   232             << QVariant(0)             // world edge     42
   233             << QVariant()              // scriptparam    43
   233             << QVariant()              // scriptparam    43
   234             ;
   234             ;
   423             << QVariant(100)           // get away time  41
   423             << QVariant(100)           // get away time  41
   424             << QVariant(0)             // world edge     42
   424             << QVariant(0)             // world edge     42
   425             << QVariant()              // scriptparam    43
   425             << QVariant()              // scriptparam    43
   426             ;
   426             ;
   427 
   427 
   428     QList<QVariant> forts;
   428     QList<QVariant> timeless;
   429     forts
   429     timeless
   430             << predefSchemesNames[7]   // name           0
   430             << predefSchemesNames[7]   // name           0
   431             << QVariant(true)          // fortsmode      1
   431             << QVariant(false)         // fortsmode      1
   432             << QVariant(true)          // team divide    2
   432             << QVariant(false)         // team divide    2
   433             << QVariant(false)         // solid land     3
   433             << QVariant(false)         // solid land     3
   434             << QVariant(false)         // border         4
   434             << QVariant(false)         // border         4
   435             << QVariant(false)         // low gravity    5
   435             << QVariant(false)         // low gravity    5
   436             << QVariant(false)         // laser sight    6
   436             << QVariant(false)         // laser sight    6
   437             << QVariant(false)         // invulnerable   7
   437             << QVariant(false)         // invulnerable   7
   446             << QVariant(false)         // disable girders 16
   446             << QVariant(false)         // disable girders 16
   447             << QVariant(false)         // disable land objects 17
   447             << QVariant(false)         // disable land objects 17
   448             << QVariant(false)         // AI survival    18
   448             << QVariant(false)         // AI survival    18
   449             << QVariant(false)         // inf. attack    19
   449             << QVariant(false)         // inf. attack    19
   450             << QVariant(false)         // reset weps     20
   450             << QVariant(false)         // reset weps     20
       
   451             << QVariant(true)          // per hog ammo   21
       
   452             << QVariant(false)         // no wind        22
       
   453             << QVariant(false)         // more wind      23
       
   454             << QVariant(false)         // tag team       24
       
   455             << QVariant(false)         // bottom border  25
       
   456             << QVariant(100)           // damage modfier 26
       
   457             << QVariant(9999)          // turn time      27
       
   458             << QVariant(100)           // init health    28
       
   459             << QVariant(15)            // sudden death   29
       
   460             << QVariant(5)             // case prob      30
       
   461             << QVariant(3)             // mines time     31
       
   462             << QVariant(5)             // mines number   32
       
   463             << QVariant(10)            // mine dud pct   33
       
   464             << QVariant(2)             // explosives     34
       
   465             << QVariant(0)             // air mines      35
       
   466             << QVariant(35)            // health case pct 36
       
   467             << QVariant(30)            // health case amt 37
       
   468             << QVariant(0)             // water rise amt 38
       
   469             << QVariant(0)             // health dec amt 39
       
   470             << QVariant(100)           // rope modfier   40
       
   471             << QVariant(100)           // get away time  41
       
   472             << QVariant(0)             // world edge     42
       
   473             << QVariant()              // scriptparam    43
       
   474             ;
       
   475 
       
   476     QList<QVariant> thinkingportals;
       
   477     thinkingportals
       
   478             << predefSchemesNames[8]   // name           0
       
   479             << QVariant(false)         // fortsmode      1
       
   480             << QVariant(false)         // team divide    2
       
   481             << QVariant(false)         // solid land     3
       
   482             << QVariant(false)         // border         4
       
   483             << QVariant(false)         // low gravity    5
       
   484             << QVariant(false)         // laser sight    6
       
   485             << QVariant(false)         // invulnerable   7
       
   486             << QVariant(false)         // reset health   8
       
   487             << QVariant(false)         // vampiric       9
       
   488             << QVariant(false)         // karma          10
       
   489             << QVariant(true)          // artillery      11
       
   490             << QVariant(true)          // random order   12
       
   491             << QVariant(false)         // king           13
       
   492             << QVariant(false)         // place hog      14
       
   493             << QVariant(false)         // shared ammo    15
       
   494             << QVariant(false)         // disable girders 16
       
   495             << QVariant(false)         // disable land objects 17
       
   496             << QVariant(false)         // AI survival    18
       
   497             << QVariant(false)         // inf. attack    19
       
   498             << QVariant(false)         // reset weps     20
   451             << QVariant(false)         // per hog ammo   21
   499             << QVariant(false)         // per hog ammo   21
       
   500             << QVariant(false)         // no wind        22
       
   501             << QVariant(false)         // more wind      23
       
   502             << QVariant(false)         // tag team       24
       
   503             << QVariant(false)         // bottom border  25
       
   504             << QVariant(100)           // damage modfier 26
       
   505             << QVariant(45)            // turn time      27
       
   506             << QVariant(100)           // init health    28
       
   507             << QVariant(15)            // sudden death   29
       
   508             << QVariant(2)             // case prob      30
       
   509             << QVariant(3)             // mines time     31
       
   510             << QVariant(5)             // mines number   32
       
   511             << QVariant(0)             // mine dud pct   33
       
   512             << QVariant(5)             // explosives     34
       
   513             << QVariant(4)             // air mines      35
       
   514             << QVariant(25)            // health case pct 36
       
   515             << QVariant(25)            // health case amt 37
       
   516             << QVariant(47)            // water rise amt 38
       
   517             << QVariant(5)             // health dec amt 39
       
   518             << QVariant(100)           // rope modfier   40
       
   519             << QVariant(100)           // get away time  41
       
   520             << QVariant(0)             // world edge     42
       
   521             << QVariant()              // scriptparam    43
       
   522             ;
       
   523 
       
   524     QList<QVariant> kingmode;
       
   525     kingmode
       
   526             << predefSchemesNames[9]  // name           0
       
   527             << QVariant(false)         // fortsmode      1
       
   528             << QVariant(false)         // team divide    2
       
   529             << QVariant(false)         // solid land     3
       
   530             << QVariant(false)         // border         4
       
   531             << QVariant(false)         // low gravity    5
       
   532             << QVariant(false)         // laser sight    6
       
   533             << QVariant(false)         // invulnerable   7
       
   534             << QVariant(false)         // reset health   8
       
   535             << QVariant(false)         // vampiric       9
       
   536             << QVariant(false)         // karma          10
       
   537             << QVariant(false)         // artillery      11
       
   538             << QVariant(true)          // random order   12
       
   539             << QVariant(true)          // king           13
       
   540             << QVariant(false)         // place hog      14
       
   541             << QVariant(false)         // shared ammo    15
       
   542             << QVariant(false)         // disable girders 16
       
   543             << QVariant(false)         // disable land objects 17
       
   544             << QVariant(false)         // AI survival    18
       
   545             << QVariant(false)         // inf. attack    19
       
   546             << QVariant(false)         // reset weps     20
       
   547             << QVariant(false)         // per hog ammo   21
       
   548             << QVariant(false)         // no wind        22
       
   549             << QVariant(false)         // more wind      23
       
   550             << QVariant(false)         // tag team       24
       
   551             << QVariant(false)         // bottom border  25
       
   552             << QVariant(100)           // damage modfier 26
       
   553             << QVariant(45)            // turn time      27
       
   554             << QVariant(100)           // init health    28
       
   555             << QVariant(15)            // sudden death   29
       
   556             << QVariant(5)             // case prob      30
       
   557             << QVariant(3)             // mines time     31
       
   558             << QVariant(4)             // mines number   32
       
   559             << QVariant(0)             // mine dud pct   33
       
   560             << QVariant(2)             // explosives     34
       
   561             << QVariant(0)             // air mines      35
       
   562             << QVariant(35)            // health case pct 36
       
   563             << QVariant(25)            // health case amt 37
       
   564             << QVariant(47)            // water rise amt 38
       
   565             << QVariant(5)             // health dec amt 39
       
   566             << QVariant(100)           // rope modfier   40
       
   567             << QVariant(100)           // get away time  41
       
   568             << QVariant(0)             // world edge     42
       
   569             << QVariant()              // scriptparam    43
       
   570             ;
       
   571 
       
   572 	QList<QVariant> construction;
       
   573     construction
       
   574             << predefSchemesNames[10]  // name           0
       
   575             << QVariant(false)         // fortsmode      1
       
   576             << QVariant(false)         // team divide    2
       
   577             << QVariant(false)         // solid land     3
       
   578             << QVariant(false)         // border         4
       
   579             << QVariant(false)         // low gravity    5
       
   580             << QVariant(false)         // laser sight    6
       
   581             << QVariant(false)         // invulnerable   7
       
   582             << QVariant(false)         // reset health   8
       
   583             << QVariant(false)         // vampiric       9
       
   584             << QVariant(false)         // karma          10
       
   585             << QVariant(false)         // artillery      11
       
   586             << QVariant(true)          // random order   12
       
   587             << QVariant(false)          // king           13
       
   588             << QVariant(false)         // place hog      14
       
   589             << QVariant(false)         // shared ammo    15
       
   590             << QVariant(true)         // disable girders 16
       
   591             << QVariant(true)         // disable land objects 17
       
   592             << QVariant(false)         // AI survival    18
       
   593             << QVariant(true)         // inf. attack    19
       
   594             << QVariant(false)         // reset weps     20
       
   595             << QVariant(true)         // per hog ammo   21
   452             << QVariant(false)         // no wind        22
   596             << QVariant(false)         // no wind        22
   453             << QVariant(false)         // more wind      23
   597             << QVariant(false)         // more wind      23
   454             << QVariant(false)         // tag team       24
   598             << QVariant(false)         // tag team       24
   455             << QVariant(false)         // bottom border  25
   599             << QVariant(false)         // bottom border  25
   456             << QVariant(100)           // damage modfier 26
   600             << QVariant(100)           // damage modfier 26
   471             << QVariant(100)           // get away time  41
   615             << QVariant(100)           // get away time  41
   472             << QVariant(0)             // world edge     42
   616             << QVariant(0)             // world edge     42
   473             << QVariant()              // scriptparam    43
   617             << QVariant()              // scriptparam    43
   474             ;
   618             ;
   475 
   619 
   476     QList<QVariant> timeless;
   620 	QList<QVariant> hedgeeditor;
   477     timeless
   621     hedgeeditor
   478             << predefSchemesNames[8]   // name           0
   622             << predefSchemesNames[11]  // name           0
   479             << QVariant(false)         // fortsmode      1
   623             << QVariant(false)         // fortsmode      1
   480             << QVariant(false)         // team divide    2
   624             << QVariant(false)         // team divide    2
   481             << QVariant(false)         // solid land     3
   625             << QVariant(false)         // solid land     3
   482             << QVariant(false)         // border         4
   626             << QVariant(false)         // border         4
   483             << QVariant(false)         // low gravity    5
   627             << QVariant(false)         // low gravity    5
   485             << QVariant(false)         // invulnerable   7
   629             << QVariant(false)         // invulnerable   7
   486             << QVariant(false)         // reset health   8
   630             << QVariant(false)         // reset health   8
   487             << QVariant(false)         // vampiric       9
   631             << QVariant(false)         // vampiric       9
   488             << QVariant(false)         // karma          10
   632             << QVariant(false)         // karma          10
   489             << QVariant(false)         // artillery      11
   633             << QVariant(false)         // artillery      11
   490             << QVariant(true)          // random order   12
   634             << QVariant(false)         // random order   12
   491             << QVariant(false)         // king           13
   635             << QVariant(false)         // king           13
   492             << QVariant(false)         // place hog      14
   636             << QVariant(false)         // place hog      14
   493             << QVariant(false)         // shared ammo    15
   637             << QVariant(false)         // shared ammo    15
   494             << QVariant(false)         // disable girders 16
   638             << QVariant(false)         // disable girders 16
   495             << QVariant(false)         // disable land objects 17
   639             << QVariant(false)         // disable land objects 17
   502             << QVariant(false)         // tag team       24
   646             << QVariant(false)         // tag team       24
   503             << QVariant(false)         // bottom border  25
   647             << QVariant(false)         // bottom border  25
   504             << QVariant(100)           // damage modfier 26
   648             << QVariant(100)           // damage modfier 26
   505             << QVariant(9999)          // turn time      27
   649             << QVariant(9999)          // turn time      27
   506             << QVariant(100)           // init health    28
   650             << QVariant(100)           // init health    28
   507             << QVariant(15)            // sudden death   29
   651             << QVariant(50)            // sudden death   29
   508             << QVariant(5)             // case prob      30
       
   509             << QVariant(3)             // mines time     31
       
   510             << QVariant(5)             // mines number   32
       
   511             << QVariant(10)            // mine dud pct   33
       
   512             << QVariant(2)             // explosives     34
       
   513             << QVariant(0)             // air mines      35
       
   514             << QVariant(35)            // health case pct 36
       
   515             << QVariant(30)            // health case amt 37
       
   516             << QVariant(0)             // water rise amt 38
       
   517             << QVariant(0)             // health dec amt 39
       
   518             << QVariant(100)           // rope modfier   40
       
   519             << QVariant(100)           // get away time  41
       
   520             << QVariant(0)             // world edge     42
       
   521             << QVariant()              // scriptparam    43
       
   522             ;
       
   523 
       
   524     QList<QVariant> thinkingportals;
       
   525     thinkingportals
       
   526             << predefSchemesNames[9]   // name           0
       
   527             << QVariant(false)         // fortsmode      1
       
   528             << QVariant(false)         // team divide    2
       
   529             << QVariant(false)         // solid land     3
       
   530             << QVariant(false)         // border         4
       
   531             << QVariant(false)         // low gravity    5
       
   532             << QVariant(false)         // laser sight    6
       
   533             << QVariant(false)         // invulnerable   7
       
   534             << QVariant(false)         // reset health   8
       
   535             << QVariant(false)         // vampiric       9
       
   536             << QVariant(false)         // karma          10
       
   537             << QVariant(true)          // artillery      11
       
   538             << QVariant(true)          // random order   12
       
   539             << QVariant(false)         // king           13
       
   540             << QVariant(false)         // place hog      14
       
   541             << QVariant(false)         // shared ammo    15
       
   542             << QVariant(false)         // disable girders 16
       
   543             << QVariant(false)         // disable land objects 17
       
   544             << QVariant(false)         // AI survival    18
       
   545             << QVariant(false)         // inf. attack    19
       
   546             << QVariant(false)         // reset weps     20
       
   547             << QVariant(false)         // per hog ammo   21
       
   548             << QVariant(false)         // no wind        22
       
   549             << QVariant(false)         // more wind      23
       
   550             << QVariant(false)         // tag team       24
       
   551             << QVariant(false)         // bottom border  25
       
   552             << QVariant(100)           // damage modfier 26
       
   553             << QVariant(45)            // turn time      27
       
   554             << QVariant(100)           // init health    28
       
   555             << QVariant(15)            // sudden death   29
       
   556             << QVariant(2)             // case prob      30
       
   557             << QVariant(3)             // mines time     31
       
   558             << QVariant(5)             // mines number   32
       
   559             << QVariant(0)             // mine dud pct   33
       
   560             << QVariant(5)             // explosives     34
       
   561             << QVariant(4)             // air mines      35
       
   562             << QVariant(25)            // health case pct 36
       
   563             << QVariant(25)            // health case amt 37
       
   564             << QVariant(47)            // water rise amt 38
       
   565             << QVariant(5)             // health dec amt 39
       
   566             << QVariant(100)           // rope modfier   40
       
   567             << QVariant(100)           // get away time  41
       
   568             << QVariant(0)             // world edge     42
       
   569             << QVariant()              // scriptparam    43
       
   570             ;
       
   571 
       
   572     QList<QVariant> kingmode;
       
   573     kingmode
       
   574             << predefSchemesNames[10]  // name           0
       
   575             << QVariant(false)         // fortsmode      1
       
   576             << QVariant(false)         // team divide    2
       
   577             << QVariant(false)         // solid land     3
       
   578             << QVariant(false)         // border         4
       
   579             << QVariant(false)         // low gravity    5
       
   580             << QVariant(false)         // laser sight    6
       
   581             << QVariant(false)         // invulnerable   7
       
   582             << QVariant(false)         // reset health   8
       
   583             << QVariant(false)         // vampiric       9
       
   584             << QVariant(false)         // karma          10
       
   585             << QVariant(false)         // artillery      11
       
   586             << QVariant(true)          // random order   12
       
   587             << QVariant(true)          // king           13
       
   588             << QVariant(false)         // place hog      14
       
   589             << QVariant(false)         // shared ammo    15
       
   590             << QVariant(false)         // disable girders 16
       
   591             << QVariant(false)         // disable land objects 17
       
   592             << QVariant(false)         // AI survival    18
       
   593             << QVariant(false)         // inf. attack    19
       
   594             << QVariant(false)         // reset weps     20
       
   595             << QVariant(false)         // per hog ammo   21
       
   596             << QVariant(false)         // no wind        22
       
   597             << QVariant(false)         // more wind      23
       
   598             << QVariant(false)         // tag team       24
       
   599             << QVariant(false)         // bottom border  25
       
   600             << QVariant(100)           // damage modfier 26
       
   601             << QVariant(45)            // turn time      27
       
   602             << QVariant(100)           // init health    28
       
   603             << QVariant(15)            // sudden death   29
       
   604             << QVariant(5)             // case prob      30
       
   605             << QVariant(3)             // mines time     31
       
   606             << QVariant(4)             // mines number   32
       
   607             << QVariant(0)             // mine dud pct   33
       
   608             << QVariant(2)             // explosives     34
       
   609             << QVariant(0)             // air mines      35
       
   610             << QVariant(35)            // health case pct 36
       
   611             << QVariant(25)            // health case amt 37
       
   612             << QVariant(47)            // water rise amt 38
       
   613             << QVariant(5)             // health dec amt 39
       
   614             << QVariant(100)           // rope modfier   40
       
   615             << QVariant(100)           // get away time  41
       
   616             << QVariant(0)             // world edge     42
       
   617             << QVariant()              // scriptparam    43
       
   618             ;
       
   619 
       
   620 	QList<QVariant> construction;
       
   621     construction
       
   622             << predefSchemesNames[11]  // name           0
       
   623             << QVariant(false)         // fortsmode      1
       
   624             << QVariant(false)         // team divide    2
       
   625             << QVariant(false)         // solid land     3
       
   626             << QVariant(false)         // border         4
       
   627             << QVariant(false)         // low gravity    5
       
   628             << QVariant(false)         // laser sight    6
       
   629             << QVariant(false)         // invulnerable   7
       
   630             << QVariant(false)         // reset health   8
       
   631             << QVariant(false)         // vampiric       9
       
   632             << QVariant(false)         // karma          10
       
   633             << QVariant(false)         // artillery      11
       
   634             << QVariant(true)          // random order   12
       
   635             << QVariant(false)          // king           13
       
   636             << QVariant(false)         // place hog      14
       
   637             << QVariant(false)         // shared ammo    15
       
   638             << QVariant(true)         // disable girders 16
       
   639             << QVariant(true)         // disable land objects 17
       
   640             << QVariant(false)         // AI survival    18
       
   641             << QVariant(true)         // inf. attack    19
       
   642             << QVariant(false)         // reset weps     20
       
   643             << QVariant(true)         // per hog ammo   21
       
   644             << QVariant(false)         // no wind        22
       
   645             << QVariant(false)         // more wind      23
       
   646             << QVariant(false)         // tag team       24
       
   647             << QVariant(false)         // bottom border  25
       
   648             << QVariant(100)           // damage modfier 26
       
   649             << QVariant(45)            // turn time      27
       
   650             << QVariant(100)           // init health    28
       
   651             << QVariant(15)            // sudden death   29
       
   652             << QVariant(5)             // case prob      30
   652             << QVariant(5)             // case prob      30
   653             << QVariant(3)             // mines time     31
   653             << QVariant(3)             // mines time     31
   654             << QVariant(0)             // mines number   32
   654             << QVariant(0)             // mines number   32
   655             << QVariant(0)             // mine dud pct   33
   655             << QVariant(0)             // mine dud pct   33
   656             << QVariant(0)             // explosives     34
   656             << QVariant(0)             // explosives     34
   657             << QVariant(0)             // air mines      35
   657             << QVariant(0)             // air mines      35
   658             << QVariant(35)            // health case pct 36
   658             << QVariant(35)            // health case pct 36
   659             << QVariant(25)            // health case amt 37
   659             << QVariant(25)            // health case amt 37
   660             << QVariant(47)            // water rise amt 38
   660             << QVariant(0)            // water rise amt 38
   661             << QVariant(5)             // health dec amt 39
   661             << QVariant(0)             // health dec amt 39
   662             << QVariant(100)           // rope modfier   40
   662             << QVariant(100)           // rope modfier   40
   663             << QVariant(100)           // get away time  41
   663             << QVariant(100)           // get away time  41
   664             << QVariant(0)             // world edge     42
   664             << QVariant(0)             // world edge     42
   665             << QVariant()              // scriptparam    43
   665             << QVariant()              // scriptparam    43
   666             ;
   666             ;
       
   667 			
       
   668  
   667 			
   669 			
   668     schemes.append(defaultScheme);
   670     schemes.append(defaultScheme);
   669     schemes.append(proMode);
   671     schemes.append(proMode);
   670     schemes.append(shoppa);
   672     schemes.append(shoppa);
   671     schemes.append(cleanslate);
   673     schemes.append(cleanslate);
   672     schemes.append(minefield);
   674     schemes.append(minefield);
   673     schemes.append(barrelmayhem);
   675     schemes.append(barrelmayhem);
   674     schemes.append(tunnelhogs);
   676     schemes.append(tunnelhogs);
   675     schemes.append(forts);
       
   676     schemes.append(timeless);
   677     schemes.append(timeless);
   677     schemes.append(thinkingportals);
   678     schemes.append(thinkingportals);
   678     schemes.append(kingmode);
   679     schemes.append(kingmode);
   679 	schemes.append(construction);
   680     schemes.append(construction);
       
   681     schemes.append(hedgeeditor);
   680 
   682 
   681 
   683 
   682     int size = fileConfig.beginReadArray("schemes");
   684     int size = fileConfig.beginReadArray("schemes");
   683     for (int i = 0; i < size; ++i)
   685     for (int i = 0; i < size; ++i)
   684     {
   686     {
   718 {
   720 {
   719     if (parent.isValid())
   721     if (parent.isValid())
   720         return 0;
   722         return 0;
   721     else
   723     else
   722         return defaultScheme.size();
   724         return defaultScheme.size();
       
   725 }
       
   726 
       
   727 bool AmmoSchemeModel::hasScheme(QString name)
       
   728 {
       
   729     for(int i=0; i<schemes.size(); i++)
       
   730     {
       
   731         if(schemes[i][0] == name)
       
   732         {
       
   733             return true;
       
   734         }
       
   735     }
       
   736     return false;
   723 }
   737 }
   724 
   738 
   725 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   739 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   726 {
   740 {
   727     Q_UNUSED(index);
   741     Q_UNUSED(index);
   753     beginInsertRows(parent, schemes.size(), schemes.size());
   767     beginInsertRows(parent, schemes.size(), schemes.size());
   754 
   768 
   755     if (row == -1)
   769     if (row == -1)
   756     {
   770     {
   757         QList<QVariant> newScheme = defaultScheme;
   771         QList<QVariant> newScheme = defaultScheme;
   758         newScheme[0] = QVariant(tr("New"));
   772 
       
   773         QString newName = tr("New");
       
   774         if(hasScheme(newName))
       
   775         {
       
   776             //name already used -> look for an appropriate name:
       
   777             int i=2;
       
   778             while(hasScheme(newName = tr("New (%1)").arg(i++))) ;
       
   779         }
       
   780         newScheme[0] = QVariant(newName);
   759         schemes.insert(schemes.size(), newScheme);
   781         schemes.insert(schemes.size(), newScheme);
   760     }
   782     }
   761     else
   783     else
   762     {
   784     {
   763         QList<QVariant> newScheme = schemes[row];
   785         QList<QVariant> newScheme = schemes[row];
   764         newScheme[0] = QVariant(tr("Copy of %1").arg(newScheme[0].toString()));
   786         QString oldName = newScheme[0].toString();
       
   787         QString newName = tr("Copy of %1").arg(oldName);
       
   788         if(hasScheme(newName))
       
   789         {
       
   790             //name already used -> look for an appropriate name:
       
   791             int i=2;
       
   792             while(hasScheme(newName = tr("Copy of %1 (%2)").arg(oldName).arg(i++)));
       
   793         }
       
   794         newScheme[0] = QVariant(newName);
   765         schemes.insert(schemes.size(), newScheme);
   795         schemes.insert(schemes.size(), newScheme);
   766     }
   796     }
   767 
   797 
   768     endInsertRows();
   798     endInsertRows();
   769 
   799