digiKam
limitedtextedit.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2020-08-29
7  * Description : a widget to edit a long text with limited string size.
8  *
9  * Copyright (C) 2020-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef DIGIKAM_LIMITED_TEXT_EDIT_H
24 #define DIGIKAM_LIMITED_TEXT_EDIT_H
25 
26 // Qt includes
27 
28 #include <QPlainTextEdit>
29 #include <QKeyEvent>
30 #include <QMimeData>
31 
33 {
34 
35 class LimitedTextEdit : public QPlainTextEdit
36 {
37  Q_OBJECT
38 
39 public:
40 
41  explicit LimitedTextEdit(QWidget* const parent = nullptr);
42  ~LimitedTextEdit() override;
43 
44  void setMaxLength(int length);
45  int maxLength() const;
46 
47  int leftCharacters() const;
48 
49 protected:
50 
51  void insertFromMimeData(const QMimeData* source) override;
52 
53  void keyPressEvent(QKeyEvent* e) override;
54 
55 private:
56 
57  int m_maxLength;
58 };
59 
60 } // namespace DigikamGenericMetadataEditPlugin
61 
62 #endif // DIGIKAM_LIMITED_TEXT_EDIT_H
void insertFromMimeData(const QMimeData *source) override
Definition: limitedtextedit.cpp:105
void setMaxLength(int length)
Definition: limitedtextedit.cpp:58
int leftCharacters() const
Definition: limitedtextedit.cpp:51
void keyPressEvent(QKeyEvent *e) override
Definition: limitedtextedit.cpp:70
int maxLength() const
Definition: limitedtextedit.cpp:46
~LimitedTextEdit() override
Definition: limitedtextedit.cpp:42
LimitedTextEdit(QWidget *const parent=nullptr)
Definition: limitedtextedit.cpp:36
Definition: altlangstringedit.cpp:39