QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
FieldLabel Class Reference

The name of a key: value field in PasswordDialog, editable in place: double-click or the context menu renames it, the context menu can also remove the field (#132). More...

#include <fieldlabel.h>

Inheritance diagram for FieldLabel:
Collaboration diagram for FieldLabel:

Public Slots

void startEdit ()
 Open the in-place editor over the label.

Signals

void renamed (const QString &from, const QString &to)
 The user typed a different name and confirmed it.
void removeRequested ()
 The user chose "Remove field".

Public Member Functions

 FieldLabel (const QString &name, QWidget *parent=nullptr)
 Label for the field called name.
 ~FieldLabel () override
 Takes an open editor with it: the editor is a sibling, not a child, so it would otherwise stay behind when the field is removed while its name is being edited.

Protected Member Functions

void mouseDoubleClickEvent (QMouseEvent *event) override
 A left double-click starts editing the name.
void contextMenuEvent (QContextMenuEvent *event) override
 Menu with Rename field and Remove field.
auto eventFilter (QObject *watched, QEvent *event) -> bool override
 Escape in the editor cancels the edit.

Private Member Functions

void finishEdit (bool commit)
 Close the editor, putting the label back in its place.

Private Attributes

QPointer< QLineEdit > m_editor
 The line edit open over the label while a rename is in progress; null otherwise. A sibling in the parent's form layout rather than a child, so the destructor deletes it explicitly.

Detailed Description

The name of a key: value field in PasswordDialog, editable in place: double-click or the context menu renames it, the context menu can also remove the field (#132).

The label only reports what the user asked for; PasswordDialog owns the line edit the field belongs to and decides whether a new name is usable.

Definition at line 26 of file fieldlabel.h.

Constructor & Destructor Documentation

◆ FieldLabel()

FieldLabel::FieldLabel ( const QString & name,
QWidget * parent = nullptr )
explicit

Label for the field called name.

Parameters
namethe field's key, as shown and as written back
parentowning widget

Definition at line 16 of file fieldlabel.cpp.

Here is the caller graph for this function:

◆ ~FieldLabel()

FieldLabel::~FieldLabel ( )
override

Takes an open editor with it: the editor is a sibling, not a child, so it would otherwise stay behind when the field is removed while its name is being edited.

Definition at line 40 of file fieldlabel.cpp.

Member Function Documentation

◆ contextMenuEvent()

void FieldLabel::contextMenuEvent ( QContextMenuEvent * event)
overrideprotected

Menu with Rename field and Remove field.

Parameters
eventthe context menu event

Definition at line 33 of file fieldlabel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

auto FieldLabel::eventFilter ( QObject * watched,
QEvent * event ) -> bool
overrideprotected

Escape in the editor cancels the edit.

Parameters
watchedthe editor
eventthe event to inspect
Returns
true when the event was consumed

Definition at line 72 of file fieldlabel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finishEdit()

void FieldLabel::finishEdit ( bool commit)
private

Close the editor, putting the label back in its place.

Parameters
commitemit renamed() for a changed, non-empty name

Definition at line 91 of file fieldlabel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void FieldLabel::mouseDoubleClickEvent ( QMouseEvent * event)
overrideprotected

A left double-click starts editing the name.

Parameters
eventthe mouse event

Definition at line 25 of file fieldlabel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeRequested

void FieldLabel::removeRequested ( )
signal

The user chose "Remove field".

Here is the call graph for this function:
Here is the caller graph for this function:

◆ renamed

void FieldLabel::renamed ( const QString & from,
const QString & to )
signal

The user typed a different name and confirmed it.

Parameters
fromthe name before, still shown until the receiver accepts
tothe new name, trimmed, never empty, without a colon
Here is the caller graph for this function:

◆ startEdit

void FieldLabel::startEdit ( )
slot

Open the in-place editor over the label.

Definition at line 42 of file fieldlabel.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_editor

QPointer<QLineEdit> FieldLabel::m_editor
private

The line edit open over the label while a rename is in progress; null otherwise. A sibling in the parent's form layout rather than a child, so the destructor deletes it explicitly.

Definition at line 92 of file fieldlabel.h.


The documentation for this class was generated from the following files: