VirtualBox

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

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use