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