mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
8c89f6fe15
The code follows the other edit-commands, but uses its own base class, because it is distinctly different. Editing the tag field does not simply mean setting the tag for all dives, but rather adding and removing individual tags. This class will be reused for editing of dive buddies and masters. Modify the tag widget thus that it sends an editingFinished() signal when it goes out of focus. The editingFinished() signal was prevented by hooking into the return, enter and tab key-events. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
36 lines
818 B
C++
36 lines
818 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef TAGWIDGET_H
|
|
#define TAGWIDGET_H
|
|
|
|
#include "groupedlineedit.h"
|
|
#include <QPair>
|
|
|
|
class QCompleter;
|
|
|
|
class TagWidget : public GroupedLineEdit {
|
|
Q_OBJECT
|
|
public:
|
|
explicit TagWidget(QWidget *parent = 0);
|
|
void setCompleter(QCompleter *completer);
|
|
QPair<int, int> getCursorTagPosition();
|
|
void highlight();
|
|
void setText(const QString &text);
|
|
void clear();
|
|
void setCursorPosition(int position);
|
|
void wheelEvent(QWheelEvent *event);
|
|
void fixPopupPosition(int delta);
|
|
public
|
|
slots:
|
|
void reparse();
|
|
void completionSelected(const QString &text);
|
|
void completionHighlighted(const QString &text);
|
|
|
|
protected:
|
|
void keyPressEvent(QKeyEvent *e);
|
|
private:
|
|
void focusOutEvent(QFocusEvent *ev) override;
|
|
QCompleter *m_completer;
|
|
bool lastFinishedTag;
|
|
};
|
|
|
|
#endif // TAGWIDGET_H
|