keeping with the refactoring

This commit is contained in:
Blue 2023-02-03 21:43:13 +03:00
parent edf1ee60cd
commit bf11d8a74e
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
8 changed files with 298 additions and 6 deletions

View file

@ -89,6 +89,22 @@ Qt::ItemFlags Models::EMails::flags(const QModelIndex& index) const {
return f;
}
bool Models::EMails::setEditable(bool editable) {
if (edit != editable) {
edit = editable;
if (deque.size() > 0) {
int lastRow = deque.size() - 1;
QModelIndex begin = createIndex(0, 0, &(deque[0]));
QModelIndex end = createIndex(lastRow, columnCount() - 1, &(deque[lastRow]));
emit dataChanged(begin, end);
}
return true;
}
return false;
}
bool Models::EMails::setData(const QModelIndex& index, const QVariant& value, int role) {
if (role == Qt::EditRole && checkIndex(index)) {
Shared::VCard::Email& item = deque[index.row()];

View file

@ -33,6 +33,7 @@ class EMails : public QAbstractTableModel {
public:
EMails(bool edit = false, QObject *parent = nullptr);
bool setEditable(bool editable);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;

View file

@ -107,6 +107,22 @@ Qt::ItemFlags Models::Phones::flags(const QModelIndex& index) const {
return f;
}
bool Models::Phones::setEditable(bool editable) {
if (edit != editable) {
edit = editable;
if (deque.size() > 0) {
int lastRow = deque.size() - 1;
QModelIndex begin = createIndex(0, 0, &(deque[0]));
QModelIndex end = createIndex(lastRow, columnCount() - 1, &(deque[lastRow]));
emit dataChanged(begin, end);
}
return true;
}
return false;
}
bool Models::Phones::dropPrefered() {
bool dropped = false;
int i = 0;

View file

@ -30,9 +30,10 @@ class Phones : public QAbstractTableModel {
public:
Phones(bool edit = false, QObject *parent = nullptr);
bool setEditable(bool editable);
QVariant data(const QModelIndex& index, int role) const override;
int columnCount(const QModelIndex& parent) const override;
int rowCount(const QModelIndex& parent) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool isPreferred(quint32 row) const;