QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
fieldlabel.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#ifndef FIELDLABEL_H_
9
#define FIELDLABEL_H_
10
11
#include <QLabel>
12
#include <QPointer>
13
14
class
QLineEdit;
15
26
class
FieldLabel
:
public
QLabel {
27
Q_OBJECT
28
29
public
:
35
explicit
FieldLabel
(
const
QString &name, QWidget *parent =
nullptr
);
41
~FieldLabel
()
override
;
42
43
public
slots:
47
void
startEdit
();
48
49
signals:
55
void
renamed
(
const
QString &from,
const
QString &to);
59
void
removeRequested
();
60
61
protected
:
66
void
mouseDoubleClickEvent
(QMouseEvent *event)
override
;
71
void
contextMenuEvent
(QContextMenuEvent *event)
override
;
78
auto
eventFilter
(QObject *watched, QEvent *event) ->
bool
override
;
79
80
private
:
85
void
finishEdit
(
bool
commit);
86
92
QPointer<QLineEdit>
m_editor
;
93
};
94
95
#endif
// FIELDLABEL_H_
FieldLabel::FieldLabel
FieldLabel(const QString &name, QWidget *parent=nullptr)
Label for the field called name.
Definition
fieldlabel.cpp:16
FieldLabel::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *event) override
Menu with Rename field and Remove field.
Definition
fieldlabel.cpp:33
FieldLabel::m_editor
QPointer< QLineEdit > m_editor
The line edit open over the label while a rename is in progress; null otherwise. A sibling in the par...
Definition
fieldlabel.h:92
FieldLabel::removeRequested
void removeRequested()
The user chose "Remove field".
FieldLabel::finishEdit
void finishEdit(bool commit)
Close the editor, putting the label back in its place.
Definition
fieldlabel.cpp:91
FieldLabel::renamed
void renamed(const QString &from, const QString &to)
The user typed a different name and confirmed it.
FieldLabel::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *event) override
A left double-click starts editing the name.
Definition
fieldlabel.cpp:25
FieldLabel::startEdit
void startEdit()
Open the in-place editor over the label.
Definition
fieldlabel.cpp:42
FieldLabel::eventFilter
auto eventFilter(QObject *watched, QEvent *event) -> bool override
Escape in the editor cancels the edit.
Definition
fieldlabel.cpp:72
src
fieldlabel.h
Generated by
1.18.0