bool operator<(const DateWeight &o) const { return date < o.date; }
};
typedef QList<DateWeight> WeightList;
+
WeightDataModel(QString &datafile, QObject *parent = 0);
- int rowCount(const QModelIndex &/**/) const { return weights.size(); }
- int columnCount(const QModelIndex &/**/) const { return 2; }
+
+ int size() const { return weights.size(); }
+ int rowCount(const QModelIndex& = QModelIndex()) const { return weights.size(); }
+ int columnCount(const QModelIndex& = QModelIndex()) const { return 2; }
Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
+ bool dateExists(const QDate &date) const;
+ int rowOfDate(const QDate &date) const;
+ QModelIndex indexOfDate(const QDate &date) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ const WeightList &getWeights() const { return weights; }
+ double minWeight() const;
+ double maxWeight() const;
+
bool setData(const QModelIndex &index, const QVariant &value, int role);
bool setDataForRow(int row, const DateWeight &dw);
void setWeightForDate(const QDate &date, double weight);
void setWeightForDate(const DateWeight &dw);
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
- int rowOfDate(const QDate &date) const;
- QModelIndex indexOfDate(const QDate &date) const;
- bool dateExists(const QDate &date) const;
- int rowForNewDate(const QDate &date) const;
void clear();
-
- int size() const { return weights.size(); }
- const WeightList &getWeights() const { return weights; }
private:
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ int rowForNewDate(const QDate &date) const;
void writeToDisk();
void readFromDisk();
-private:
WeightList weights;
QFile datafile;
};