equal
deleted
inserted
replaced
22 |
22 |
23 AmmoSchemeModel::AmmoSchemeModel(QObject* parent) : |
23 AmmoSchemeModel::AmmoSchemeModel(QObject* parent) : |
24 QAbstractTableModel(parent) |
24 QAbstractTableModel(parent) |
25 { |
25 { |
26 defaultScheme |
26 defaultScheme |
27 << "Default" // name |
27 << QVariant(tr("Default")) // name 0 |
28 << "false" // fortsmode |
28 << QVariant(false) // fortsmode 1 |
29 << "false" // team divide |
29 << QVariant(false) // team divide 2 |
30 << "false" // solid land |
30 << QVariant(false) // solid land 3 |
31 << "false" // border |
31 << QVariant(false) // border 4 |
32 << "45" // turn time |
32 << QVariant(45) // turn time 5 |
33 << "101" // init health |
33 << QVariant(100) // init health 6 |
34 << "15" // sudden death |
34 << QVariant(15) // sudden death 7 |
35 << "5" // case probability |
35 << QVariant(5) // case prob 8 |
36 ; |
36 ; |
37 |
37 |
38 schemes.append(defaultScheme); |
38 schemes.append(defaultScheme); |
39 } |
39 } |
40 |
40 |
73 || index.row() >= schemes.size() |
73 || index.row() >= schemes.size() |
74 || index.column() >= defaultScheme.size() |
74 || index.column() >= defaultScheme.size() |
75 || role != Qt::EditRole) |
75 || role != Qt::EditRole) |
76 return false; |
76 return false; |
77 |
77 |
78 schemes[index.row()][index.column()] = value.toString(); |
78 schemes[index.row()][index.column()] = value; |
79 |
79 |
80 emit dataChanged(index, index); |
80 emit dataChanged(index, index); |
81 return true; |
81 return true; |
82 } |
82 } |
83 |
83 |
84 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent) |
84 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent) |
85 { |
85 { |
86 beginInsertRows(parent, row, row); |
86 beginInsertRows(parent, row, row); |
87 |
87 |
88 QStringList newScheme = defaultScheme; |
88 QList<QVariant> newScheme = defaultScheme; |
89 newScheme[0] = tr("new"); |
89 newScheme[0] = QVariant(tr("new")); |
90 |
90 |
91 schemes.insert(row, newScheme); |
91 schemes.insert(row, newScheme); |
92 |
92 |
93 endInsertRows(); |
93 endInsertRows(); |
94 } |
94 } |
109 || index.column() >= defaultScheme.size() |
109 || index.column() >= defaultScheme.size() |
110 || (role != Qt::EditRole && role != Qt::DisplayRole) |
110 || (role != Qt::EditRole && role != Qt::DisplayRole) |
111 ) |
111 ) |
112 return QVariant(); |
112 return QVariant(); |
113 |
113 |
114 return QVariant::fromValue(schemes[index.row()][index.column()]); |
114 return schemes[index.row()][index.column()]; |
115 } |
115 } |