forked from blue/squawk
keeping with the refactoring
This commit is contained in:
parent
edf1ee60cd
commit
bf11d8a74e
8 changed files with 298 additions and 6 deletions
|
@ -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()];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue