/* QAD - Qt ADvanced Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef QIPEDIT_H #define QIPEDIT_H #include #include #include #include #include #include #include "qad_export.h" class QAD_EXPORT QIPEdit: public QWidget { Q_OBJECT Q_PROPERTY(QString IP READ IP WRITE setIP) public: QIPEdit(QWidget * parent = 0, const QString & ip = ""); ~QIPEdit(); QString IP(); private: void returnPress(int index); inline void textChange(int index, const QString & text) {if (text.length() == 3 && isVisible()) returnPress(index); emit valueChanged(IP());} int cind; QBoxLayout * layout; QVector edits; QVector dots; public slots: void setIP(const QString & text); private slots: void returnPressed0() {returnPress(0);} void returnPressed1() {returnPress(1);} void returnPressed2() {returnPress(2);} void returnPressed3() {returnPress(3);} void textChanged0(const QString & text) {textChange(0, text);} void textChanged1(const QString & text) {textChange(1, text);} void textChanged2(const QString & text) {textChange(2, text);} void textChanged3(const QString & text) {textChange(3, text);} signals: void valueChanged(QString); }; #endif // QIPEDIT_H