File indexing completed on 2024-04-14 03:40:27
0001 /* 0002 KBruch - line edit used for entering prime factors 0003 SPDX-FileCopyrightText: 2011 Sebastian Stein <seb.kde@hpfsc.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef PRIMEFACTORSLINEEDIT_H 0009 #define PRIMEFACTORSLINEEDIT_H 0010 0011 #include <QLineEdit> 0012 #include <QKeyEvent> 0013 0014 class QString; 0015 0016 /** 0017 * line edit used for entering prime factors 0018 * based on KRestrictedLine class 0019 * 0020 * \author Sebastian Stein 0021 */ 0022 class PrimeFactorsLineEdit : public QLineEdit 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 /** constructor */ 0028 explicit PrimeFactorsLineEdit(QWidget* parent = nullptr); 0029 0030 /** destructor */ 0031 ~PrimeFactorsLineEdit() override; 0032 0033 /** return the factors entered */ 0034 QStringList getFactors() const; 0035 0036 /** called when the text in QLineEdit's content changes */ 0037 void textHasChanged(const QString &text); 0038 0039 Q_SIGNALS: 0040 /** emitted when QLineEdit's content changes and it's correct 0041 itIs is true if the content is correct otherwise. 0042 */ 0043 void contentIsRight(bool itIs); 0044 0045 private: 0046 /** will content the factor the application will used: 0047 * 2, 3, 5, 7, 11, 13, 17, 19 */ 0048 QStringList m_usedFactors; 0049 /** the factors entered in the QLineEdit */ 0050 QStringList m_theFactors; 0051 0052 /** will check if the QLineEdit's content is right */ 0053 bool checkCorrectness(const QString &text); 0054 /** will check if every factors' element is actually a factor */ 0055 bool areFactors(const QStringList &factors); 0056 0057 /** reimplement keyPressEvent inherited from QWidget */ 0058 void keyPressEvent(QKeyEvent * event) override; 0059 }; 0060 0061 #endif // PRIMEFACTORSLINEEDIT_H