1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 2007-2012 Licq developers <licq-dev@googlegroups.com> 4 * 5 * Licq is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Licq is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Licq; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef TIMEZONEEDIT_H 21 #define TIMEZONEEDIT_H 22 23 #include <QSpinBox> 24 #include <QValidator> 25 26 namespace LicqQtGui 27 { 28 /** 29 * Input field for timezones allowing both manual entering and stepping using 30 * buttons. 31 */ 32 class TimeZoneEdit : public QSpinBox 33 { 34 Q_OBJECT 35 36 public: 37 /** 38 * Constructor, creates a time zone input control 39 * 40 * @param parent Parent widget 41 */ 42 TimeZoneEdit(QWidget* parent = NULL); 43 44 /** 45 * Set time zone 46 * 47 * @param data A time zone in seconds from GMT 48 */ 49 void setData(int data); 50 51 /** 52 * Get current time zone 53 * 54 * @return Time zone currently selected in seconds from GMT 55 */ 56 int data() const; 57 58 private: 59 /** 60 * Test if user input is a valid time zone or at least is the beginning of one 61 * 62 * @param input Entered text to test 63 * @param pos Postition in string 64 * @return Acceptable if input is a valid time zone, Intermediate if it is 65 * the beginning of one, otherwise Invalid. 66 */ 67 QValidator::State validate(QString& input, int& pos) const; 68 69 /** 70 * Convert internal counter to a string representation of the zone 71 * 72 * @param v Numerical time zone value 73 * @return Time zone as text 74 */ 75 QString textFromValue(int v) const; 76 77 /** 78 * Convert time zone in text form to internal counter value 79 * 80 * @param text Time zone as text string 81 * @return Numerical time zone value 82 */ 83 int valueFromText(const QString& text) const; 84 }; 85 86 } // namespace LicqQtGui 87 88 #endif 89