-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 56 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 7 |
3 files changed, 58 insertions, 20 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3cfc1f2..826c69b 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -78,25 +78,24 @@ #include "addresseeeditorwidget.h" AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, QWidget *parent, const char *name ) : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), mBlockSignals( false ) { mAConfig = AddresseeConfig::instance(); - kdDebug(5720) << "AddresseeEditorWidget()" << endl; mFormattedNameType = NameEditDialog::CustomName; initGUI(); mCategoryDialog = 0; mCategoryEditDialog = 0; // Load the empty addressee as defaults load(); mDirty = false; } AddresseeEditorWidget::~AddresseeEditorWidget() @@ -623,24 +622,25 @@ void AddresseeEditorWidget::setupTab2() layout->addWidget( label, 7, 1 ); mSpouseEdit = new KLineEdit( tab2 ); connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mSpouseEdit ); //US layout->addWidget( mSpouseEdit, 5, 2 ); layout->addWidget( mSpouseEdit, 7, 2 ); label = new QLabel( i18n( "Birthday:" ), tab2 ); //US layout->addWidget( label, 4, 3 ); layout->addWidget( label, 8, 1 ); mBirthdayPicker = new KDateEdit( tab2 ); + mBirthdayPicker->toggleDateFormat(); mBirthdayPicker->setHandleInvalid( true ); connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), SLOT( dateChanged( QDate ) ) ); #ifndef KAB_EMBEDDED //US invalid dates are handdled by the KDateEdit widget itself connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), SLOT( invalidDate() ) ); connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), SLOT( emitModified() ) ); #endif //KAB_EMBEDDED @@ -938,25 +938,24 @@ void AddresseeEditorWidget::setupTab3_1() // 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") ); @@ -1019,66 +1018,73 @@ void AddresseeEditorWidget::load() 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; + if ( !dirty() ) { + 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 + if ( mBirthdayPicker->inputIsValid() ) { + QDate da = mBirthdayPicker->date(); + if ( da > QDate::currentDate() ) + da.setYMD(da.year()-100, da.month(), da.day() ); + mAddressee.setBirthday( QDateTime( da ) ); + qDebug("bday %s ",da.toString().latin1()); + } + else { mAddressee.setBirthday( QDateTime() ); - + mBirthdayPicker->clear(); + } 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 ) ); QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } - else + else { mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); + mAnniversaryPicker->clear(); + } // 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; @@ -1105,36 +1111,56 @@ void AddresseeEditorWidget::save() ++addressIter ) mAddressee.removeAddress( *addressIter ); addresses = mAddressEditWidget->addresses(); for ( addressIter = addresses.begin(); addressIter != addresses.end(); ++addressIter ) mAddressee.insertAddress( *addressIter ); mDirty = false; } bool AddresseeEditorWidget::dirty() { + + if ( ! mDirty ) { + if ( mBirthdayPicker->inputIsValid() ) { + QDate da = mBirthdayPicker->date(); + if ( !(da == mAddressee.birthday().date())) + mDirty = true; + } + else { + mBirthdayPicker->clear(); + } + if ( mAnniversaryPicker->inputIsValid() ) { + QDate da = mAnniversaryPicker->date(); + if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), + "%Y-%m-%d")) + mDirty = true; + } + else { + mAnniversaryPicker->clear(); + } + } 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 ); + 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() ); } } @@ -1160,25 +1186,25 @@ void AddresseeEditorWidget::nameBoxChanged() 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 ( KApplication::execDialog( &dialog) ) { 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. diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index d781f67..4230c07 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -62,24 +62,39 @@ int main( int argc, char **argv ) #else QString fileName ; fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); QApplication::addLibraryPath ( qApp->applicationDirPath () ); #endif KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); KAddressBookMain m ; //US MainWindow m; QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); + { + KConfig kon ( locateLocal( "config", "korganizerrc" ) ); + kon.setGroup("Locale"); + KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); + QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); + KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) ); + KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); + dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); + KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); + kon.setGroup("Time & Date"); + KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), + kon.readNumEntry( "DaylightsavingStart", 90), + kon.readNumEntry( "DaylightsavingEnd",304) ); + KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); + } #ifndef DESKTOP_VERSION a.showMainWidget( &m ); #else a.setMainWidget( &m ); m.resize (640, 480 ); m.show(); #endif a.exec(); } qDebug("KA: Bye! "); } diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index fb7eb22..8213c2b 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp @@ -100,25 +100,25 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, mFormattedNameCombo->setMaximumWidth(100); layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); mFormattedNameEdit = new KLineEdit( page ); mFormattedNameEdit->setEnabled( type == CustomName ); layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); - layout->addMultiCellWidget( mParseBox, 6, 6, 0, 1 ); + layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); // Fill in the values mFamilyNameEdit->setText( addr.familyName() ); mGivenNameEdit->setText( addr.givenName() ); mAdditionalNameEdit->setText( addr.additionalName() ); mFormattedNameEdit->setText( addr.formattedName() ); // Prefix and suffix combos //US KConfig config( "kabcrc" ); KConfig config( locateLocal("config", "kabcrc") ); config.setGroup( "General" ); @@ -166,28 +166,25 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); updateTypeCombo(); mFormattedNameCombo->setCurrentItem( type ); -#ifdef KAB_EMBEDDED - resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); -#endif //KAB_EMBEDDED - + mChanged = false; } NameEditDialog::~NameEditDialog() { } QString NameEditDialog::familyName() const { return mFamilyNameEdit->text(); } |