QTfrontend/ammoSchemeModel.cpp
changeset 2948 3f21a9dc93d0
parent 2915 a02f276035e8
child 3172 ae5c7f97df44
equal deleted inserted replaced
2947:803b277e4894 2948:3f21a9dc93d0
    21 
    21 
    22 #include "ammoSchemeModel.h"
    22 #include "ammoSchemeModel.h"
    23 #include "hwconsts.h"
    23 #include "hwconsts.h"
    24 
    24 
    25 QList<QVariant> defaultScheme = QList<QVariant>()
    25 QList<QVariant> defaultScheme = QList<QVariant>()
    26 		<< QVariant("Default")     // name           0
    26         << QVariant("Default")     // name           0
    27 		<< QVariant(false)         // fortsmode      1
    27         << QVariant(false)         // fortsmode      1
    28 		<< QVariant(false)         // team divide    2
    28         << QVariant(false)         // team divide    2
    29 		<< QVariant(false)         // solid land     3
    29         << QVariant(false)         // solid land     3
    30 		<< QVariant(false)         // border         4
    30         << QVariant(false)         // border         4
    31 		<< QVariant(false)         // low gravity    5
    31         << QVariant(false)         // low gravity    5
    32 		<< QVariant(false)         // laser sight    6
    32         << QVariant(false)         // laser sight    6
    33 		<< QVariant(false)         // invulnerable   7
    33         << QVariant(false)         // invulnerable   7
    34 		<< QVariant(true)          // add mines      8
    34         << QVariant(true)          // add mines      8
    35 		<< QVariant(false)         // vampiric       9
    35         << QVariant(false)         // vampiric       9
    36 		<< QVariant(false)         // karma          10
    36         << QVariant(false)         // karma          10
    37 		<< QVariant(false)         // artillery      11
    37         << QVariant(false)         // artillery      11
    38 		<< QVariant(true)          // random order   12
    38         << QVariant(true)          // random order   12
    39 		<< QVariant(false)         // king           13
    39         << QVariant(false)         // king           13
    40 		<< QVariant(false)         // place hog      14
    40         << QVariant(false)         // place hog      14
    41 		<< QVariant(false)         // shared ammo    15
    41         << QVariant(false)         // shared ammo    15
    42 		<< QVariant(false)		   //disable girders 16
    42         << QVariant(false)         //disable girders 16
    43 		<< QVariant(100)           // damage modfier 17
    43         << QVariant(100)           // damage modfier 17
    44 		<< QVariant(45)            // turn time      18
    44         << QVariant(45)            // turn time      18
    45 		<< QVariant(100)           // init health    19
    45         << QVariant(100)           // init health    19
    46 		<< QVariant(15)            // sudden death   20
    46         << QVariant(15)            // sudden death   20
    47 		<< QVariant(5)             // case prob      21
    47         << QVariant(5)             // case prob      21
    48 		<< QVariant(3)             //  mines time    22
    48         << QVariant(3)             //  mines time    22
    49 		<< QVariant(4)             //  landadds      23
    49         << QVariant(4)             //  landadds      23
    50 		<< QVariant(0)             // mine dud pct   24
    50         << QVariant(0)             // mine dud pct   24
    51 		<< QVariant(2)             // explosives     25
    51         << QVariant(2)             // explosives     25
    52 		;
    52         ;
    53 
    53 
    54 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
    54 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
    55 	QAbstractTableModel(parent),
    55     QAbstractTableModel(parent),
    56 	numberOfDefaultSchemes(4),
    56     numberOfDefaultSchemes(4),
    57 	fileConfig(fileName, QSettings::IniFormat)
    57     fileConfig(fileName, QSettings::IniFormat)
    58 {
    58 {
    59 	QStringList predefSchemesNames;
    59     QStringList predefSchemesNames;
    60 	predefSchemesNames
    60     predefSchemesNames
    61 		<< "Default"
    61         << "Default"
    62 		<< "Pro mode"
    62         << "Pro mode"
    63 		<< "Shoppa"
    63         << "Shoppa"
    64 		<< "Basketball"
    64         << "Basketball"
    65 		<< "Minefield";
    65         << "Minefield";
    66 
    66 
    67 	spNames = QStringList()
    67     spNames = QStringList()
    68 		<< "name"             //  0
    68         << "name"             //  0
    69 		<< "fortsmode"        //  1
    69         << "fortsmode"        //  1
    70 		<< "divteams"         //  2
    70         << "divteams"         //  2
    71 		<< "solidland"        //  3
    71         << "solidland"        //  3
    72 		<< "border"           //  4
    72         << "border"           //  4
    73 		<< "lowgrav"          //  5
    73         << "lowgrav"          //  5
    74 		<< "laser"            //  6
    74         << "laser"            //  6
    75 		<< "invulnerability"  //  7
    75         << "invulnerability"  //  7
    76 		<< "mines"            //  8
    76         << "mines"            //  8
    77 		<< "vampiric"         //  9
    77         << "vampiric"         //  9
    78 		<< "karma"            // 10
    78         << "karma"            // 10
    79 		<< "artillery"        // 11
    79         << "artillery"        // 11
    80 		<< "randomorder"      // 12
    80         << "randomorder"      // 12
    81 		<< "king"             // 13
    81         << "king"             // 13
    82 		<< "placehog"         // 14
    82         << "placehog"         // 14
    83 		<< "sharedammo"       // 15
    83         << "sharedammo"       // 15
    84 		<< "disablegirders"	  // 16
    84         << "disablegirders"   // 16
    85 		<< "damagefactor"     // 17
    85         << "damagefactor"     // 17
    86 		<< "turntime"         // 18
    86         << "turntime"         // 18
    87 		<< "health"           // 19
    87         << "health"           // 19
    88 		<< "suddendeath"      // 20
    88         << "suddendeath"      // 20
    89 		<< "caseprobability"  // 21
    89         << "caseprobability"  // 21
    90 		<< "minestime"        // 22
    90         << "minestime"        // 22
    91 		<< "landadds"         // 23
    91         << "landadds"         // 23
    92 		<< "minedudpct"       // 24
    92         << "minedudpct"       // 24
    93 		<< "explosives"       // 25
    93         << "explosives"       // 25
    94 		;
    94         ;
    95 
    95 
    96 	QList<QVariant> proMode;
    96     QList<QVariant> proMode;
    97 	proMode
    97     proMode
    98 		<< predefSchemesNames[1]   // name           0
    98         << predefSchemesNames[1]   // name           0
    99 		<< QVariant(false)         // fortsmode      1
    99         << QVariant(false)         // fortsmode      1
   100 		<< QVariant(false)         // team divide    2
   100         << QVariant(false)         // team divide    2
   101 		<< QVariant(false)         // solid land     3
   101         << QVariant(false)         // solid land     3
   102 		<< QVariant(false)         // border         4
   102         << QVariant(false)         // border         4
   103 		<< QVariant(false)         // low gravity    5
   103         << QVariant(false)         // low gravity    5
   104 		<< QVariant(false)         // laser sight    6
   104         << QVariant(false)         // laser sight    6
   105 		<< QVariant(false)         // invulnerable   7
   105         << QVariant(false)         // invulnerable   7
   106 		<< QVariant(false)         // add mines      8
   106         << QVariant(false)         // add mines      8
   107 		<< QVariant(false)         // vampiric       9
   107         << QVariant(false)         // vampiric       9
   108 		<< QVariant(false)         // karma          10
   108         << QVariant(false)         // karma          10
   109 		<< QVariant(false)         // artillery      11
   109         << QVariant(false)         // artillery      11
   110 		<< QVariant(true)          // random order   12
   110         << QVariant(true)          // random order   12
   111 		<< QVariant(false)         // king           13
   111         << QVariant(false)         // king           13
   112 		<< QVariant(false)         // place hog      14
   112         << QVariant(false)         // place hog      14
   113 		<< QVariant(true)          // shared ammo    15
   113         << QVariant(true)          // shared ammo    15
   114 		<< QVariant(false)		   //disable girders 16
   114         << QVariant(false)         //disable girders 16
   115 		<< QVariant(100)           // damage modfier 17
   115         << QVariant(100)           // damage modfier 17
   116 		<< QVariant(15)            // turn time      18
   116         << QVariant(15)            // turn time      18
   117 		<< QVariant(100)           // init health    19
   117         << QVariant(100)           // init health    19
   118 		<< QVariant(15)            // sudden death   20
   118         << QVariant(15)            // sudden death   20
   119 		<< QVariant(0)             // case prob      21
   119         << QVariant(0)             // case prob      21
   120 		<< QVariant(3)             //  mines time    22
   120         << QVariant(3)             //  mines time    22
   121 		<< QVariant(4)             //  landadds      23
   121         << QVariant(4)             //  landadds      23
   122 		<< QVariant(0)             // mine dud pct   24
   122         << QVariant(0)             // mine dud pct   24
   123 		<< QVariant(2)             // explosives     25
   123         << QVariant(2)             // explosives     25
   124 		;
   124         ;
   125 
   125 
   126 	QList<QVariant> shoppa;
   126     QList<QVariant> shoppa;
   127 	shoppa
   127     shoppa
   128 		<< predefSchemesNames[2]   // name           0
   128         << predefSchemesNames[2]   // name           0
   129 		<< QVariant(false)         // fortsmode      1
   129         << QVariant(false)         // fortsmode      1
   130 		<< QVariant(false)         // team divide    2
   130         << QVariant(false)         // team divide    2
   131 		<< QVariant(true)          // solid land     3
   131         << QVariant(true)          // solid land     3
   132 		<< QVariant(true)          // border         4
   132         << QVariant(true)          // border         4
   133 		<< QVariant(false)         // low gravity    5
   133         << QVariant(false)         // low gravity    5
   134 		<< QVariant(false)         // laser sight    6
   134         << QVariant(false)         // laser sight    6
   135 		<< QVariant(false)         // invulnerable   7
   135         << QVariant(false)         // invulnerable   7
   136 		<< QVariant(false)         // add mines      8
   136         << QVariant(false)         // add mines      8
   137 		<< QVariant(false)         // vampiric       9
   137         << QVariant(false)         // vampiric       9
   138 		<< QVariant(false)         // karma          10
   138         << QVariant(false)         // karma          10
   139 		<< QVariant(false)         // artillery      11
   139         << QVariant(false)         // artillery      11
   140 		<< QVariant(true)          // random order   12
   140         << QVariant(true)          // random order   12
   141 		<< QVariant(false)         // king           13
   141         << QVariant(false)         // king           13
   142 		<< QVariant(false)         // place hog      14
   142         << QVariant(false)         // place hog      14
   143 		<< QVariant(true)          // shared ammo    15
   143         << QVariant(true)          // shared ammo    15
   144 		<< QVariant(true)		   //disable girders 16
   144         << QVariant(true)          //disable girders 16
   145 		<< QVariant(100)           // damage modfier 17
   145         << QVariant(100)           // damage modfier 17
   146 		<< QVariant(30)            // turn time      18
   146         << QVariant(30)            // turn time      18
   147 		<< QVariant(100)           // init health    19
   147         << QVariant(100)           // init health    19
   148 		<< QVariant(50)            // sudden death   20
   148         << QVariant(50)            // sudden death   20
   149 		<< QVariant(1)             // case prob      21
   149         << QVariant(1)             // case prob      21
   150 		<< QVariant(3)             //  mines time    22
   150         << QVariant(3)             //  mines time    22
   151 		<< QVariant(4)             //  landadds      23
   151         << QVariant(4)             //  landadds      23
   152 		<< QVariant(0)             // mine dud pct   24
   152         << QVariant(0)             // mine dud pct   24
   153 		<< QVariant(0)             // explosives     25
   153         << QVariant(0)             // explosives     25
   154 		;
   154         ;
   155 
   155 
   156 	QList<QVariant> basketball;
   156     QList<QVariant> basketball;
   157 	basketball
   157     basketball
   158 		<< predefSchemesNames[3]   // name           0
   158         << predefSchemesNames[3]   // name           0
   159 		<< QVariant(false)         // fortsmode      1
   159         << QVariant(false)         // fortsmode      1
   160 		<< QVariant(false)         // team divide    2
   160         << QVariant(false)         // team divide    2
   161 		<< QVariant(true)          // solid land     3
   161         << QVariant(true)          // solid land     3
   162 		<< QVariant(true)          // border         4
   162         << QVariant(true)          // border         4
   163 		<< QVariant(true)          // low gravity    5
   163         << QVariant(true)          // low gravity    5
   164 		<< QVariant(false)         // laser sight    6
   164         << QVariant(false)         // laser sight    6
   165 		<< QVariant(true)          // invulnerable   7
   165         << QVariant(true)          // invulnerable   7
   166 		<< QVariant(false)         // add mines      8
   166         << QVariant(false)         // add mines      8
   167 		<< QVariant(false)         // vampiric       9
   167         << QVariant(false)         // vampiric       9
   168 		<< QVariant(false)         // karma          10
   168         << QVariant(false)         // karma          10
   169 		<< QVariant(false)         // artillery      11
   169         << QVariant(false)         // artillery      11
   170 		<< QVariant(true)          // random order   12
   170         << QVariant(true)          // random order   12
   171 		<< QVariant(false)         // king           13
   171         << QVariant(false)         // king           13
   172 		<< QVariant(false)         // place hog      14
   172         << QVariant(false)         // place hog      14
   173 		<< QVariant(true)          // shared ammo    15
   173         << QVariant(true)          // shared ammo    15
   174 		<< QVariant(true)		   //disable girders 16
   174         << QVariant(true)          //disable girders 16
   175 		<< QVariant(100)           // damage modfier 17
   175         << QVariant(100)           // damage modfier 17
   176 		<< QVariant(30)            // turn time      18
   176         << QVariant(30)            // turn time      18
   177 		<< QVariant(100)           // init health    19
   177         << QVariant(100)           // init health    19
   178 		<< QVariant(15)            // sudden death   20
   178         << QVariant(15)            // sudden death   20
   179 		<< QVariant(0)             // case prob      21
   179         << QVariant(0)             // case prob      21
   180 		<< QVariant(3)             //  mines time    22
   180         << QVariant(3)             //  mines time    22
   181 		<< QVariant(4)             //  landadds      23
   181         << QVariant(4)             //  landadds      23
   182 		<< QVariant(0)             // mine dud pct   24
   182         << QVariant(0)             // mine dud pct   24
   183 		<< QVariant(0)             // explosives     25
   183         << QVariant(0)             // explosives     25
   184 		;
   184         ;
   185 
   185 
   186 	QList<QVariant> minefield;
   186     QList<QVariant> minefield;
   187 	minefield
   187     minefield
   188 		<< predefSchemesNames[4]   // name           0
   188         << predefSchemesNames[4]   // name           0
   189 		<< QVariant(false)         // fortsmode      1
   189         << QVariant(false)         // fortsmode      1
   190 		<< QVariant(false)         // team divide    2
   190         << QVariant(false)         // team divide    2
   191 		<< QVariant(false)         // solid land     3
   191         << QVariant(false)         // solid land     3
   192 		<< QVariant(false)         // border         4
   192         << QVariant(false)         // border         4
   193 		<< QVariant(false)         // low gravity    5
   193         << QVariant(false)         // low gravity    5
   194 		<< QVariant(false)         // laser sight    6
   194         << QVariant(false)         // laser sight    6
   195 		<< QVariant(false)         // invulnerable   7
   195         << QVariant(false)         // invulnerable   7
   196 		<< QVariant(true)          // add mines      8
   196         << QVariant(true)          // add mines      8
   197 		<< QVariant(false)         // vampiric       9
   197         << QVariant(false)         // vampiric       9
   198 		<< QVariant(false)         // karma          10
   198         << QVariant(false)         // karma          10
   199 		<< QVariant(false)         // artillery      11
   199         << QVariant(false)         // artillery      11
   200 		<< QVariant(true)          // random order   12
   200         << QVariant(true)          // random order   12
   201 		<< QVariant(false)         // king           13
   201         << QVariant(false)         // king           13
   202 		<< QVariant(false)         // place hog      14
   202         << QVariant(false)         // place hog      14
   203 		<< QVariant(true)          // shared ammo    15
   203         << QVariant(true)          // shared ammo    15
   204 		<< QVariant(true)		   //disable girders 16
   204         << QVariant(true)          //disable girders 16
   205 		<< QVariant(150)           // damage modfier 17
   205         << QVariant(150)           // damage modfier 17
   206 		<< QVariant(30)            // turn time      18
   206         << QVariant(30)            // turn time      18
   207 		<< QVariant(50)            // init health    19
   207         << QVariant(50)            // init health    19
   208 		<< QVariant(15)            // sudden death   20
   208         << QVariant(15)            // sudden death   20
   209 		<< QVariant(0)             // case prob      21
   209         << QVariant(0)             // case prob      21
   210 		<< QVariant(0)             //  mines time    22
   210         << QVariant(0)             //  mines time    22
   211 		<< QVariant(80)            //  landadds      23
   211         << QVariant(80)            //  landadds      23
   212 		<< QVariant(0)             // mine dud pct   24
   212         << QVariant(0)             // mine dud pct   24
   213 		<< QVariant(0)             // explosives     25
   213         << QVariant(0)             // explosives     25
   214 		;
   214         ;
   215 
   215 
   216 	schemes.append(defaultScheme);
   216     schemes.append(defaultScheme);
   217 	schemes.append(proMode);
   217     schemes.append(proMode);
   218 	schemes.append(shoppa);
   218     schemes.append(shoppa);
   219 	schemes.append(basketball);
   219     schemes.append(basketball);
   220 	schemes.append(minefield);
   220     schemes.append(minefield);
   221 
   221 
   222 
   222 
   223 	int size = fileConfig.beginReadArray("schemes");
   223     int size = fileConfig.beginReadArray("schemes");
   224 	for (int i = 0; i < size; ++i) {
   224     for (int i = 0; i < size; ++i) {
   225 		fileConfig.setArrayIndex(i);
   225         fileConfig.setArrayIndex(i);
   226 
   226 
   227 		if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
   227         if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
   228 		{
   228         {
   229 			QList<QVariant> scheme;
   229             QList<QVariant> scheme;
   230 
   230 
   231 			for (int k = 0; k < spNames.size(); ++k)
   231             for (int k = 0; k < spNames.size(); ++k)
   232 				scheme << fileConfig.value(spNames[k], defaultScheme[k]);
   232                 scheme << fileConfig.value(spNames[k], defaultScheme[k]);
   233 
   233 
   234 			schemes.append(scheme);
   234             schemes.append(scheme);
   235 		}
   235         }
   236 	}
   236     }
   237 	fileConfig.endArray();
   237     fileConfig.endArray();
   238 }
   238 }
   239 
   239 
   240 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   240 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   241 {
   241 {
   242 	return QVariant();
   242     return QVariant();
   243 }
   243 }
   244 
   244 
   245 int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
   245 int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
   246 {
   246 {
   247 	if (parent.isValid())
   247     if (parent.isValid())
   248 		return 0;
   248         return 0;
   249 	else
   249     else
   250 		return schemes.size();
   250         return schemes.size();
   251 }
   251 }
   252 
   252 
   253 int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
   253 int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
   254 {
   254 {
   255 	if (parent.isValid())
   255     if (parent.isValid())
   256 		return 0;
   256         return 0;
   257 	else
   257     else
   258 		return defaultScheme.size();
   258         return defaultScheme.size();
   259 }
   259 }
   260 
   260 
   261 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   261 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
   262 {
   262 {
   263 	return
   263     return
   264 		Qt::ItemIsEnabled
   264         Qt::ItemIsEnabled
   265 		| Qt::ItemIsSelectable
   265         | Qt::ItemIsSelectable
   266 		| Qt::ItemIsEditable;
   266         | Qt::ItemIsEditable;
   267 }
   267 }
   268 
   268 
   269 bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
   269 bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
   270 {
   270 {
   271 	if (!index.isValid() || index.row() < numberOfDefaultSchemes
   271     if (!index.isValid() || index.row() < numberOfDefaultSchemes
   272 		|| index.row() >= schemes.size()
   272         || index.row() >= schemes.size()
   273 		|| index.column() >= defaultScheme.size()
   273         || index.column() >= defaultScheme.size()
   274 		|| role != Qt::EditRole)
   274         || role != Qt::EditRole)
   275 		return false;
   275         return false;
   276 
   276 
   277 	schemes[index.row()][index.column()] = value;
   277     schemes[index.row()][index.column()] = value;
   278 
   278 
   279 	emit dataChanged(index, index);
   279     emit dataChanged(index, index);
   280 	return true;
   280     return true;
   281 }
   281 }
   282 
   282 
   283 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
   283 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
   284 {
   284 {
   285 	beginInsertRows(parent, row, row);
   285     beginInsertRows(parent, row, row);
   286 
   286 
   287 	QList<QVariant> newScheme = defaultScheme;
   287     QList<QVariant> newScheme = defaultScheme;
   288 	newScheme[0] = QVariant(tr("new"));
   288     newScheme[0] = QVariant(tr("new"));
   289 
   289 
   290 	schemes.insert(row, newScheme);
   290     schemes.insert(row, newScheme);
   291 
   291 
   292 	endInsertRows();
   292     endInsertRows();
   293 
   293 
   294 	return true;
   294     return true;
   295 }
   295 }
   296 
   296 
   297 bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
   297 bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
   298 {
   298 {
   299 	if(count != 1
   299     if(count != 1
   300 		|| row < numberOfDefaultSchemes
   300         || row < numberOfDefaultSchemes
   301 		|| row >= schemes.size())
   301         || row >= schemes.size())
   302 		return false;
   302         return false;
   303 
   303 
   304 	beginRemoveRows(parent, row, row);
   304     beginRemoveRows(parent, row, row);
   305 
   305 
   306 	schemes.removeAt(row);
   306     schemes.removeAt(row);
   307 
   307 
   308 	endRemoveRows();
   308     endRemoveRows();
   309 
   309 
   310 	return true;
   310     return true;
   311 }
   311 }
   312 
   312 
   313 QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
   313 QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
   314 {
   314 {
   315 	if (!index.isValid() || index.row() < 0
   315     if (!index.isValid() || index.row() < 0
   316 		|| index.row() >= schemes.size()
   316         || index.row() >= schemes.size()
   317 		|| index.column() >= defaultScheme.size()
   317         || index.column() >= defaultScheme.size()
   318 		|| (role != Qt::EditRole && role != Qt::DisplayRole)
   318         || (role != Qt::EditRole && role != Qt::DisplayRole)
   319 		)
   319         )
   320 		return QVariant();
   320         return QVariant();
   321 
   321 
   322 	return schemes[index.row()][index.column()];
   322     return schemes[index.row()][index.column()];
   323 }
   323 }
   324 
   324 
   325 void AmmoSchemeModel::Save()
   325 void AmmoSchemeModel::Save()
   326 {
   326 {
   327 	fileConfig.beginWriteArray("schemes", schemes.size());
   327     fileConfig.beginWriteArray("schemes", schemes.size());
   328 
   328 
   329 	for (int i = 0; i < schemes.size(); ++i) {
   329     for (int i = 0; i < schemes.size(); ++i) {
   330 		fileConfig.setArrayIndex(i);
   330         fileConfig.setArrayIndex(i);
   331 
   331 
   332 		QList<QVariant> scheme = schemes[i];
   332         QList<QVariant> scheme = schemes[i];
   333 
   333 
   334 		for (int k = 0; k < scheme.size(); ++k)
   334         for (int k = 0; k < scheme.size(); ++k)
   335 			fileConfig.setValue(spNames[k], scheme[k]);
   335             fileConfig.setValue(spNames[k], scheme[k]);
   336 	}
   336     }
   337 	fileConfig.endArray();
   337     fileConfig.endArray();
   338 }
   338 }
   339 
   339 
   340 
   340 
   341 NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
   341 NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
   342 	QAbstractTableModel(parent)
   342     QAbstractTableModel(parent)
   343 {
   343 {
   344 	netScheme = defaultScheme;
   344     netScheme = defaultScheme;
   345 }
   345 }
   346 
   346 
   347 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   347 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
   348 {
   348 {
   349 	return QVariant();
   349     return QVariant();
   350 }
   350 }
   351 
   351 
   352 int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
   352 int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
   353 {
   353 {
   354 	if (parent.isValid())
   354     if (parent.isValid())
   355 		return 0;
   355         return 0;
   356 	else
   356     else
   357 		return 1;
   357         return 1;
   358 }
   358 }
   359 
   359 
   360 int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
   360 int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
   361 {
   361 {
   362 	if (parent.isValid())
   362     if (parent.isValid())
   363 		return 0;
   363         return 0;
   364 	else
   364     else
   365 		return defaultScheme.size();
   365         return defaultScheme.size();
   366 }
   366 }
   367 
   367 
   368 QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
   368 QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
   369 {
   369 {
   370 	if (!index.isValid() || index.row() < 0
   370     if (!index.isValid() || index.row() < 0
   371 		|| index.row() > 1
   371         || index.row() > 1
   372 		|| index.column() >= defaultScheme.size()
   372         || index.column() >= defaultScheme.size()
   373 		|| (role != Qt::EditRole && role != Qt::DisplayRole)
   373         || (role != Qt::EditRole && role != Qt::DisplayRole)
   374 		)
   374         )
   375 		return QVariant();
   375         return QVariant();
   376 
   376 
   377 	return netScheme[index.column()];
   377     return netScheme[index.column()];
   378 }
   378 }
   379 
   379 
   380 void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
   380 void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
   381 {
   381 {
   382 	if(cfg.size() != netScheme.size())
   382     if(cfg.size() != netScheme.size())
   383 	{
   383     {
   384 		qWarning("Incorrect scheme cfg size");
   384         qWarning("Incorrect scheme cfg size");
   385 		return;
   385         return;
   386 	}
   386     }
   387 
   387 
   388 	for(int i = 0; i < cfg.size(); ++i)
   388     for(int i = 0; i < cfg.size(); ++i)
   389 		netScheme[i] = QVariant(cfg[i]);
   389         netScheme[i] = QVariant(cfg[i]);
   390 
   390 
   391 	reset();
   391     reset();
   392 }
   392 }