-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 6 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 10 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 39 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 14 |
6 files changed, 33 insertions, 39 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index d8c1aca..5e42640 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -1,122 +1,121 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qapplication.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include "addresseeeditorwidget.h" #include "kabcore.h" #include "addresseeeditordialog.h" AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, const char *name ) : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, KDialogBase::Ok, parent, name, true ) { QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page ); mEditorWidget = new AddresseeEditorWidget( core, false, page ); connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), SLOT( widgetModified() ) ); layout->addWidget( mEditorWidget ); enableButton( KDialogBase::Apply, false ); if ( QApplication::desktop()->width() < 480 ) { hideButtons(); } } AddresseeEditorDialog::~AddresseeEditorDialog() { - qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()"); //emit editorDestroyed( mEditorWidget->addressee().uid() ); } void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) { enableButton( KDialogBase::Apply, false ); mEditorWidget->setAddressee( addr ); } KABC::Addressee AddresseeEditorDialog::addressee() { return mEditorWidget->addressee(); } bool AddresseeEditorDialog::dirty() { return mEditorWidget->dirty(); } void AddresseeEditorDialog::slotApply() { if ( mEditorWidget->dirty() ) { mEditorWidget->save(); emit contactModified( mEditorWidget->addressee() ); } enableButton( KDialogBase::Apply, false ); KDialogBase::slotApply(); } void AddresseeEditorDialog:: accept () { slotOk(); } void AddresseeEditorDialog::slotOk() { slotApply(); //KDialogBase::slotOk(); emit okClicked(); QDialog::accept(); } void AddresseeEditorDialog::widgetModified() { enableButton( KDialogBase::Apply, true ); } void AddresseeEditorDialog::slotCancel() { KDialogBase::slotCancel(); } #ifndef KAB_EMBEDDED #include "addresseeeditordialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 4365ee5..3cfc1f2 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -812,473 +812,469 @@ void AddresseeEditorWidget::setupTab2_1() connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), SLOT( emitModified() ) ); label->setBuddy( mAnniversaryPicker ); layout->addWidget( mAnniversaryPicker, 5, 4 ); bar = new KSeparator( KSeparator::HLine, tab2 ); layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); */ ////////////////////////////////////// // Notes label = new QLabel( i18n( "Note:" ), tab2_2 ); label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); //US layout->addWidget( label, 7, 0 ); layout->addWidget( label, 0, 0 ); #ifndef KAB_EMBEDDED mNoteEdit = new QTextEdit( tab2_2 ); mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); #else //KAB_EMBEDDED mNoteEdit = new QMultiLineEdit( tab2_2 ); mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); #endif //KAB_EMBEDDED connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); label->setBuddy( mNoteEdit ); //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); layout->addWidget( mNoteEdit, 1, 0); // Build the layout and add to the tab widget layout->activate(); // required mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); } void AddresseeEditorWidget::setupTab3() { // This is the Misc tab QWidget *tab3 = new QWidget( mTabWidget ); QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); //US layout->setColStretch( 2, 1 ); ////////////////////////////////////// // Geo mGeoWidget = new GeoWidget( tab3 ); // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mGeoWidget, 0, 0 ); /*US ////////////////////////////////////// // Sound #ifndef KAB_EMBEDDED mSoundWidget = new SoundWidget( tab3 ); mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); #else //KAB_EMBEDDED qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); #endif //KAB_EMBEDDED ////////////////////////////////////// // Images mImageWidget = new ImageWidget( tab3 ); mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); */ //US /* KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); */ ////////////////////////////////////// // Keys mKeyWidget = new KeyWidget( tab3 ); //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); layout->addWidget( mKeyWidget, 1, 0 ); mTabWidget->addTab( tab3, i18n( "&Misc" ) ); } void AddresseeEditorWidget::setupTab3_1() { // This is the Misc tab QWidget *tab3 = new QWidget( mTabWidget ); //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); layout->setMargin( KDialogBase::marginHint() ); layout->setSpacing( KDialogBase::spacingHint() ); //US layout->setColStretch( 2, 1 ); /*US ////////////////////////////////////// // Geo mGeoWidget = new GeoWidget( tab3 ); mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); */ ////////////////////////////////////// // Sound #ifndef KAB_EMBEDDED mSoundWidget = new SoundWidget( tab3 ); mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); #else //KAB_EMBEDDED //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); #endif //KAB_EMBEDDED ////////////////////////////////////// // Images mImageWidget = new ImageWidget( tab3 ); mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); /*US ////////////////////////////////////// // Keys mKeyWidget = new KeyWidget( tab3 ); mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); */ mTabWidget->addTab( tab3, i18n( "&Images" ) ); } void AddresseeEditorWidget::load() { kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; // Block signals in case anything tries to emit modified // CS: This doesn't seem to work. bool block = signalsBlocked(); blockSignals( true ); mBlockSignals = true; // used for internal signal blocking mNameEdit->setText( mAddressee.assembledName() ); if ( mAddressee.formattedName().isEmpty() ) { //US KConfig config( "kaddressbookrc" ); KConfig config( locateLocal("config", "kaddressbookrc") ); config.setGroup( "General" ); mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); } else { if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) mFormattedNameType = NameEditDialog::SimpleName; else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) mFormattedNameType = NameEditDialog::FullName; else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) mFormattedNameType = NameEditDialog::ReverseName; else mFormattedNameType = NameEditDialog::CustomName; } mFormattedNameLabel->setText( mAddressee.formattedName() ); mRoleEdit->setText( mAddressee.role() ); mOrgEdit->setText( mAddressee.organization() ); //US mURLEdit->setURL( mAddressee.url().url() ); mURLEdit->setText( mAddressee.url().prettyURL() ); //US?? mURLEdit->home( false ); // mNoteEdit->setText( mAddressee.note() ); mNoteEdit->setText( mAddressee.note() ); mEmailWidget->setEmails( mAddressee.emails() ); mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); mBirthdayPicker->setDate( mAddressee.birthday().date() ); //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate mAnniversaryPicker->setDate( dt ); mNicknameEdit->setText( mAddressee.nickName() ); mCategoryEdit->setText( mAddressee.categories().join( "," ) ); mGeoWidget->setGeo( mAddressee.geo() ); mImageWidget->setPhoto( mAddressee.photo() ); mImageWidget->setLogo( mAddressee.logo() ); mKeyWidget->setKeys( mAddressee.keys() ); mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); #ifndef KAB_EMBEDDED mSoundWidget->setSound( mAddressee.sound() ); #else //KAB_EMBEDDED //US qDebug("AddresseeEditorWidget::load has to be changed 2"); #endif //KAB_EMBEDDED // Load customs mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); blockSignals( block ); mBlockSignals = false; mDirty = false; } void AddresseeEditorWidget::save() { if ( !mDirty ) return; mAddressee.setRole( mRoleEdit->text() ); mAddressee.setOrganization( mOrgEdit->text() ); mAddressee.setUrl( KURL( mURLEdit->text() ) ); mAddressee.setNote( mNoteEdit->text() ); if ( mBirthdayPicker->inputIsValid() ) mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); else mAddressee.setBirthday( QDateTime() ); mAddressee.setNickName( mNicknameEdit->text() ); mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); mAddressee.setGeo( mGeoWidget->geo() ); mAddressee.setPhoto( mImageWidget->photo() ); mAddressee.setLogo( mImageWidget->logo() ); mAddressee.setKeys( mKeyWidget->keys() ); #ifndef KAB_EMBEDDED mAddressee.setSound( mSoundWidget->sound() ); #else //KAB_EMBEDDED //US qDebug("AddresseeEditorWidget::save sound not supported"); #endif //KAB_EMBEDDED mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); // save custom fields mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); if ( mAnniversaryPicker->inputIsValid() ) { //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); - int orgformat = KGlobal::locale()->getIntDateFormat(); - QDate da = mAnniversaryPicker->date(); - KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate - QString dt = KGlobal::locale()->formatDate(da, true); - KGlobal::locale()->setIntDateFormat(orgformat ); + QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } else mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); // Save the email addresses QStringList emails = mAddressee.emails(); QStringList::Iterator iter; for ( iter = emails.begin(); iter != emails.end(); ++iter ) mAddressee.removeEmail( *iter ); emails = mEmailWidget->emails(); bool first = true; for ( iter = emails.begin(); iter != emails.end(); ++iter ) { mAddressee.insertEmail( *iter, first ); first = false; } // Save the phone numbers KABC::PhoneNumber::List phoneNumbers; KABC::PhoneNumber::List::Iterator phoneIter; phoneNumbers = mAddressee.phoneNumbers(); for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); ++phoneIter ) mAddressee.removePhoneNumber( *phoneIter ); phoneNumbers = mPhoneEditWidget->phoneNumbers(); for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); ++phoneIter ) mAddressee.insertPhoneNumber( *phoneIter ); // Save the addresses KABC::Address::List addresses; KABC::Address::List::Iterator addressIter; addresses = mAddressee.addresses(); for ( addressIter = addresses.begin(); addressIter != addresses.end(); ++addressIter ) mAddressee.removeAddress( *addressIter ); addresses = mAddressEditWidget->addresses(); for ( addressIter = addresses.begin(); addressIter != addresses.end(); ++addressIter ) mAddressee.insertAddress( *addressIter ); mDirty = false; } bool AddresseeEditorWidget::dirty() { return mDirty; } void AddresseeEditorWidget::nameTextChanged( const QString &text ) { // use the addressee class to parse the name for us mAConfig->setUid( mAddressee.uid() ); if ( mAConfig->automaticNameParsing() ) { if ( !mAddressee.formattedName().isEmpty() ) { QString fn = mAddressee.formattedName(); mAddressee.setNameFromString( text ); mAddressee.setFormattedName( fn ); } else { // use extra addressee to avoid a formatted name assignment Addressee addr; addr.setNameFromString( text ); mAddressee.setPrefix( addr.prefix() ); mAddressee.setGivenName( addr.givenName() ); mAddressee.setAdditionalName( addr.additionalName() ); mAddressee.setFamilyName( addr.familyName() ); mAddressee.setSuffix( addr.suffix() ); } } nameBoxChanged(); emitModified(); } void AddresseeEditorWidget::nameBoxChanged() { KABC::Addressee addr; mAConfig->setUid( mAddressee.uid() ); if ( mAConfig->automaticNameParsing() ) { addr.setNameFromString( mNameEdit->text() ); mNameLabel->hide(); mNameEdit->show(); } else { addr = mAddressee; mNameEdit->hide(); mNameLabel->setText( mNameEdit->text() ); mNameLabel->show(); } if ( mFormattedNameType != NameEditDialog::CustomName ) { mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); } } void AddresseeEditorWidget::nameButtonClicked() { // show the name dialog. NameEditDialog dialog( mAddressee, mFormattedNameType, this ); if ( dialog.exec() ) { if ( dialog.changed() ) { mAddressee.setFamilyName( dialog.familyName() ); mAddressee.setGivenName( dialog.givenName() ); mAddressee.setPrefix( dialog.prefix() ); mAddressee.setSuffix( dialog.suffix() ); mAddressee.setAdditionalName( dialog.additionalName() ); mFormattedNameType = dialog.formattedNameType(); if ( mFormattedNameType == NameEditDialog::CustomName ) { mFormattedNameLabel->setText( dialog.customFormattedName() ); mAddressee.setFormattedName( dialog.customFormattedName() ); } // Update the name edit. bool block = mNameEdit->signalsBlocked(); mNameEdit->blockSignals( true ); mNameEdit->setText( mAddressee.assembledName() ); mNameEdit->blockSignals( block ); // Update the combo box. nameBoxChanged(); emitModified(); } } } void AddresseeEditorWidget::categoryButtonClicked() { // Show the category dialog if ( mCategoryDialog == 0 ) { mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), SLOT(categoriesSelected( const QStringList& ) ) ); connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); } mCategoryDialog->setCategories(); mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); mCategoryDialog->show(); mCategoryDialog->raise(); } void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) { mCategoryEdit->setText( list.join( "," ) ); } void AddresseeEditorWidget::editCategories() { if ( mCategoryEditDialog == 0 ) { mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), SLOT( categoryButtonClicked() ) ); } mCategoryEditDialog->show(); mCategoryEditDialog->raise(); } void AddresseeEditorWidget::emitModified() { mDirty = true; KABC::Addressee::List list; if ( mIsExtension && !mBlockSignals ) { save(); list.append( mAddressee ); } emit modified( list ); } void AddresseeEditorWidget::dateChanged( QDate ) { emitModified(); } //US invalid dates are handdled by the KDateEdit widget itself void AddresseeEditorWidget::invalidDate() { KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); } void AddresseeEditorWidget::pageChanged( QWidget *wdg ) { #ifndef KAB_EMBEDDED if ( wdg ) KAcceleratorManager::manage( wdg ); #else //KAB_EMBEDDED //US #endif //KAB_EMBEDDED } QString AddresseeEditorWidget::title() const { return i18n( "Contact Editor" ); } QString AddresseeEditorWidget::identifier() const { return i18n( "contact_editor" ); } #ifndef KAB_EMBEDDED #include "addresseeeditorwidget.moc" #endif //KAB_EMBEDDED diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c3c3d47..58b3d70 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1523,513 +1523,513 @@ void CalendarView::readSettings() config->setGroup("WidgetLayout"); QStringList list; list = config->readListEntry("MainLayout"); int x,y,w,h; if ( ! list.isEmpty() ) { x = list[0].toInt(); y = list[1].toInt(); w = list[2].toInt(); h = list[3].toInt(); topLevelWidget()->setGeometry(x,y,w,h); } else { topLevelWidget()->setGeometry( 40 ,40 , 640, 440); } list = config->readListEntry("EditEventLayout"); if ( ! list.isEmpty() ) { x = list[0].toInt(); y = list[1].toInt(); w = list[2].toInt(); h = list[3].toInt(); mEventEditor->setGeometry(x,y,w,h); } list = config->readListEntry("EditTodoLayout"); if ( ! list.isEmpty() ) { x = list[0].toInt(); y = list[1].toInt(); w = list[2].toInt(); h = list[3].toInt(); mTodoEditor->setGeometry(x,y,w,h); } list = config->readListEntry("ViewerLayout"); if ( ! list.isEmpty() ) { x = list[0].toInt(); y = list[1].toInt(); w = list[2].toInt(); h = list[3].toInt(); getEventViewerDialog()->setGeometry(x,y,w,h); } #endif // pending read sync settings; mSyncProfileNames.clear(); mSyncProfileNames << "Profile_1"; mSyncProfileNames << "Profile_2"; mSyncProfileNames << "Profile_3"; mSyncProfileNames << "Profile_4"; mSyncProfileNames << "Profile_5"; KSyncProfile* temp = new KSyncProfile (); temp->setName("Profile_1" ); mSyncProfiles.append( temp ); temp = new KSyncProfile (); temp->setName("Profile_2" ); mSyncProfiles.append( temp ); temp = new KSyncProfile (); temp->setName("Profile_3" ); mSyncProfiles.append( temp ); temp = new KSyncProfile (); temp->setName("Profile_4" ); mSyncProfiles.append( temp ); temp = new KSyncProfile (); temp->setName("Profile_5" ); mSyncProfiles.append( temp ); } void CalendarView::writeSettings() { // kdDebug() << "CalendarView::writeSettings" << endl; KConfig *config = KOGlobals::config(); #ifndef KORG_NOSPLITTER config->setGroup("KOrganizer Geometry"); QValueList<int> list = mPanner->sizes(); config->writeEntry("Separator1",list); list = mLeftSplitter->sizes(); config->writeEntry("Separator2",list); #endif mViewManager->writeSettings( config ); mTodoList->saveLayout(config,QString("Todo Layout")); mDialogManager->writeSettings( config ); //KOPrefs::instance()->usrWriteConfig(); KOPrefs::instance()->writeConfig(); writeFilterSettings(config); config->setGroup( "Views" ); config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); #ifdef DESKTOP_VERSION config->setGroup("WidgetLayout"); QStringList list ;//= config->readListEntry("MainLayout"); int x,y,w,h; QWidget* wid; wid = topLevelWidget(); x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("MainLayout",list ); wid = mEventEditor; x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("EditEventLayout",list ); wid = mTodoEditor; x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("EditTodoLayout",list ); wid = getEventViewerDialog(); x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("ViewerLayout",list ); wid = mDialogManager->getSearchDialog(); if ( wid ) { x = wid->geometry().x(); y = wid->geometry().y(); w = wid->width(); h = wid->height(); list.clear(); list << QString::number( x ); list << QString::number( y ); list << QString::number( w ); list << QString::number( h ); config->writeEntry("SearchLayout",list ); } #endif config->sync(); } void CalendarView::readFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::readFilterSettings()" << endl; mFilters.clear(); config->setGroup("General"); QStringList filterList = config->readListEntry("CalendarFilters"); QStringList::ConstIterator it = filterList.begin(); QStringList::ConstIterator end = filterList.end(); while(it != end) { // kdDebug() << " filter: " << (*it) << endl; CalFilter *filter; filter = new CalFilter(*it); config->setGroup("Filter_" + (*it)); //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); filter->setCriteria(config->readNumEntry("Criteria",0)); filter->setCategoryList(config->readListEntry("CategoryList")); mFilters.append(filter); ++it; } if (mFilters.count() == 0) { CalFilter *filter = new CalFilter(i18n("Default")); mFilters.append(filter); } mFilterView->updateFilters(); config->setGroup("FilterView"); mFilterView->blockSignals(true); mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); mFilterView->setSelectedFilter(config->readEntry("Current Filter")); mFilterView->blockSignals(false); // We do it manually to avoid it being done twice by the above calls updateFilter(); } void CalendarView::writeFilterSettings(KConfig *config) { // kdDebug() << "CalendarView::writeFilterSettings()" << endl; QStringList filterList; CalFilter *filter = mFilters.first(); while(filter) { // kdDebug() << " fn: " << filter->name() << endl; filterList << filter->name(); config->setGroup("Filter_" + filter->name()); config->writeEntry("Criteria",filter->criteria()); config->writeEntry("CategoryList",filter->categoryList()); filter = mFilters.next(); } config->setGroup("General"); config->writeEntry("CalendarFilters",filterList); config->setGroup("FilterView"); config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); } void CalendarView::goToday() { mNavigator->selectToday(); } void CalendarView::goNext() { mNavigator->selectNext(); } void CalendarView::goPrevious() { mNavigator->selectPrevious(); } void CalendarView::goNextMonth() { mNavigator->selectNextMonth(); } void CalendarView::goPreviousMonth() { mNavigator->selectPreviousMonth(); } void CalendarView::writeLocale() { KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); + KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); QString dummy = KOPrefs::instance()->mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = KOPrefs::instance()->mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, KOPrefs::instance()->mDaylightsavingStart, KOPrefs::instance()->mDaylightsavingEnd ); KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); } void CalendarView::updateConfig() { writeLocale(); if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); emit configChanged(); mTodoList->updateConfig(); // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); // To make the "fill window" configurations work //mViewManager->raiseCurrentView(); } void CalendarView::eventChanged(Event *event) { changeEventDisplay(event,KOGlobals::EVENTEDITED); //updateUnmanagedViews(); } void CalendarView::eventAdded(Event *event) { changeEventDisplay(event,KOGlobals::EVENTADDED); } void CalendarView::eventToBeDeleted(Event *) { kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; } void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); } void CalendarView::checkZaurusId( int id, bool todo ) { if ( id >= 0 ) { Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); if ( lse ) { QString des = lse->description(); QString pref = "e"; if ( todo ) pref = "t"; des += pref+ QString::number ( id ) + ","; lse->setReadOnly( false ); lse->setDescription( des ); lse->setReadOnly( true ); } } } void CalendarView::changeIncidenceDisplay(Incidence *which, int action) { updateUnmanagedViews(); //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); if ( action == KOGlobals::EVENTDELETED ) { //delete mCalendar->checkAlarmForIncidence( 0, true ); if ( mEventViewerDialog ) mEventViewerDialog->hide(); } else mCalendar->checkAlarmForIncidence( which , false ); } // most of the changeEventDisplays() right now just call the view's // total update mode, but they SHOULD be recoded to be more refresh-efficient. void CalendarView::changeEventDisplay(Event *which, int action) { // kdDebug() << "CalendarView::changeEventDisplay" << endl; changeIncidenceDisplay((Incidence *)which, action); mDateNavigator->updateView(); //mDialogManager->updateSearchDialog(); if (which) { // If there is an event view visible update the display mViewManager->currentView()->changeEventDisplay(which,action); // TODO: check, if update needed // if (which->getTodoStatus()) { mTodoList->updateView(); // } } else { mViewManager->currentView()->updateView(); } } void CalendarView::updateTodoViews() { mTodoList->updateView(); mViewManager->currentView()->updateView(); } void CalendarView::updateView(const QDate &start, const QDate &end) { mTodoList->updateView(); mViewManager->updateView(start, end); //mDateNavigator->updateView(); } void CalendarView::updateView() { DateList tmpList = mNavigator->selectedDates(); // We assume that the navigator only selects consecutive days. updateView( tmpList.first(), tmpList.last() ); } void CalendarView::updateUnmanagedViews() { mDateNavigator->updateDayMatrix(); } int CalendarView::msgItemDelete() { return KMessageBox::warningContinueCancel(this, i18n("This item will be\npermanently deleted."), i18n("KO/Pi Confirmation"),i18n("Delete")); } void CalendarView::edit_cut() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.cutEvent(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } void CalendarView::edit_copy() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->type() == "Event" ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.copyEvent(anEvent); } void CalendarView::edit_paste() { QDate date = mNavigator->selectedDates().first(); DndFactory factory( mCalendar ); Event *pastedEvent = factory.pasteEvent( date ); changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); } void CalendarView::edit_options() { mDialogManager->showOptionsDialog(); //writeSettings(); } void CalendarView::edit_sync_options() { //mDialogManager->showSyncOptions(); //KOPrefs::instance()->mSyncAlgoPrefs QDialog dia( this, "dia", true ); dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); QVBoxLayout lay ( &dia ); lay.setSpacing( 2 ); lay.setMargin( 3 ); lay.addWidget(&gr); QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); //QRadioButton both( i18n("Take both on conflict"), &gr ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { case 0: loc.setChecked( true); break; case 1: rem.setChecked( true ); break; case 2: newest.setChecked( true); break; case 3: ask.setChecked( true); break; case 4: f_loc.setChecked( true); break; case 5: f_rem.setChecked( true); break; case 6: // both.setChecked( true); break; default: break; } if ( dia.exec() ) { KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; } } void CalendarView::slotSelectPickerDate( QDate d) { mDateFrame->hide(); if ( mDatePickerMode == 1 ) { mNavigator->slotDaySelect( d ); } else if ( mDatePickerMode == 2 ) { if ( mMoveIncidence->type() == "Todo" ) { Todo * to = (Todo *) mMoveIncidence; QTime tim; if ( to->hasDueDate() ) tim = to->dtDue().time(); else { diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 0547a2e..b2001ec 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -197,453 +197,447 @@ void KOWhatsNextView::updateView() itemAdded = true; } appendEvent(todo); } todo = todos.next(); } if ( !itemAdded && iii == 0 ) { // appendDay ( iii, mEventDate ); //mText += "<table>"; // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; //mText +="</table>"; } if ( itemAdded ) mText += "</table>\n"; mEventDate = mEventDate.addDays( 1 ); } int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; if (todos.count() > 0 && topmostPrios > 0 ) { // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); // mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; // mText += i18n("Overdue To-Do:") + "</h2>\n"; //mText += "<ul>\n"; bool gotone = false; int priority = 1; int priosFound = 0; #ifdef DESKTOP_VERSION mText +="<p></p>"; #endif mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; mText += "<ul>\n"; while (!gotone && priority<6) { todo = todos.first(); while(todo) { if (!todo->isCompleted() && (todo->priority() == priority) ) { if ( appendTodo(todo) ) gotone = true; } todo = todos.next(); } if ( gotone ) { gotone = false; ++priosFound; if ( priosFound == topmostPrios ) break; } priority++; // kdDebug() << "adding the todos..." << endl; } mText += "</ul>\n"; } int replys = 0; events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); if (events.count() > 0) { Event *ev = events.first(); while(ev) { Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText += "<p></p>"; // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; mText += "<table>\n"; } replys++; appendEvent(ev,true); } } ev = events.next(); } } todos = calendar()->todos(); if (todos.count() > 0) { Todo *to = todos.first(); while(to) { Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); if (me!=0) { if (me->status()==Attendee::NeedsAction && me->RSVP()) { if (replys == 0) { mText += "<p></p>"; // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); mText += "<h2>"; //<img src=\""; // mText += ipath; // mText += "\">"; mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; mText += "<table>\n"; } replys++; appendEvent(to); } } kdDebug () << "check for todo-replys..." << endl; to = todos.next(); } } if (replys > 0 ) mText += "</table>\n"; mText += "</td></tr>\n</table>\n"; kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl; mView->setText(mText); mView->setFocus(); // QPixmap bPix = SmallIcon( "back" ); // qDebug("xxxxxxxxxxxxxxxxxxxxx "); // QWidget* test = new QWidget(); // test->setBackgroundMode(FixedPixmap ); // test->setBackgroundPixmap ( bPix ); // test->resize( 300, 400 ); // test->show(); // mView->setBackgroundMode(FixedPixmap ); // mView->setBackgroundPixmap ( bPix ); } void KOWhatsNextView::appendDay( int i, QDate eventDate ) { QString date; QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { if ( i == 0 ) { mText += "<table>\n"; return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; } else if ( i == 1 ) date = "<em><font color=\"#000080\">" + day + "</font></em>" ; else date = "<em><font color=\"#000080\">" + day + "</font></em>"; //mText += "<h2>" + date + "</h2>\n"; mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } else { if ( i == 0 ) { mText += "<table>\n"; return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; } #ifdef DESKTOP_VERSION else if ( i == 1 ) { date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; } else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; #else else if ( i == 1 ) { date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; } else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; #endif //mText += "<h2>" + date + "</h2>\n"; mText += "<big><big><strong>" + date + "</strong></big></big>\n"; mText += "<table>\n"; } } void KOWhatsNextView::showDates(const QDate &, const QDate &) { updateView(); } void KOWhatsNextView::showEvents(QPtrList<Event>) { } void KOWhatsNextView::changeEventDisplay(Event *, int action) { switch(action) { case KOGlobals::EVENTADDED: updateView(); break; case KOGlobals::EVENTEDITED: updateView(); break; case KOGlobals::EVENTDELETED: updateView(); break; default: updateView(); kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; } } void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) { if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") ) return; QDateTime cdt = QDateTime::currentDateTime(); mText += "<tr><td><b>"; if (ev->type()=="Event") { if (!ev->doesFloat()) { Event *event = static_cast<Event *>(ev); QDateTime st,end; if ( event->recurrence()->doesRecur() ) { QDate recDate= mEventDate; int days = event->dtStart().date().daysTo (event->dtEnd().date() ); while ( ! event->recursOn( recDate ) ) { recDate = recDate.addDays( -1 ); } st = QDateTime ( recDate, event->dtStart().time() ); end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); } else { st = event->dtStart(); end = event->dtEnd(); } if (reply) mText += "on " + event->dtStartDateStr() + ": "; QString dateText; // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); if ( st.date() < mEventDate ) dateText = "++:++-"; else dateText = event->dtStartTimeStr() + "-"; if ( end.date() > mEventDate ) dateText += "++:++"; else dateText += event->dtEndTimeStr(); if ( notRed ) mText += dateText; else { if ( end < cdt ) mText += "<font color=\"#F00000\">" + dateText + "</font>"; else if ( st < cdt ) mText += "<font color=\"#008000\">" + dateText + "</font>"; else mText += dateText; } } else { mText += i18n("Allday:"); } } else { mTodos.append( ev ); mText += i18n("ToDo:"); if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; QString dfs = KGlobal::locale()->dateFormatShort(); - KGlobal::locale()->setIntDateFormat( 3 ); KGlobal::locale()->setDateFormatShort("%d.%b"); - mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>"; - + mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; KGlobal::locale()->setDateFormatShort(dfs); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); } else { if (!ev->doesFloat() ) if( ( (Todo*)ev)->dtDue() < cdt ) { mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; } else mText +=((Todo*)ev)->dtDueTimeStr(); mTodos.append( ev ); } } mText += "</b></td><td>"; bool needClose = false; if ( ev->cancelled() ) { mText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() ) { if ( !needClose) mText +="["; mText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) mText +="["; mText += "i"; needClose =true; } if ( ev->recurrence()->doesRecur() ) { if ( !needClose) mText +="["; mText += "r"; needClose =true; } if ( needClose ) { mText += "] "; } if ( ev->cancelled() ) mText += "</font>"; mText += "<a "; if (ev->type()=="Event") mText += "href=\"event:"; if (ev->type()=="Todo") mText += "href=\"todo:"; mText += ev->uid() + "\">"; if ( ev->summary().length() > 0 ) mText += ev->summary(); else mText += i18n("-no summary-"); mText += "</a>"; if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) mText += " ("+ev->location() +")"; if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) mText += " ["+ev->relatedTo()->summary() +"]"; mText += "</td></tr>\n"; } bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) { if ( mTodos.find( ev ) != mTodos.end() ) return false; mTodos.append( ev ); if ( !isSub ) mText += "<p>"; else mText += "<li>"; mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; mText += ind; bool needClose = false; if ( ev->cancelled() ) { mText += "<font color=\"#F00000\">[c"; needClose =true; } if ( ev->isAlarmEnabled() ) { if ( !needClose) mText +="["; mText += "a"; needClose =true; } if ( ev->description().length() > 0 ) { if ( !needClose) mText +="["; mText += "i"; needClose =true; } // if ( ev->recurrence()->doesRecur() ) { // if ( !needClose) // mText +="("; // mText += "r"; // needClose =true; // } if ( needClose ) mText += "] "; if ( ev->cancelled() ) mText += "</font>"; mText += "<a href=\"todo:" + ev->uid() + "\">"; mText += ev->summary(); mText += "</a>"; if ( ((Todo*)ev)->hasDueDate () ) { QString year = ""; int ye = ((Todo*)ev)->dtDue().date().year(); if ( QDateTime::currentDateTime().date().year() != ye ) year = QString::number( ye ); QString dfs = KGlobal::locale()->dateFormatShort(); - KGlobal::locale()->setIntDateFormat( 3 ); KGlobal::locale()->setDateFormatShort("%d.%b"); - mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>"; - + mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; KGlobal::locale()->setDateFormatShort(dfs); - KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); } if ( KOPrefs::instance()->mWNViewShowLocation ) if ( !ev->location().isEmpty() ) mText += " ("+ev->location() +")"; if ( !isSub ) { if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) mText += " ["+ev->relatedTo()->summary() +"]"; mText += "</p>\n"; } else { ind += "-"; mText += "</li>\n"; } QPtrList<Incidence> Relations = ev->relations(); Incidence *to; for (to=Relations.first();to;to=Relations.next()) { if (!((Todo*)to)->isCompleted()) appendTodo( to, ind , true ); } return true; } /* void KOWhatsNextView::createEventViewer() { if (!mEventViewer) { mEventViewer = new KOEventViewerDialog(this); } } */ void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) { if ( mEventViewer ) delete mEventViewer; mEventViewer = v; } // TODO: Create this function in CalendarView and remove it from here void KOWhatsNextView::showIncidence(const QString &uid) { if ( !mEventViewer ) { qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); return; } //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); if (uid.startsWith("event:")) { #ifdef DESKTOP_VERSION Event *event = calendar()->event(uid.mid(8)); #else Event *event = calendar()->event(uid.mid(6)); #endif //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); if (!event) return; //createEventViewer(); mEventViewer->setEvent(event); } else if (uid.startsWith("todo:")) { #ifdef DESKTOP_VERSION Todo *todo = calendar()->todo(uid.mid(7)); #else Todo *todo = calendar()->todo(uid.mid(5)); #endif if (!todo) return; //createEventViewer(); mEventViewer->setTodo(todo); } else { return; } mEventViewer->showMe(); mEventViewer->raise(); } diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index d77e251..9d7e60b 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp @@ -1,881 +1,884 @@ #include <qregexp.h> #include <qapplication.h> #include "kdebug.h" #include "kcalendarsystemgregorian.h" #include "klocale.h" QDict<QString> *mLocaleDict = 0; void setLocaleDict( QDict<QString> * dict ) { mLocaleDict = dict; } QString i18n(const char *text) { if ( ! mLocaleDict ) return QString( text ); else { QString* ret = mLocaleDict->find(QString(text)) ; if ( ret == 0 ) { return QString( text ); } else { if ( (*ret).isEmpty() ) return QString( text ); else return (*ret); } } } QString i18n(const char *,const char *text) { return i18n( text ); } QString i18n(const char *text1, const char *textn, int num) { if ( num == 1 ) return i18n( text1 ); else { QString text = i18n( textn ); int pos = text.find( "%n" ); if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); return text; } } inline void put_it_in( QChar *buffer, uint& index, const QString &s ) { for ( uint l = 0; l < s.length(); l++ ) buffer[index++] = s.at( l ); } inline void put_it_in( QChar *buffer, uint& index, int number ) { buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; } static int readInt(const QString &str, uint &pos) { if (!str.at(pos).isDigit()) return -1; int result = 0; for (; str.length() > pos && str.at(pos).isDigit(); pos++) { result *= 10; result += str.at(pos).digitValue(); } return result; } KLocale::KLocale() : mCalendarSystem( 0 ) { m_decimalSymbol = "."; m_positiveSign = ""; m_negativeSign = "-"; m_thousandsSeparator = ","; mWeekStartsMonday = true; mHourF24Format = true; - mIntDateFormat = 0; + mIntDateFormat = Default; mLanguage = 0; mDateFormat = "%a %Y %b %d"; mDateFormatShort = "%Y-%m-%d"; mTimeZoneList << i18n ("-11:00 US/Samoa") << i18n ("-10:00 US/Hawaii") << i18n ("-09:00 US/Alaska") << i18n ("-08:00 US/Pacific") << i18n ("-07:00 US/Mountain") << i18n ("-06:00 US/Central") << i18n ("-05:00 US/Eastern") << i18n ("-04:00 Brazil/West") << i18n ("-03:00 Brazil/East") << i18n ("-02:00 Brazil/DeNoronha") << i18n ("-01:00 Atlantic/Azores") << i18n (" 00:00 Europe/London(UTC)") << i18n ("+01:00 Europe/Oslo(CET)") << i18n ("+02:00 Europe/Helsinki") << i18n ("+03:00 Europe/Moscow") << i18n ("+04:00 Indian/Mauritius") << i18n ("+05:00 Indian/Maldives") << i18n ("+06:00 Indian/Chagos") << i18n ("+07:00 Asia/Bangkok") << i18n ("+08:00 Asia/Hongkong") << i18n ("+09:00 Asia/Tokyo") << i18n ("+10:00 Asia/Vladivostok") << i18n ("+11:00 Asia/Magadan") << i18n ("+12:00 Asia/Kamchatka") // << i18n (" xx:xx User defined offset") << i18n (" Local Time"); mSouthDaylight = false; mTimeZoneOffset = 0; daylightEnabled = false; } void KLocale::setDateFormat( QString s ) { mDateFormat = s; } void KLocale::setDateFormatShort( QString s ) { mDateFormatShort = s; } void KLocale::setHore24Format ( bool b ) { mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } -int KLocale::getIntDateFormat( ) +KLocale::IntDateFormat KLocale::getIntDateFormat( ) { - return mIntDateFormat ; + return mIntDateFormat; } -void KLocale::setIntDateFormat( int i ) +void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) { mIntDateFormat = i; } void KLocale::setLanguage( int i ) { mLanguage = i; } QString KLocale::translate( const char *index ) const { return i18n( index ); } QString KLocale::translate( const char *, const char *fallback) const { return i18n( fallback ); } QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const { const QString rst = timeFormat(); // only "pm/am" here can grow, the rest shrinks, but // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; uint index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); format_index++ ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'H': put_it_in( buffer, index, pTime.hour() ); break; case 'I': put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); break; case 'M': put_it_in( buffer, index, pTime.minute() ); break; case 'S': if (includeSecs) put_it_in( buffer, index, pTime.second() ); else { // we remove the seperator sign before the seconds and // assume that works everywhere --index; break; } break; case 'k': number = pTime.hour(); case 'l': // to share the code if ( rst.at( format_index ).unicode() == 'l' ) number = (pTime.hour() + 11) % 12 + 1; if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'p': { QString s; if ( pTime.hour() >= 12 ) put_it_in( buffer, index, i18n("pm") ); else put_it_in( buffer, index, i18n("am") ); break; } default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } -QString KLocale::formatDate(const QDate &pDate, bool shortFormat) const +QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const { - const QString rst = shortFormat?dateFormatShort():dateFormat(); + const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); // I'm rather safe than sorry QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; unsigned int index = 0; bool escape = false; int number = 0; for ( uint format_index = 0; format_index < rst.length(); ++format_index ) { if ( !escape ) { if ( rst.at( format_index ).unicode() == '%' ) escape = true; else buffer[index++] = rst.at( format_index ); } else { switch ( rst.at( format_index ).unicode() ) { case '%': buffer[index++] = '%'; break; case 'Y': put_it_in( buffer, index, pDate.year() / 100 ); case 'y': put_it_in( buffer, index, pDate.year() % 100 ); break; case 'n': number = pDate.month(); case 'e': // to share the code if ( rst.at( format_index ).unicode() == 'e' ) number = pDate.day(); if ( number / 10 ) buffer[index++] = number / 10 + '0'; buffer[index++] = number % 10 + '0'; break; case 'm': put_it_in( buffer, index, pDate.month() ); break; case 'b': put_it_in( buffer, index, monthName(pDate.month(), true) ); break; case 'B': put_it_in( buffer, index, monthName(pDate.month(), false) ); break; case 'd': put_it_in( buffer, index, pDate.day() ); break; case 'a': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); break; case 'A': put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); break; default: buffer[index++] = rst.at( format_index ); break; } escape = false; } } QString ret( buffer, index ); delete [] buffer; return ret; } QString KLocale::formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSeconds) const { return QString( "%1 %2") .arg( formatDate( pDateTime.date(), shortFormat ) ) .arg( formatTime( pDateTime.time(), includeSeconds ) ); } QString KLocale::formatDateTime(const QDateTime &pDateTime) const { return formatDateTime(pDateTime, true); } QDate KLocale::readDate(const QString &intstr, bool* ok) const { QDate date; date = readDate(intstr, true, ok); if (date.isValid()) return date; return readDate(intstr, false, ok); } QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const { QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); return readDate( intstr, fmt, ok ); } QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const { //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; QString str = intstr.simplifyWhiteSpace().lower(); int day = -1, month = -1; // allow the year to be omitted if not in the format int year = QDate::currentDate().year(); uint strpos = 0; uint fmtpos = 0; while (fmt.length() > fmtpos || str.length() > strpos) { if ( !(fmt.length() > fmtpos && str.length() > strpos) ) goto error; QChar c = fmt.at(fmtpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = fmt.at(fmtpos++); switch (c) { case 'a': case 'A': // this will just be ignored { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 8; j++) { QString s = weekDayName(j, c == 'a').lower(); int len = s.length(); if (str.mid(strpos, len) == s) strpos += len; } break; } case 'b': case 'B': { // Cristian Tache: porting to Win: Block added because of "j" redefinition for (int j = 1; j < 13; j++) { QString s = monthName(j, c == 'b').lower(); int len = s.length(); if (str.mid(strpos, len) == s) { month = j; strpos += len; } } break; } case 'd': case 'e': day = readInt(str, strpos); if (day < 1 || day > 31) goto error; break; case 'n': case 'm': month = readInt(str, strpos); if (month < 1 || month > 12) goto error; break; case 'Y': case 'y': year = readInt(str, strpos); if (year < 0) goto error; // Qt treats a year in the range 0-100 as 1900-1999. // It is nicer for the user if we treat 0-68 as 2000-2068 if (year < 69) year += 2000; else if (c == 'y') year += 1900; break; } } //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; if ( year != -1 && month != -1 && day != -1 ) { if (ok) *ok = true; return QDate(year, month, day); } error: if (ok) *ok = false; return QDate(); // invalid date } QTime KLocale::readTime(const QString &intstr, bool *ok) const { QTime _time; _time = readTime(intstr, true, ok); if (_time.isValid()) return _time; return readTime(intstr, false, ok); } QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const { QString str = intstr.simplifyWhiteSpace().lower(); QString Format = timeFormat().simplifyWhiteSpace(); if (!seconds) Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds bool g_12h = false; bool pm = false; uint strpos = 0; uint Formatpos = 0; while (Format.length() > Formatpos || str.length() > strpos) { if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; QChar c = Format.at(Formatpos++); if (c != '%') { if (c.isSpace()) strpos++; else if (c != str.at(strpos++)) goto error; continue; } // remove space at the begining if (str.length() > strpos && str.at(strpos).isSpace()) strpos++; c = Format.at(Formatpos++); switch (c) { case 'p': { QString s; s = i18n("pm").lower(); int len = s.length(); if (str.mid(strpos, len) == s) { pm = true; strpos += len; } else { s = i18n("am").lower(); len = s.length(); if (str.mid(strpos, len) == s) { pm = false; strpos += len; } else goto error; } } break; case 'k': case 'H': g_12h = false; hour = readInt(str, strpos); if (hour < 0 || hour > 23) goto error; break; case 'l': case 'I': g_12h = true; hour = readInt(str, strpos); if (hour < 1 || hour > 12) goto error; break; case 'M': minute = readInt(str, strpos); if (minute < 0 || minute > 59) goto error; break; case 'S': second = readInt(str, strpos); if (second < 0 || second > 59) goto error; break; } } if (g_12h) { hour %= 12; if (pm) hour += 12; } if (ok) *ok = true; return QTime(hour, minute, second); error: if (ok) *ok = false; return QTime(-1, -1, -1); // return invalid date if it didn't work // This will be removed in the near future, since it gives a warning on stderr. // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. } bool KLocale::use12Clock() const { return !mHourF24Format ;; } bool KLocale::weekStartsMonday() const { return mWeekStartsMonday; } int KLocale::weekStartDay() const { if ( mWeekStartsMonday ) return 1; return 7; } QString KLocale::weekDayName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("Monday", "Mon"); case 2: return i18n("Tuesday", "Tue"); case 3: return i18n("Wednesday", "Wed"); case 4: return i18n("Thursday", "Thu"); case 5: return i18n("Friday", "Fri"); case 6: return i18n("Saturday", "Sat"); case 7: return i18n("Sunday", "Sun"); } else switch ( i ) { case 1: return i18n("Monday"); case 2: return i18n("Tuesday"); case 3: return i18n("Wednesday"); case 4: return i18n("Thursday"); case 5: return i18n("Friday"); case 6: return i18n("Saturday"); case 7: return i18n("Sunday"); } return QString::null; } QString KLocale::monthName(int i,bool shortName) const { if ( shortName ) switch ( i ) { case 1: return i18n("January", "Jan"); case 2: return i18n("February", "Feb"); case 3: return i18n("March", "Mar"); case 4: return i18n("April", "Apr"); case 5: return i18n("May short", "May"); case 6: return i18n("June", "Jun"); case 7: return i18n("July", "Jul"); case 8: return i18n("August", "Aug"); case 9: return i18n("September", "Sep"); case 10: return i18n("October", "Oct"); case 11: return i18n("November", "Nov"); case 12: return i18n("December", "Dec"); } else switch (i) { case 1: return i18n("January"); case 2: return i18n("February"); case 3: return i18n("March"); case 4: return i18n("April"); case 5: return i18n("May long", "May"); case 6: return i18n("June"); case 7: return i18n("July"); case 8: return i18n("August"); case 9: return i18n("September"); case 10: return i18n("October"); case 11: return i18n("November"); case 12: return i18n("December"); } return QString::null; } QString KLocale::country() const { return QString::null; } -QString KLocale::dateFormat() const -{ +QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const +{ + const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; + if ( QApplication::desktop()->width() < 480 ) { - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%a %d %b %Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%a %b %d %Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) return "%a %Y %b %d"; } else { - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%A %d %B %Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%A %B %d %Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) return "%A %Y %B %d"; } return mDateFormat ; } -QString KLocale::dateFormatShort() const +QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const { + const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; - if ( mIntDateFormat == 0 ) + if ( dformat == Default ) return "%d.%m.%Y"; - else if ( mIntDateFormat == 1 ) + else if ( dformat == Format1 ) return "%m.%d.%Y"; - else if ( mIntDateFormat == 2 ) + else if ( dformat == ISODate ) // = Qt::ISODate return "%Y-%m-%d"; return mDateFormatShort ; } QString KLocale::timeFormat() const { if ( mHourF24Format) return "%H:%M:%S"; return "%I:%M:%S%p"; } void KLocale::insertCatalogue ( const QString & ) { } KCalendarSystem *KLocale::calendar() { if ( !mCalendarSystem ) { mCalendarSystem = new KCalendarSystemGregorian; } return mCalendarSystem; } int KLocale::timezoneOffset( QString timeZone ) { int ret = 1001; int index = mTimeZoneList.findIndex( timeZone ); if ( index < 24 ) ret = ( index-11 ) * 60 ; return ret; } QStringList KLocale::timeZoneList() const { return mTimeZoneList; } void KLocale::setTimezone( const QString &timeZone ) { mTimeZoneOffset = timezoneOffset( timeZone ); } void KLocale::setDaylightSaving( bool b, int start , int end ) { daylightEnabled = b; daylightStart = start; daylightEnd = end; mSouthDaylight = (end < start); // qDebug("klocale daylight %d %d %d ", b, start , end ); } int KLocale::localTimeOffset( const QDateTime &dt ) { bool addDaylight = false; if ( daylightEnabled ) { int d_end, d_start; int dayofyear = dt.date().dayOfYear(); int year = dt.date().year(); int add = 0; if ( QDate::leapYear(year) ) add = 1; QDate date ( year,1,1 ); if ( daylightEnd > 59 ) d_end = daylightEnd +add; else d_end = daylightEnd; if ( daylightStart > 59 ) d_start = daylightStart +add; else d_start = daylightStart; QDate s_date = date.addDays( d_start -1 ); QDate e_date = date.addDays( d_end -1 ); int dof = s_date.dayOfWeek(); if ( dof < 7 ) s_date = s_date.addDays( -dof ); dof = e_date.dayOfWeek(); if ( dof < 7 ) e_date = e_date.addDays( -dof ); QTime startTime ( 3,0,0 ); QDateTime startDt( s_date, startTime ); QDateTime endDt( e_date, startTime ); //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); if ( mSouthDaylight ) { if ( ! ( endDt < dt && dt < startDt) ) addDaylight = true; } else { if ( startDt < dt && dt < endDt ) addDaylight = true; } } int addMin = 0; if ( addDaylight ) addMin = 60; return mTimeZoneOffset + addMin; } // ****************************************************************** // added LR QString KLocale::formatNumber(double num, int precision) const { bool neg = num < 0; if (precision == -1) precision = 2; QString res = QString::number(neg?-num:num, 'f', precision); int pos = res.find('.'); if (pos == -1) pos = res.length(); else res.replace(pos, 1, decimalSymbol()); while (0 < (pos -= 3)) res.insert(pos, thousandsSeparator()); // thousand sep // How can we know where we should put the sign? res.prepend(neg?negativeSign():positiveSign()); return res; } QString KLocale::formatNumber(const QString &numStr) const { return formatNumber(numStr.toDouble()); } double KLocale::readNumber(const QString &_str, bool * ok) const { QString str = _str.stripWhiteSpace(); bool neg = str.find(negativeSign()) == 0; if (neg) str.remove( 0, negativeSign().length() ); /* will hold the scientific notation portion of the number. Example, with 2.34E+23, exponentialPart == "E+23" */ QString exponentialPart; int EPos; EPos = str.find('E', 0, false); if (EPos != -1) { exponentialPart = str.mid(EPos); str = str.left(EPos); } int pos = str.find(decimalSymbol()); QString major; QString minor; if ( pos == -1 ) major = str; else { major = str.left(pos); minor = str.mid(pos + decimalSymbol().length()); } // Remove thousand separators int thlen = thousandsSeparator().length(); int lastpos = 0; while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) { // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N int fromEnd = major.length() - pos; if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error || pos - lastpos > 3 // More than 3 digits between two separators -> error || pos == 0 // Can't start with a separator || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators { if (ok) *ok = false; return 0.0; } lastpos = pos; major.remove( pos, thlen ); } if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator { if (ok) *ok = false; return 0.0; } QString tot; if (neg) tot = '-'; tot += major + '.' + minor + exponentialPart; return tot.toDouble(ok); } QString KLocale::decimalSymbol() const { return m_decimalSymbol; } QString KLocale::thousandsSeparator() const { return m_thousandsSeparator; } QString KLocale::positiveSign() const { return m_positiveSign; } QString KLocale::negativeSign() const { return m_negativeSign; } diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h index 7470cd2..f6c0253 100644 --- a/microkde/kdecore/klocale.h +++ b/microkde/kdecore/klocale.h @@ -1,110 +1,112 @@ #ifndef MINIKDE_KLOCALE_H #define MINIKDE_KLOCALE_H #include <qstring.h> #include <qstringlist.h> #include <qdatetime.h> #include <qdict.h> #ifndef I18N_NOOP #define I18N_NOOP(x) (x) #endif class KCalendarSystem; void setLocaleDict( QDict<QString> * dict ); QString i18n(const char *text); QString i18n(const char *hint, const char *text); QString i18n(const char *text1, const char *textn, int num); // Qt3's uic generates i18n( "msg", "comment" ) calls which conflict // with our i18n method. we use uic -tr tr2i18n to redirect // to the right i18n() function inline QString tr2i18n(const char* message, const char* =0) { return i18n( message); } class KLocale { public: KLocale(); QString formatNumber(double num, int precision = -1) const; QString formatNumber(const QString &numStr) const; double readNumber(const QString &numStr, bool * ok = 0) const; QString decimalSymbol() const; QString thousandsSeparator() const; QString positiveSign() const; QString negativeSign() const; QString translate( const char *index ) const; QString translate( const char *index, const char *fallback) const; - QString formatDate(const QDate &pDate, bool shortFormat = false) const; + enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; + + QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; QString formatTime(const QTime &pTime, bool includeSecs = false) const; QString formatDateTime(const QDateTime &pDateTime) const; QString formatDateTime(const QDateTime &pDateTime, bool shortFormat, bool includeSecs = false) const; QDate readDate(const QString &str, bool* ok = 0) const; QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; QTime readTime(const QString &str, bool* ok = 0) const; bool use12Clock() const; bool weekStartsMonday() const; int weekStartDay() const; QString weekDayName(int,bool=false) const; QString monthName(int,bool=false) const; QString country() const; - QString dateFormat() const; - QString dateFormatShort() const; + QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; + QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; QString timeFormat() const; void insertCatalogue ( const QString & ); KCalendarSystem *calendar(); void setHore24Format ( bool ); void setWeekStartMonday( bool ); - void setIntDateFormat( int ); - int getIntDateFormat( ); + void setIntDateFormat( IntDateFormat ); + IntDateFormat getIntDateFormat( ); void setLanguage( int ); void setDateFormat( QString ); void setDateFormatShort( QString ); QString m_decimalSymbol; QString m_thousandsSeparator; QString m_currencySymbol; QString m_monetaryDecimalSymbol; QString m_monetaryThousandsSeparator; QString m_positiveSign; QString m_negativeSign; int timezoneOffset( QString ); QStringList timeZoneList() const; void setDaylightSaving( bool, int , int ); int localTimeOffset(const QDateTime &); void setTimezone( const QString &timeZone ); private: QTime readTime(const QString &str, bool seconds, bool *ok) const; QDate readDate(const QString &str, bool shortFormat, bool *ok) const; KCalendarSystem *mCalendarSystem; bool mWeekStartsMonday; bool mHourF24Format; - int mIntDateFormat; + IntDateFormat mIntDateFormat; int mLanguage; QString mDateFormat; QString mDateFormatShort; QStringList mTimeZoneList; bool daylightEnabled; int mDaylightTZoffset; int mNondaylightTZoffset; bool mSouthDaylight; int daylightStart, daylightEnd, mTimeZoneOffset; }; #endif |