kalarm/lib
timeedit.h
Go to the documentation of this file.00001 /* 00002 * timeedit.h - time-of-day edit widget, with AM/PM shown depending on locale 00003 * Program: kalarm 00004 * Copyright (c) 2004-2006 by David Jarvie <software@astrojar.org.uk> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef TIMEEDIT_H 00022 #define TIMEEDIT_H 00023 00024 #include <QDateTime> 00025 #include <khbox.h> 00026 00027 class ComboBox; 00028 class TimeSpinBox; 00029 00030 00050 class TimeEdit : public KHBox 00051 { 00052 Q_OBJECT 00053 public: 00057 explicit TimeEdit(QWidget* parent = 0); 00059 bool isReadOnly() const { return mReadOnly; } 00065 virtual void setReadOnly(bool readOnly); 00067 bool isValid() const; 00073 void setValid(bool valid); 00075 int value() const; 00077 QTime time() const { int m = value(); return QTime(m/60, m%60); } 00079 bool wrapping() const; 00083 void setWrapping(bool on); 00085 int minimum() const; 00087 int maximum() const; 00089 QTime maxTime() const { int mv = maximum(); return QTime(mv/60, mv%60); } 00091 void setMinimum(int minutes); 00093 void setMaximum(int minutes); 00095 void setMaximum(const QTime& time) { setMaximum(time.hour()*60 + time.minute()); } 00096 public slots: 00098 virtual void setValue(int minutes); 00100 void setValue(const QTime& t) { setValue(t.hour()*60 + t.minute()); } 00101 signals: 00106 void valueChanged(int minutes); 00107 00108 private slots: 00109 void slotValueChanged(int); 00110 void slotAmPmChanged(int item); 00111 private: 00112 void setAmPmCombo(int am, int pm); 00113 00114 TimeSpinBox* mSpinBox; // always holds the 24-hour time 00115 ComboBox* mAmPm; 00116 int mAmIndex; // mAmPm index to "am", or -1 if none 00117 int mPmIndex; // mAmPm index to "pm", or -1 if none 00118 bool mReadOnly; // the widget is read only 00119 }; 00120 00121 #endif // TIMEEDIT_H
KDE 4.2 API Reference