1 | /* $Id: QIStyledItemDelegate.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - Qt extensions: QIStyledItemDelegate class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 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_QIStyledItemDelegate_h
|
---|
29 | #define FEQT_INCLUDED_SRC_extensions_QIStyledItemDelegate_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QStyledItemDelegate>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UILibraryDefs.h"
|
---|
39 |
|
---|
40 | /** QStyledItemDelegate subclass extending standard functionality. */
|
---|
41 | class SHARED_LIBRARY_STUFF QIStyledItemDelegate : public QStyledItemDelegate
|
---|
42 | {
|
---|
43 | Q_OBJECT;
|
---|
44 |
|
---|
45 | signals:
|
---|
46 |
|
---|
47 | /** Notifies listeners about @a pEditor created for particular model @a index. */
|
---|
48 | void sigEditorCreated(QWidget *pEditor, const QModelIndex &index) const;
|
---|
49 |
|
---|
50 | /** Notifies listeners about editor's Enter key triggering. */
|
---|
51 | void sigEditorEnterKeyTriggered();
|
---|
52 |
|
---|
53 | public:
|
---|
54 |
|
---|
55 | /** Constructs delegate passing @a pParent to the base-class. */
|
---|
56 | QIStyledItemDelegate(QObject *pParent);
|
---|
57 |
|
---|
58 | /** Defines whether delegate should watch for the editor's data commits. */
|
---|
59 | void setWatchForEditorDataCommits(bool fWatch);
|
---|
60 | /** Defines whether delegate should watch for the editor's Enter key triggering. */
|
---|
61 | void setWatchForEditorEnterKeyTriggering(bool fWatch);
|
---|
62 |
|
---|
63 | protected:
|
---|
64 |
|
---|
65 | /** Returns the widget used to edit the item specified by @a index.
|
---|
66 | * The @a pParent widget and style @a option are used to control how the editor widget appears. */
|
---|
67 | virtual QWidget *createEditor(QWidget *pParent,
|
---|
68 | const QStyleOptionViewItem &option,
|
---|
69 | const QModelIndex &index) const RT_OVERRIDE;
|
---|
70 |
|
---|
71 | private:
|
---|
72 |
|
---|
73 | /** Holds whether delegate should watch for the editor's data commits. */
|
---|
74 | bool m_fWatchForEditorDataCommits : 1;
|
---|
75 | /** Holds whether delegate should watch for the editor's Enter key triggering. */
|
---|
76 | bool m_fWatchForEditorEnterKeyTriggering : 1;
|
---|
77 | };
|
---|
78 |
|
---|
79 | #endif /* !FEQT_INCLUDED_SRC_extensions_QIStyledItemDelegate_h */
|
---|