author | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-13 21:35:12 (UTC) |
commit | bd6b4acb39498ffea3beea7d9b5f7620b60c14db (patch) (side-by-side diff) | |
tree | e2d7425b7bb49fbcb7acb5ced497ac1fed06dfaf | |
parent | 06eabf6e82c0390699d11fd12580d91261829431 (diff) | |
download | kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.zip kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.gz kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.bz2 |
Many bugfixes
-rw-r--r-- | kabc/addressee.cpp | 12 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 50 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 15 | ||||
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | libkdepim/addresseeview.cpp | 10 | ||||
-rw-r--r-- | libkdepim/kdateedit.cpp | 17 | ||||
-rw-r--r-- | libkdepim/kdateedit.h | 3 | ||||
-rw-r--r-- | microkde/kdeui/kaction.cpp | 44 |
10 files changed, 112 insertions, 48 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 6b282e2..4cdd5e5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -708,221 +708,225 @@ void Addressee::setSecrecy( const Secrecy &secrecy ) mData->secrecy = secrecy; } Secrecy Addressee::secrecy() const { return mData->secrecy; } QString Addressee::secrecyLabel() { return i18n("Security Class"); } void Addressee::setLogo( const Picture &logo ) { if ( logo == mData->logo ) return; detach(); mData->empty = false; mData->logo = logo; } Picture Addressee::logo() const { return mData->logo; } QString Addressee::logoLabel() { return i18n("Logo"); } void Addressee::setPhoto( const Picture &photo ) { if ( photo == mData->photo ) return; detach(); mData->empty = false; mData->photo = photo; } Picture Addressee::photo() const { return mData->photo; } QString Addressee::photoLabel() { return i18n("Photo"); } void Addressee::setSound( const Sound &sound ) { if ( sound == mData->sound ) return; detach(); mData->empty = false; mData->sound = sound; } Sound Addressee::sound() const { return mData->sound; } QString Addressee::soundLabel() { return i18n("Sound"); } void Addressee::setAgent( const Agent &agent ) { if ( agent == mData->agent ) return; detach(); mData->empty = false; mData->agent = agent; } Agent Addressee::agent() const { return mData->agent; } QString Addressee::agentLabel() { return i18n("Agent"); } void Addressee::setNameFromString( const QString &str ) { setFormattedName( str ); setName( str ); - QStringList titles; + static bool first = true; + static QStringList titles; + static QStringList suffixes; + static QStringList prefixes; + + if ( first ) { + first = false; titles += i18n( "Dr." ); titles += i18n( "Miss" ); titles += i18n( "Mr." ); titles += i18n( "Mrs." ); titles += i18n( "Ms." ); titles += i18n( "Prof." ); - QStringList suffixes; suffixes += i18n( "I" ); suffixes += i18n( "II" ); suffixes += i18n( "III" ); suffixes += i18n( "Jr." ); suffixes += i18n( "Sr." ); - QStringList prefixes; prefixes += "van"; prefixes += "von"; prefixes += "de"; -//US KConfig config( "kabcrc" ); KConfig config( locateLocal( "config", "kabcrc") ); config.setGroup( "General" ); titles += config.readListEntry( "Prefixes" ); titles.remove( "" ); prefixes += config.readListEntry( "Inclusions" ); prefixes.remove( "" ); suffixes += config.readListEntry( "Suffixes" ); suffixes.remove( "" ); + } // clear all name parts setPrefix( "" ); setGivenName( "" ); setAdditionalName( "" ); setFamilyName( "" ); setSuffix( "" ); if ( str.isEmpty() ) return; int i = str.find(','); if( i < 0 ) { QStringList parts = QStringList::split( " ", str ); int leftOffset = 0; int rightOffset = parts.count() - 1; QString suffix; while ( rightOffset >= 0 ) { if ( suffixes.contains( parts[ rightOffset ] ) ) { suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); rightOffset--; } else break; } setSuffix( suffix ); if ( rightOffset < 0 ) return; if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); rightOffset--; } else setFamilyName( parts[ rightOffset ] ); QString prefix; while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } setPrefix( prefix ); if ( leftOffset < rightOffset ) { setGivenName( parts[ leftOffset ] ); leftOffset++; } QString additionalName; while ( leftOffset < rightOffset ) { additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } setAdditionalName( additionalName ); } else { QString part1 = str.left( i ); QString part2 = str.mid( i + 1 ); QStringList parts = QStringList::split( " ", part1 ); int leftOffset = 0; int rightOffset = parts.count() - 1; QString suffix; while ( rightOffset >= 0 ) { if ( suffixes.contains( parts[ rightOffset ] ) ) { suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); rightOffset--; } else break; } setSuffix( suffix ); if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); rightOffset--; } else setFamilyName( parts[ rightOffset ] ); QString prefix; while ( leftOffset < rightOffset ) { if ( titles.contains( parts[ leftOffset ] ) ) { prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); leftOffset++; } else break; } parts = QStringList::split( " ", part2 ); leftOffset = 0; rightOffset = parts.count(); while ( leftOffset < rightOffset ) { diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3cfc1f2..826c69b 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -1,186 +1,185 @@ /* 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 <qcheckbox.h> #include <qhbox.h> #include <qlabel.h> #include <qlayout.h> #include <qlistbox.h> #include <qpushbutton.h> #include <qtabwidget.h> #ifndef KAB_EMBEDDED #include <qtextedit.h> #include <kaccelmanager.h> #include "keywidget.h" #include "soundwidget.h" #else //KAB_EMBEDDED #include <qmultilineedit.h> #endif //KAB_EMBEDDED #include "keywidget.h" #include "geowidget.h" #include "imagewidget.h" #include "nameeditdialog.h" #include "phoneeditwidget.h" #include "secrecywidget.h" #include <qtoolbutton.h> #include <qtooltip.h> #include <kapplication.h> #include <kconfig.h> #include <kcombobox.h> #include <kdebug.h> #include <kdialogbase.h> #include <kglobal.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> #include <kseparator.h> #include <ksqueezedtextlabel.h> #include <libkdepim/categoryeditdialog.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/kdateedit.h> #include "addresseditwidget.h" #include "emaileditwidget.h" #include "kabcore.h" #include "kabprefs.h" #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() { kdDebug(5720) << "~AddresseeEditorWidget()" << endl; } void AddresseeEditorWidget::contactsSelectionChanged() { KABC::Addressee::List list = selectedContacts(); mAddressee = list[ 0 ]; load(); } void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) { mAddressee = addr; load(); } const KABC::Addressee &AddresseeEditorWidget::addressee() { return mAddressee; } void AddresseeEditorWidget::textChanged( const QString& ) { emitModified(); } void AddresseeEditorWidget::initGUI() { QVBoxLayout *layout = new QVBoxLayout( this ); mTabWidget = new QTabWidget( this ); layout->addWidget( mTabWidget ); setupTab1(); setupTab1_1(); setupTab2(); setupTab2_1(); setupTab3(); setupTab3_1(); mNameEdit->setFocus(); connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), SLOT( pageChanged(QWidget*) ) ); } void AddresseeEditorWidget::setupTab1() { // This is the General tab QWidget *tab1 = new QWidget( mTabWidget ); //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); QLabel *label; KSeparator* bar; QPushButton *button; ////////////////////////////////// // Upper left group (person info) // Person icon /* LR label = new QLabel( tab1 ); //US ambiguous call. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); layout->addMultiCellWidget( label, 0, 1, 0, 0 ); */ // First name button = new QPushButton( i18n( "Name..." ), tab1 ); //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); mNameEdit = new KLineEdit( tab1, "mNameEdit" ); connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( nameTextChanged( const QString& ) ) ); connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); mNameLabel = new KSqueezedTextLabel( tab1 ); mNameLabel->hide(); @@ -539,192 +538,193 @@ void AddresseeEditorWidget::setupTab2() QLabel *label; KSeparator* bar; /////////////////////// // Office info // Department label = new QLabel( tab2 ); //US loadIcon call is ambiguous. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); layout->addMultiCellWidget( label, 0, 1, 0, 0 ); label = new QLabel( i18n( "Department:" ), tab2 ); layout->addWidget( label, 0, 1 ); mDepartmentEdit = new KLineEdit( tab2 ); connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mDepartmentEdit ); layout->addWidget( mDepartmentEdit, 0, 2 ); label = new QLabel( i18n( "Office:" ), tab2 ); layout->addWidget( label, 1, 1 ); mOfficeEdit = new KLineEdit( tab2 ); connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mOfficeEdit ); layout->addWidget( mOfficeEdit, 1, 2 ); label = new QLabel( i18n( "Profession:" ), tab2 ); layout->addWidget( label, 2, 1 ); mProfessionEdit = new KLineEdit( tab2 ); connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mProfessionEdit ); layout->addWidget( mProfessionEdit, 2, 2 ); label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); //US layout->addWidget( label, 0, 3 ); layout->addWidget( label, 3, 1 ); mManagerEdit = new KLineEdit( tab2 ); connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mManagerEdit ); //US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); layout->addWidget( mManagerEdit, 3, 2 ); label = new QLabel( i18n( "Assistant's name:" ), tab2 ); //US layout->addWidget( label, 1, 3 ); layout->addWidget( label, 4, 1 ); mAssistantEdit = new KLineEdit( tab2 ); connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mAssistantEdit ); //US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); layout->addWidget( mAssistantEdit, 4, 2 ); bar = new KSeparator( KSeparator::HLine, tab2 ); //US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); ///////////////////////////////////////////////// // Personal info label = new QLabel( tab2 ); //US loadIcon call is ambiguous. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); //US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); layout->addMultiCellWidget( label, 6, 7, 0, 0 ); label = new QLabel( i18n( "Nick name:" ), tab2 ); //US layout->addWidget( label, 4, 1 ); layout->addWidget( label, 6, 1 ); mNicknameEdit = new KLineEdit( tab2 ); connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mNicknameEdit ); //US layout->addWidget( mNicknameEdit, 4, 2 ); layout->addWidget( mNicknameEdit, 6, 2 ); label = new QLabel( i18n( "Spouse's name:" ), tab2 ); //US layout->addWidget( label, 5, 1 ); 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 label->setBuddy( mBirthdayPicker ); //US layout->addWidget( mBirthdayPicker, 4, 4 ); layout->addWidget( mBirthdayPicker, 8, 2 ); label = new QLabel( i18n( "Anniversary:" ), tab2 ); //US layout->addWidget( label, 5, 3 ); layout->addWidget( label, 9, 1 ); mAnniversaryPicker = new KDateEdit( tab2 ); mAnniversaryPicker->setHandleInvalid( true ); connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), SLOT( dateChanged( QDate ) ) ); #ifndef KAB_EMBEDDED //US invalid dates are handled by the KDateEdit widget itself connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), SLOT( invalidDate() ) ); connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), SLOT( emitModified() ) ); #endif //KAB_EMBEDDED label->setBuddy( mAnniversaryPicker ); //US layout->addWidget( mAnniversaryPicker, 5, 4 ); layout->addWidget( mAnniversaryPicker, 9, 2 ); /*US bar = new KSeparator( KSeparator::HLine, tab2 ); layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); ////////////////////////////////////// // Notes label = new QLabel( i18n( "Note:" ), tab2 ); label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); layout->addWidget( label, 7, 0 ); #ifndef KAB_EMBEDDED mNoteEdit = new QTextEdit( tab2 ); mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); #else //KAB_EMBEDDED mNoteEdit = new QMultiLineEdit( tab2 ); //US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); //US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); qDebug("AddresseeEditorWidget::setupTab2 has to be changed"); #endif //KAB_EMBEDDED connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); label->setBuddy( mNoteEdit ); layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); */ // Build the layout and add to the tab widget layout->activate(); // required mTabWidget->addTab( tab2, i18n( "&Details" ) ); } void AddresseeEditorWidget::setupTab2_1() { // This is the Details tab QWidget *tab2_2 = new QWidget( mTabWidget ); QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); layout->setMargin( KDialogBase::marginHintSmall() ); layout->setSpacing( KDialogBase::spacingHintSmall() ); QLabel *label; KSeparator* bar; /*US /////////////////////// // Office info // Department label = new QLabel( tab2 ); //US loadIcon call is ambiguous. Add one more parameter //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); layout->addMultiCellWidget( label, 0, 1, 0, 0 ); label = new QLabel( i18n( "Department:" ), tab2 ); layout->addWidget( label, 0, 1 ); mDepartmentEdit = new KLineEdit( tab2 ); connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), SLOT( textChanged( const QString& ) ) ); label->setBuddy( mDepartmentEdit ); layout->addWidget( mDepartmentEdit, 0, 2 ); @@ -854,415 +854,441 @@ void AddresseeEditorWidget::setupTab3() 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; + 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; } // 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() { + + 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 ); } 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 ( 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. 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 diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index d781f67..4230c07 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -1,169 +1,184 @@ #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #include <stdlib.h> #else #include <qapplication.h> #include <qwindowsstyle.h> #include <qplatinumstyle.h> #include <qmainwindow.h> #endif #include <kstandarddirs.h> #include <kglobal.h> #include <stdio.h> #include <qdir.h> #include "kaddressbookmain.h" #include "externalapphandler.h" int main( int argc, char **argv ) { #ifndef DESKTOP_VERSION QPEApplication a( argc, argv ); a.setKeepRunning (); #else QApplication a( argc, argv ); QApplication::setStyle( new QPlatinumStyle ()); QString hdir = QDir::homeDirPath(); // there is a bug when creating dirs for WIN 98 // it is difficult to fix, because we have no WIN 98 runnung // such that we try it to create the dirs at startup here if ( hdir == "C:\\" ) { // win 98 or ME QDir app_dir; if ( !app_dir.exists("C:\\kdepim") ) app_dir.mkdir ("C:\\kdepim"); if ( !app_dir.exists("C:\\kdepim\\apps") ) app_dir.mkdir ("C:\\kdepim\\apps"); if ( !app_dir.exists("C:\\kdepim\\config") ) app_dir.mkdir ("C:\\kdepim\\config"); if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); } #endif bool exitHelp = false; if ( argc > 1 ) { QString command = argv[1]; if ( command == "-help" ){ printf("KA/E command line commands:\n"); printf(" no command: Start KA/E in usual way\n"); printf(" -help: This output\n"); printf(" KA/E is exiting now. Bye!\n"); exitHelp = true; } } if ( ! exitHelp ) { KGlobal::setAppName( "kaddressbook" ); #ifndef DESKTOP_VERSION if ( QApplication::desktop()->width() > 320 ) KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); else KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); #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! "); } /* #include <stdlib.h> #include <qstring.h> #include <kabc/stdaddressbook.h> #include <kaboutdata.h> #include <kcmdlineargs.h> #include <kcrash.h> #include <kdebug.h> #include <klocale.h> #include <kstartupinfo.h> #include <kuniqueapplication.h> #include <kwin.h> #include "kaddressbookmain.h" #include "kabcore.h" extern "C" { void crashHandler( int ) { KABC::StdAddressBook::handleCrash(); ::exit( 0 ); } } class KAddressBookApp : public KUniqueApplication { public: KAddressBookApp() : mMainWin( 0 ) {} ~KAddressBookApp() {} int newInstance(); private: KAddressBookMain *mMainWin; }; int KAddressBookApp::newInstance() { if ( isRestored() ) { // There can only be one main window if ( KMainWindow::canBeRestored( 1 ) ) { mMainWin = new KAddressBookMain; mMainWin->show(); mMainWin->restore( 1 ); } } else { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString addrStr = args->getOption( "addr" ); QCString uidStr = args->getOption( "uid" ); QString addr; QString uid; if ( !addrStr.isEmpty() ) addr = QString::fromLocal8Bit( addrStr ); if ( !uidStr.isEmpty() ) uid = QString::fromLocal8Bit( uidStr ); if ( args->isSet( "editor-only" ) ) { if ( !mMainWin ) mMainWin = new KAddressBookMain; KStartupInfo::appStarted(); mMainWin->hide(); } else { if ( mMainWin ) { mMainWin->show(); KWin::setActiveWindow( mMainWin->winId() ); } else { mMainWin = new KAddressBookMain; mMainWin->show(); } } // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do if ( !addr.isEmpty() ) mMainWin->addEmail( addr ); if ( !uid.isEmpty() ) mMainWin->showContactEditor( uid ); if ( args->isSet( "new-contact" ) ) { mMainWin->newContact(); diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index fb7eb22..8213c2b 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp @@ -16,261 +16,258 @@ 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 <qlabel.h> #include <qlistbox.h> #include <qlistview.h> #include <qtooltip.h> #include <qpushbutton.h> #include <qcheckbox.h> #include <qstring.h> #ifndef KAB_EMBEDDED #include <kaccelmanager.h> #else //KAB_EMBEDDED #include <kstandarddirs.h> #endif //KAB_EMBEDDED #include <kapplication.h> #include <kbuttonbox.h> #include <kconfig.h> #include <klineedit.h> #include <klistview.h> #include <kcombobox.h> #include <klocale.h> #include <kglobal.h> #include <kdebug.h> #include <kiconloader.h> #include <kmessagebox.h> #include "nameeditdialog.h" NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, QWidget *parent, const char *name ) : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, Ok, parent, name, true ) { QWidget *page = plainPage(); QGridLayout *layout = new QGridLayout( page, 5, 3 ); layout->setSpacing( spacingHint() ); layout->addColSpacing( 2, 100 ); QLabel *label; label = new QLabel( i18n( "Honorific prefixes:" ), page ); layout->addWidget( label, 0, 0 ); mPrefixCombo = new KComboBox( page ); mPrefixCombo->setDuplicatesEnabled( false ); mPrefixCombo->setEditable( true ); label->setBuddy( mPrefixCombo ); layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); label = new QLabel( i18n( "Given name:" ), page ); layout->addWidget( label, 1, 0 ); mGivenNameEdit = new KLineEdit( page ); label->setBuddy( mGivenNameEdit ); layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); label = new QLabel( i18n( "Additional names:" ), page ); layout->addWidget( label, 2, 0 ); mAdditionalNameEdit = new KLineEdit( page ); label->setBuddy( mAdditionalNameEdit ); layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); label = new QLabel( i18n( "Family names:" ), page ); layout->addWidget( label, 3, 0 ); mFamilyNameEdit = new KLineEdit( page ); label->setBuddy( mFamilyNameEdit ); layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); label = new QLabel( i18n( "Honorific suffixes:" ), page ); layout->addWidget( label, 4, 0 ); mSuffixCombo = new KComboBox( page ); mSuffixCombo->setDuplicatesEnabled( false ); mSuffixCombo->setEditable( true ); label->setBuddy( mSuffixCombo ); layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); mFormattedNameCombo = new KComboBox( page ); 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" ); QStringList sTitle; sTitle += i18n( "Dr." ); sTitle += i18n( "Miss" ); sTitle += i18n( "Mr." ); sTitle += i18n( "Mrs." ); sTitle += i18n( "Ms." ); sTitle += i18n( "Prof." ); sTitle += config.readListEntry( "Prefixes" ); sTitle.sort(); QStringList sSuffix; sSuffix += i18n( "I" ); sSuffix += i18n( "II" ); sSuffix += i18n( "III" ); sSuffix += i18n( "Jr." ); sSuffix += i18n( "Sr." ); sSuffix += config.readListEntry( "Suffixes" ); sSuffix.sort(); mPrefixCombo->insertStringList( sTitle ); mSuffixCombo->insertStringList( sSuffix ); #ifndef KAB_EMBEDDED mPrefixCombo->setCurrentText( addr.prefix() ); mSuffixCombo->setCurrentText( addr.suffix() ); #else //KAB_EMBEDDED mPrefixCombo->setEditText( addr.prefix() ); mSuffixCombo->setEditText( addr.suffix() ); #endif //KAB_EMBEDDED AddresseeConfig::instance()->setUid( addr.uid() ); mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); #ifndef KAB_EMBEDDED KAcceleratorManager::manage( this ); #endif //KAB_EMBEDDED connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 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(); } QString NameEditDialog::givenName() const { return mGivenNameEdit->text(); } QString NameEditDialog::prefix() const { return mPrefixCombo->currentText(); } QString NameEditDialog::suffix() const { return mSuffixCombo->currentText(); } QString NameEditDialog::additionalName() const { return mAdditionalNameEdit->text(); } QString NameEditDialog::customFormattedName() const { return mFormattedNameEdit->text(); } int NameEditDialog::formattedNameType() const { return mFormattedNameCombo->currentItem(); } bool NameEditDialog::changed() const { return mChanged; } QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) { switch ( type ) { case SimpleName: return addr.givenName() + " " + addr.familyName(); break; case FullName: return addr.prefix() + " " + addr.givenName() + " " + addr.additionalName() + " " + addr.familyName() + " " + addr.suffix(); break; case ReverseName: return addr.familyName() + ", " + addr.givenName(); break; default: return ""; break; } } void NameEditDialog::parseBoxChanged( bool value ) { //AddresseeConfig::instance()->setUid( addr.uid() ); AddresseeConfig::instance()->setAutomaticNameParsing( value ); } void NameEditDialog::typeChanged( int pos ) { mFormattedNameEdit->setEnabled( pos == 0 ); } void NameEditDialog::modified() { mChanged = true; } void NameEditDialog::updateTypeCombo() { KABC::Addressee addr; addr.setPrefix( mPrefixCombo->currentText() ); addr.setGivenName( mGivenNameEdit->text() ); addr.setAdditionalName( mAdditionalNameEdit->text() ); addr.setFamilyName( mFamilyNameEdit->text() ); addr.setSuffix( mSuffixCombo->currentText() ); int pos = mFormattedNameCombo->currentItem(); mFormattedNameCombo->clear(); diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index ed591fc..c3a1627 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -1,135 +1,137 @@ // CHANGED 2004-09-31 Lutz Rogowski #include "genericwrapper.h" #include <libetpan/libetpan.h> #include "mailtypes.h" #include <kconfig.h> #include <kglobal.h> #include <kstandarddirs.h> using namespace Opie::Core; Genericwrapper::Genericwrapper() : AbstractMail() { bodyCache.clear(); m_storage = 0; m_folder = 0; } Genericwrapper::~Genericwrapper() { if (m_folder) { mailfolder_free(m_folder); } if (m_storage) { mailstorage_free(m_storage); } cleanMimeCache(); } QString Genericwrapper::parseDateTime( mailimf_date_time *date ) { static bool init = false ; if ( ! init ) { 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)") ); init = true; } QDate da (date->dt_year,date->dt_month, date->dt_day ); QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); QDateTime dt ( da ,ti ); int off = KGlobal::locale()->localTimeOffset( dt ); //dt = dt.addSecs( off*60 ); QString ret; if ( da == QDate::currentDate () ) ret = KGlobal::locale()->formatTime( ti,true); else { ret = KGlobal::locale()->formatDateTime( dt,true,true); } #if 0 if ( off < 0 ) ret += " -"; else ret += " +"; ret += QString::number( off / 60 ); ret += "h"; #endif #if 0 char tmp[23]; // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); return QString( tmp ); #endif return ret; } void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) { if (!mime) { return; } mailmime_field*field = 0; mailmime_single_fields fields; memset(&fields, 0, sizeof(struct mailmime_single_fields)); if (mime->mm_mime_fields != NULL) { mailmime_single_fields_init(&fields, mime->mm_mime_fields, mime->mm_content_type); } mailmime_content*type = fields.fld_content; clistcell*current; if (!type) { target->setType("text"); target->setSubtype("plain"); } else { target->setSubtype(type->ct_subtype); switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { case MAILMIME_DISCRETE_TYPE_TEXT: target->setType("text"); break; case MAILMIME_DISCRETE_TYPE_IMAGE: target->setType("image"); break; case MAILMIME_DISCRETE_TYPE_AUDIO: target->setType("audio"); break; case MAILMIME_DISCRETE_TYPE_VIDEO: target->setType("video"); break; case MAILMIME_DISCRETE_TYPE_APPLICATION: target->setType("application"); break; case MAILMIME_DISCRETE_TYPE_EXTENSION: default: if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); } break; } if (type->ct_parameters) { fillParameters(target,type->ct_parameters); } } if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { field = (mailmime_field*)current->data; switch(field->fld_type) { case MAILMIME_FIELD_TRANSFER_ENCODING: target->setEncoding(getencoding(field->fld_data.fld_encoding)); diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index d5d31e2..258bd43 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1167,196 +1167,198 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->addEvent( eventRSync ); QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); QString delmess; if ( delFut ) { delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); mes += delmess; } if ( KOPrefs::instance()->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); mCalendar->checkAlarmForIncidence( 0, true ); return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { mCurrentSyncName= s; } bool CalendarView::syncCalendar(QString filename, int mode) { mGlobalSyncMode = SYNC_MODE_NORMAL; CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); FileStorage* storage = new FileStorage( calendar ); bool syncOK = false; storage->setFileName( filename ); // qDebug("loading ... "); if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); storage->save(); } } setModified( true ); } delete storage; delete calendar; if ( syncOK ) updateView(); return syncOK; } void CalendarView::syncPhone() { syncExternal( 1 ); } void CalendarView::syncExternal( int mode ) { mGlobalSyncMode = SYNC_MODE_EXTERNAL; //mCurrentSyncDevice = "sharp-DTM"; if ( KOPrefs::instance()->mAskForPreferences ) edit_sync_options(); qApp->processEvents(); CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); bool syncOK = false; bool loadSuccess = false; PhoneFormat* phoneFormat = 0; #ifndef DESKTOP_VERSION SharpFormat* sharpFormat = 0; if ( mode == 0 ) { // sharp sharpFormat = new SharpFormat () ; loadSuccess = sharpFormat->load( calendar, mCalendar ); } else #endif if ( mode == 1 ) { // phone phoneFormat = new PhoneFormat (mCurrentSyncDevice, KOPrefs::instance()->mPhoneDevice, KOPrefs::instance()->mPhoneConnection, KOPrefs::instance()->mPhoneModel); loadSuccess = phoneFormat->load( calendar,mCalendar); } else return; if ( loadSuccess ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); + if ( phoneFormat ) { while ( inc ) { inc->removeID(mCurrentSyncDevice); inc = iL.next(); } + } #ifndef DESKTOP_VERSION if ( sharpFormat ) sharpFormat->save(calendar); #endif if ( phoneFormat ) phoneFormat->save(calendar); iL = calendar->rawIncidences(); inc = iL.first(); Incidence* loc; while ( inc ) { if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { loc = mCalendar->incidence(inc->uid() ); if ( loc ) { loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); } } inc = iL.next(); } Incidence* lse = getLastSyncEvent(); if ( lse ) { lse->setReadOnly( false ); lse->setDescription( "" ); lse->setReadOnly( true ); } } } setModified( true ); } else { QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), question, i18n("Ok")) ; } delete calendar; updateView(); return ;//syncOK; } void CalendarView::syncSharp() { syncExternal( 0 ); } #include <kabc/stdaddressbook.h> bool CalendarView::importBday() { KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; int count = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); bar.setCaption (i18n("Reading addressbook - close to abort!") ); qApp->processEvents(); count = 0; int addCount = 0; KCal::Attendee* a = 0; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { if ( ! bar.isVisible() ) return false; bar.setProgress( count++ ); qApp->processEvents(); //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); if ( (*it).birthday().date().isValid() ){ a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) ++addCount; } QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); if ( anni.isValid() ){ a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) ++addCount; } } updateView(); topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); return true; } bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) { //qDebug("addAnni "); Event * ev = new Event(); diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp index d710541..5c69010 100644 --- a/libkdepim/addresseeview.cpp +++ b/libkdepim/addresseeview.cpp @@ -1,223 +1,229 @@ /* This file is part of libkdepim. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kabc/address.h> #include <kabc/addressee.h> #include <kabc/phonenumber.h> #include <kglobal.h> //US#include <kglobalsettings.h> #include <kiconloader.h> #include <klocale.h> //US #include <kstringhandler.h> #include <qscrollview.h> #include <qregexp.h> #include <qfile.h> #include <qapplication.h> #include "externalapphandler.h" #include "addresseeview.h" //US #ifndef DESKTOP_VERSION //US #include <qtopia/qcopenvelope_qws.h> //US #include <qpe/qpeapplication.h> //US #endif //US static int kphoneInstalled = 0; using namespace KPIM; AddresseeView::AddresseeView( QWidget *parent, const char *name ) //US : KTextBrowser( parent, name ) : QTextBrowser( parent, name ) { //US setWrapPolicy( QTextEdit::AtWordBoundary ); setLinkUnderline( false ); // setVScrollBarMode( QScrollView::AlwaysOff ); //setHScrollBarMode( QScrollView::AlwaysOff ); //US QStyleSheet *sheet = styleSheet(); //US QStyleSheetItem *link = sheet->item( "a" ); //US link->setColor( KGlobalSettings::linkColor() ); } void AddresseeView::setSource(const QString& n) { - qDebug("********AddresseeView::setSource %s", n.latin1()); + //qDebug("********AddresseeView::setSource %s", n.latin1()); if ( n.left( 6 ) == "mailto" ) ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); else if ( n.left( 7 ) == "phoneto" ) ExternalAppHandler::instance()->callByPhone( n.mid(8) ); else if ( n.left( 5 ) == "faxto" ) ExternalAppHandler::instance()->callByFax( n.mid(6) ); else if ( n.left( 5 ) == "smsto" ) ExternalAppHandler::instance()->callBySMS( n.mid(6) ); else if ( n.left( 7 ) == "pagerto" ) ExternalAppHandler::instance()->callByPager( n.mid(8) ); } void AddresseeView::setAddressee( const KABC::Addressee& addr ) { ExternalAppHandler* eah = ExternalAppHandler::instance(); bool kemailAvail = eah->isEmailAppAvailable(); bool kphoneAvail = eah->isPhoneAppAvailable(); bool kfaxAvail = eah->isFaxAppAvailable(); bool ksmsAvail = eah->isSMSAppAvailable(); bool kpagerAvail = eah->isPagerAppAvailable(); mAddressee = addr; // clear view setText( QString::null ); if ( mAddressee.isEmpty() ) return; QString name = ( mAddressee.assembledName().isEmpty() ? mAddressee.formattedName() : mAddressee.assembledName() ); QString dynamicPart; QStringList emails = mAddressee.emails(); QStringList::ConstIterator emailIt; QString type = i18n( "Email" ); emailIt = emails.begin(); if ( emailIt != emails.end() ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) .arg( type ) .arg( name ) .arg( *emailIt ) .arg( *emailIt ); ++emailIt; } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( type ) .arg( *emailIt ); ++emailIt; } } - + if ( mAddressee.birthday().date().isValid() ) { + dynamicPart += QString( + "<tr><td align=\"right\"><b>%1</b></td>" + "<td align=\"left\">%2</td></tr>" ) + .arg( i18n ("Birthday") ) + .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); + } KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); KABC::PhoneNumber::List::ConstIterator phoneIt; QString extension; int phonetype; QString sms; for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { phonetype = (*phoneIt).type(); if (ksmsAvail && ( ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) ) ) { sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) .arg( (*phoneIt).number() ); } else sms = ""; extension = QString::null; if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { if (kfaxAvail) extension = "faxto:"; } else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { if (kpagerAvail) extension = "pagerto:"; } else if (kphoneAvail) { extension = "phoneto:"; } else extension = QString::null; if ( !extension.isEmpty() ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) .arg( extension ) .arg( (*phoneIt).number() ) .arg( (*phoneIt).number() ) .arg( sms ); } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2 %3</td></tr>" ) .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) .arg( (*phoneIt).number() ) .arg( sms ); } } for ( ; emailIt != emails.end(); ++emailIt ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) .arg( type ) .arg( name ) .arg( *emailIt ) .arg( *emailIt ); } else { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( type ) .arg( *emailIt ); } } if ( !mAddressee.url().url().isEmpty() ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Homepage" ) ) //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); .arg( mAddressee.url().url() ); //qDebug("AddresseeView::setAddressee has to be verified."); } KABC::Address::List addresses = mAddressee.addresses(); KABC::Address::List::ConstIterator addrIt; for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { if ( true /*(*addrIt).label().isEmpty()*/ ) { QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); //qDebug("adresss %s ",formattedAddress.latin1() ); formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); //qDebug("AddresseeView::setAddressee has to be verified."); dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp index 5fb948a..c4c0081 100644 --- a/libkdepim/kdateedit.cpp +++ b/libkdepim/kdateedit.cpp @@ -31,193 +31,199 @@ #include <kdatepicker.h> #include <kdebug.h> #include <kglobal.h> #include <kiconloader.h> #include <klocale.h> #include <kmessagebox.h> #include <knotifyclient.h> #include <qpalette.h> #include "kdateedit.h" //#include "kdateedit.moc" KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) : QHBox(parent, name) { dateFormShort = true; withoutDp = withoutDP; mDateEdit = new QLineEdit(this); mDateEdit->setText(KGlobal::locale()->formatDate(QDate::currentDate(),dateFormShort)); setFocusProxy(mDateEdit); mDateEdit->installEventFilter(this); // Highlight Background and Textcolor QPalette palette = QWidget::palette(); unsigned char red, green, blue; red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); mDateEdit->setPalette( palette ); if ( withoutDP ) { mDateFrame = 0; mDateButton = 0; mDatePicker = 0; } else { QPixmap pixmap = SmallIcon("smallcal"); mDateButton = new QPushButton(this); mDateButton->setPixmap(pixmap); mDateFrame = new QVBox(0,0,WType_Popup); // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); mDateFrame->setLineWidth(3); mDateFrame->hide(); mDatePicker = new KDatePicker(mDateFrame,QDate::currentDate()); connect(mDatePicker,SIGNAL(dateEntered(QDate)),SLOT(setDate(QDate))); connect(mDatePicker,SIGNAL(dateEntered(QDate)),SIGNAL(dateChanged(QDate))); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(setDate(QDate))); connect(mDatePicker,SIGNAL(dateSelected(QDate)),SIGNAL(dateChanged(QDate))); connect(mDatePicker,SIGNAL(dateSelected(QDate)),mDateFrame,SLOT(hide())); connect(mDateButton,SIGNAL(clicked()),SLOT(toggleDatePicker())); //mDateFrame->resize( 400, 300 ); } connect(mDateEdit,SIGNAL(returnPressed()),SLOT(lineEnterPressed())); connect(mDateEdit,SIGNAL(textChanged(const QString &)), SLOT(textChanged(const QString &))); // Create the keyword list. This will be used to match against when the user // enters information. mKeywordMap[i18n("tomorrow")] = 1; mKeywordMap[i18n("today")] = 0; mKeywordMap[i18n("yesterday")] = -1; /* * This loop uses some math tricks to figure out the offset in days * to the next date the given day of the week occurs. There * are two cases, that the new day is >= the current day, which means * the new day has not occured yet or that the new day < the current day, * which means the new day is already passed (so we need to find the * day in the next week). */ QString dayName; int currentDay = QDate::currentDate().dayOfWeek(); for (int i = 1; i <= 7; ++i) { dayName = KGlobal::locale()->weekDayName(i).lower(); if (i >= currentDay) mKeywordMap[dayName] = i - currentDay; else mKeywordMap[dayName] = 7 - currentDay + i; } mTextChanged = false; mHandleInvalid = false; QWidget::setTabOrder( mDateEdit, mDateButton ); } KDateEdit::~KDateEdit() { delete mDateFrame; } - +void KDateEdit::clear() +{ + bool b = mDateEdit->signalsBlocked(); + mDateEdit->blockSignals(true); + mDateEdit->setText(""); + mDateEdit->blockSignals(b); +} void KDateEdit::setDate(QDate newDate) { if (!newDate.isValid() && !mHandleInvalid) return; if ( readDate() == newDate ) return; QString dateString = ""; if(newDate.isValid()) dateString = KGlobal::locale()->formatDate( newDate, dateFormShort ); mTextChanged = false; // We do not want to generate a signal here, since we explicity setting // the date bool b = mDateEdit->signalsBlocked(); mDateEdit->blockSignals(true); mDateEdit->setText(dateString); mDateEdit->blockSignals(b); } void KDateEdit::setDate( QDate date,int *cpos,const int key ,const bool dateFormShort) { QString dateForm = dateFormShort ? KGlobal::locale()->dateFormatShort() : KGlobal::locale()->dateFormat(); int begin = dateForm.find("%"); int space = 0; int allStrLength = 0; int strLength = 0; int repeat = 0; // witch? Day, Month or Year switch? while(1){ switch ( dateForm.at(begin + 1).latin1() ) { case 'd':// 16 (month day) strLength = 2; //Ok break; case 'm':// 01 (month) strLength = 2; //Ok break; case 'a':// Mon (Weekday) strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); break; case 'A':// Monday (Weekday) strLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); break; case 'b':// Jan (monthName) strLength = KGlobal::locale()->monthName(date.month(), true).length(); break; case 'B':// January (monthName) strLength = KGlobal::locale()->monthName(date.month(), false).length(); break; case 'y':// 04 (year short) strLength = 2; //Ok break; case 'Y':// 2004 (year) strLength = 4; //Ok break; default: break; } space = begin - (repeat++ * 2); // all select? then dayswitch if( (mDateEdit->text().length() == mDateEdit->markedText().length() ) && ( (dateForm.at(begin + 1).latin1() == 'd') || (dateForm.at(begin + 1).latin1() == 'a') || (dateForm.at(begin + 1).latin1() == 'A') ) ) { break; } // mDateEdit-StringPos == CursorPosition(cpos) then break and set date if( ( (space + allStrLength) <= *cpos && *cpos <= (space + allStrLength + strLength) ) || *cpos < begin ) { break; } allStrLength += strLength; begin = dateForm.find("%", begin +1); } // set date switch ( dateForm.at(begin + 1).latin1() ) { case 'd': case 'a': case 'A': if(key == Key_Up) { setDate( date.addDays( 1 ) ); } else if(key == Key_Down) { setDate( date.addDays( -1 ) ); } maxDay = readDate().day(); break; case 'm': case 'b': case 'B': if(key == Key_Up) { @@ -370,117 +376,122 @@ void KDateEdit::setSelect( int from, int to ) { // return; mDateEdit->setSelection( from , to ); } void KDateEdit::toggleDatePicker() { if( mDateFrame->isVisible() ) { mDateFrame->hide(); } else { QPoint tmpPoint = mapToGlobal(mDateButton->geometry().bottomRight()); QSize datepickersize = mDatePicker->sizeHint(); if ( tmpPoint.x() < 7+datepickersize.width() ) tmpPoint.setX( 7+datepickersize.width() ); int h = QApplication::desktop()->height(); if ( tmpPoint.y() + datepickersize.height() > h ) tmpPoint.setY( h - datepickersize.height() ); mDateFrame->setGeometry(tmpPoint.x()-datepickersize.width()-7, tmpPoint.y(), datepickersize.width()+2*mDateFrame->lineWidth(), datepickersize.height()+2*mDateFrame->lineWidth()); QDate date = readDate(); if(date.isValid()) { mDatePicker->setDate(date); } else { mDatePicker->setDate(QDate::currentDate()); } mDateFrame->show(); } } void KDateEdit::lineEnterPressed() { QDate date = readDate(); if(date.isValid()) { // Update the edit. This is needed if the user has entered a // word rather than the actual date. setDate(date); emit(dateChanged(date)); emit returnPressed(); } else { if ( withoutDp ) { KNotifyClient::beep(); } else { if ( !mDateEdit->text().isEmpty() ) { mTextChanged = false; QString text = i18n( "You entered an invalid date!\n Will use current date instead." ); if ( KMessageBox::warningContinueCancel( 0, text ) == KMessageBox::Continue ) { setDate( QDate::currentDate() ); emit dateChanged( QDate::currentDate() ); } } } } } bool KDateEdit::inputIsValid() { return readDate().isValid(); } QDate KDateEdit::readDate() const { QString text = mDateEdit->text(); QDate date; if (mKeywordMap.contains(text.lower())) { date = QDate::currentDate().addDays(mKeywordMap[text.lower()]); } else { date = KGlobal::locale()->readDate(text); } return date; } bool KDateEdit::eventFilter(QObject *, QEvent *e) { // We only process the focus out event if the text has changed // since we got focus if ((e->type() == QEvent::FocusOut) && mTextChanged) { lineEnterPressed(); mTextChanged = false; } // switch dateFormShort by double klick with mouse else if (e->type() == QEvent::MouseButtonDblClick) { - dateFormShort = dateFormShort?false:true; - mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort)); + toggleDateFormat(); } else if (e->type() == QEvent::FocusIn) { maxDay = readDate().day(); } return false; } +void KDateEdit::toggleDateFormat() +{ + dateFormShort = ! dateFormShort; + mDateEdit->setText(KGlobal::locale()->formatDate(readDate(),dateFormShort)); + +} void KDateEdit::textChanged(const QString &) { if(mHandleInvalid && mDateEdit->text().stripWhiteSpace().isEmpty()) { QDate date; //invalid date emit(dateChanged(date)); } else { mTextChanged = true; } maxDay = readDate().day(); } diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h index 742d843..cf3b90a 100644 --- a/libkdepim/kdateedit.h +++ b/libkdepim/kdateedit.h @@ -1,140 +1,141 @@ /* This file is part of libkdepim. Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 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., 675 Mass Ave, Cambridge, MA 02139, 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. */ #ifndef KDATEEDIT_H #define KDATEEDIT_H #include <qhbox.h> #include <qvbox.h> #include <qdatetime.h> #include <qmap.h> class QLineEdit; class QPushButton; class QObject; class QEvent; class KDatePicker; class KDateValidator; /** * A date editing widget that consists of a line edit followed by * a small push button. The line edit contains the date in text form, * and the push button will display a 'popup' style date picker. * * This widget also supports advanced features like allowing the user * to type in the day name to get the date. The following keywords * are supported (in the native language): tomorrow, yesturday, today, * monday, tuesday, wednesday, thursday, friday, saturday, sunday. * * @author Cornelius Schumacher <schumacher@kde.org> * @author Mike Pilone <mpilone@slac.com> */ class KDateEdit : public QHBox { Q_OBJECT public: KDateEdit(QWidget *parent=0, const char *name=0, bool withoutDP = false ); virtual ~KDateEdit(); /** @return True if the date in the text edit is valid, * false otherwise. This will not modify the display of the date, * but only check for validity. */ bool inputIsValid(); /** @return The date entered. This will not * modify the display of the date, but only return it. */ QDate date() const; /** @param handleInvalid If true the date edit accepts invalid dates * and displays them as the empty ("") string. It also returns an invalid date. * If false (default) invalid dates are not accepted and instead the date * of today will be returned. */ void setHandleInvalid(bool handleInvalid); /** Checks for a focus out event. The display of the date is updated * to display the proper date when the focus leaves. */ virtual bool eventFilter(QObject *o, QEvent *e); - + void toggleDateFormat(); + void clear(); signals: /** This signal is emitted whenever the user modifies the date. This * may not get emitted until the user presses enter in the line edit or * focus leaves the widget (ie: the user confirms their selection). */ void dateChanged(QDate); void returnPressed(); public slots: /** Sets the date. * * @param date The new date to display. This date must be valid or * it will not be displayed. */ void setDate(QDate date); // set Date with key_up key_down to relation of cursor Position // and set selection from begin to end of single date void setDate(QDate, int *cpos, const int, const bool); /** Sets the date edit to be enabled or disabled (grayed out) * * @param on Enabled if true, disabled if false */ void setEnabled(bool on); protected slots: void toggleDatePicker(); void lineEnterPressed(); void textChanged(const QString &); private: /** Reads the text from the line edit. If the text is a keyword, the * word will be translated to a date. If the text is not a keyword, the * text will be interpreted as a date. */ QDate readDate() const; /** Maps the text that the user can enter to the offset in days from * today. For example, the text 'tomorrow' is mapped to +1. */ QMap<QString, int> mKeywordMap; bool mTextChanged; bool mHandleInvalid; QPushButton *mDateButton; QLineEdit *mDateEdit; KDatePicker *mDatePicker; QVBox *mDateFrame; int maxDay; bool withoutDp; protected: virtual void keyPressEvent(QKeyEvent *qke); void setSelect ( int, int ); bool dateFormShort; char lengthMonthName; }; #endif diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp index 77d36a5..d38a6d5 100644 --- a/microkde/kdeui/kaction.cpp +++ b/microkde/kdeui/kaction.cpp @@ -119,193 +119,192 @@ KAction::KAction( const QString& text, const KShortcut& cut, : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); } KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, const QObject* receiver, const char* slot, KActionCollection* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); d->setIconName( sIconName ); } KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, const QObject* receiver, const char* slot, KActionCollection* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); d->setIconSet( pix ); } KAction::KAction( const KGuiItem& item, const KShortcut& cut, const QObject* receiver, const char* slot, KActionCollection* parent, const char* name ) : QObject( parent, name ) { initPrivate( item.text(), cut, receiver, slot ); if( item.hasIconSet() ) setIcon( item.iconName() ); setToolTip( item.toolTip() ); setWhatsThis( item.whatsThis() ); } // KDE 4: remove KAction::KAction( const QString& text, const KShortcut& cut, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, 0, 0 ); } KAction::KAction( const QString& text, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); } KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, 0, 0 ); setIconSet( pix ); } KAction::KAction( const QString& text, const QString& pix, const KShortcut& cut, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, 0, 0 ); d->setIconName( pix ); } KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); setIconSet( pix ); } KAction::KAction( const QString& text, const QString& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( text, cut, receiver, slot ); d->setIconName(pix); } KAction::KAction( QObject* parent, const char* name ) : QObject( parent, name ) { initPrivate( QString::null, KShortcut(), 0, 0 ); } // KDE 4: remove end KAction::~KAction() { - kdDebug(129) << "KAction::~KAction( this = \"" << name() << "\" )" << endl; // -- ellis #ifndef KDE_NO_COMPAT if (d->m_kaccel) unplugAccel(); #endif // If actionCollection hasn't already been destructed, if ( m_parentCollection ) { m_parentCollection->take( this ); for( uint i = 0; i < d->m_kaccelList.count(); i++ ) //US d->m_kaccelList[i]->remove( name() ); qDebug("KAction::KAction~ ...1 has top be fixed"); } // Do not call unplugAll from here, as tempting as it sounds. // KAction is designed around the idea that you need to plug // _and_ to unplug it "manually". Unplugging leads to an important // slowdown when e.g. closing the window, in which case we simply // want to destroy everything asap, not to remove actions one by one // from the GUI. delete d; d = 0; } void KAction::initPrivate( const QString& text, const KShortcut& cut, const QObject* receiver, const char* slot ) { d = new KActionPrivate; d->m_cutDefault = cut; //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); m_parentCollection = (KActionCollection *)( parent() ); kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; if ( m_parentCollection ) m_parentCollection->insert( this ); if ( receiver && slot ) connect( this, SIGNAL( activated() ), receiver, slot ); if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; d->setText( text ); initShortcut( cut ); } bool KAction::isPlugged() const { return (containerCount() > 0) || d->m_kaccel; } bool KAction::isPlugged( const QWidget *container ) const { return findContainer( container ) > -1; } bool KAction::isPlugged( const QWidget *container, int id ) const { int i = findContainer( container ); return ( i > -1 && itemId( i ) == id ); } bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const { int i = findContainer( container ); return ( i > -1 && representative( i ) == _representative ); } /* Three actionCollection conditions: 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow) 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient) a) addClient() will be called on object b) we just want to add the actions to another KXMLGUIClient object The question is how to do we incorporate #2b into the XMLGUI framework? We have a KCommandHistory object with undo and redo actions in a passed actionCollection We have a KoDoc object which holds a KCommandHistory object and the actionCollection We have two KoView objects which both point to the same KoDoc object Undo and Redo should be available in both KoView objects, and calling the undo->setEnabled() should affect both KoViews When addClient is called, it needs to be able to find the undo and redo actions When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts have the same scope as the KoView actionCollection KXMLGUIClient::addSubActionCollection Document: create document actions @@ -342,673 +341,674 @@ shortcut may be set: On Construction: [via initShortcut()] insert into KAccel of m_parentCollection, if kaccel() && isAutoConnectShortcuts() exists On Plug: [via plug() -> plugShortcut()] insert into KAccel of m_parentCollection, if exists and not already inserted into On Read XML: [via setShortcut()] set in all current KAccels insert into KAccel of m_parentCollection, if exists and not already inserted into */ KAccel* KAction::kaccelCurrent() { if( m_parentCollection && m_parentCollection->builderKAccel() ) return m_parentCollection->builderKAccel(); else if( m_parentCollection && m_parentCollection->kaccel() ) return m_parentCollection->kaccel(); else return 0L; } // Only to be called from initPrivate() bool KAction::initShortcut( const KShortcut& cut ) { d->m_cut = cut; // Only insert action into KAccel if it has a valid name, if( qstrcmp( name(), "unnamed" ) != 0 && m_parentCollection && m_parentCollection->isAutoConnectShortcuts() && m_parentCollection->kaccel() ) { insertKAccel( m_parentCollection->kaccel() ); return true; } return false; } // Only to be called from plug() void KAction::plugShortcut() { KAccel* kaccel = kaccelCurrent(); //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl; if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) { // Check if already plugged into current KAccel object for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { if( d->m_kaccelList[i] == kaccel ) return; } insertKAccel( kaccel ); } } bool KAction::setShortcut( const KShortcut& cut ) { qDebug("KAction::setShortcut~ ...1 has top be fixed"); /*US bool bChanged = (d->m_cut != cut); d->m_cut = cut; KAccel* kaccel = kaccelCurrent(); bool bInsertRequired = true; // Apply new shortcut to all existing KAccel objects for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { // Check whether shortcut has already been plugged into // the current kaccel object. if( d->m_kaccelList[i] == kaccel ) bInsertRequired = false; if( bChanged ) updateKAccelShortcut( d->m_kaccelList[i] ); } // Only insert action into KAccel if it has a valid name, if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) insertKAccel( kaccel ); if( bChanged ) { // KDE 4: remove if ( d->m_kaccel ) d->m_kaccel->setShortcut( name(), cut ); // KDE 4: remove end int len = containerCount(); for( int i = 0; i < len; ++i ) updateShortcut( i ); } */ return true; } bool KAction::updateKAccelShortcut( KAccel* kaccel ) { - qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); + //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); + // Check if action is permitted /*US if (kapp && !kapp->authorizeKAction(name())) return false; bool b = true; if ( !kaccel->actions().actionPtr( name() ) ) { if(!d->m_cut.isNull() ) { kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; b = kaccel->insert( name(), d->plainText(), QString::null, d->m_cut, this, SLOT(slotActivated()), isShortcutConfigurable(), isEnabled() ); } } else b = kaccel->setShortcut( name(), d->m_cut ); return b; */ return true; } void KAction::insertKAccel( KAccel* kaccel ) { - qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); + //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); + /*US //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; if ( !kaccel->actions().actionPtr( name() ) ) { if( updateKAccelShortcut( kaccel ) ) { d->m_kaccelList.append( kaccel ); connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); } } else kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis */ } void KAction::removeKAccel( KAccel* kaccel ) { - qDebug("KAction::removeKAccel~ ...1 has top be fixed"); + // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); + /*US //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { if( d->m_kaccelList[i] == kaccel ) { kaccel->remove( name() ); d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); break; } } */ } // KDE 4: remove void KAction::setAccel( int keyQt ) { setShortcut( KShortcut(keyQt) ); } // KDE 4: remove end void KAction::updateShortcut( int i ) { int id = itemId( i ); QWidget* w = container( i ); if ( w->inherits( "QPopupMenu" ) ) { QPopupMenu* menu = static_cast<QPopupMenu*>(w); updateShortcut( menu, id ); } else if ( w->inherits( "QMenuBar" ) ) //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); - qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); + + ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); } void KAction::updateShortcut( QPopupMenu* menu, int id ) { /*US //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; // If the action has a KAccel object, // show the string representation of its shortcut. if ( d->m_kaccel || d->m_kaccelList.count() ) { QString s = menu->text( id ); int i = s.find( '\t' ); if ( i >= 0 ) s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); else s += "\t" + d->m_cut.seq(0).toString(); menu->changeItem( id, s ); } // Otherwise insert the shortcut itself into the popup menu. else { // This is a fall-hack in case the KAction is missing a proper parent collection. // It should be removed eventually. --ellis menu->setAccel( d->m_cut.keyCodeQt(), id ); kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; } */ - qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); + + +//qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); } const KShortcut& KAction::shortcut() const { return d->m_cut; } const KShortcut& KAction::shortcutDefault() const { return d->m_cutDefault; } QString KAction::shortcutText() const { return d->m_cut.toStringInternal(); } void KAction::setShortcutText( const QString& s ) { setShortcut( KShortcut(s) ); } int KAction::accel() const { - qDebug("KAction::accel() ...1 has top be fixed"); + // qDebug("KAction::accel() ...1 has top be fixed"); //US return d->m_cut.keyCodeQt(); return 0; } void KAction::setGroup( const QString& grp ) { d->m_group = grp; int len = containerCount(); for( int i = 0; i < len; ++i ) updateGroup( i ); } void KAction::updateGroup( int ) { // DO SOMETHING } QString KAction::group() const { return d->m_group; } bool KAction::isEnabled() const { return d->isEnabled(); } bool KAction::isShortcutConfigurable() const { return d->m_configurable; } void KAction::setToolTip( const QString& tt ) { - qDebug("KAction::setToolTip ...1 has top be fixed"); + //qDebug("KAction::setToolTip ...1 has top be fixed"); d->setToolTip( tt ); int len = containerCount(); for( int i = 0; i < len; ++i ) updateToolTip( i ); } void KAction::updateToolTip( int i ) { - qDebug("KAction::updateToolTip ...1 has top be fixed"); + //qDebug("KAction::updateToolTip ...1 has top be fixed"); QWidget *w = container( i ); if ( w->inherits( "KToolBar" ) ) QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); else if ( w->inherits( "QToolBar" ) ) QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); } QString KAction::toolTip() const { return d->toolTip(); } int KAction::plug( QWidget *w, int index ) { //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; if (w == 0) { kdWarning(129) << "KAction::plug called with 0 argument\n"; return -1; } -#ifndef NDEBUG - KAccel* kaccel = kaccelCurrent(); - // If there is a shortcut, but no KAccel available - if( !d->m_cut.isNull() && kaccel == 0 ) { - kdWarning(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis -//US kdDebug(129) << kdBacktrace() << endl; - } -#endif + // Check if action is permitted //US if (kapp && !kapp->authorizeKAction(name())) //US return -1; plugShortcut(); if ( w->inherits("QPopupMenu") ) { QPopupMenu* menu = static_cast<QPopupMenu*>( w ); int id; // Don't insert shortcut into menu if it's already in a KAccel object. //qDebug("KAction::plug warning: real shortcuts not available yet. "); //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); int keyQt = 0; if ( d->hasIcon() ) { /*US KInstance *instance; if ( m_parentCollection ) instance = m_parentCollection->instance(); else instance = KGlobal::instance(); */ id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet SLOT( slotActivated() ), keyQt, -1, index ); } else id = menu->insertItem( d->text(), this, SLOT( slotActivated() ), //dsweet keyQt, -1, index ); // If the shortcut is already in a KAccel object, then // we need to set the menu item's shortcut text. /*US if ( d->m_kaccelList.count() || d->m_kaccel ) updateShortcut( menu, id ); */ // call setItemEnabled only if the item really should be disabled, // because that method is slow and the item is per default enabled if ( !d->isEnabled() ) menu->setItemEnabled( id, false ); if ( !d->whatsThis().isEmpty() ) menu->setWhatsThis( id, whatsThisWithIcon() ); addContainer( menu, id ); connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); if ( m_parentCollection ) m_parentCollection->connectHighlight( menu, this ); return d->m_containers.count() - 1; } else if ( w->inherits( "KToolBar" ) ) { KToolBar *bar = static_cast<KToolBar *>( w ); int id_ = getToolButtonID(); /*US KInstance *instance; if ( m_parentCollection ) instance = m_parentCollection->instance(); else instance = KGlobal::instance(); */ if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly { bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, SLOT( slotActivated() ), d->isEnabled(), d->plainText(), index ); } else { QString icon = d->iconName(); if ( icon.isEmpty() ) icon = "unknown"; bar->insertButton( icon, id_, SIGNAL( clicked() ), this, SLOT( slotActivated() ), d->isEnabled(), d->plainText(), index/*US, instance*/ ); } bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); //US if ( !d->whatsThis().isEmpty() ) //US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); if ( !d->toolTip().isEmpty() ) QToolTip::add( bar->getButton(id_), d->toolTip() ); addContainer( bar, id_ ); connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); if ( m_parentCollection ) m_parentCollection->connectHighlight( bar, this ); return containerCount() - 1; } return -1; } void KAction::unplug( QWidget *w ) { int i = findContainer( w ); if ( i == -1 ) return; int id = itemId( i ); if ( w->inherits( "QPopupMenu" ) ) { QPopupMenu *menu = static_cast<QPopupMenu *>( w ); menu->removeItem( id ); } else if ( w->inherits( "KToolBar" ) ) { KToolBar *bar = static_cast<KToolBar *>( w ); bar->removeItemDelayed( id ); } else if ( w->inherits( "QMenuBar" ) ) { QMenuBar *bar = static_cast<QMenuBar *>( w ); bar->removeItem( id ); } removeContainer( i ); if ( m_parentCollection ) m_parentCollection->disconnectHighlight( w, this ); } void KAction::plugAccel(KAccel *kacc, bool configurable) { - qDebug("KAction::plugAccel ...1 has top be fixed"); + // qDebug("KAction::plugAccel ...1 has top be fixed"); + /*US kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; kdDebug(129) << kdBacktrace() << endl; //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; if ( d->m_kaccel ) unplugAccel(); // If the parent collection's accel ptr isn't set yet //if ( m_parentCollection && !m_parentCollection->accel() ) // m_parentCollection->setAccel( kacc ); // We can only plug this action into the given KAccel object // if it does not already contain an action with the same name. if ( !kacc->actions().actionPtr(name()) ) { d->m_kaccel = kacc; d->m_kaccel->insert(name(), d->plainText(), QString::null, KShortcut(d->m_cut), this, SLOT(slotActivated()), configurable, isEnabled()); connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); } else kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis */ } void KAction::unplugAccel() { - qDebug("KAction::unplugAccel ...1 has top be fixed"); + // qDebug("KAction::unplugAccel ...1 has top be fixed"); /*US //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; if ( d->m_kaccel ) { d->m_kaccel->remove(name()); d->m_kaccel = 0; } */ } void KAction::plugMainWindowAccel( QWidget *w ) { - qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); + // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); + /*US // Note: topLevelWidget() stops too early, we can't use it. QWidget * tl = w; QWidget * n; while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store tl = n; KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow if (mw) plugAccel( mw->accel() ); else kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; */ } void KAction::setEnabled(bool enable) { //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; if ( enable == d->isEnabled() ) return; // KDE 4: remove //US if (d->m_kaccel) //US d->m_kaccel->setEnabled(name(), enable); // KDE 4: remove end //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) //US d->m_kaccelList[i]->setEnabled( name(), enable ); d->setEnabled( enable ); int len = containerCount(); for( int i = 0; i < len; ++i ) updateEnabled( i ); emit enabled( d->isEnabled() ); } void KAction::updateEnabled( int i ) { QWidget *w = container( i ); if ( w->inherits("QPopupMenu") ) static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); else if ( w->inherits("QMenuBar") ) static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); else if ( w->inherits( "KToolBar" ) ) { static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); } } void KAction::setShortcutConfigurable( bool b ) { d->m_configurable = b; } void KAction::setText( const QString& text ) { /*US // KDE 4: remove if (d->m_kaccel) { KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); if (pAction) pAction->setLabel( text ); } // KDE 4: remove end for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); if (pAction) pAction->setLabel( text ); } */ d->setText( text ); int len = containerCount(); for( int i = 0; i < len; ++i ) updateText( i ); } void KAction::updateText( int i ) { QWidget *w = container( i ); if ( w->inherits( "QPopupMenu" ) ) { int id = itemId( i ); static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); updateShortcut( static_cast<QPopupMenu*>(w), id ); } else if ( w->inherits( "QMenuBar" ) ) static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); else if ( w->inherits( "KToolBar" ) ) { - qDebug("KAction::updateText ...3 has top be fixed"); + //qDebug("KAction::updateText ...3 has top be fixed"); QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); if ( button->inherits( "KToolBarButton" ) ) static_cast<KToolBarButton *>(button)->setText( d->plainText() ); } } QString KAction::text() const { return d->text(); } QString KAction::plainText() const { return d->plainText( ); } void KAction::setIcon( const QString &icon ) { d->setIconName( icon ); // now handle any toolbars int len = containerCount(); for ( int i = 0; i < len; ++i ) updateIcon( i ); } void KAction::updateIcon( int id ) { QWidget* w = container( id ); if ( w->inherits( "QPopupMenu" ) ) { int itemId_ = itemId( id ); static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); } else if ( w->inherits( "QMenuBar" ) ) static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); else if ( w->inherits( "KToolBar" ) ) static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); else if ( w->inherits( "QToolBar" ) ) { qDebug("KAction::updateIcon has top be fixed"); //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); } } QString KAction::icon() const { return d->iconName( ); } void KAction::setIconSet( const QIconSet &iconset ) { d->setIconSet( iconset ); int len = containerCount(); for( int i = 0; i < len; ++i ) updateIconSet( i ); } void KAction::updateIconSet( int id ) { QWidget *w = container( id ); if ( w->inherits( "QPopupMenu" ) ) { int itemId_ = itemId( id ); static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); } else if ( w->inherits( "QMenuBar" ) ) static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); else if ( w->inherits( "KToolBar" ) ) { if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); else static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); } } QIconSet KAction::iconSet( KIcon::Group group, int size ) const { return d->iconSet( group, size ); } bool KAction::hasIcon() const { return d->hasIcon(); } void KAction::setWhatsThis( const QString& text ) { @@ -1025,191 +1025,191 @@ void KAction::updateWhatsThis( int i ) QPopupMenu* pm = popupMenu( i ); if ( pm ) { pm->setWhatsThis( itemId( i ), d->whatsThis() ); return; } KToolBar *tb = toolBar( i ); if ( tb ) { QWidget *w = tb->getButton( itemId( i ) ); //US QWhatsThis::remove( w ); //US QWhatsThis::add( w, d->whatsThis() ); return; } } QString KAction::whatsThis() const { return d->whatsThis(); } QString KAction::whatsThisWithIcon() const { QString text = whatsThis(); if (!d->iconName().isEmpty()) return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); return text; } QWidget* KAction::container( int index ) const { assert( index < containerCount() ); return d->m_containers[ index ].m_container; } KToolBar* KAction::toolBar( int index ) const { //US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); return (KToolBar *)( d->m_containers[ index ].m_container ); } QPopupMenu* KAction::popupMenu( int index ) const { //US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); return (QPopupMenu *)( d->m_containers[ index ].m_container ); } QWidget* KAction::representative( int index ) const { return d->m_containers[ index ].m_representative; } int KAction::itemId( int index ) const { return d->m_containers[ index ].m_id; } int KAction::containerCount() const { return d->m_containers.count(); } uint KAction::kaccelCount() const { return d->m_kaccelList.count(); } void KAction::addContainer( QWidget* c, int id ) { KActionPrivate::Container p; p.m_container = c; p.m_id = id; d->m_containers.append( p ); } void KAction::addContainer( QWidget* c, QWidget* w ) { KActionPrivate::Container p; p.m_container = c; p.m_representative = w; d->m_containers.append( p ); } void KAction::activate() { slotActivated(); } void KAction::slotActivated() { emit activated(); } void KAction::slotDestroyed() { - kdDebug(129) << "KAction::slotDestroyed(): this = " << this << ", name = \"" << name() << "\", sender = " << sender() << endl; + const QObject* o = sender(); /* // KDE 4: remove if ( o == d->m_kaccel ) { d->m_kaccel = 0; return; } // KDE 4: remove end for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { if ( o == d->m_kaccelList[i] ) { disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); return; } } */ int i; do { i = findContainer( static_cast<const QWidget*>( o ) ); if ( i != -1 ) removeContainer( i ); } while ( i != -1 ); } int KAction::findContainer( const QWidget* widget ) const { int pos = 0; QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); while( it != d->m_containers.end() ) { if ( (*it).m_representative == widget || (*it).m_container == widget ) return pos; ++it; ++pos; } return -1; } void KAction::removeContainer( int index ) { int i = 0; QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); while( it != d->m_containers.end() ) { if ( i == index ) { d->m_containers.remove( it ); return; } ++it; ++i; } } // FIXME: Remove this (ellis) void KAction::slotKeycodeChanged() { qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); /*US kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); if( pAction ) setShortcut(pAction->shortcut()); */ } KActionCollection *KAction::parentCollection() const { return m_parentCollection; } void KAction::unplugAll() { while ( containerCount() != 0 ) unplug( container( 0 ) ); } void KAction::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } /* vim: et sw=2 ts=2 */ //US #include "kaction.moc" |