VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: QITableView.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QITableView class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2024 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 pParentRow. */
54 QITableViewCell(QITableViewRow *pParentRow)
55 : m_pRow(pParentRow)
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 pParentTable. */
81 QITableViewRow(QITableView *pParentTable)
82 : m_pTable(pParentTable)
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 /** Makes sure current editor data committed. */
120 void makeSureEditorDataCommitted();
121
122protected slots:
123
124 /** Stores the created @a pEditor for passed @a index in the map. */
125 virtual void sltEditorCreated(QWidget *pEditor, const QModelIndex &index);
126 /** Clears the destoyed @a pEditor from the map. */
127 virtual void sltEditorDestroyed(QObject *pEditor);
128
129protected:
130
131 /** Handles index change from @a previous to @a current. */
132 virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous) RT_OVERRIDE;
133
134private:
135
136 /** Prepares all. */
137 void prepare();
138 /** Cleanups all. */
139 void cleanup();
140
141 /** Holds the map of editors stored for passed indexes. */
142 QMap<QModelIndex, QObject*> m_editors;
143};
144
145
146#endif /* !FEQT_INCLUDED_SRC_extensions_QITableView_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette