| 1 |
/*************************************************************************** |
| 2 |
grainmodel.cpp |
| 3 |
------------------- |
| 4 |
Grain model |
| 5 |
------------------- |
| 6 |
Copyright 2006-2008, David Johnson |
| 7 |
Please see the header file for copyright and license information |
| 8 |
***************************************************************************/ |
| 9 |
|
| 10 |
#include <QApplication> |
| 11 |
#include <QMessageBox> |
| 12 |
#include <QPair> |
| 13 |
|
| 14 |
#include "data.h"cxx . . $ `<file>/src/data.h`/ |
| 15 |
#include "recipe.h"cxx . . $ `<file>/src/recipe.h`/ |
| 16 |
#include "resource.h"cxx . . $ `<file>/src/resource.h`/ |
| 17 |
#include "grainmodel.h"cxx . . $ `<file>/src/grainmodel.h`/ |
| 18 |
|
| 19 |
using namespace Resource; |
| 20 |
|
| 21 |
////////////////////////////////////////////////////////////////////////////// |
| 22 |
// GrainModel() |
| 23 |
// ------------ |
| 24 |
// Constructor |
| 25 |
|
| 26 |
// TODO: add "unique" flag, disallowing duplicates (for DatabaseTool) |
| 27 |
|
| 28 |
GrainModelcxx . . $ GrainModel#::GrainModelcxx . . $ GrainModel#GrainModel(25815c0855af4671).(QObjectcxx . . $ QObject# *parent, GrainListcxx . . $ GrainList# *list) |
| 29 |
: QAbstractTableModelcxx . . $ QAbstractTableModel#(parent), list_cxx . . $ GrainModel#list_.(list) |
| 30 |
{} |
| 31 |
|
| 32 |
GrainModelcxx . . $ GrainModel#::~cxx . . $ GrainModel#`~GrainModel`(ced63f7c635d850d).GrainModelcxx . . $ GrainModel#(){} |
| 33 |
|
| 34 |
////////////////////////////////////////////////////////////////////////////// |
| 35 |
// flush() |
| 36 |
// ------- |
| 37 |
// Reset the model |
| •38 |
// The reset() method is obsolete with Qt5. |
| 39 |
|
| 40 |
void GrainModelcxx . . $ GrainModel#::flushcxx . . $ GrainModel#flush(49f6e7a06ebc5aa8).() |
| 41 |
{ |
| •42 |
// reset(); |
| 43 |
} |
| 44 |
|
| 45 |
////////////////////////////////////////////////////////////////////////////// |
| 46 |
// data() |
| 47 |
// ------ |
| 48 |
// Return data at index |
| 49 |
|
| 50 |
QVariantcxx . . $ QVariant# GrainModelcxx . . $ GrainModel#::datacxx . . $ GrainModel#data(69b5b18a001c0029).(const QModelIndexcxx . . $ QModelIndex# &index, int role) const |
| 51 |
{ |
| 52 |
if (!index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).()) return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 53 |
if (index.rowcxx . . $ QModelIndex#row(ea6fe5115c70a13f).() >= list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).()) return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 54 |
|
| 55 |
// row is the entry in the QList |
| 56 |
const Graincxx . . $ Grain# &grain = list_cxx . . $ GrainModel#list_.->atcxx . . $ QList#at(e2681f9bb6b2f357).(index.rowcxx . . $ QModelIndex#row(ea6fe5115c70a13f).()); |
| 57 |
|
| 58 |
// column is the grain "field" |
| 59 |
if (role == Qtcxx . . $ Qt/::DisplayRolecxx . . $ Qt/DisplayRole.) { |
| 60 |
switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) { |
| 61 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 62 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..namecxx . . $ Grain#name(a2fb7a6ce195d51).(); |
| 63 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: |
| 64 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..weightcxx . . $ Grain#weight(e805bc742de5fe4b).().toStringcxx . . $ Quantity#toString(3f3c3d0e9c0eb37f).(3); |
| 65 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 66 |
return QStringcxx . . $ QVariant#QVariant(3520e46b33348bf6).::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(grain.extractcxx . . $ Grain#extract(21b6c25e127938e2).(), 'f', 3); |
| 67 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 68 |
return QStringcxx . . $ QVariant#QVariant(3520e46b33348bf6).::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(grain.colorcxx . . $ Grain#color(21b6c25e127938e2).(), 'f', 1) +cxx . . $ operator+(eab1ea5b6c36e9b2). Resourcecxx . . $ Resource/::DEGREEcxx . . $ Resource/DEGREE.; |
| 69 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 70 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..typecxx . . $ Grain#type(a2fb7a6ce195d51).(); |
| 71 |
case USEcxx . . $ GrainModel#USE.: |
| 72 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..usecxx . . $ Grain#use(a2fb7a6ce195d51).(); |
| 73 |
default: |
| 74 |
return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 75 |
} |
| 76 |
} else if (role == Qtcxx . . $ Qt/::EditRolecxx . . $ Qt/EditRole.) { |
| 77 |
switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) { |
| 78 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 79 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..namecxx . . $ Grain#name(a2fb7a6ce195d51).(); |
| 80 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: { |
| 81 |
// return converted quantity |
| 82 |
Weightcxx . . $ Weight# weight = graincxx . . $ Weight#Weight(fcd19e49ee58ab66)..weightcxx . . $ Grain#weight(e805bc742de5fe4b).(); |
| 83 |
weight.convertcxx . . $ Quantity#convert(7d797d468467b63d).(Datacxx . . $ Data#::instancecxx . . $ Data#instance(ddf71f0b6dfdf13b).()->defaultGrainUnitcxx . . $ Data#defaultGrainUnit(1a4d46a500733df5).()); |
| 84 |
return weightcxx . . $ QVariant#QVariant(ba8836b59fb42830)..amountcxx . . $ Quantity#amount(21b6c25e127938e2).(); |
| 85 |
} |
| 86 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 87 |
return graincxx . . $ QVariant#QVariant(ba8836b59fb42830)..extractcxx . . $ Grain#extract(21b6c25e127938e2).(); |
| 88 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 89 |
return graincxx . . $ QVariant#QVariant(ba8836b59fb42830)..colorcxx . . $ Grain#color(21b6c25e127938e2).(); |
| 90 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 91 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..typecxx . . $ Grain#type(a2fb7a6ce195d51).(); |
| 92 |
case USEcxx . . $ GrainModel#USE.: |
| 93 |
return graincxx . . $ QVariant#QVariant(3520e46b33348bf6)..usecxx . . $ Grain#use(a2fb7a6ce195d51).(); |
| 94 |
default: |
| 95 |
return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 96 |
} |
| 97 |
} else if (role == Qtcxx . . $ Qt/::TextAlignmentRolecxx . . $ Qt/TextAlignmentRole.) { |
| 98 |
switch (index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).()) { |
| 99 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 100 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 101 |
case USEcxx . . $ GrainModel#USE.: |
| 102 |
return Qtcxx . . $ QVariant#QVariant(d4f767463ce0a6b3).::AlignLeftcxx . . $ Qt/AlignLeft.; |
| 103 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: |
| 104 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 105 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 106 |
default: |
| 107 |
return Qtcxx . . $ QVariant#QVariant(d4f767463ce0a6b3).::AlignRightcxx . . $ Qt/AlignRight.; |
| 108 |
} |
| 109 |
} else { |
| 110 |
return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
////////////////////////////////////////////////////////////////////////////// |
| 115 |
// setData() |
| 116 |
// --------- |
| 117 |
// Set data at index |
| 118 |
|
| 119 |
bool GrainModelcxx . . $ GrainModel#::setDatacxx . . $ GrainModel#setData(6d1d8401440d0a2c).(const QModelIndexcxx . . $ QModelIndex# &index, |
| 120 |
const QVariantcxx . . $ QVariant# &value, int role) |
| 121 |
{ |
| 122 |
static bool deleting = false; |
| 123 |
|
| 124 |
Graincxx . . $ Grain# graincxx . . $ Grain#Grain(49f6e7a06ebc5aa8).; |
| 125 |
QStringcxx . . $ QString# namecxx . . $ QString#QString(ced63f7c635d850d).; |
| 126 |
int row = index.rowcxx . . $ QModelIndex#row(ea6fe5115c70a13f).(); |
| 127 |
int column = index.columncxx . . $ QModelIndex#column(ea6fe5115c70a13f).(); |
| 128 |
|
| 129 |
if (!index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).()) return false; |
| 130 |
if (role != Qtcxx . . $ Qt/::EditRolecxx . . $ Qt/EditRole.) return false; |
| 131 |
if (row >= list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).()) return false; |
| 132 |
|
| 133 |
// grab existing grain |
| 134 |
grain =cxx . . $ Grain#`operator=`(7fead45929ea56fe). list_cxx . . $ GrainModel#list_.->valuecxx . . $ QList#value(b4be2ec6940d8d62).(row); |
| 135 |
|
| 136 |
switch (column) { |
| 137 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 138 |
// editing name as several special cases |
| 139 |
name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). value.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).(); |
| 140 |
|
| 141 |
// deleting name deletes ingredient |
| 142 |
if (name.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 143 |
if (row >= list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).()) return false; // empty |
| 144 |
|
| 145 |
// TODO: for some reason this gets entered recursively... |
| 146 |
if (deleting) return false; |
| 147 |
deleting = true; |
| 148 |
|
| 149 |
int status = QMessageBoxcxx . . $ QMessageBox#::questioncxx . . $ QMessageBox#question(a9e3742e6f7b4147).(QApplicationcxx . . $ QApplication#::activeWindowcxx . . $ QApplication#activeWindow(9b769eeb00a33a04).(), |
| 150 |
TITLEcxx . . $ Resource/TITLE. +cxx . . $ operator+(57364c1b23444736). trcxx . . $ GrainModel#tr(75d9f1c324b4579d).(" - Delete?"), |
| 151 |
trcxx . . $ GrainModel#tr(75d9f1c324b4579d).("Do you wish to remove this entry?"), |
| 152 |
QMessageBoxcxx . . $ QMessageBox#::Yescxx . . $ QMessageBox#Yes. |cxx . . $ `operator|`(67530149e923fc12). QMessageBoxcxx . . $ QMessageBox#::Cancelcxx . . $ QMessageBox#Cancel.); |
| 153 |
if (status == QMessageBoxcxx . . $ QMessageBox#::Yescxx . . $ QMessageBox#Yes.) { |
| 154 |
// remove grain |
| 155 |
beginRemoveRowscxx . . $ QAbstractItemModel#beginRemoveRows(d1f44b3c3a3f9fa).(index.parentcxx . . $ QModelIndex#parent(a394cbc57608ce34).(), row, row); |
| 156 |
|
| 157 |
list_cxx . . $ GrainModel#list_.->removeAtcxx . . $ QList#removeAt(d4f767463ce0a6b3).(row); |
| 158 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! modifiedcxx . . $ GrainModel#modified(49f6e7a06ebc5aa8).(); |
| 159 |
endRemoveRowscxx . . $ QAbstractItemModel#endRemoveRows(49f6e7a06ebc5aa8).(); |
| 160 |
|
| 161 |
deleting = false; |
| 162 |
return true; |
| 163 |
} else { |
| 164 |
// ignore |
| 165 |
deleting = false; |
| 166 |
return false; |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
// no change, nothing to do |
| 171 |
if (name ==cxx . . $ `operator==`(5bc2975d2d751687). list_cxx . . $ GrainModel#list_.->atcxx . . $ QList#at(e2681f9bb6b2f357).(row).namecxx . . $ Grain#name(a2fb7a6ce195d51).()) { |
| 172 |
return false; |
| 173 |
} |
| 174 |
|
| 175 |
// changed name |
| 176 |
grain.setNamecxx . . $ Grain#setName(3520e46b33348bf6).(name); |
| 177 |
if (Datacxx . . $ Data#::instancecxx . . $ Data#instance(ddf71f0b6dfdf13b).()->hasGraincxx . . $ Data#hasGrain(e1defb592416720d).(name)) { |
| 178 |
Graincxx . . $ Grain# newgrain = Datacxx . . $ Data#::instancecxx . . $ Data#instance(ddf71f0b6dfdf13b).()->graincxx . . $ Data#grain(1f2faa94dd8d6cf).(name); |
| 179 |
// we don't override weight |
| 180 |
grain.setExtractcxx . . $ Grain#setExtract(ba8836b59fb42830).(newgrain.extractcxx . . $ Grain#extract(21b6c25e127938e2).()); |
| 181 |
grain.setColorcxx . . $ Grain#setColor(ba8836b59fb42830).(newgrain.colorcxx . . $ Grain#color(21b6c25e127938e2).()); |
| 182 |
grain.setTypecxx . . $ Grain#setType(3520e46b33348bf6).(newgrain.typecxx . . $ Grain#type(a2fb7a6ce195d51).()); |
| 183 |
grain.setUsecxx . . $ Grain#setUse(3520e46b33348bf6).(newgrain.usecxx . . $ Grain#use(a2fb7a6ce195d51).()); |
| 184 |
} |
| 185 |
break; |
| 186 |
|
| 187 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: |
| 188 |
grain.setWeightcxx . . $ Grain#setWeight(fcd19e49ee58ab66).(Weightcxx . . $ Weight#Weight(2884c06fcedbb8a7).(value.toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).(), |
| 189 |
Datacxx . . $ Data#::instancecxx . . $ Data#instance(ddf71f0b6dfdf13b).()->defaultGrainUnitcxx . . $ Data#defaultGrainUnit(1a4d46a500733df5).())); |
| 190 |
break; |
| 191 |
|
| 192 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 193 |
grain.setExtractcxx . . $ Grain#setExtract(ba8836b59fb42830).(value.toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).()); |
| 194 |
break; |
| 195 |
|
| 196 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 197 |
grain.setColorcxx . . $ Grain#setColor(ba8836b59fb42830).(value.toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).()); |
| 198 |
break; |
| 199 |
|
| 200 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 201 |
grain.setTypecxx . . $ Grain#setType(3520e46b33348bf6).(value.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 202 |
break; |
| 203 |
|
| 204 |
case USEcxx . . $ GrainModel#USE.: |
| 205 |
grain.setUsecxx . . $ Grain#setUse(3520e46b33348bf6).(value.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).()); |
| 206 |
break; |
| 207 |
|
| 208 |
default: |
| 209 |
return false; |
| 210 |
} |
| 211 |
|
| 212 |
list_cxx . . $ GrainModel#list_.->replacecxx . . $ QList#replace(20dcc09d4a3213bb).(row, grain); |
| 213 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! modifiedcxx . . $ GrainModel#modified(49f6e7a06ebc5aa8).(); |
| 214 |
|
| 215 |
// whole row may have changed |
| 216 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! dataChangedcxx . . $ QAbstractItemModel#dataChanged(ae8a85c811f0c28a).(index.siblingcxx . . $ QModelIndex#sibling(ed2c7c7bbed3ca7f).(row, NAMEcxx . . $ GrainModel#NAME.), |
| 217 |
index.siblingcxx . . $ QModelIndex#sibling(ed2c7c7bbed3ca7f).(row, USEcxx . . $ GrainModel#USE.)); |
| 218 |
|
| 219 |
return true; |
| 220 |
} |
| 221 |
|
| 222 |
////////////////////////////////////////////////////////////////////////////// |
| 223 |
// insertRows() |
| 224 |
// ------------ |
| 225 |
// Insert rows into table |
| 226 |
|
| 227 |
bool GrainModelcxx . . $ GrainModel#::insertRowscxx . . $ GrainModel#insertRows(c4e00837c4ba3150).(int row, int count, const QModelIndexcxx . . $ QModelIndex#&) |
| 228 |
{ |
| 229 |
if (count != 1) return false; // only insert one row at a time |
| 230 |
if ((row < 0) || (row >= list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).())) row = list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).(); |
| 231 |
|
| 232 |
Graincxx . . $ Grain# grain = Datacxx . . $ Data#::instancecxx . . $ Data#instance(ddf71f0b6dfdf13b).()->graincxx . . $ Data#grain(1f2faa94dd8d6cf).(trcxx . . $ GrainModel#tr(75d9f1c324b4579d).("Generic")); |
| 233 |
|
| 234 |
beginInsertRowscxx . . $ QAbstractItemModel#beginInsertRows(d1f44b3c3a3f9fa).(QModelIndexcxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).(), row, row); |
| 235 |
list_cxx . . $ GrainModel#list_.->insertcxx . . $ QList#insert(20dcc09d4a3213bb).(row, grain); |
| 236 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! modifiedcxx . . $ GrainModel#modified(49f6e7a06ebc5aa8).(); |
| 237 |
endInsertRowscxx . . $ QAbstractItemModel#endInsertRows(49f6e7a06ebc5aa8).(); |
| 238 |
return true; |
| 239 |
} |
| 240 |
|
| 241 |
////////////////////////////////////////////////////////////////////////////// |
| 242 |
// removeRows() |
| 243 |
// ------------ |
| 244 |
// Remove rows from table |
| 245 |
|
| 246 |
bool GrainModelcxx . . $ GrainModel#::removeRowscxx . . $ GrainModel#removeRows(c4e00837c4ba3150).(int row, int count, const QModelIndexcxx . . $ QModelIndex#&) |
| 247 |
{ |
| 248 |
if (count != 1) return false; // only remove one row at a time |
| 249 |
if ((row < 0) || (row >= list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).())) return false; |
| 250 |
|
| 251 |
int status = QMessageBoxcxx . . $ QMessageBox#::questioncxx . . $ QMessageBox#question(a9e3742e6f7b4147).(QApplicationcxx . . $ QApplication#::activeWindowcxx . . $ QApplication#activeWindow(9b769eeb00a33a04).(), |
| 252 |
TITLEcxx . . $ Resource/TITLE. +cxx . . $ operator+(57364c1b23444736). trcxx . . $ GrainModel#tr(75d9f1c324b4579d).(" - Delete?"), |
| 253 |
trcxx . . $ GrainModel#tr(75d9f1c324b4579d).("Do you wish to remove this entry?"), |
| 254 |
QMessageBoxcxx . . $ QMessageBox#::Yescxx . . $ QMessageBox#Yes. |cxx . . $ `operator|`(67530149e923fc12). QMessageBoxcxx . . $ QMessageBox#::Cancelcxx . . $ QMessageBox#Cancel.); |
| 255 |
if (status == QMessageBoxcxx . . $ QMessageBox#::Cancelcxx . . $ QMessageBox#Cancel.) { |
| 256 |
return false; |
| 257 |
} |
| 258 |
|
| 259 |
beginRemoveRowscxx . . $ QAbstractItemModel#beginRemoveRows(d1f44b3c3a3f9fa).(QModelIndexcxx . . $ QModelIndex#QModelIndex(ced63f7c635d850d).(), row, row); |
| 260 |
list_cxx . . $ GrainModel#list_.->removeAtcxx . . $ QList#removeAt(d4f767463ce0a6b3).(row); |
| 261 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! modifiedcxx . . $ GrainModel#modified(49f6e7a06ebc5aa8).(); |
| 262 |
endRemoveRowscxx . . $ QAbstractItemModel#endRemoveRows(49f6e7a06ebc5aa8).(); |
| 263 |
return true; |
| 264 |
} |
| 265 |
|
| 266 |
////////////////////////////////////////////////////////////////////////////// |
| 267 |
// headerData() |
| 268 |
// ------------ |
| 269 |
// Return header information |
| 270 |
|
| 271 |
QVariantcxx . . $ QVariant# GrainModelcxx . . $ GrainModel#::headerDatacxx . . $ GrainModel#headerData(b8cfec0985494997).(int section, Qtcxx . . $ Qt/::Orientationcxx . . $ Qt/Orientation# orientation, |
| 272 |
int role) const |
| 273 |
{ |
| 274 |
if (orientation == Qtcxx . . $ Qt/::Horizontalcxx . . $ Qt/Horizontal. && role == Qtcxx . . $ Qt/::DisplayRolecxx . . $ Qt/DisplayRole.) { |
| 275 |
switch (section) { |
| 276 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 277 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Grain"); |
| 278 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: |
| 279 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Weight"); |
| 280 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 281 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Extract"); |
| 282 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 283 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Color"); |
| 284 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 285 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Type"); |
| 286 |
case USEcxx . . $ GrainModel#USE.: |
| 287 |
return trcxx . . $ QVariant#QVariant(3520e46b33348bf6).("Use"); |
| 288 |
default: |
| 289 |
return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).(); |
| 294 |
} |
| 295 |
|
| 296 |
////////////////////////////////////////////////////////////////////////////// |
| 297 |
// flags() |
| 298 |
// ------ |
| 299 |
// Return flags at index |
| 300 |
|
| 301 |
Qtcxx . . $ Qt/::ItemFlagscxx . . $ Qt/ItemFlags# GrainModelcxx . . $ GrainModel#::flagscxx . . $ GrainModel#flags(36b38c1b3d3f7b45).(const QModelIndexcxx . . $ QModelIndex# &index) const |
| 302 |
{ |
| 303 |
if (!index.isValidcxx . . $ QModelIndex#isValid(3482b152b9333168).()) return Qtcxx . . $ QFlags#QFlags(93d577a3e9528307).::ItemIsEnabledcxx . . $ Qt/ItemIsEnabled.; |
| 304 |
|
| 305 |
return QAbstractTableModelcxx . . $ QAbstractTableModel#::flagscxx . . $ QAbstractTableModel#flags(36b38c1b3d3f7b45).(index) |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). Qtcxx . . $ Qt/::ItemIsEditablecxx . . $ Qt/ItemIsEditable.; |
| 306 |
} |
| 307 |
|
| 308 |
////////////////////////////////////////////////////////////////////////////// |
| 309 |
// rowCount() |
| 310 |
// ---------- |
| 311 |
// Return number of rows of data |
| 312 |
|
| 313 |
int GrainModelcxx . . $ GrainModel#::rowCountcxx . . $ GrainModel#rowCount(e3878d4d6cd9529c).(const QModelIndexcxx . . $ QModelIndex# &) const |
| 314 |
{ |
| 315 |
return list_cxx . . $ GrainModel#list_.->countcxx . . $ QList#count(455f465bc33b4cdf).(); |
| 316 |
} |
| 317 |
|
| 318 |
////////////////////////////////////////////////////////////////////////////// |
| 319 |
// columnCount() |
| 320 |
// ------------- |
| 321 |
// Return number of columns of data |
| 322 |
|
| 323 |
int GrainModelcxx . . $ GrainModel#::columnCountcxx . . $ GrainModel#columnCount(e3878d4d6cd9529c).(const QModelIndexcxx . . $ QModelIndex# &) const |
| 324 |
{ |
| 325 |
return COUNTcxx . . $ GrainModel#COUNT.; |
| 326 |
} |
| 327 |
|
| 328 |
////////////////////////////////////////////////////////////////////////////// |
| 329 |
// sort() |
| 330 |
// ------ |
| 331 |
// Sort by column |
| 332 |
|
| 333 |
void GrainModelcxx . . $ GrainModel#::sortcxx . . $ GrainModel#sort(11168df8d4e8286d).(int column, Qtcxx . . $ Qt/::SortOrdercxx . . $ Qt/SortOrder# order) |
| 334 |
{ |
| 335 |
QListcxx . . $ QList#<QPaircxx . . $ QPair#<QStringcxx . . $ QString#,Graincxx . . $ Grain#> > sortlistcxx . . $ QList#QList(ced63f7c635d850d).; |
| 336 |
|
| 337 |
foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`!(Grain grain, *list_) { |
| 338 |
QStringcxx . . $ QString# fieldcxx . . $ QString#QString(ced63f7c635d850d).; |
| 339 |
switch (column) { |
| 340 |
case NAMEcxx . . $ GrainModel#NAME.: |
| 341 |
field =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). grain.namecxx . . $ Grain#name(a2fb7a6ce195d51).(); |
| 342 |
break; |
| 343 |
case WEIGHTcxx . . $ GrainModel#WEIGHT.: |
| 344 |
field =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(grain.weightcxx . . $ Grain#weight(e805bc742de5fe4b).().amountcxx . . $ Quantity#amount(21b6c25e127938e2).()).rightJustifiedcxx . . $ QString#rightJustified(63a88914f7cad4ec).(8,'0'cxx . . $ QChar#QChar(f349c77f591a7878).); |
| 345 |
break; |
| 346 |
case EXTRACTcxx . . $ GrainModel#EXTRACT.: |
| 347 |
field =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(grain.extractcxx . . $ Grain#extract(21b6c25e127938e2).(),'f',3).rightJustifiedcxx . . $ QString#rightJustified(63a88914f7cad4ec).(8,'0'cxx . . $ QChar#QChar(f349c77f591a7878).); |
| 348 |
break; |
| 349 |
case COLORcxx . . $ GrainModel#COLOR.: |
| 350 |
field =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#::numbercxx . . $ QString#number(ac5d358e2e30f7ea).(grain.colorcxx . . $ Grain#color(21b6c25e127938e2).(),'f',1).rightJustifiedcxx . . $ QString#rightJustified(63a88914f7cad4ec).(8,'0'cxx . . $ QChar#QChar(f349c77f591a7878).); |
| 351 |
break; |
| 352 |
case TYPEcxx . . $ GrainModel#TYPE.: |
| 353 |
field =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). grain.typecxx . . $ Grain#type(a2fb7a6ce195d51).(); |
| 354 |
break; |
| 355 |
case USEcxx . . $ GrainModel#USE.: |
| 356 |
default: |
| 357 |
field =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). grain.usecxx . . $ Grain#use(a2fb7a6ce195d51).(); |
| 358 |
break; |
| 359 |
} |
| 360 |
sortlist.appendcxx . . $ QList#append(77d9f17553126ecb).(QPaircxx . . $ QPair#QPair(ce1e23113bcdb2b4).<QStringcxx . . $ QString#,Graincxx . . $ Grain#>(field, grain)); |
| 361 |
} |
| 362 |
|
| 363 |
// sort list |
| 364 |
qSortcxx . . $ qSort(249673c20e2b8d5).(sortlist.begincxx . . $ QList#begin(ca2520f641887418).(), sortlist.endcxx . . $ QList#end(ca2520f641887418).()); |
| 365 |
|
| 366 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! layoutAboutToBeChangedcxx . . $ QAbstractItemModel#layoutAboutToBeChanged(17ff3201f1a6fa68).(); |
| 367 |
|
| 368 |
// create new list |
| 369 |
list_cxx . . $ GrainModel#list_.->clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 370 |
QPaircxx . . $ QPair#<QStringcxx . . $ QString#,Graincxx . . $ Grain#> paircxx . . $ QPair#QPair(7d94e3e767b7b77f).; |
| 371 |
foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`!(pair, sortlist) { |
| 372 |
if (order == Qtcxx . . $ Qt/::AscendingOrdercxx . . $ Qt/AscendingOrder.) |
| 373 |
list_cxx . . $ GrainModel#list_.->appendcxx . . $ QList#append(77d9f17553126ecb).(pair.secondcxx . . $ QPair#second.); |
| 374 |
else |
| 375 |
list_cxx . . $ GrainModel#list_.->prependcxx . . $ QList#prepend(77d9f17553126ecb).(pair.secondcxx . . $ QPair#second.); |
| 376 |
} |
| 377 |
|
| 378 |
emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! layoutChangedcxx . . $ QAbstractItemModel#layoutChanged(17ff3201f1a6fa68).(); |
| 379 |
} |