VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITableView.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: QITableView.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QITableView class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_extensions_QITableView_h
29#define FEQT_INCLUDED_SRC_extensions_QITableView_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QTableView>
36
37/* GUI includes: */
38#include "UILibraryDefs.h"
39
40/* Forward declarations: */
41class QITableViewCell;
42class QITableViewRow;
43class QITableView;
44
45
46/** OObject subclass used as cell for the QITableView. */
47class SHARED_LIBRARY_STUFF QITableViewCell : public QObject
48{
49 Q_OBJECT;
50
51public:
52
53 /** Constructs table-view cell for passed @a pParent. */
54 QITableViewCell(QITableViewRow *pParent)
55 : m_pRow(pParent)
56 {}
57
58 /** Defines the parent @a pRow reference. */
59 void setRow(QITableViewRow *pRow) { m_pRow = pRow; }
60 /** Returns the parent row reference. */
61 QITableViewRow *row() const { return m_pRow; }
62
63 /** Returns the cell text. */
64 virtual QString text() const = 0;
65
66private:
67
68 /** Holds the parent row reference. */
69 QITableViewRow *m_pRow;
70};
71
72
73/** OObject subclass used as row for the QITableView. */
74class SHARED_LIBRARY_STUFF QITableViewRow : public QObject
75{
76 Q_OBJECT;
77
78public:
79
80 /** Constructs table-view row for passed @a pParent. */
81 QITableViewRow(QITableView *pParent)
82 : m_pTable(pParent)
83 {}
84
85 /** Defines the parent @a pTable reference. */
86 void setTable(QITableView *pTable) { m_pTable = pTable; }
87 /** Returns the parent table reference. */
88 QITableView *table() const { return m_pTable; }
89
90 /** Returns the number of children. */
91 virtual int childCount() const = 0;
92 /** Returns the child item with @a iIndex. */
93 virtual QITableViewCell *childItem(int iIndex) const = 0;
94
95private:
96
97 /** Holds the parent table reference. */
98 QITableView *m_pTable;
99};
100
101
102/** QTableView subclass extending standard functionality. */
103class SHARED_LIBRARY_STUFF QITableView : public QTableView
104{
105 Q_OBJECT;
106
107signals:
108
109 /** Notifies listeners about index changed from @a previous to @a current. */
110 void sigCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
111
112public:
113
114 /** Constructs table-view passing @a pParent to the base-class. */
115 QITableView(QWidget *pParent = 0);
116 /** Destructs table-view. */
117 virtual ~QITableView() RT_OVERRIDE;
118
119 /** Returns the number of children. */
120 virtual int childCount() const { return 0; }
121 /** Returns the child item with @a iIndex. */
122 virtual QITableViewRow *childItem(int /* iIndex */) const { return 0; }
123
124 /** Makes sure current editor data committed. */
125 void makeSureEditorDataCommitted();
126
127protected slots:
128
129 /** Stores the created @a pEditor for passed @a index in the map. */
130 virtual void sltEditorCreated(QWidget *pEditor, const QModelIndex &index);
131 /** Clears the destoyed @a pEditor from the map. */
132 virtual void sltEditorDestroyed(QObject *pEditor);
133
134protected:
135
136 /** Handles index change from @a previous to @a current. */
137 virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous) RT_OVERRIDE;
138
139private:
140
141 /** Prepares all. */
142 void prepare();
143 /** Cleanups all. */
144 void cleanup();
145
146 /** Holds the map of editors stored for passed indexes. */
147 QMap<QModelIndex, QObject*> m_editors;
148};
149
150
151#endif /* !FEQT_INCLUDED_SRC_extensions_QITableView_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use