summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-04-14 17:48:58 (UTC)
committer zautrix <zautrix>2005-04-14 17:48:58 (UTC)
commitbbdca90c599aaea557d31552c6bc33fc15e397cd (patch) (unidiff)
treee41b5eb16239664d2217e5436db61610099b60ef /libkdepim
parent5ea16ef9058a21016402dd5affc0a7f82857e606 (diff)
downloadkdepimpi-bbdca90c599aaea557d31552c6bc33fc15e397cd.zip
kdepimpi-bbdca90c599aaea557d31552c6bc33fc15e397cd.tar.gz
kdepimpi-bbdca90c599aaea557d31552c6bc33fc15e397cd.tar.bz2
today added
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kdateedit.cpp9
-rw-r--r--libkdepim/kdateedit.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp
index 3d9e690..bf38479 100644
--- a/libkdepim/kdateedit.cpp
+++ b/libkdepim/kdateedit.cpp
@@ -63,30 +63,34 @@ KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP )
63 if ( withoutDP ) { 63 if ( withoutDP ) {
64 mDateFrame = 0; 64 mDateFrame = 0;
65 mDateButton = 0; 65 mDateButton = 0;
66 mDatePicker = 0; 66 mDatePicker = 0;
67 } else { 67 } else {
68 QPixmap pixmap = SmallIcon("smallcal"); 68 QPixmap pixmap = SmallIcon("smallcal");
69 mDateButton = new QPushButton(this); 69 mDateButton = new QPushButton(this);
70 mDateButton->setPixmap(pixmap); 70 mDateButton->setPixmap(pixmap);
71 QPixmap pixmap2 = SmallIcon("today_small");
72 QPushButton* nowButton = new QPushButton(this);
73 nowButton->setPixmap(pixmap2);
71 74
72 mDateFrame = new QVBox(0,0,WType_Popup); 75 mDateFrame = new QVBox(0,0,WType_Popup);
73 // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 76 // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
74 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 77 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
75 mDateFrame->setLineWidth(3); 78 mDateFrame->setLineWidth(3);
76 mDateFrame->hide(); 79 mDateFrame->hide();
77 80
78 mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); 81 mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate());
79 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); 82 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate)));
80 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); 83 connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate)));
81 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); 84 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate)));
82 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); 85 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate)));
83 connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); 86 connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide()));
84 connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); 87 connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker()));
88 connect(nowButton,SIGNAL(clicked()),SLOT(goToNow()));
85 mDateButton->setFocusPolicy( QWidget::NoFocus ); 89 mDateButton->setFocusPolicy( QWidget::NoFocus );
86 mDateButton->setAutoDefault( false ); 90 mDateButton->setAutoDefault( false );
87 //mDateFrame->resize( 400, 300 ); 91 //mDateFrame->resize( 400, 300 );
88 92
89 } 93 }
90 connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); 94 connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed()));
91 connect(mDateEdit,SIGNAL(textChanged(const QString &)), 95 connect(mDateEdit,SIGNAL(textChanged(const QString &)),
92 SLOT(textChanged(const QString &))); 96 SLOT(textChanged(const QString &)));
@@ -127,16 +131,21 @@ KDateEdit::~KDateEdit()
127} 131}
128void KDateEdit::clear() 132void KDateEdit::clear()
129{ 133{
130 bool b = mDateEdit->signalsBlocked(); 134 bool b = mDateEdit->signalsBlocked();
131 mDateEdit->blockSignals(true); 135 mDateEdit->blockSignals(true);
132 mDateEdit->setText(""); 136 mDateEdit->setText("");
133 mDateEdit->blockSignals(b); 137 mDateEdit->blockSignals(b);
134} 138}
139void KDateEdit::goToNow()
140{
141 setDate(QDate::currentDate() );
142 emit setTimeTo( QTime::currentTime() );
143}
135void KDateEdit::setDate(QDate newDate) 144void KDateEdit::setDate(QDate newDate)
136{ 145{
137 if (!newDate.isValid() && !mHandleInvalid) 146 if (!newDate.isValid() && !mHandleInvalid)
138 return; 147 return;
139 if ( readDate() == newDate ) 148 if ( readDate() == newDate )
140 return; 149 return;
141 QString dateString = ""; 150 QString dateString = "";
142 if(newDate.isValid()) 151 if(newDate.isValid())
diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h
index cf3b90a..2d8c452 100644
--- a/libkdepim/kdateedit.h
+++ b/libkdepim/kdateedit.h
@@ -82,16 +82,17 @@ class KDateEdit : public QHBox
82 void clear(); 82 void clear();
83 signals: 83 signals:
84 /** This signal is emitted whenever the user modifies the date. This 84 /** This signal is emitted whenever the user modifies the date. This
85 * may not get emitted until the user presses enter in the line edit or 85 * may not get emitted until the user presses enter in the line edit or
86 * focus leaves the widget (ie: the user confirms their selection). 86 * focus leaves the widget (ie: the user confirms their selection).
87 */ 87 */
88 void dateChanged(QDate); 88 void dateChanged(QDate);
89 void returnPressed(); 89 void returnPressed();
90 void setTimeTo( QTime );
90 public slots: 91 public slots:
91 /** Sets the date. 92 /** Sets the date.
92 * 93 *
93 * @param date The new date to display. This date must be valid or 94 * @param date The new date to display. This date must be valid or
94 * it will not be displayed. 95 * it will not be displayed.
95 */ 96 */
96 void setDate(QDate date); 97 void setDate(QDate date);
97 // set Date with key_up key_down to relation of cursor Position 98 // set Date with key_up key_down to relation of cursor Position
@@ -103,16 +104,17 @@ class KDateEdit : public QHBox
103 * @param on Enabled if true, disabled if false 104 * @param on Enabled if true, disabled if false
104 */ 105 */
105 void setEnabled(bool on); 106 void setEnabled(bool on);
106 107
107 protected slots: 108 protected slots:
108 void toggleDatePicker(); 109 void toggleDatePicker();
109 void lineEnterPressed(); 110 void lineEnterPressed();
110 void textChanged(const QString &); 111 void textChanged(const QString &);
112 void goToNow();
111 113
112 private: 114 private:
113 /** Reads the text from the line edit. If the text is a keyword, the 115 /** Reads the text from the line edit. If the text is a keyword, the
114 * word will be translated to a date. If the text is not a keyword, the 116 * word will be translated to a date. If the text is not a keyword, the
115 * text will be interpreted as a date. 117 * text will be interpreted as a date.
116 */ 118 */
117 QDate readDate() const; 119 QDate readDate() const;
118 120