File indexing completed on 2024-05-19 05:14:38
0001 /* 0002 This file is part of KAddressBook. 0003 0004 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <Akonadi/ContactsTreeModel> 0012 0013 #include <QObject> 0014 0015 class QWidget; 0016 0017 /** 0018 * @short A manager for the contacts model columns. 0019 * 0020 * This class manages which columns shall be provided by the 0021 * contacts model. It keeps track of the configuration file 0022 * and the user configuration. 0023 * 0024 * @author Tobias Koenig <tokoe@kde.org> 0025 */ 0026 class ModelColumnManager : public QObject 0027 { 0028 Q_OBJECT 0029 public: 0030 /** 0031 * Creates a new model column manager. 0032 * 0033 * @param model The model that shall be managed. 0034 * @param parent The parent object. 0035 */ 0036 explicit ModelColumnManager(Akonadi::ContactsTreeModel *model, QObject *parent = nullptr); 0037 0038 /** 0039 * Loads the user configuration and applies it to the model. 0040 */ 0041 void load(); 0042 0043 /** 0044 * Stores the user configuration. 0045 */ 0046 void store(); 0047 0048 /** 0049 * Sets the widget that shall provide a RMB menu to 0050 * configure the columns to be shown. 0051 */ 0052 void setWidget(QWidget *view); 0053 0054 protected: 0055 bool eventFilter(QObject *watched, QEvent *event) override; 0056 0057 private: 0058 void adaptHeaderView(); 0059 Akonadi::ContactsTreeModel *const mModel; 0060 Akonadi::ContactsTreeModel::Columns mColumns; 0061 QWidget *mWidget = nullptr; 0062 };