QTfrontend/ammoSchemeModel.cpp
changeset 1885 75489216b5b0
parent 1884 40e59e9f82ce
child 1887 d68939b3f7f0
equal deleted inserted replaced
1884:40e59e9f82ce 1885:75489216b5b0
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  */
    17  */
    18 
    18 
       
    19 #include <QDebug>
    19 #include <QModelIndex>
    20 #include <QModelIndex>
    20 #include "ammoSchemeModel.h"
    21 #include "ammoSchemeModel.h"
    21 
    22 
    22 AmmoSchemeModel::AmmoSchemeModel(QObject* parent) :
    23 AmmoSchemeModel::AmmoSchemeModel(QObject* parent) :
    23   QAbstractTableModel(parent)
    24   QAbstractTableModel(parent)
    24 {
    25 {
    25 	defaultScheme
    26 	defaultScheme
    26 		<< "Default"
    27 		<< "Default" // name
    27 		<< "45"
    28 		<< "0" // fortsmode
    28 		<< "0"
    29 		<< "0" // team divide
    29 		<< "0"
    30 		<< "0" // solid land
    30 		<< "0"
    31 		<< "0" // border
    31 		<< "0"
    32 		<< "45" // turn time
       
    33 		<< "100" // init health
       
    34 		<< "15" // sudden death
       
    35 		<< "5" // case probability
    32 		;
    36 		;
    33 
    37 
    34 	schemes.append(defaultScheme);
    38 	schemes.append(defaultScheme);
    35 }
    39 }
    36 
    40 
    66 bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
    70 bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
    67 {
    71 {
    68 	if (!index.isValid() || index.row() < 0
    72 	if (!index.isValid() || index.row() < 0
    69 		|| index.row() >= schemes.size()
    73 		|| index.row() >= schemes.size()
    70 		|| index.column() >= defaultScheme.size()
    74 		|| index.column() >= defaultScheme.size()
    71 		|| role != Qt::DisplayRole)
    75 		|| role != Qt::EditRole)
    72 		return false;
    76 		return false;
    73 
    77 
    74 	schemes[index.row()][index.column()] = value.toString();
    78 	schemes[index.row()][index.column()] = value.toString();
       
    79 
    75 	emit dataChanged(index, index);
    80 	emit dataChanged(index, index);
    76 	return true;
    81 	return true;
    77 }
    82 }
    78 
    83 
    79 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
    84 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)