summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweekheader.ui198
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp64
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.h12
3 files changed, 252 insertions, 22 deletions
diff --git a/core/pim/datebook/datebookweekheader.ui b/core/pim/datebook/datebookweekheader.ui
index f7b20f8..591b625 100644
--- a/core/pim/datebook/datebookweekheader.ui
+++ b/core/pim/datebook/datebookweekheader.ui
@@ -1,163 +1,335 @@
<!DOCTYPE UI><UI>
<class>DateBookWeekHeaderBase</class>
<comment>*********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
*********************************************************************</comment>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>DateBookWeekHeaderBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>281</width>
- <height>30</height>
+ <width>249</width>
+ <height>26</height>
</rect>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>6</number>
+ <number>0</number>
</property>
<widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>backmonth</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap></pixmap>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>backweek</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap></pixmap>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>toggleButton</name>
+ <bool>false</bool>
+ </property>
+ <property>
+ <name>toolTip</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>spinYear</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>prefix</name>
<string>Y: </string>
</property>
<property stdset="1">
<name>maxValue</name>
<number>2037</number>
</property>
<property stdset="1">
<name>minValue</name>
<number>1970</number>
</property>
<property stdset="1">
<name>value</name>
<number>2002</number>
</property>
</widget>
<widget>
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
<cstring>spinWeek</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>prefix</name>
<string>W: </string>
</property>
<property stdset="1">
<name>maxValue</name>
<number>52</number>
</property>
<property stdset="1">
<name>minValue</name>
<number>1</number>
</property>
<property stdset="1">
<name>value</name>
<number>1</number>
</property>
</widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1_1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
<widget>
- <class>QLabel</class>
+ <class>QToolButton</class>
<property stdset="1">
<name>name</name>
<cstring>labelDate</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>font</name>
<font>
<bold>1</bold>
</font>
</property>
<property stdset="1">
<name>text</name>
<string>00. Jan-00. Jan</string>
</property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
<property stdset="1">
- <name>alignment</name>
- <set>AlignCenter</set>
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
<property>
- <name>hAlign</name>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>forwardweek</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap></pixmap>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>forwardmonth</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap></pixmap>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
</property>
</widget>
</hbox>
</widget>
<connections>
<connection>
- <sender>spinYear</sender>
- <signal>valueChanged(int)</signal>
+ <sender>backmonth</sender>
+ <signal>clicked()</signal>
+ <receiver>DateBookWeekHeaderBase</receiver>
+ <slot>prevMonth()</slot>
+ </connection>
+ <connection>
+ <sender>backweek</sender>
+ <signal>clicked()</signal>
+ <receiver>DateBookWeekHeaderBase</receiver>
+ <slot>prevWeek()</slot>
+ </connection>
+ <connection>
+ <sender>forwardweek</sender>
+ <signal>clicked()</signal>
+ <receiver>DateBookWeekHeaderBase</receiver>
+ <slot>nextWeek()</slot>
+ </connection>
+ <connection>
+ <sender>forwardmonth</sender>
+ <signal>clicked()</signal>
<receiver>DateBookWeekHeaderBase</receiver>
- <slot>yearChanged( int )</slot>
+ <slot>nextMonth()</slot>
</connection>
<connection>
- <sender>spinWeek</sender>
- <signal>valueChanged(int)</signal>
+ <sender>labelDate</sender>
+ <signal>clicked()</signal>
<receiver>DateBookWeekHeaderBase</receiver>
- <slot>weekChanged( int )</slot>
+ <slot>pickDate()</slot>
</connection>
<slot access="public">yearChanged( int )</slot>
<slot access="public">nextWeek()</slot>
<slot access="public">prevWeek()</slot>
<slot access="public">weekChanged( int )</slot>
+ <slot access="public">nextMonth()</slot>
+ <slot access="public">prevMonth()</slot>
+ <slot access="public">pickDate()</slot>
</connections>
</UI>
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index e7c7208..5f555d5 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -1,126 +1,180 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "datebookweekheaderimpl.h"
+#include "datebookweekheader.h"
+#include "datebookweek.h"
#include <qlabel.h>
#include <qspinbox.h>
#include <qdatetime.h>
+#include <qpe/resource.h>
+#include <qpe/datebookmonth.h>
+
+#include <qtoolbutton.h>
/*
* Constructs a DateBookWeekHeader which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent,
const char* name, WFlags fl )
: DateBookWeekHeaderBase( parent, name, fl ),
bStartOnMonday( startOnMonday )
{
setBackgroundMode( PaletteButton );
labelDate->setBackgroundMode( PaletteButton );
+
+ backmonth->setPixmap( Resource::loadPixmap("fastback") );
+ backweek->setPixmap( Resource::loadPixmap("back") );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
+ spinYear->hide();
+ spinWeek->hide();
}
/*
* Destroys the object and frees any allocated resources
*/
DateBookWeekHeader::~DateBookWeekHeader()
{
// no need to delete child widgets, Qt does it all for us
}
+void DateBookWeekHeader::pickDate()
+{
+ static QPopupMenu *m1 = 0;
+ static DateBookMonth *picker = 0;
+ QDate currDate = dateFromWeek( week, year, bStartOnMonday );
+ if ( !m1 ) {
+ m1 = new QPopupMenu( this );
+ picker = new DateBookMonth( m1, 0, TRUE );
+ m1->insertItem( picker );
+ connect( picker, SIGNAL( dateClicked( int, int, int ) ),
+ this, SLOT( setDate( int, int, int ) ) );
+// connect( m1, SIGNAL( aboutToHide() ),
+// this, SLOT( gotHide() ) );
+ }
+ picker->setDate( currDate.year(), currDate.month(), currDate.day() );
+ m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
+ picker->setFocus();
+}
/*
* public slot
*/
void DateBookWeekHeader::yearChanged( int y )
{
setDate( y, week );
}
+void DateBookWeekHeader::nextMonth()
+{
+ QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
+ calcWeek( mydate.addDays(28), week, year, bStartOnMonday ); // Add 4 weeks.
+ setDate( year, week ); // update view
+}
+void DateBookWeekHeader::prevMonth()
+{
+ QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
+ calcWeek( mydate.addDays(-28), week, year, bStartOnMonday ); // Subtract 4 weeks
+ setDate( year, week ); // update view
+}
/*
* public slot
*/
void DateBookWeekHeader::nextWeek()
{
- if ( week < 52 )
- week++;
+ QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
+ calcWeek( mydate.addDays(7), week, year, bStartOnMonday); // Add 1 week
+// if ( week < 52 )
+// week++;
setDate( year, week );
}
/*
* public slot
*/
void DateBookWeekHeader::prevWeek()
{
- if ( week > 1 )
- week--;
+ QDate mydate = dateFromWeek( week, year, bStartOnMonday ); // Get current week
+ calcWeek( mydate.addDays(-7), week, year, bStartOnMonday); // Add 1 week
+// if ( week > 1 )
+// week--;
setDate( year, week );
}
/*
* public slot
*/
void DateBookWeekHeader::weekChanged( int w )
{
setDate( year, w );
}
+void DateBookWeekHeader::setDate( int y, int m, int d )
+{
+ calcWeek( QDate(y,m,d), week, year, bStartOnMonday );
+ setDate( year, week );
+}
+
void DateBookWeekHeader::setDate( int y, int w )
{
year = y;
week = w;
spinYear->setValue( y );
spinWeek->setValue( w );
QDate d = dateFromWeek( week, year, bStartOnMonday );
QString s = QString::number( d.day() ) + ". " + d.monthName( d.month() )
+ "-";
d = d.addDays( 6 );
s += QString::number( d.day() ) + ". " + d.monthName( d.month() );
- labelDate->setText( s );
+ s += " ("+tr("week")+":"+QString::number( w )+")";
+ labelDate->setText( s );
emit dateChanged( y, w );
}
void DateBookWeekHeader::setStartOfWeek( bool onMonday )
{
bStartOnMonday = onMonday;
setDate( year, week );
}
// dateFromWeek
// compute the date from the week in the year
QDate dateFromWeek( int week, int year, bool startOnMonday )
{
QDate d;
d.setYMD( year, 1, 1 );
int dayOfWeek = d.dayOfWeek();
if ( startOnMonday ) {
if ( dayOfWeek <= 4 ) {
d = d.addDays( ( week - 1 ) * 7 - dayOfWeek + 1 );
} else {
d = d.addDays( (week) * 7 - dayOfWeek + 1 );
}
} else {
if ( dayOfWeek <= 4 || dayOfWeek == 7) {
d = d.addDays( ( week - 1 ) * 7 - dayOfWeek % 7 );
} else {
d = d.addDays( ( week ) * 7 - dayOfWeek % 7 );
}
}
return d;
}
diff --git a/core/pim/datebook/datebookweekheaderimpl.h b/core/pim/datebook/datebookweekheaderimpl.h
index 2abef46..2e5a6ca 100644
--- a/core/pim/datebook/datebookweekheaderimpl.h
+++ b/core/pim/datebook/datebookweekheaderimpl.h
@@ -1,62 +1,66 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DATEBOOKDAYHEADER_H
#define DATEBOOKDAYHEADER_H
#include <qdatetime.h>
#include "datebookweekheader.h"
class DateBookWeekHeader : public DateBookWeekHeaderBase
{
Q_OBJECT
public:
DateBookWeekHeader( bool startOnMonday, QWidget* parent = 0,
const char* name = 0, WFlags fl = 0 );
~DateBookWeekHeader();
void setDate( int y, int w );
void setStartOfWeek( bool onMonday );
signals:
void dateChanged( int y, int w );
public slots:
- void yearChanged( int );
- void nextWeek();
- void prevWeek();
- void weekChanged( int );
+ void pickDate();
+ void yearChanged( int );
+ void nextMonth();
+ void prevMonth();
+ void nextWeek();
+ void prevWeek();
+ void weekChanged( int );
+ void setDate( int y, int m, int d);
protected slots:
void keyPressEvent(QKeyEvent *e)
{
e->ignore();
}
private:
int year,
week;
bool bStartOnMonday;
};
QDate dateFromWeek( int week, int year, bool startOnMonday );
#endif // DATEBOOKDAYHEADER_H