From 1ae15dd2d9e2f8360929960267b2a9dda5595ab5 Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Thu, 14 Oct 2010 11:12:56 +0000 Subject: change class name --- examples/GuiClient/GuiClient.pro | 4 +- examples/GuiClient/customLabel.cpp | 109 ------------------------------- examples/GuiClient/customLabel.h | 60 ----------------- examples/GuiClient/mainDialog.cpp | 6 +- examples/GuiClient/mainDialog.ui | 6 +- examples/GuiClient/signInStatusLabel.cpp | 109 +++++++++++++++++++++++++++++++ examples/GuiClient/signInStatusLabel.h | 60 +++++++++++++++++ 7 files changed, 177 insertions(+), 177 deletions(-) delete mode 100644 examples/GuiClient/customLabel.cpp delete mode 100644 examples/GuiClient/customLabel.h create mode 100644 examples/GuiClient/signInStatusLabel.cpp create mode 100644 examples/GuiClient/signInStatusLabel.h (limited to 'examples/GuiClient') diff --git a/examples/GuiClient/GuiClient.pro b/examples/GuiClient/GuiClient.pro index bb17ac5f..c25c9b1b 100644 --- a/examples/GuiClient/GuiClient.pro +++ b/examples/GuiClient/GuiClient.pro @@ -16,7 +16,7 @@ SOURCES += main.cpp \ rosterListView.cpp \ searchLineEdit.cpp \ statusWidget.cpp \ - customLabel.cpp \ + signInStatusLabel.cpp \ statusAvatarWidget.cpp \ statusTextWidget.cpp \ statusToolButton.cpp \ @@ -38,7 +38,7 @@ HEADERS += chatMsgGraphicsItem.h \ rosterListView.h \ searchLineEdit.h \ statusWidget.h \ - customLabel.h \ + signInStatusLabel.h \ statusAvatarWidget.h \ statusTextWidget.h \ statusToolButton.h \ diff --git a/examples/GuiClient/customLabel.cpp b/examples/GuiClient/customLabel.cpp deleted file mode 100644 index ec29d678..00000000 --- a/examples/GuiClient/customLabel.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008-2010 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * http://code.google.com/p/qxmpp - * - * This file is a part of QXmpp library. - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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. - * - */ - - -#include "customLabel.h" -#include - -customLabel::customLabel(QWidget* parent):QLabel(parent), m_timer(this), - m_option(None) -{ - m_timer.setSingleShot(false); - - bool check = connect(&m_timer, SIGNAL(timeout()), SLOT(timeout())); - Q_ASSERT(check); - Q_UNUSED(check); -} - -void customLabel::setCustomText(const QString& text, customLabel::Option op, - int countDown) -{ - m_text = text; - m_option = op; - m_countDown = countDown; - switch(op) - { - case None: - m_timer.stop(); - m_postfix = ""; - break; - case WithProgressEllipsis: -// m_timer.start(400); - m_postfix = ""; - break; - case CountDown: - m_timer.start(1000); - m_postfix = ""; - break; - default: - m_timer.stop(); - m_postfix = ""; - break; - } - - if(m_option == CountDown) - setText(m_text.arg(m_countDown) + m_postfix); - else - setText(m_text + m_postfix); - - updateGeometry(); -} - -void customLabel::timeout() -{ - switch(m_option) - { - case None: - break; - case WithProgressEllipsis: - if(m_postfix == "") - m_postfix = "."; - else if(m_postfix == ".") - m_postfix = ".."; - else if(m_postfix == "..") - m_postfix = "..."; - else if(m_postfix == "...") - m_postfix = ""; - break; - case CountDown: - if(m_countDown == 0) - m_timer.stop(); - --m_countDown; - break; - default: - break; - } - - if(m_option == CountDown) - setText(m_text.arg(m_countDown) + m_postfix); - else - setText(m_text + m_postfix); - updateGeometry(); -} - -//QSize customLabel::sizeHint() const -//{ -// QFont font; -// QFontMetrics fm(font); -// return QSize(fm.width(m_text) + 15, 20); -//} diff --git a/examples/GuiClient/customLabel.h b/examples/GuiClient/customLabel.h deleted file mode 100644 index 7d4ead81..00000000 --- a/examples/GuiClient/customLabel.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2008-2010 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * Source: - * http://code.google.com/p/qxmpp - * - * This file is a part of QXmpp library. - * - * This library 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 2.1 of the License, or (at your option) any later version. - * - * This library 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. - * - */ - - -#ifndef CUSTOMLABEL_H -#define CUSTOMLABEL_H - -#include -#include - -class customLabel : public QLabel -{ - Q_OBJECT - -public: - enum Option - { - None = 0, - WithProgressEllipsis, - CountDown - }; - customLabel(QWidget* parent = 0); - - void setCustomText(const QString& text, customLabel::Option op = None, - int countDown = 0); - -// QSize sizeHint() const; - -private slots: - void timeout(); - -private: - QTimer m_timer; - customLabel::Option m_option; - QString m_text; - QString m_postfix; - int m_countDown; -}; - -#endif // CUSTOMLABEL_H diff --git a/examples/GuiClient/mainDialog.cpp b/examples/GuiClient/mainDialog.cpp index 258af314..2322b13a 100644 --- a/examples/GuiClient/mainDialog.cpp +++ b/examples/GuiClient/mainDialog.cpp @@ -541,17 +541,17 @@ void mainDialog::startConnection() void mainDialog::showLoginStatus(const QString& msg) { - ui->label_status->setCustomText(msg, customLabel::None); + ui->label_status->setCustomText(msg, signInStatusLabel::None); } void mainDialog::showLoginStatusWithProgress(const QString& msg) { - ui->label_status->setCustomText(msg, customLabel::WithProgressEllipsis); + ui->label_status->setCustomText(msg, signInStatusLabel::WithProgressEllipsis); } void mainDialog::showLoginStatusWithCounter(const QString& msg, int time) { - ui->label_status->setCustomText(msg, customLabel::CountDown, time); + ui->label_status->setCustomText(msg, signInStatusLabel::CountDown, time); } void mainDialog::updateVCard(const QString& bareJid) diff --git a/examples/GuiClient/mainDialog.ui b/examples/GuiClient/mainDialog.ui index 0d174462..987b5dca 100644 --- a/examples/GuiClient/mainDialog.ui +++ b/examples/GuiClient/mainDialog.ui @@ -233,7 +233,7 @@ - + @@ -351,9 +351,9 @@
searchLineEdit.h
- customLabel + signInStatusLabel QLabel -
customLabel.h
+
signInStatusLabel.h
diff --git a/examples/GuiClient/signInStatusLabel.cpp b/examples/GuiClient/signInStatusLabel.cpp new file mode 100644 index 00000000..bc4437e3 --- /dev/null +++ b/examples/GuiClient/signInStatusLabel.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2008-2010 The QXmpp developers + * + * Author: + * Manjeet Dahiya + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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. + * + */ + + +#include "signInStatusLabel.h" +#include + +signInStatusLabel::signInStatusLabel(QWidget* parent):QLabel(parent), m_timer(this), + m_option(None) +{ + m_timer.setSingleShot(false); + + bool check = connect(&m_timer, SIGNAL(timeout()), SLOT(timeout())); + Q_ASSERT(check); + Q_UNUSED(check); +} + +void signInStatusLabel::setCustomText(const QString& text, signInStatusLabel::Option op, + int countDown) +{ + m_text = text; + m_option = op; + m_countDown = countDown; + switch(op) + { + case None: + m_timer.stop(); + m_postfix = ""; + break; + case WithProgressEllipsis: +// m_timer.start(400); + m_postfix = ""; + break; + case CountDown: + m_timer.start(1000); + m_postfix = ""; + break; + default: + m_timer.stop(); + m_postfix = ""; + break; + } + + if(m_option == CountDown) + setText(m_text.arg(m_countDown) + m_postfix); + else + setText(m_text + m_postfix); + + updateGeometry(); +} + +void signInStatusLabel::timeout() +{ + switch(m_option) + { + case None: + break; + case WithProgressEllipsis: + if(m_postfix == "") + m_postfix = "."; + else if(m_postfix == ".") + m_postfix = ".."; + else if(m_postfix == "..") + m_postfix = "..."; + else if(m_postfix == "...") + m_postfix = ""; + break; + case CountDown: + if(m_countDown == 0) + m_timer.stop(); + --m_countDown; + break; + default: + break; + } + + if(m_option == CountDown) + setText(m_text.arg(m_countDown) + m_postfix); + else + setText(m_text + m_postfix); + updateGeometry(); +} + +//QSize signInStatusLabel::sizeHint() const +//{ +// QFont font; +// QFontMetrics fm(font); +// return QSize(fm.width(m_text) + 15, 20); +//} diff --git a/examples/GuiClient/signInStatusLabel.h b/examples/GuiClient/signInStatusLabel.h new file mode 100644 index 00000000..3eae8686 --- /dev/null +++ b/examples/GuiClient/signInStatusLabel.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2008-2010 The QXmpp developers + * + * Author: + * Manjeet Dahiya + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library 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 2.1 of the License, or (at your option) any later version. + * + * This library 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. + * + */ + + +#ifndef SIGNINSTATUSLABEL_H +#define SIGNINSTATUSLABEL_H + +#include +#include + +class signInStatusLabel : public QLabel +{ + Q_OBJECT + +public: + enum Option + { + None = 0, + WithProgressEllipsis, + CountDown + }; + signInStatusLabel(QWidget* parent = 0); + + void setCustomText(const QString& text, signInStatusLabel::Option op = None, + int countDown = 0); + +// QSize sizeHint() const; + +private slots: + void timeout(); + +private: + QTimer m_timer; + signInStatusLabel::Option m_option; + QString m_text; + QString m_postfix; + int m_countDown; +}; + +#endif // SIGNINSTATUSLABEL_H -- cgit v1.2.3