Skip to content

Commit

Permalink
Fix header of contacts dir model
Browse files Browse the repository at this point in the history
  • Loading branch information
dragotin committed Feb 18, 2025
1 parent 3fa0854 commit 23641cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/models/contactsdirmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "models/contactsdirmodel.h"

QVariantList CTMItem::_headers{ "Name", "City", "UID" };
QVariantList CTMItem::_headers{ "Name", "City" };

CTMItem::CTMItem(KContacts::Addressee& addressee, CTMItem* parentItem)
:_parentItem(parentItem), _addressee(addressee)
Expand Down Expand Up @@ -151,8 +151,8 @@ Qt::ItemFlags ContactsDirModel::flags(const QModelIndex &index) const

QVariant ContactsDirModel::headerData(int section, Qt::Orientation orientation, int role) const
{
return orientation == Qt::Horizontal && role == Qt::DisplayRole
? _rootItem->data(section) : QVariant{};
return orientation == Qt::Horizontal && role == Qt::DisplayRole && section < CTMItem::_headers.size()
? CTMItem::_headers.at(section) : QVariant{};
}

QModelIndex ContactsDirModel::index(int row, int column, const QModelIndex &parent) const
Expand Down
2 changes: 1 addition & 1 deletion src/models/contactsdirmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CTMItem
void appendChild(std::unique_ptr<CTMItem> &child);
KContacts::Addressee getAddressee() const;

static QVariantList _headers;
private:
std::vector<std::unique_ptr<CTMItem>> _childItems;
static QVariantList _headers;
CTMItem* _parentItem;
KContacts::Addressee _addressee;
};
Expand Down

0 comments on commit 23641cc

Please sign in to comment.