Skip to content

Commit

Permalink
Have separate methods for appending and prepending contacts
Browse files Browse the repository at this point in the history
Have cases where both are needed.
  • Loading branch information
pvuorela committed May 27, 2019
1 parent e9cef9f commit 0bacf98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/calendarcontactmodel.cpp
Expand Up @@ -82,7 +82,16 @@ QList<CalendarData::EmailContact> CalendarContactModel::getList()
return m_contacts;
}

void CalendarContactModel::add(const QString &name, const QString &email)
void CalendarContactModel::append(const QString &name, const QString &email)
{
beginInsertRows(QModelIndex(), m_contacts.length(), m_contacts.length());
m_contacts.append(CalendarData::EmailContact(name, email));
endInsertRows();

emit countChanged();
}

void CalendarContactModel::prepend(const QString &name, const QString &email)
{
beginInsertRows(QModelIndex(), 0, 0);
m_contacts.prepend(CalendarData::EmailContact(name, email));
Expand Down
3 changes: 2 additions & 1 deletion src/calendarcontactmodel.h
Expand Up @@ -23,7 +23,8 @@ class CalendarContactModel : public QAbstractListModel

int count() const;

Q_INVOKABLE void add(const QString &name, const QString &email);
Q_INVOKABLE void append(const QString &name, const QString &email);
Q_INVOKABLE void prepend(const QString &name, const QString &email);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE bool hasEmail(const QString &email) const;
Q_INVOKABLE QString name(int index) const;
Expand Down

0 comments on commit 0bacf98

Please sign in to comment.