digiKam
dconfigdlgmodels_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-11-03
7  * Description : A dialog base class which can handle multiple pages.
8  *
9  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2007 by Matthias Kretz <kretz at kde dot org>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DCONFIG_DLG_MODELS_PRIVATE_H
26 #define DIGIKAM_DCONFIG_DLG_MODELS_PRIVATE_H
27 
28 #include "dconfigdlgmodels.h"
29 
30 namespace Digikam
31 {
32 
33 class Q_DECL_HIDDEN DConfigDlgModelPrivate
34 {
35  Q_DECLARE_PUBLIC(DConfigDlgModel)
36 
37 public:
38 
40  virtual ~DConfigDlgModelPrivate() = default;
41 
42 protected:
43 
45 
46 private:
47 
48  Q_DISABLE_COPY(DConfigDlgModelPrivate)
49 };
50 
51 // ----------------------------------------------------------------------------
52 
53 class Q_DECL_HIDDEN PageItem
54 {
55 public:
56 
57  explicit PageItem(DConfigDlgWdgItem* pageItem, PageItem* parent = nullptr);
58  ~PageItem();
59 
60  void appendChild(PageItem* child);
61  void insertChild(int row, PageItem* child);
62  void removeChild(int row);
63 
64  PageItem* child(int row);
65  int childCount() const;
66  int columnCount() const;
67  int row() const;
68  PageItem* parent();
69 
70  DConfigDlgWdgItem* pageWidgetItem() const;
71 
72  PageItem* findChild(const DConfigDlgWdgItem* item);
73 
74  void dump(int indent = 0);
75 
76 private:
77 
78  DConfigDlgWdgItem* mPageWidgetItem;
79  QList<PageItem*> mChildItems;
80  PageItem* mParentItem;
81 };
82 
83 // ----------------------------------------------------------------------------
84 
86 {
87  Q_DECLARE_PUBLIC(DConfigDlgWdgModel)
88 
89 protected:
90 
92  : rootItem(new PageItem(nullptr, nullptr))
93  {
94  }
95 
97  {
98  delete rootItem;
99  rootItem = nullptr;
100  }
101 
103  {
104  Q_Q(DConfigDlgWdgModel);
105  DConfigDlgWdgItem* const item = qobject_cast<DConfigDlgWdgItem*>(q->sender());
106 
107  if (!item)
108  {
109  return;
110  }
111 
112  const QModelIndex index = q->index(item);
113 
114  if (!index.isValid())
115  {
116  return;
117  }
118 
119  emit q->dataChanged(index, index);
120  }
121 
122  void _k_itemToggled(bool checked)
123  {
124  Q_Q(DConfigDlgWdgModel);
125  DConfigDlgWdgItem* const item = qobject_cast<DConfigDlgWdgItem*>(q->sender());
126 
127  if (!item)
128  {
129  return;
130  }
131 
132  emit q->toggled(item, checked);
133  }
134 
135 protected:
136 
137  PageItem* rootItem = nullptr;
138 
139 private:
140 
141  // Disable
143  DConfigDlgWdgModelPrivate& operator=(const DConfigDlgWdgModelPrivate&) = delete;
144 };
145 
146 } // namespace Digikam
147 
148 #endif // DIGIKAM_DCONFIG_DLG_MODELS_PRIVATE_H
Definition: dconfigdlgmodels_p.h:34
virtual ~DConfigDlgModelPrivate()=default
DConfigDlgModel * q_ptr
Definition: dconfigdlgmodels_p.h:44
A base class for a model used by DConfigDlgView.
Definition: dconfigdlgmodels.h:56
Definition: dconfigdlgmodels.h:105
Definition: dconfigdlgmodels_p.h:86
void _k_itemChanged()
Definition: dconfigdlgmodels_p.h:102
DConfigDlgWdgModelPrivate()
Definition: dconfigdlgmodels_p.h:91
~DConfigDlgWdgModelPrivate()
Definition: dconfigdlgmodels_p.h:96
void _k_itemToggled(bool checked)
Definition: dconfigdlgmodels_p.h:122
Definition: dconfigdlgmodels.h:248
Definition: dconfigdlgmodels_p.h:54
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43