From e44b91159d2fefeb495b2c77c64ba3e7cbc0869e Mon Sep 17 00:00:00 2001 From: Michal Kubecek Date: Fri, 17 Apr 2015 14:05:41 +0200 Subject: automatic conversion of numberconversionform.ui --- src/gui/numberconversionform.cpp | 79 ++++++++++ src/gui/numberconversionform.h | 24 +++ src/gui/numberconversionform.ui | 301 +++++++++++++++++--------------------- src/gui/numberconversionform.ui.h | 84 ----------- src/gui/twinkle.pro | 8 +- 5 files changed, 243 insertions(+), 253 deletions(-) create mode 100644 src/gui/numberconversionform.cpp create mode 100644 src/gui/numberconversionform.h delete mode 100644 src/gui/numberconversionform.ui.h diff --git a/src/gui/numberconversionform.cpp b/src/gui/numberconversionform.cpp new file mode 100644 index 0000000..16d0b3c --- /dev/null +++ b/src/gui/numberconversionform.cpp @@ -0,0 +1,79 @@ +#include "numberconversionform.h" + +#include "gui.h" + +/* + * Constructs a NumberConversionForm which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +NumberConversionForm::NumberConversionForm(QWidget* parent) + : QDialog(parent) +{ + setupUi(this); +} + +/* + * Destroys the object and frees any allocated resources + */ +NumberConversionForm::~NumberConversionForm() +{ + // no need to delete child widgets, Qt does it all for us +} + +void NumberConversionForm::init() +{ + QRegExp rxNoAtSign("[^@]*"); + + exprLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this)); + replaceLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this)); +} + +int NumberConversionForm::exec(QString &expr, QString &replace) +{ + exprLineEdit->setText(expr); + replaceLineEdit->setText(replace); + int retval = QDialog::exec(); + + if (retval == QDialog::Accepted) { + expr = exprLineEdit->text(); + replace = replaceLineEdit->text(); + } + + return retval; +} + +void NumberConversionForm::validate() +{ + QString expr = exprLineEdit->text(); + QString replace = replaceLineEdit->text(); + + if (expr.isEmpty()) { + ((t_gui *)ui)->cb_show_msg(this, + tr("Match expression may not be empty.").ascii(), MSG_CRITICAL); + exprLineEdit->setFocus(); + exprLineEdit->selectAll(); + return; + } + + if (replace.isEmpty()) { + ((t_gui *)ui)->cb_show_msg(this, + tr("Replace value may not be empty.").ascii(), MSG_CRITICAL); + replaceLineEdit->setFocus(); + replaceLineEdit->selectAll(); + return; + } + + try { + boost::regex re(expr.ascii()); + } catch (boost::bad_expression) { + ((t_gui *)ui)->cb_show_msg(this, + tr("Invalid regular expression.").ascii(), MSG_CRITICAL); + exprLineEdit->setFocus(); + return; + } + + accept(); +} diff --git a/src/gui/numberconversionform.h b/src/gui/numberconversionform.h new file mode 100644 index 0000000..cacf47e --- /dev/null +++ b/src/gui/numberconversionform.h @@ -0,0 +1,24 @@ +#ifndef NUMBERCONVERSIONFORM_H +#define NUMBERCONVERSIONFORM_H + +#include +#include "ui_numberconversionform.h" + +class NumberConversionForm : public QDialog, private Ui::NumberConversionForm +{ + Q_OBJECT + +public: + NumberConversionForm(QWidget* parent = 0); + ~NumberConversionForm(); + + int exec(QString& expr, QString& replace); + +public slots: + void validate(); + +private: + void init(); +}; + +#endif // NUMBERCONVERSIONFORM_H diff --git a/src/gui/numberconversionform.ui b/src/gui/numberconversionform.ui index 5ad490c..2a44110 100644 --- a/src/gui/numberconversionform.ui +++ b/src/gui/numberconversionform.ui @@ -1,175 +1,144 @@ - -NumberConversionForm - - - NumberConversionForm - + + + + + + NumberConversionForm + - - 0 - 0 - 436 - 122 - + + 0 + 0 + 436 + 122 + - - Twinkle - Number conversion + + Twinkle - Number conversion - - - unnamed - - - - layout43 - - - - unnamed - - - - exprTextLabel - - - &Match expression: - - - exprLineEdit - - - - - replaceTextLabel - - - &Replace: - - - replaceLineEdit - - - - - replaceLineEdit - - - Perl style format string for the replacement number. - - - - - exprLineEdit - - - Perl style regular expression matching the number format you want to modify. - - - - - - - spacer62 - - - Vertical - - - Expanding - - + + + + + + + &Match expression: + + + exprLineEdit + + + false + + + + + + + &Replace: + + + replaceLineEdit + + + false + + + + + + + Perl style format string for the replacement number. + + + + + + + Perl style regular expression matching the number format you want to modify. + + + + + + + + + + 20 + 20 + + + + QSizePolicy::Expanding + + + Qt::Vertical + + + + + + + + - 20 - 20 + 71 + 20 - - - - - layout44 - - - - unnamed - - - - spacer61 - - - Horizontal - - - Expanding - - - - 71 - 20 - - - - - - okPushButton - - - &OK - - - Alt+O - - - - - cancelPushButton - - - &Cancel - - - Alt+C - - - - - - - - - cancelPushButton - clicked() - NumberConversionForm - reject() - - - okPushButton - clicked() - NumberConversionForm - validate() - - - + + + QSizePolicy::Expanding + + + Qt::Horizontal + + + + + + + &OK + + + Alt+O + + + + + + + &Cancel + + + Alt+C + + + + + + + + + qPixmapFromMimeSource + exprLineEdit replaceLineEdit okPushButton cancelPushButton - - - qstring.h - gui.h - boost/regex.hpp - qregexp.h - qvalidator.h - numberconversionform.ui.h - - - validate() - - - init() - exec( QString & expr, QString & replace ) - - - - + + + + cancelPushButton + clicked() + NumberConversionForm + reject() + + + okPushButton + clicked() + NumberConversionForm + validate() + + + diff --git a/src/gui/numberconversionform.ui.h b/src/gui/numberconversionform.ui.h deleted file mode 100644 index 6bbdaec..0000000 --- a/src/gui/numberconversionform.ui.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you want to add, delete, or rename functions or slots, use -** Qt Designer to update this file, preserving your code. -** -** You should not define a constructor or destructor in this file. -** Instead, write your code in functions called init() and destroy(). -** These will automatically be called by the form's constructor and -** destructor. -*****************************************************************************/ - -/* - Copyright (C) 2005-2009 Michel de Boer - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -void NumberConversionForm::init() -{ - QRegExp rxNoAtSign("[^@]*"); - - exprLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this)); - replaceLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this)); -} - -int NumberConversionForm::exec(QString &expr, QString &replace) -{ - exprLineEdit->setText(expr); - replaceLineEdit->setText(replace); - int retval = QDialog::exec(); - - if (retval == QDialog::Accepted) { - expr = exprLineEdit->text(); - replace = replaceLineEdit->text(); - } - - return retval; -} - -void NumberConversionForm::validate() -{ - QString expr = exprLineEdit->text(); - QString replace = replaceLineEdit->text(); - - if (expr.isEmpty()) { - ((t_gui *)ui)->cb_show_msg(this, - tr("Match expression may not be empty.").ascii(), MSG_CRITICAL); - exprLineEdit->setFocus(); - exprLineEdit->selectAll(); - return; - } - - if (replace.isEmpty()) { - ((t_gui *)ui)->cb_show_msg(this, - tr("Replace value may not be empty.").ascii(), MSG_CRITICAL); - replaceLineEdit->setFocus(); - replaceLineEdit->selectAll(); - return; - } - - try { - boost::regex re(expr.ascii()); - } catch (boost::bad_expression) { - ((t_gui *)ui)->cb_show_msg(this, - tr("Invalid regular expression.").ascii(), MSG_CRITICAL); - exprLineEdit->setFocus(); - return; - } - - accept(); -} diff --git a/src/gui/twinkle.pro b/src/gui/twinkle.pro index 6c7e7f6..b4c73c2 100644 --- a/src/gui/twinkle.pro +++ b/src/gui/twinkle.pro @@ -1,7 +1,7 @@ TEMPLATE = app LANGUAGE = C++ -CONFIG += qt warn_on release thread +CONFIG += qt warn_on debug thread LIBS += ../libtwinkle.a ../parser/libsipparser.a ../sdp/libsdpparser.a ../sockets/libsocket.a ../threads/libthread.a ../audio/libaudio.a ../audits/libaudits.a ../stun/libstun.a ../mwi/libmwi.a ../im/libim.a ../patterns/libpatterns.a ../presence/libpresence.a ../utils/libutils.a -lsndfile -lmagic -lncurses -lreadline -lX11 @@ -13,6 +13,7 @@ HEADERS += gui.h \ dtmfform.h \ deregisterform.h \ logviewform.h \ + numberconversionform.h \ historylistview.h \ freedesksystray.h \ twinklesystray.h \ @@ -32,6 +33,7 @@ SOURCES += main.cpp \ dtmfform.cpp \ deregisterform.cpp \ logviewform.cpp \ + numberconversionform.cpp \ historylistview.cpp \ freedesksystray.cpp \ twinklesystray.cpp \ @@ -44,7 +46,8 @@ SOURCES += main.cpp \ FORMS = dtmfform.ui \ deregisterform.ui \ - logviewform.ui + logviewform.ui \ + numberconversionform.ui #The following line was changed from FORMS to FORMS3 by qt3to4 FORMS3 = mphoneform.ui \ @@ -63,7 +66,6 @@ FORMS3 = mphoneform.ui \ getaddressform.ui \ historyform.ui \ selectuserform.ui \ - numberconversionform.ui \ addresscardform.ui \ messageform.ui \ buddyform.ui \ -- cgit v1.2.3