mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Desktop: create new custom TextEdit widget for notes-field
Currently, the notes field uses a QTextEdit, which doesn't send a signal if it goes out of focus. But for undo of dive-editing we don't want to create an undo object for *every* text change. Thus, create a custom TextEdit widget that derives from QTextEdit and turns the focusOutEvent into a editingFinished signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0882ca64b0
commit
2bb2643ae4
4 changed files with 35 additions and 1 deletions
|
@ -126,6 +126,8 @@ set(SUBSURFACE_INTERFACE
|
||||||
tableview.h
|
tableview.h
|
||||||
tagwidget.cpp
|
tagwidget.cpp
|
||||||
tagwidget.h
|
tagwidget.h
|
||||||
|
textedit.cpp
|
||||||
|
textedit.h
|
||||||
updatemanager.cpp
|
updatemanager.cpp
|
||||||
updatemanager.h
|
updatemanager.h
|
||||||
usersurvey.cpp
|
usersurvey.cpp
|
||||||
|
|
|
@ -454,7 +454,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="notes">
|
<widget class="TextEdit" name="notes">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -601,6 +601,11 @@
|
||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header>desktop-widgets/locationinformation.h</header>
|
<header>desktop-widgets/locationinformation.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>TextEdit</class>
|
||||||
|
<extends>QTextEdit</extends>
|
||||||
|
<header>desktop-widgets/textedit.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../subsurface.qrc"/>
|
<include location="../../subsurface.qrc"/>
|
||||||
|
|
7
desktop-widgets/textedit.cpp
Normal file
7
desktop-widgets/textedit.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "textedit.h"
|
||||||
|
|
||||||
|
void TextEdit::focusOutEvent(QFocusEvent *ev)
|
||||||
|
{
|
||||||
|
QTextEdit::focusOutEvent(ev);
|
||||||
|
emit editingFinished();
|
||||||
|
}
|
20
desktop-widgets/textedit.h
Normal file
20
desktop-widgets/textedit.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#ifndef TEXTEDIT_H
|
||||||
|
#define TEXTEDIT_H
|
||||||
|
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
// QTextEdit does not possess a signal that fires when the user finished
|
||||||
|
// editing the text. This subclass therefore overrides the focusOutEvent
|
||||||
|
// and sends the textEdited signal.
|
||||||
|
class TextEdit : public QTextEdit {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using QTextEdit::QTextEdit; // Make constructors of QTextEdit available
|
||||||
|
signals:
|
||||||
|
void editingFinished();
|
||||||
|
private:
|
||||||
|
void focusOutEvent(QFocusEvent *ev) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue