-rw-r--r-- | core/pim/datebook/datebook.pro | 6 | ||||
-rw-r--r-- | core/pim/datebook/dateentryimpl.cpp | 1 | ||||
-rw-r--r-- | core/pim/datebook/noteentry.ui | 28 | ||||
-rw-r--r-- | core/pim/datebook/noteentryimpl.cpp | 1 | ||||
-rw-r--r-- | core/pim/datebook/onoteedit.cpp | 19 | ||||
-rw-r--r-- | core/pim/datebook/onoteedit.h | 19 |
6 files changed, 67 insertions, 7 deletions
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro index 60c2b08..cf3ed30 100644 --- a/core/pim/datebook/datebook.pro +++ b/core/pim/datebook/datebook.pro @@ -1,56 +1,58 @@ TEMPLATE = app CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = datebookday.h \ datebook.h \ dateentryimpl.h \ datebookdayheaderimpl.h \ datebooksettings.h \ datebookweek.h \ datebookweeklst.h \ datebookweekheaderimpl.h \ repeatentry.h \ timepicker.h \ - noteentryimpl.h + noteentryimpl.h \ + onoteedit.h SOURCES = main.cpp \ datebookday.cpp \ datebook.cpp \ dateentryimpl.cpp \ datebookdayheaderimpl.cpp \ datebooksettings.cpp \ datebookweek.cpp \ datebookweeklst.cpp \ datebookweekheaderimpl.cpp \ repeatentry.cpp \ timepicker.cpp \ - noteentryimpl.cpp + noteentryimpl.cpp \ + onoteedit.cpp INTERFACES = dateentry.ui \ datebookdayheader.ui \ datebooksettingsbase.ui \ datebookweekheader.ui \ datebookweeklstheader.ui \ datebookweeklstdayhdr.ui \ repeatentrybase.ui \ noteentry.ui INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TARGET = datebook TRANSLATIONS = ../i18n/pt_BR/datebook.ts TRANSLATIONS += ../i18n/de/datebook.ts TRANSLATIONS += ../i18n/en/datebook.ts TRANSLATIONS += ../i18n/hu/datebook.ts TRANSLATIONS += ../i18n/pl/datebook.ts TRANSLATIONS += ../i18n/sl/datebook.ts TRANSLATIONS += ../i18n/ja/datebook.ts TRANSLATIONS += ../i18n/ko/datebook.ts TRANSLATIONS += ../i18n/no/datebook.ts TRANSLATIONS += ../i18n/zh_CN/datebook.ts TRANSLATIONS += ../i18n/zh_TW/datebook.ts TRANSLATIONS += ../i18n/fr/datebook.ts diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp index 9cc5073..dab3375 100644 --- a/core/pim/datebook/dateentryimpl.cpp +++ b/core/pim/datebook/dateentryimpl.cpp @@ -1,299 +1,300 @@ /********************************************************************** ** 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 "dateentryimpl.h" #include "repeatentry.h" #include <qpe/qpeapplication.h> #include <qpe/categoryselect.h> #include <qpe/datebookmonth.h> #include <qpe/global.h> #include <qpe/timeconversion.h> #include <qpe/timestring.h> #include <qpe/tzselect.h> #include <qevent.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qpopupmenu.h> #include <qscrollview.h> #include <qspinbox.h> #include <qtoolbutton.h> #include "timepicker.h" +#include "onoteedit.h" #include <stdlib.h> #include <stdio.h> /* * Constructs a DateEntry which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start, const QDateTime &end, bool whichClock, QWidget* parent, const char* name ) : DateEntryBase( parent, name ), ampm( whichClock ), startWeekOnMonday( startOnMonday ), m_showStart(true) { init(); setDates(start,end); setFocusProxy(comboDescription); } bool DateEntry::eventFilter(QObject *obj, QEvent *ev ) { if( ev->type() == QEvent::FocusIn ){ if( obj == comboStart ){ timePickerStart->setHour(startTime.hour()); timePickerStart->setMinute(startTime.minute()); TimePickerLabel->setText( tr("Start Time" ) ); m_showStart= true; }else if( obj == comboEnd ){ timePickerStart->setHour(endTime.hour()); timePickerStart->setMinute(endTime.minute()); TimePickerLabel->setText( tr("End Time") ); m_showStart = false; } } else if( ev->type() == QEvent::FocusOut ){ if( obj == comboEnd ){ QString s; s.sprintf("%.2d:%.2d",endTime.hour(), endTime.minute()); comboEnd->setText(s); } else if( obj == comboStart ){ QString s; s.sprintf("%.2d:%.2d",startTime.hour(), startTime.minute()); comboStart->setText(s); } } return false; } static void addOrPick( QComboBox* combo, const QString& t ) { // Pick an item if one excists for (int i=0; i<combo->count(); i++) { if ( combo->text(i) == t ) { combo->setCurrentItem(i); return; } } // Else add one combo->insertItem(t); combo->setCurrentItem(combo->count()-1); } DateEntry::DateEntry( bool startOnMonday, const Event &event, bool whichClock, QWidget* parent, const char* name ) : DateEntryBase( parent, name ), ampm( whichClock ), startWeekOnMonday( startOnMonday ), m_showStart(true) { init(); setDates(event.start(),event.end()); comboCategory->setCategories( event.categories(), "Calendar", tr("Calendar") ); if(!event.description().isEmpty()) addOrPick( comboDescription, event.description() ); if(!event.location().isEmpty()) addOrPick( comboLocation, event.location() ); checkAlarm->setChecked( event.hasAlarm() ); checkAllDay->setChecked( event.type() == Event::AllDay ); if(!event.notes().isEmpty()) noteStr=event.notes(); else noteStr=""; spinAlarm->setValue(event.alarmTime()); if ( event.alarmSound() != Event::Silent ) comboSound->setCurrentItem( 1 ); if ( event.hasRepeat() ) { rp = event.repeatPattern(); cmdRepeat->setText( tr("Repeat...") ); } setRepeatLabel(); } void DateEntry::setDates( const QDateTime& s, const QDateTime& e ) { startDate = s.date(); endDate = e.date(); startTime = s.time(); endTime = e.time(); startDateChanged( s.date().year(), s.date().month(), s.date().day() ); endDateChanged( e.date().year(), e.date().month(), e.date().day() ); updateTimeEdit(true,true); } void DateEntry::updateTimeEdit(bool s, bool e) { // Comboboxes QString strStart, strEnd; int shour, ehour; if ( ampm ) { shour = startTime.hour(); ehour = endTime.hour(); if ( shour >= 12 ) { if ( shour > 12 ) shour -= 12; strStart.sprintf( "%d:%02d PM", shour, startTime.minute() ); } else { if ( shour == 0 ) shour = 12; strStart.sprintf( "%d:%02d AM", shour, startTime.minute() ); } if ( ehour == 24 && endTime.minute() == 0 ) { strEnd = "11:59 PM"; // or "midnight" } else if ( ehour >= 12 ) { if ( ehour > 12 ) ehour -= 12; strEnd.sprintf( "%d:%02d PM", ehour, endTime.minute() ); } else { if ( ehour == 0 ) ehour = 12; strEnd.sprintf( "%d:%02d AM", ehour, endTime.minute() ); } } else { strStart.sprintf( "%02d:%02d", startTime.hour(), startTime.minute() ); strEnd.sprintf( "%02d:%02d", endTime.hour(), endTime.minute() ); } if (s) comboStart->setText(strStart); if (e) comboEnd->setText(strEnd); } void DateEntry::init() { comboDescription->setInsertionPolicy(QComboBox::AtCurrent); comboLocation->setInsertionPolicy(QComboBox::AtCurrent); initCombos(); QPopupMenu *m1 = new QPopupMenu( this ); startPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( startPicker ); buttonStart->setPopup( m1 ); connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( startDateChanged( int, int, int ) ) ); //Let start button change both start and end dates connect( startPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( endDateChanged( int, int, int ) ) ); connect( qApp, SIGNAL( clockChanged( bool ) ), this, SLOT( slotChangeClock( bool ) ) ); connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotChangeStartOfWeek(bool)) ); connect( editNote, SIGNAL(clicked()), this, SLOT(slotEditNote()) ); QPopupMenu *m2 = new QPopupMenu( this ); endPicker = new DateBookMonth( m2, 0, TRUE ); m2->insertItem( endPicker ); buttonEnd->setPopup( m2 ); connect( endPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( endDateChanged( int, int, int ) ) ); connect(timePickerStart, SIGNAL( timeChanged(const QTime &) ), this, SLOT( startTimePicked(const QTime &) )); // install eventFilters comboEnd->installEventFilter( this ); comboStart->installEventFilter( this ); } /* * Destroys the object and frees any allocated resources */ DateEntry::~DateEntry() { // no need to delete child widgets, Qt does it all for us //cout << "Del: " << comboStart->currentText() << endl; } /* * public slot */ void DateEntry::slotEditNote() { QString s; s.sprintf("<B>%d/%d</B> ", startDate.day(), startDate.month()); NoteEntry noteDlg(s+comboDescription->currentText(), noteStr, this,0,TRUE); #if defined(Q_WS_QWS) || defined(_WS_QWS_) noteDlg.showMaximized(); #endif if (noteDlg.exec() ) { noteStr=noteDlg.note->text(); } } void DateEntry::endDateChanged( int y, int m, int d ) { endDate.setYMD( y, m, d ); if ( endDate < startDate ) { endDate = startDate; } buttonEnd->setText( TimeString::shortDate( endDate ) ); endPicker->setDate( endDate.year(), endDate.month(), endDate.day() ); } static QTime parseTime( const QString& s, bool ampm ) { QTime tmpTime; QStringList l = QStringList::split( ':', s ); int hour = l[0].toInt(); if ( ampm ) { int i=0; while (i<int(l[1].length()) && l[1][i]>='0' && l[1][i]<='9') i++; QString digits = l[1].left(i); if ( l[1].contains( "PM", FALSE ) ) { if ( hour != 12 ) hour += 12; } else { if ( hour == 12 ) hour = 0; } l[1] = digits; } int minute = l[1].toInt(); if ( minute > 59 ) minute = 59; else if ( minute < 0 ) minute = 0; if ( hour > 23 ) { hour = 23; minute = 59; } else if ( hour < 0 ) hour = 0; diff --git a/core/pim/datebook/noteentry.ui b/core/pim/datebook/noteentry.ui index ce3c4ad..0bea06e 100644 --- a/core/pim/datebook/noteentry.ui +++ b/core/pim/datebook/noteentry.ui @@ -1,68 +1,86 @@ <!DOCTYPE UI><UI> <class>NoteEntryBase</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>NoteEntryBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> <width>465</width> <height>500</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Edit Note</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>eventLabel</cstring> </property> <property stdset="1"> <name>text</name> <string><b>1/10</b> Lunch</string> </property> <property stdset="1"> <name>alignment</name> <set>AlignCenter</set> </property> <property> <name>hAlign</name> </property> </widget> <widget> - <class>QMultiLineEdit</class> + <class>ONoteEdit</class> <property stdset="1"> <name>name</name> <cstring>note</cstring> </property> - <property stdset="1"> - <name>wordWrap</name> - <enum>WidgetWidth</enum> - </property> </widget> </vbox> </widget> +<customwidgets> + <customwidget> + <class>ONoteEdit</class> + <header location="local">onoteedit.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>7</hordata> + <verdata>7</verdata> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image> + <name>image0</name> + <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> + </image> +</images> </UI> diff --git a/core/pim/datebook/noteentryimpl.cpp b/core/pim/datebook/noteentryimpl.cpp index 9e1abb9..0e45985 100644 --- a/core/pim/datebook/noteentryimpl.cpp +++ b/core/pim/datebook/noteentryimpl.cpp @@ -1,16 +1,17 @@ #include "noteentryimpl.h" #include "qstring.h" #include "qmultilinedit.h" #include "qlabel.h" +#include "onoteedit.h" NoteEntry::NoteEntry(const QString &title, const QString ¬eStr, QWidget* parent, const char* name, bool modal, WFlags fl) : NoteEntryBase(parent, name, modal, fl) { eventLabel->setText(title); note->setText(noteStr); int l=note->length(); note->setCursorPosition(l,l,false); } diff --git a/core/pim/datebook/onoteedit.cpp b/core/pim/datebook/onoteedit.cpp new file mode 100644 index 0000000..d66ad86 --- a/dev/null +++ b/core/pim/datebook/onoteedit.cpp @@ -0,0 +1,19 @@ +#include "onoteedit.h" + +ONoteEdit::ONoteEdit (QWidget * parent, const char * name) : + QMultiLineEdit(parent,name) { + setDefaultTabStop(2); + setWordWrap(WidgetWidth); +} + +// Copy indentation from previous line +void ONoteEdit::newLine() { + int l,c; + getCursorPosition(&l,&c); + QString s=textLine(l); + + insert("\n"); + + int i=0; + while (s[i]==' ' || s[i]=='\t') insert(QString(s[i])), i++; +} diff --git a/core/pim/datebook/onoteedit.h b/core/pim/datebook/onoteedit.h new file mode 100644 index 0000000..2f71d0d --- a/dev/null +++ b/core/pim/datebook/onoteedit.h @@ -0,0 +1,19 @@ +#ifndef ONOTEEDIT_H +#define ONOTEEDIT_H + +#include <qmultilineedit.h> + +class ONoteEdit: public QMultiLineEdit { + + Q_OBJECT + + public: + + ONoteEdit (QWidget * parent=0, const char * name=0); + + protected: + + virtual void newLine (); +}; + +#endif |