-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 | 35 | ||||
-rw-r--r-- | microkde/kdecore/klocale.h | 14 |
6 files changed, 31 insertions, 37 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index d8c1aca..5e42640 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp @@ -53,17 +53,16 @@ AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, 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 ); diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 4365ee5..3cfc1f2 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -1060,21 +1060,17 @@ void AddresseeEditorWidget::save() 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; diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c3c3d47..58b3d70 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1771,17 +1771,17 @@ void CalendarView::goNextMonth() 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 ); diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 0547a2e..b2001ec 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -445,22 +445,19 @@ void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) } } 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(); @@ -562,22 +559,19 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 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"; 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 @@ -81,17 +81,17 @@ KLocale::KLocale() : mCalendarSystem( 0 ) 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") @@ -134,22 +134,22 @@ void KLocale::setDateFormatShort( QString s ) void KLocale::setHore24Format ( bool b ) { mHourF24Format = b; } void KLocale::setWeekStartMonday( bool b ) { mWeekStartsMonday = b; } -int KLocale::getIntDateFormat( ) +KLocale::IntDateFormat KLocale::getIntDateFormat( ) { 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 @@ -236,19 +236,19 @@ QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const 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; @@ -639,45 +639,48 @@ QString KLocale::monthName(int i,bool shortName) const 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 { 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 @@ -36,17 +36,19 @@ class KLocale 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; @@ -56,27 +58,27 @@ class KLocale 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; @@ -90,17 +92,17 @@ class KLocale 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; |