F:/KPlato/koffice/kplato/kptdurationwidget.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 - 2006 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KPTDURATIONWIDGET_H
00021 #define KPTDURATIONWIDGET_H
00022 
00023 #include "ui_kptdurationwidget.h"
00024 
00025 #include <QFrame>
00026 
00027 #include "kptduration.h"
00028 
00029 class QRegExpValidator;
00030 class QLineEdit;
00031 class QLabel;
00032 class QString;
00033 
00034 namespace KPlato
00035 {
00036 
00037 class DurationWidget : public QFrame, public Ui_DurationWidget
00038 {
00039     Q_OBJECT
00040 public:
00041     enum { Days = 0x1, Hours = 0x2, Minutes = 0x4, Seconds = 0x8, Milliseconds = 0x10 } Fields;
00042 
00043     DurationWidget(QWidget *parent=0);
00044     ~DurationWidget();
00045 
00049     struct FieldDescriptor
00050     {
00051         // Which field is to my left, and what conversion factor separates us?
00052         QLineEdit *left;
00053         double leftScale;
00054     
00055         // Which field am I, and how am I formatted?
00056         QLineEdit *current;
00057         const char *format;
00058     
00059         // Which field is to my right, and what conversion factor separates us?
00060         QLineEdit *right;
00061         double rightScale;
00062     
00063         // If I am hidden, who else hides with me?
00064         QLabel *separator;
00065     
00066         // Used for calculating a correct duration
00067         double fullScale;
00068         double scale;
00069     
00070         // Used for displaying a unit behind each field
00071         QLabel *unit;
00072     };
00073 
00074     Duration value() const;
00075     
00076     void setVisibleFields( int fieldMask );
00077     int visibleFields();
00078     void setFieldLeftscale(int f, double ls);
00079     void setFieldRightscale(int f, double rs);
00080     void setFieldScale(int f, double scale);
00081     void setFieldUnit(int f, QString unit);
00082 
00083 signals:
00084     void valueChanged();
00085     
00086 public slots:
00087     virtual void setValue( const KPlato::Duration & newDuration );
00088     virtual void handleLostFocus( int field );
00089 
00090 private:
00091     QString m_decimalPoint;
00092     QRegExpValidator *m_validator;
00093     struct FieldDescriptor *m_fields;
00094 
00095     qint64 setValueMilliseconds( qint64 milliseconds );
00096     qint64 setValueSeconds( qint64 seconds );
00097     qint64 setValueMinutes( qint64 mins );
00098     qint64 setValueHours( qint64 mins );
00099     qint64 setValueDays( qint64 mins );
00100     double power( double m, int e );
00101     double fraction( QString number, int * exp );
00102 
00103 private slots:
00104     virtual void dddLostFocus();
00105     virtual void hhLostFocus();
00106     virtual void mmLostFocus();
00107     virtual void ssLostFocus();
00108     virtual void msLostFocus();
00109 
00110 };
00111 
00112 }  //KPlato namespace
00113 
00114 #endif

Généré le Wed Nov 22 23:40:56 2006 pour KPlato par  doxygen 1.5.1-p1