33 files changed, 432 insertions, 365 deletions
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp index e2325d2..92a1737 100644 --- a/libkdepim/categoryeditdialog.cpp +++ b/libkdepim/categoryeditdialog.cpp @@ -1,141 +1,142 @@ /* This file is part of libkdepim. Copyright (c) 2000, 2001, 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., 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 <qstringlist.h> #include <qlineedit.h> -#include <qlistview.h> -#include <qheader.h> +#include <q3listview.h> +#include <q3header.h> #include <qpushbutton.h> #include <qapplication.h> +#include <QDesktopWidget> #include "kpimprefs.h" #include "categoryeditdialog.h" using namespace KPIM; CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, const char* name, bool modal, - WFlags fl ) + Qt::WFlags fl ) : CategoryEditDialog_base( parent, name, modal, fl ), mPrefs( prefs ) { mCategories->header()->hide(); QStringList::Iterator it; bool categoriesExist=false; for (it = mPrefs->mCustomCategories.begin(); it != mPrefs->mCustomCategories.end(); ++it ) { - new QListViewItem(mCategories,*it); + new Q3ListViewItem(mCategories,*it); categoriesExist=true; } - connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)), - SLOT(editItem(QListViewItem *))); + connect(mCategories,SIGNAL(selectionChanged(Q3ListViewItem *)), + SLOT(editItem(Q3ListViewItem *))); connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); mButtonRemove->setEnabled(categoriesExist); mButtonModify->setEnabled(categoriesExist); #ifndef DESKTOP_VERSION mButtonOk->hide(); mButtonCancel->hide(); #endif mButtonAdd->setEnabled(!mEdit->text().isEmpty()); if ( QApplication::desktop()->width() > 460 ) resize( 300, 360 ); else showMaximized(); } /* * Destroys the object and frees any allocated resources */ CategoryEditDialog::~CategoryEditDialog() { // no need to delete child widgets, Qt does it all for us } void CategoryEditDialog::slotTextChanged(const QString &text) { mButtonAdd->setEnabled(!text.isEmpty()); } void CategoryEditDialog::add() { if (!mEdit->text().isEmpty()) { - new QListViewItem(mCategories,mEdit->text()); + new Q3ListViewItem(mCategories,mEdit->text()); mEdit->setText(""); mButtonRemove->setEnabled(mCategories->childCount()>0); mButtonModify->setEnabled(mCategories->childCount()>0); } } void CategoryEditDialog::remove() { if (mCategories->currentItem()) { delete mCategories->currentItem(); mButtonRemove->setEnabled(mCategories->childCount()>0); mButtonModify->setEnabled(mCategories->childCount()>0); } } void CategoryEditDialog::modify() { if (!mEdit->text().isEmpty()) { if (mCategories->currentItem()) { mCategories->currentItem()->setText(0,mEdit->text()); } } } void CategoryEditDialog::accept() { slotOk(); } void CategoryEditDialog::slotOk() { slotApply(); QDialog::accept(); } void CategoryEditDialog::slotApply() { mPrefs->mCustomCategories.clear(); - QListViewItem *item = mCategories->firstChild(); + Q3ListViewItem *item = mCategories->firstChild(); while(item) { mPrefs->mCustomCategories.append(item->text(0)); item = item->nextSibling(); } mPrefs->writeConfig(); emit categoryConfigChanged(); } -void CategoryEditDialog::editItem(QListViewItem *item) +void CategoryEditDialog::editItem(Q3ListViewItem *item) { mEdit->setText(item->text(0)); mButtonRemove->setEnabled(true); mButtonModify->setEnabled(true); } //US #include "categoryeditdialog.moc" diff --git a/libkdepim/categoryeditdialog.h b/libkdepim/categoryeditdialog.h index 9bb3201..828894f 100644 --- a/libkdepim/categoryeditdialog.h +++ b/libkdepim/categoryeditdialog.h @@ -1,86 +1,86 @@ /* This file is part of libkdepim. Copyright (c) 2000, 2001, 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., 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. */ #ifndef KPIM_CATEGORYEDITDIALOG_H #define KPIM_CATEGORYEDITDIALOG_H #include <categoryeditdialog_base.h> -#include <qlistview.h> +#include <q3listview.h> class KPimPrefs; namespace KPIM { - class CategorySelectItem :public QObject, public QCheckListItem + class CategorySelectItem :public QObject, public Q3CheckListItem { Q_OBJECT public: - CategorySelectItem(QListView * parent, const QString & text, Type tt) : QObject( parent ), - QCheckListItem (parent, text, tt ) + CategorySelectItem(Q3ListView * parent, const QString & text, Type tt) : QObject( parent ), + Q3CheckListItem (parent, text, tt ) {;} signals: - void stateChanged( QListViewItem*); + void stateChanged( Q3ListViewItem*); protected: virtual void stateChange(bool b) { - QCheckListItem::stateChange(b); + Q3CheckListItem::stateChange(b); emit stateChanged( this ); } }; class CategoryEditDialog : public CategoryEditDialog_base { Q_OBJECT public: CategoryEditDialog( KPimPrefs *prefs, QWidget* parent = 0, const char* name = 0, - bool modal = FALSE, WFlags fl = 0 ); + bool modal = FALSE, Qt::WFlags fl = 0 ); ~CategoryEditDialog(); public slots: void add(); void remove(); void modify(); void accept(); void slotOk(); void slotApply(); signals: void categoryConfigChanged(); private slots: - void editItem(QListViewItem *item); + void editItem(Q3ListViewItem *item); void slotTextChanged(const QString &text); - + private: KPimPrefs *mPrefs; }; } #endif diff --git a/libkdepim/categoryeditdialog_base.cpp b/libkdepim/categoryeditdialog_base.cpp index 1908576..c85f6e5 100644 --- a/libkdepim/categoryeditdialog_base.cpp +++ b/libkdepim/categoryeditdialog_base.cpp @@ -1,155 +1,159 @@ #include <klocale.h> /**************************************************************************** ** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui' ** ** Created: Sat Mar 29 21:46:09 2003 ** by: The User Interface Compiler () ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #include "categoryeditdialog_base.h" #include <qvariant.h> -#include <qheader.h> +#include <q3header.h> #include <qlineedit.h> -#include <qlistview.h> +#include <q3listview.h> #include <qpushbutton.h> #include <qlayout.h> #include <qtooltip.h> -#include <qwhatsthis.h> +#include <q3whatsthis.h> +//Added by qt3to4: +#include <Q3GridLayout> +#include <Q3HBoxLayout> +#include <Q3VBoxLayout> /* * Constructs a CategoryEditDialog_base as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ -CategoryEditDialog_base::CategoryEditDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) +CategoryEditDialog_base::CategoryEditDialog_base( QWidget* parent, const char* name, bool modal, Qt::WFlags fl ) : QDialog( parent, name, true, fl ) { if ( !name ) setName( "CategoryEditDialog_base" ); - CategoryEditDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "CategoryEditDialog_baseLayout"); + CategoryEditDialog_baseLayout = new Q3GridLayout( this, 1, 1, 11, 6, "CategoryEditDialog_baseLayout"); mEdit = new QLineEdit( this, "mEdit" ); CategoryEditDialog_baseLayout->addMultiCellWidget( mEdit, 1, 1, 0, 0 ); - Layout13 = new QHBoxLayout( 0, 0, 6, "Layout13"); + Layout13 = new Q3HBoxLayout( 0, 0, 6, "Layout13"); // mButtonHelp = new QPushButton( this, "mButtonHelp" ); //mButtonHelp->setAutoDefault( TRUE ); //Layout13->addWidget( mButtonHelp ); //QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); //Layout13->addItem( spacer ); //mApply = new QPushButton( this, "mApply" ); // Layout13->addWidget( mApply ); mButtonOk = new QPushButton( this, "mButtonOk" ); mButtonOk->setAutoDefault( TRUE ); mButtonOk->setDefault( TRUE ); Layout13->addWidget( mButtonOk ); mButtonCancel = new QPushButton( this, "mButtonCancel" ); mButtonCancel->setAutoDefault( TRUE ); Layout13->addWidget( mButtonCancel ); CategoryEditDialog_baseLayout->addMultiCellLayout( Layout13, 2, 2, 0, 1 ); - mCategories = new QListView( this, "mCategories" ); + mCategories = new Q3ListView( this, "mCategories" ); mCategories->addColumn( tr2i18n( "Category" ) ); CategoryEditDialog_baseLayout->addWidget( mCategories, 0, 0 ); - layout103 = new QVBoxLayout( 0, 0, 6, "layout103"); + layout103 = new Q3VBoxLayout( 0, 0, 6, "layout103"); mButtonAdd = new QPushButton( this, "mButtonAdd" ); CategoryEditDialog_baseLayout->addMultiCellWidget(mButtonAdd , 1, 1, 1, 1 ); //layout103->addWidget( mButtonAdd ); mButtonModify = new QPushButton( this, "mButtonModify" ); layout103->addWidget( mButtonModify ); mButtonRemove = new QPushButton( this, "mButtonRemove" ); layout103->addWidget( mButtonRemove ); QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); layout103->addItem( spacer_2 ); CategoryEditDialog_baseLayout->addLayout( layout103, 0, 1 ); languageChange(); resize( sizeHint() ); // signals and slots connections connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( mButtonAdd, SIGNAL( clicked() ), this, SLOT( add() ) ); connect( mButtonModify, SIGNAL( clicked() ), this, SLOT( modify() ) ); connect( mButtonRemove, SIGNAL( clicked() ), this, SLOT( remove() ) ); connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) ); //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) ); // tab order // setTabOrder( mCategories, mEdit ); // setTabOrder( mEdit, mButtonAdd ); // setTabOrder( mButtonAdd, mButtonModify ); // setTabOrder( mButtonModify, mButtonRemove ); // setTabOrder( mButtonRemove, mButtonHelp ); // setTabOrder( mButtonHelp, mApply ); // setTabOrder( mApply, mButtonOk ); // setTabOrder( mButtonOk, mButtonCancel ); } /* * Destroys the object and frees any allocated resources */ CategoryEditDialog_base::~CategoryEditDialog_base() { // no need to delete child widgets, Qt does it all for us } /* * Sets the strings of the subwidgets using the current * language. */ void CategoryEditDialog_base::languageChange() { setCaption( tr2i18n( "Edit Categories" ) ); // mButtonHelp->setText( tr2i18n( "&Help" ) ); // mApply->setText( tr2i18n( "&Apply" ) ); mButtonOk->setText( tr2i18n( "&OK" ) ); mButtonCancel->setText( tr2i18n( "&Cancel" ) ); mCategories->header()->setLabel( 0, tr2i18n( "Category" ) ); mButtonAdd->setText( tr2i18n( "A&dd" ) ); mButtonModify->setText( tr2i18n( "&Modify" ) ); mButtonRemove->setText( tr2i18n( "&Remove" ) ); } void CategoryEditDialog_base::add() { qWarning( "CategoryEditDialog_base::add(): Not implemented yet" ); } void CategoryEditDialog_base::modify() { qWarning( "CategoryEditDialog_base::modify(): Not implemented yet" ); } void CategoryEditDialog_base::slotApply() { qWarning( "CategoryEditDialog_base::slotApply(): Not implemented yet" ); } void CategoryEditDialog_base::remove() { qWarning( "CategoryEditDialog_base::remove(): Not implemented yet" ); } void CategoryEditDialog_base::slotOk() { qWarning( "CategoryEditDialog_base::slotOk(): Not implemented yet" ); } //US #include "categoryeditdialog_base.moc" diff --git a/libkdepim/categoryeditdialog_base.h b/libkdepim/categoryeditdialog_base.h index 5557ad0..cd577b0 100644 --- a/libkdepim/categoryeditdialog_base.h +++ b/libkdepim/categoryeditdialog_base.h @@ -1,58 +1,62 @@ /**************************************************************************** ** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryeditdialog_base.ui' ** ** Created: Sat Mar 29 21:45:20 2003 ** by: The User Interface Compiler () ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef CATEGORYEDITDIALOG_BASE_H #define CATEGORYEDITDIALOG_BASE_H #include <qvariant.h> #include <qdialog.h> - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; +//Added by qt3to4: +#include <Q3VBoxLayout> +#include <Q3GridLayout> +#include <Q3HBoxLayout> + +class Q3VBoxLayout; +class Q3HBoxLayout; +class Q3GridLayout; class QLineEdit; -class QListView; -class QListViewItem; +class Q3ListView; +class Q3ListViewItem; class QPushButton; class CategoryEditDialog_base : public QDialog { Q_OBJECT public: - CategoryEditDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + CategoryEditDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); ~CategoryEditDialog_base(); QLineEdit* mEdit; QPushButton* mButtonHelp; QPushButton* mApply; QPushButton* mButtonOk; QPushButton* mButtonCancel; - QListView* mCategories; + Q3ListView* mCategories; QPushButton* mButtonAdd; QPushButton* mButtonModify; QPushButton* mButtonRemove; public slots: virtual void add(); virtual void modify(); virtual void slotApply(); virtual void remove(); virtual void slotOk(); protected: - QGridLayout* CategoryEditDialog_baseLayout; - QHBoxLayout* Layout13; - QVBoxLayout* layout103; + Q3GridLayout* CategoryEditDialog_baseLayout; + Q3HBoxLayout* Layout13; + Q3VBoxLayout* layout103; protected slots: virtual void languageChange(); }; #endif // CATEGORYEDITDIALOG_BASE_H diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp index 2a9b43e..4f72880 100644 --- a/libkdepim/categoryselectdialog.cpp +++ b/libkdepim/categoryselectdialog.cpp @@ -1,246 +1,249 @@ /* This file is part of libkdepim. Copyright (c) 2000, 2001, 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., 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 <qlistview.h> +#include <q3listview.h> #include <qpushbutton.h> -#include <qheader.h> -#include <qapp.h> +#include <q3header.h> +#include <qapplication.h> #include <qmessagebox.h> +//Added by qt3to4: +#include <QPixmap> +#include <QDesktopWidget> #include <kmessagebox.h> #include "categoryeditdialog.h" #include "categoryselectdialog.h" #include "kpimprefs.h" using namespace KPIM; CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, const char* name, - bool modal, WFlags fl ) + bool modal, Qt::WFlags fl ) : CategorySelectDialog_base( parent, name, true, fl ), mPrefs( prefs ) { Q_UNUSED( modal ); mColorItem = 0; mColorEnabled = false; mCategories->header()->hide(); setCategories(); connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); if ( QApplication::desktop()->width() > 460 ) resize( 300, 360 ); else showMaximized(); connect( mSetColorCat, SIGNAL( clicked() ), this, SLOT( setColorCat() ) ); // connect( mCategories, SIGNAL( clicked(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); #ifndef DESKTOP_VERSION mButtonOk->hide(); mButtonCancel->hide(); #endif } void CategorySelectDialog::editCategoriesDialog() { KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); ced->exec(); delete ced; slotApply(); QStringList temp = mCategoryList; setCategories(); setSelected( temp ); } void CategorySelectDialog::setCategories() { mColorItem = 0; mCategories->clear(); mCategoryList.clear(); QStringList::Iterator it; for (it = mPrefs->mCustomCategories.begin(); it != mPrefs->mCustomCategories.end(); ++it ) { - CategorySelectItem * item = new CategorySelectItem(mCategories,*it,QCheckListItem::CheckBox); - QObject::connect( item, SIGNAL( stateChanged(QListViewItem *) ), this, SLOT( clicked(QListViewItem *) ) ); + CategorySelectItem * item = new CategorySelectItem(mCategories,*it,Q3CheckListItem::CheckBox); + QObject::connect( item, SIGNAL( stateChanged(Q3ListViewItem *) ), this, SLOT( clicked(Q3ListViewItem *) ) ); } } CategorySelectDialog::~CategorySelectDialog() { } void CategorySelectDialog::setSelected(const QStringList &selList) { clear(); QStringList::ConstIterator it; QStringList notFound; bool found = false; for (it=selList.begin();it!=selList.end();++it) { //qDebug(" CategorySelectDialog::setSelected("); - QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); + Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); while (item) { if (item->text() == *it) { item->setOn(true); if ( ! found ) setColorItem( item ); found = true; break; } - item = (QCheckListItem *)item->nextSibling(); + item = (Q3CheckListItem *)item->nextSibling(); } // if ( ! found ) { //emit updateCategoriesGlobal(); // QMessageBox::information( this, "KO/E: Information!", // "Categories found, which were not\n" // "in list of categories!\n" // "message", // "OK", "", 0, // 0, 1 ); // setSelected(selList); // return; // } } } QStringList CategorySelectDialog::selectedCategories() const { return mCategoryList; } void CategorySelectDialog::setColorEnabled() { mColorEnabled = true; mSetColorCat->show(); } void CategorySelectDialog::setColorCat() { - QCheckListItem * newColorItem = (QCheckListItem * )mCategories->currentItem (); + Q3CheckListItem * newColorItem = (Q3CheckListItem * )mCategories->currentItem (); if ( !newColorItem ) { KMessageBox::error(this,i18n("There is no current item.")); return; } if ( !newColorItem->isOn() ) newColorItem->setOn( true ); setColorItem( newColorItem ); } -void CategorySelectDialog::clicked ( QListViewItem * it ) +void CategorySelectDialog::clicked ( Q3ListViewItem * it ) { if ( ! it ) return; - QCheckListItem *i = (QCheckListItem *) it; + Q3CheckListItem *i = (Q3CheckListItem *) it; if ( !i->isOn() && i==mColorItem) { setColorItem( 0); - QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); + Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); while (item) { if (item->isOn()) { setColorItem( item ); break; } - item = (QCheckListItem *)item->nextSibling(); + item = (Q3CheckListItem *)item->nextSibling(); } } else if ( i->isOn() && !mColorItem) { setColorItem( i); } } -void CategorySelectDialog::setColorItem( QCheckListItem * newColorItem ) +void CategorySelectDialog::setColorItem( Q3CheckListItem * newColorItem ) { if ( !mColorEnabled ) return; if ( mColorItem == newColorItem) return; if ( mColorItem ) { mColorItem->setPixmap ( 0, QPixmap() ); mColorItem = 0; } if ( newColorItem ) { QPixmap pix (newColorItem->height()/2, newColorItem->height()/2 ); pix.fill(Qt::red ); newColorItem->setPixmap ( 0, pix ); mColorItem = newColorItem; } } void CategorySelectDialog::slotApply() { QStringList categories; - QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); + Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); QString colcat; while (item) { if (item->isOn()) { if ( item == mColorItem) colcat = item->text(); else categories.append(item->text()); } - item = (QCheckListItem *)item->nextSibling(); + item = (Q3CheckListItem *)item->nextSibling(); } categories.sort(); if ( ! colcat.isEmpty() ) categories.prepend( colcat ); // QString categoriesStr = categories.join(","); mCategoryList = categories; } void CategorySelectDialog::accept() { slotOk(); } void CategorySelectDialog::slotOk() { slotApply(); emit categoriesSelected(mCategoryList); emit categoriesSelected(mCategoryList.join(",")); QDialog::accept(); } void CategorySelectDialog::clear() { - QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); + Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); while (item) { item->setOn(false); - item = (QCheckListItem *)item->nextSibling(); + item = (Q3CheckListItem *)item->nextSibling(); } } void CategorySelectDialog::updateCategoryConfig() { QStringList selected; - QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); + Q3CheckListItem *item = (Q3CheckListItem *)mCategories->firstChild(); while (item) { if (item->isOn()) { selected.append(item->text()); } - item = (QCheckListItem *)item->nextSibling(); + item = (Q3CheckListItem *)item->nextSibling(); } setCategories(); setSelected(selected); } //#include "categoryselectdialog.moc" diff --git a/libkdepim/categoryselectdialog.h b/libkdepim/categoryselectdialog.h index 680a093..ff7ac58 100644 --- a/libkdepim/categoryselectdialog.h +++ b/libkdepim/categoryselectdialog.h @@ -1,75 +1,75 @@ /* This file is part of libkdepim. Copyright (c) 2000, 2001, 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., 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. */ #ifndef KPIM_CATEGORYSELECTDIALOG_H #define KPIM_CATEGORYSELECTDIALOG_H #include <categoryselectdialog_base.h> class KPimPrefs; -class QCheckListItem; +class Q3CheckListItem; namespace KPIM { class CategorySelectDialog : public CategorySelectDialog_base { Q_OBJECT public: CategorySelectDialog( KPimPrefs *prefs, QWidget* parent = 0, const char* name = 0, - bool modal = FALSE, WFlags fl = 0 ); + bool modal = FALSE, Qt::WFlags fl = 0 ); ~CategorySelectDialog(); void setCategories(); void setColorEnabled(); void setSelected(const QStringList &selList); QStringList selectedCategories() const; public slots: void slotOk(); void slotApply(); void clear(); void accept(); void editCategoriesDialog(); void updateCategoryConfig(); void setColorCat(); - void clicked ( QListViewItem * ); + void clicked ( Q3ListViewItem * ); signals: void categoriesSelected(const QString &); void categoriesSelected(const QStringList &); void editCategories(); private: bool mColorEnabled; KPimPrefs *mPrefs; QStringList mCategoryList; - QCheckListItem *mColorItem; - void setColorItem( QCheckListItem * ); + Q3CheckListItem *mColorItem; + void setColorItem( Q3CheckListItem * ); class CategorySelectDialogPrivate; CategorySelectDialogPrivate *d; }; } #endif diff --git a/libkdepim/categoryselectdialog_base.cpp b/libkdepim/categoryselectdialog_base.cpp index 4793fd7..5d53ac4 100644 --- a/libkdepim/categoryselectdialog_base.cpp +++ b/libkdepim/categoryselectdialog_base.cpp @@ -1,131 +1,134 @@ #include <klocale.h> /**************************************************************************** ** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui' ** ** Created: Sat Mar 29 21:46:05 2003 ** by: The User Interface Compiler () ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #include "categoryselectdialog_base.h" #include <qvariant.h> -#include <qheader.h> -#include <qlistview.h> +#include <q3header.h> +#include <q3listview.h> #include <qpushbutton.h> #include <qlayout.h> #include <qtooltip.h> -#include <qwhatsthis.h> +#include <q3whatsthis.h> +//Added by qt3to4: +#include <Q3VBoxLayout> +#include <Q3HBoxLayout> /* * Constructs a CategorySelectDialog_base as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ -CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) +CategorySelectDialog_base::CategorySelectDialog_base( QWidget* parent, const char* name, bool modal, Qt::WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "CategorySelectDialog_base" ); - CategorySelectDialog_baseLayout = new QVBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout"); + CategorySelectDialog_baseLayout = new Q3VBoxLayout( this, 11, 6, "CategorySelectDialog_baseLayout"); - mCategories = new QListView( this, "mCategories" ); + mCategories = new Q3ListView( this, "mCategories" ); mCategories->addColumn( i18n( "Category" ) ); CategorySelectDialog_baseLayout->addWidget( mCategories ); mSetColorCat = new QPushButton( this, "msetColor" ); CategorySelectDialog_baseLayout->addWidget( mSetColorCat ); - Layout12 = new QHBoxLayout( 0, 0, 4, "Layout12"); + Layout12 = new Q3HBoxLayout( 0, 0, 4, "Layout12"); mClear = new QPushButton( this, "mClear" ); Layout12->addWidget( mClear ); // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); //Layout12->addItem( spacer ); mButtonEdit = new QPushButton( this, "mButtonEdit" ); Layout12->addWidget( mButtonEdit ); CategorySelectDialog_baseLayout->addLayout( Layout12 ); - Layout11 = new QHBoxLayout( 0, 0, 4, "Layout11"); + Layout11 = new Q3HBoxLayout( 0, 0, 4, "Layout11"); //mButtonHelp = new QPushButton( this, "mButtonHelp" ); //Layout11->addWidget( mButtonHelp ); //QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); // Layout11->addItem( spacer_2 ); //mApply = new QPushButton( this, "mApply" ); // Layout11->addWidget( mApply ); mButtonOk = new QPushButton( this, "mButtonOk" ); mButtonOk->setOn( FALSE ); mButtonOk->setDefault( TRUE ); Layout11->addWidget( mButtonOk ); mButtonCancel = new QPushButton( this, "mButtonCancel" ); Layout11->addWidget( mButtonCancel ); CategorySelectDialog_baseLayout->addLayout( Layout11 ); languageChange(); // resize( sizeHint() ); // signals and slots connections connect( mButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( mButtonOk, SIGNAL( clicked() ), this, SLOT( slotOk() ) ); connect( mClear, SIGNAL( clicked() ), this, SLOT( clear() ) ); //connect( mApply, SIGNAL( clicked() ), this, SLOT( slotApply() ) ); // tab order setTabOrder( mCategories, mClear ); setTabOrder( mClear, mButtonEdit ); setTabOrder( mButtonEdit, mButtonOk );//mButtonHelp ); // setTabOrder( mButtonHelp, mApply ); // setTabOrder( mApply, mButtonOk ); setTabOrder( mButtonOk, mButtonCancel ); // showMaximized(); //raise(); mSetColorCat->hide(); } /* * Destroys the object and frees any allocated resources */ CategorySelectDialog_base::~CategorySelectDialog_base() { // no need to delete child widgets, Qt does it all for us } /* * Sets the strings of the subwidgets using the current * language. */ void CategorySelectDialog_base::languageChange() { setCaption( i18n( "Select Categories" ) ); mCategories->header()->setLabel( 0, tr2i18n( "Category" ) ); mClear->setText( i18n( " &Deselect All " ) ); mButtonEdit->setText( i18n( " &Edit Categories " ) ); // mButtonHelp->setText( tr2i18n( "&Help" ) ); //mApply->setText( i18n( "&Apply" ) ); mButtonOk->setText( i18n( "&OK" ) ); mSetColorCat->setText( i18n( "Set current as color category" ) ); mButtonCancel->setText( i18n( "&Cancel" ) ); } void CategorySelectDialog_base::clear() { qWarning( "CategorySelectDialog_base::clear(): Not implemented yet" ); } void CategorySelectDialog_base::slotApply() { qWarning( "CategorySelectDialog_base::slotApply(): Not implemented yet" ); } void CategorySelectDialog_base::slotOk() { qWarning( "CategorySelectDialog_base::slotOk(): Not implemented yet" ); } //US#include "categoryselectdialog_base.moc" diff --git a/libkdepim/categoryselectdialog_base.h b/libkdepim/categoryselectdialog_base.h index 59ffa22..71d4ce9 100644 --- a/libkdepim/categoryselectdialog_base.h +++ b/libkdepim/categoryselectdialog_base.h @@ -1,54 +1,58 @@ /**************************************************************************** ** Form interface generated from reading ui file '/build/kde/cvs/korge/kdepim/libkdepim/categoryselectdialog_base.ui' ** ** Created: Sat Mar 29 21:45:20 2003 ** by: The User Interface Compiler () ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef CATEGORYSELECTDIALOG_BASE_H #define CATEGORYSELECTDIALOG_BASE_H #include <qvariant.h> #include <qdialog.h> - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QListView; -class QListViewItem; +//Added by qt3to4: +#include <Q3VBoxLayout> +#include <Q3GridLayout> +#include <Q3HBoxLayout> + +class Q3VBoxLayout; +class Q3HBoxLayout; +class Q3GridLayout; +class Q3ListView; +class Q3ListViewItem; class QPushButton; class CategorySelectDialog_base : public QDialog { Q_OBJECT public: - CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + CategorySelectDialog_base( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); ~CategorySelectDialog_base(); - QListView* mCategories; + Q3ListView* mCategories; QPushButton* mClear; QPushButton* mButtonEdit; QPushButton* mButtonHelp; QPushButton* mApply; QPushButton* mButtonOk; QPushButton* mButtonCancel; QPushButton* mSetColorCat; public slots: virtual void clear(); virtual void slotApply(); virtual void slotOk(); protected: - QVBoxLayout* CategorySelectDialog_baseLayout; - QHBoxLayout* Layout12; - QHBoxLayout* Layout11; + Q3VBoxLayout* CategorySelectDialog_baseLayout; + Q3HBoxLayout* Layout12; + Q3HBoxLayout* Layout11; protected slots: virtual void languageChange(); }; #endif // CATEGORYSELECTDIALOG_BASE_H diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index f376e6c..3fc548a 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp @@ -1,413 +1,415 @@ /* 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., 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <stdlib.h> #include <qfile.h> #include <qtimer.h> #include <qmap.h> #include <qregexp.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #include <qtopia/qcopenvelope_qws.h> #else #include <qapplication.h> -#include <qprocess.h> +#include <q3process.h> +//Added by qt3to4: +#include <Q3CString> #endif #include <kstaticdeleter.h> #include <kmessagebox.h> #include "externalapphandler.h" #include "kpimglobalprefs.h" //uncomment line to get debug output //#define DEBUG_EXT_APP_HANDLER /********************************************************************************* * ********************************************************************************/ QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) { //sourceMessage passes later three parameters: sourceChannel, uid, param1 if (_usedSourceParameters == 0) _sourceMessageParameters = "QString,QString)"; else if (_usedSourceParameters == 1) _sourceMessageParameters = "(QString,QString,QString)"; else if (_usedSourceParameters == 2) _sourceMessageParameters = "(QString,QString,QString,QString)"; else if (_usedSourceParameters == 3) _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; } /*********************************************************************************/ QCopTransferItem::QCopTransferItem() { } /*********************************************************************************/ bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) { #ifndef DESKTOP_VERSION //sourceMessage passes two parameters: sourceChannel, uid QString sourceMessage = _sourceMessage + _sourceMessageParameters; #ifdef DEBUG_EXT_APP_HANDLER qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); #endif QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); e << _sourceChannel << uid; if (_usedSourceParameters == 1) e << param1; else if (_usedSourceParameters == 2) e << param1 << param2; else if (_usedSourceParameters == 3) e << param1 << param2 << param3; qApp->processEvents(); return true; #else KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); return false; #endif } /*********************************************************************************/ void QCopTransferItem::setSourceChannel(const QString& sourceChannel) { if ( !sourceChannel.isEmpty()) _sourceChannel = sourceChannel; } /*********************************************************************************/ -bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) +bool QCopTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data ) { // copied from old mail2 /* static int ii = 0; // block second call if ( ii < 2 ) { ++ii; if ( ii > 1 ) { qDebug("qcop call blocked "); return true; } } */ // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); //we are in the target and get a request from the source if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) { - QDataStream stream( data, IO_ReadOnly ); + QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly ); QString sourceChannel; QString uid; QString param1; QString param2; QString param3; stream >> sourceChannel >> uid; if (_usedSourceParameters == 0) { emit receivedMessageFromSource(sourceChannel, uid); } else if (_usedSourceParameters == 1) { stream >> param1; emit receivedMessageFromSource(sourceChannel, uid, param1); } else if (_usedSourceParameters == 2) { stream >> param1 >> param2; emit receivedMessageFromSource(sourceChannel, uid, param1, param2); } else if (_usedSourceParameters == 3) { stream >> param1 >> param2 >> param3; emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); } return true; } return false; } /********************************************************************************* * ********************************************************************************/ QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) { //targetMessage returns later two parameters: uid, and map<qstring,qstring> _targetMessageParameters = "(QString,QMAP<QString,QString>)"; } /*********************************************************************************/ bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) { #ifndef DESKTOP_VERSION //targetMessage passes two parameters: uid, map QString targetMessage = _targetMessage + _targetMessageParameters; #ifdef DEBUG_EXT_APP_HANDLER qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); #endif QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); //US we need no names in the To field. The emailadresses are enough e << uid << nameEmailMap; qApp->processEvents(); return true; #else KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); return false; #endif } /*********************************************************************************/ -bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) +bool QCopMapTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data ) { bool res = QCopTransferItem::appMessage( cmsg, data ); if (res == false) { - QDataStream stream( data, IO_ReadOnly ); + QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly ); // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); //we are in the source and get an answer from the target if ((_targetMessage + _targetMessageParameters) == cmsg.data()) { QMap<QString,QString> adrMap; QString uid; stream >> uid >> adrMap; emit receivedMessageFromTarget(uid, adrMap); return true; } } return false; } /********************************************************************************* * ********************************************************************************/ QCopListTransferItem::~QCopListTransferItem() { } QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) { //targetMessage returns later two parameters: uid, and three lists _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; } /*********************************************************************************/ bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) { #ifndef DESKTOP_VERSION //targetMessage passes two parameters: uid, map QString targetMessage = _targetMessage + _targetMessageParameters; #ifdef DEBUG_EXT_APP_HANDLER qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); for ( int i = 0; i < list3.count(); i++) qDebug("listentry list3: %s",list3[i].latin1()); #endif QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); //US we need no names in the To field. The emailadresses are enough e << uid << list1 << list2 << list3 << list4 << list5 << list6; qApp->processEvents(); return true; #else KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); return false; #endif } /*********************************************************************************/ -bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) +bool QCopListTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data ) { bool res = QCopTransferItem::appMessage( cmsg, data ); #ifdef DEBUG_EXT_APP_HANDLER qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); #endif if (res == false) { - QDataStream stream( data, IO_ReadOnly ); + QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly ); #ifdef DEBUG_EXT_APP_HANDLER qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); #endif //we are in the source and get an answer from the target if ((_targetMessage + _targetMessageParameters) == cmsg.data()) { QStringList list1; QStringList list2; QStringList list3; QStringList list4; QStringList list5; QStringList list6; QString uid; #ifdef DEBUG_EXT_APP_HANDLER qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); #endif stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); return true; } } return false; } /********************************************************************************* * ********************************************************************************/ ExternalAppHandler *ExternalAppHandler::sInstance = 0; static KStaticDeleter<ExternalAppHandler> staticDeleter; ExternalAppHandler::ExternalAppHandler() { mDefaultItems.setAutoDelete(true); mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); } ExternalAppHandler::~ExternalAppHandler() { delete mNameEmailUidListFromKAPITransfer; //delete mFindByEmailFromKAPITransfer; delete mDisplayDetails; delete mBirthdayListFromKAPITransfer; } void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ) { // this method is a conevnient way to reduce the number of parameters I have to pass emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); } void ExternalAppHandler::loadConfig() { mDefaultItems.clear(); mEmailAppAvailable = UNDEFINED; mPhoneAppAvailable = UNDEFINED; mFaxAppAvailable = UNDEFINED; mSMSAppAvailable = UNDEFINED; mPagerAppAvailable = UNDEFINED; mSIPAppAvailable = UNDEFINED; @@ -425,195 +427,195 @@ void ExternalAppHandler::loadConfig() opiepath = qtopiapath; //mailclients QString mailmsg1 = "writeMail(QString,QString)"; QString mailmsg2 = "writeMail(QMap(QString,QString))"; QString undefined = ""; addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); #ifdef DESKTOP_VERSION QString appPath; #ifdef _WIN32_ appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; #else appPath = "/usr/bin/thunderbird"; #endif addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); #ifdef _WIN32_ appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; #else appPath = "/usr/bin/mozilla"; #endif addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); #else if (( QFile::exists( qtopiapath + "/bin/ompi" )) || ( QFile::exists( opiepath + "/bin/ompi" )) || ( QFile::exists( qtpath + "/bin/ompi" ))) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || ( QFile::exists( qtpath + "/bin/qtmail" ))) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); if ( QFile::exists( opiepath + "/bin/opiemail" )) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); if ( QFile::exists( opiepath + "/bin/mailit" )) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); #endif //phoneclients addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); if (( QFile::exists( qtopiapath + "/bin/kppi" )) || ( QFile::exists( opiepath + "/bin/kppi" ))) addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); //faxclients addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); //smsclients addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); //pagerclients addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); //sipclients addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); if (( QFile::exists( qtopiapath + "/bin/kppi" )) || ( QFile::exists( opiepath + "/bin/kppi" ))) addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); } ExternalAppHandler *ExternalAppHandler::instance() { if ( !sInstance ) { sInstance = staticDeleter.setObject( new ExternalAppHandler() ); sInstance->loadConfig(); } return sInstance; } void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) { DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); mDefaultItems.append(dai); } -QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) +Q3PtrList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) { - QList<DefaultAppItem> list; + Q3PtrList<DefaultAppItem> list; DefaultAppItem* dai; for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) { if (dai->_type == type) list.append(dai); } return list; } DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) { DefaultAppItem* dai; for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) { if (dai->_type == type && dai->_id == clientid) return dai; } return 0; } bool ExternalAppHandler::isEmailAppAvailable() { if (mEmailAppAvailable == UNDEFINED) { int client = KPimGlobalPrefs::instance()->mEmailClient; if (client == KPimGlobalPrefs::NONE_EMC) mEmailAppAvailable = UNAVAILABLE; else mEmailAppAvailable = AVAILABLE; } return (mEmailAppAvailable == AVAILABLE); } bool ExternalAppHandler::isSMSAppAvailable() { #ifndef DESKTOP_VERSION if (mSMSAppAvailable == UNDEFINED) { int client = KPimGlobalPrefs::instance()->mSMSClient; if (client == KPimGlobalPrefs::NONE_SMC) mSMSAppAvailable = UNAVAILABLE; else mSMSAppAvailable = AVAILABLE; } return (mSMSAppAvailable == AVAILABLE); #else //DESKTOP_VERSION return false; #endif //DESKTOP_VERSION } bool ExternalAppHandler::isPhoneAppAvailable() { #ifndef DESKTOP_VERSION if (mPhoneAppAvailable == UNDEFINED) { int client = KPimGlobalPrefs::instance()->mPhoneClient; if (client == KPimGlobalPrefs::NONE_PHC) mPhoneAppAvailable = UNAVAILABLE; else mPhoneAppAvailable = AVAILABLE; } return (mPhoneAppAvailable == AVAILABLE); #else //DESKTOP_VERSION return false; #endif //DESKTOP_VERSION } bool ExternalAppHandler::isFaxAppAvailable() { #ifndef DESKTOP_VERSION if (mFaxAppAvailable == UNDEFINED) { int client = KPimGlobalPrefs::instance()->mFaxClient; if (client == KPimGlobalPrefs::NONE_FAC) mFaxAppAvailable = UNAVAILABLE; else mFaxAppAvailable = AVAILABLE; } return (mFaxAppAvailable == AVAILABLE); #else //DESKTOP_VERSION return false; #endif //DESKTOP_VERSION } bool ExternalAppHandler::isPagerAppAvailable() { @@ -653,297 +655,297 @@ bool ExternalAppHandler::isSIPAppAvailable() } /************************************************************************** * **************************************************************************/ //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) { #ifndef DESKTOP_VERSION QString channel; QString message2; QString parameters2; int client = KPimGlobalPrefs::instance()->mEmailClient; if (client == KPimGlobalPrefs::OTHER_EMC) { channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; } else { DefaultAppItem* dai = getDefaultItem(EMAIL, client); if (!dai) { qDebug("could not find configured email application."); return false; } channel = dai->_channel; message2 = dai->_message2; parameters2 = dai->_parameters2; } //first check if one of the mailers need the emails right in the message. message2 = translateMessage(message2, emails, urls); #ifdef DEBUG_EXT_APP_HANDLER qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); #endif QCopEnvelope e(channel.latin1(), message2.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters2, emails, urls); #else //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); QString channel; QString message2; QString parameters2; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mEmailClient; if (client == KPimGlobalPrefs::OTHER_EMC) { channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; message = KPimGlobalPrefs::instance()->mEmailOtherMessage; message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; } else { DefaultAppItem* dai = getDefaultItem(EMAIL, client); if (!dai) { qDebug("could not find configured email application."); return false; } channel = dai->_channel; message2 = dai->_message2; parameters2 = dai->_parameters2; message = dai->_message; parameters = dai->_parameters; } //first check if one of the mailers need the emails right in the message. message2 = translateMessage(message2, emails, urls); #ifdef DEBUG_EXT_APP_HANDLER qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); #endif qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); //KMessageBox::sorry( 0, message2 ); - QProcess * proc = new QProcess( this ); + Q3Process * proc = new Q3Process( this ); int i = 0; proc->addArgument( channel ); if ( message.find (" " ) > 0 ) { QStringList list = QStringList::split( " ", message ); int i = 0; while ( i < list.count ( ) ) { //qDebug("add%sdd ",list[i].latin1() ); proc->addArgument( list[i] ); //KMessageBox::sorry( 0,list[i]); ++i; } } else { proc->addArgument(message ); //KMessageBox::sorry( 0, message ); } parameters2 = translateMessage(parameters2, urls, "" ); QString arg = "to='%1'"; arg = arg.arg( emails ) + ","+parameters2;; //KMessageBox::sorry( 0,arg ); //qDebug("2add%sdd ",arg.latin1() ); proc->addArgument( arg); - proc->launch(""); + proc->launch(QString()); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the emailapplication and creates a mail with parameter emails as recipients bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) { QString channel; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mEmailClient; if (client == KPimGlobalPrefs::OTHER_EMC) { channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; message = KPimGlobalPrefs::instance()->mEmailOtherMessage; parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; } else { DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); if (!dai) { qDebug("could not find configured email application."); return false; } channel = dai->_channel; message = dai->_message; parameters = dai->_parameters; } #ifdef DESKTOP_VERSION //message = channel + " " +message + " \""+ parameters + "\""; #endif //first check if one of the mailers need the emails right in the message. message = translateMessage(message, name, emailadress); #ifdef DEBUG_EXT_APP_HANDLER qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); #endif #ifndef DESKTOP_VERSION QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters, name, emailadress); #else // DESKTOP_VERSION //KMessageBox::sorry( 0,channel ); - QProcess * proc = new QProcess( this ); + Q3Process * proc = new Q3Process( this ); proc->addArgument( channel ); if ( message.find (" " ) > 0 ) { QStringList list = QStringList::split( " ", message ); int i = 0; while ( i < list.count ( ) ) { //qDebug("add%sdd ",list[i].latin1() ); proc->addArgument( list[i] ); //KMessageBox::sorry( 0,list[i]); ++i; } } else { proc->addArgument(message ); } parameters = translateMessage(parameters, name, emailadress); //KMessageBox::information(0,parameters); proc->addArgument( parameters ); - proc->launch(""); + proc->launch(QString()); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the emailapplication and creates a mail with parameter as recipients // parameters format is // NAME <EMAIL>:SUBJECT bool ExternalAppHandler::mailToOneContact( const QString& adressline ) { QString line = adressline; int first = line.find( "<"); int last = line.find( ">"); QString name = line.left(first); QString emailadress = line.mid(first+1, last-first-1); //Subject can not be handled right now. return mailToOneContact( name, emailadress ); } /************************************************************************** * **************************************************************************/ //calls the phoneapplication with the number bool ExternalAppHandler::callByPhone( const QString& phonenumber ) { #ifndef DESKTOP_VERSION QString channel; QString message; QString parameters; int client = KPimGlobalPrefs::instance()->mPhoneClient; if (client == KPimGlobalPrefs::OTHER_PHC) { channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; } else { DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); if (!dai) { qDebug("could not find configured phone application."); return false; } channel = dai->_channel; message = dai->_message; parameters = dai->_parameters; } //first check if one of the mailers need the emails right in the message. message = translateMessage(message, phonenumber, ""); #ifdef DEBUG_EXT_APP_HANDLER qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); #endif QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters, phonenumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ //calls the smsapplication with the number bool ExternalAppHandler::callBySMS( const QString& phonenumber ) { #ifndef DESKTOP_VERSION QString channel; QString message; QString parameters; @@ -1139,183 +1141,183 @@ bool ExternalAppHandler::callBySIP( const QString& sipnumber ) parameters = dai->_parameters; } //first check if one of the sip apps need the emails right in the message. message = translateMessage(message, sipnumber, ""); #ifdef DEBUG_EXT_APP_HANDLER qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); #endif QCopEnvelope e(channel.latin1(), message.latin1()); //US we need no names in the To field. The emailadresses are enough passParameters(&e, parameters, sipnumber, ""); #else KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); #endif return true; } /************************************************************************** * **************************************************************************/ QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const { message = message.replace( QRegExp("%1"), param1 ); return message.replace( QRegExp("%2"), param2 ); } /************************************************************************** * **************************************************************************/ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const { #ifndef DESKTOP_VERSION QMap<QString, QString> valmap; bool useValMap = false; // first extract all parts of the parameters. QStringList paramlist = QStringList::split(";", parameters); //Now check how many parts we have. //=0 :no params to pass //>0 :parameters to pass for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) { QString param = (*it); QStringList keyvallist = QStringList::split("=", param); //if we have keyvalue pairs, we assume that we pass a map to the envelope QStringList::Iterator it2 = keyvallist.begin(); QString key = (*it2); key = key.replace( QRegExp("%1"), param1 ); key = key.replace( QRegExp("%2"), param2 ); ++it2; if(it2 != keyvallist.end()) { QString value = (*it2); value = value.replace( QRegExp("%1"), param1 ); value = value.replace( QRegExp("%2"), param2 ); valmap.insert(key, value); useValMap = true; } else { // qDebug("pass parameter << %s", key.latin1()); (*e) << key; } } if (useValMap == true) (*e) << valmap; #endif } /************************************************************************** * **************************************************************************/ -void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) +void ExternalAppHandler::appMessage( const Q3CString& cmsg, const QByteArray& data ) { qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); if ( cmsg == "nextView()" ) { qDebug("nextView()"); QTimer::singleShot( 0, this, SIGNAL ( nextView() )); return; } if ( cmsg == "callContactdialog()" ) { qDebug("callContactdialog()"); QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); return; } if ( cmsg == "doRingSync" ) { qDebug("doRingSync"); QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); return; } bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); if (!res) res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); if (!res) res = mDisplayDetails->appMessage( cmsg, data ); // if (!res) // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); } bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) { mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); // maybe we are sending to KA/Pi fom a different worldd... // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application // for that reason we send the current QApplication::desktop()->width() to KA/Pi //qDebug("UID %s ", sessionuid.latin1()); //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); } bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) { QStringList list4, list5, list6; mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); } bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) { mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); } bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) { QStringList list4, list5, list6; mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); } bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) { mDisplayDetails->setSourceChannel(""); return mDisplayDetails->sendMessageToTarget("", name, email, uid); } bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) { mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); } bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) { mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); } diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index b899ad7..3247fe4 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h @@ -1,294 +1,297 @@ /* This file is part of libkdepim. Copyright (c) 2004 Ulf Schenk 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef EXTERNALAPPHANDLER_H #define EXTERNALAPPHANDLER_H #include <qobject.h> #include <qlist.h> #include <qmap.h> +#include <Q3PtrList> +//Added by qt3to4: +#include <Q3CString> class QCopEnvelope; class ExternalAppHandler; class QCopTransferItem : public QObject { Q_OBJECT public: QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); QCopTransferItem(); bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); void setSourceChannel(const QString& sourceChannel); - virtual bool appMessage( const QCString& msg, const QByteArray& data ); + virtual bool appMessage( const Q3CString& msg, const QByteArray& data ); signals: void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); public: int _usedSourceParameters; QString _sourceChannel; QString _sourceMessage; QString _sourceMessageParameters; QString _targetChannel; QString _targetMessage; QString _targetMessageParameters; }; /********************************************************************************* * ********************************************************************************/ class QCopMapTransferItem : public QCopTransferItem { Q_OBJECT public: QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); - virtual bool appMessage( const QCString& msg, const QByteArray& data ); + virtual bool appMessage( const Q3CString& msg, const QByteArray& data ); signals: void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); }; /********************************************************************************* * ********************************************************************************/ class QCopListTransferItem : public QCopTransferItem { Q_OBJECT public: QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); ~QCopListTransferItem(); bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); - virtual bool appMessage( const QCString& msg, const QByteArray& data ); + virtual bool appMessage( const Q3CString& msg, const QByteArray& data ); signals: void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); }; /********************************************************************************* * ********************************************************************************/ class DefaultAppItem { public: DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) { } DefaultAppItem() { } public: int _type; int _id; QString _label; QString _channel; QString _message; QString _parameters; // a list of parameters in stringrepresentation. Delimiter is ; QString _message2; QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; }; /********************************************************************************* * ********************************************************************************/ class ExternalAppHandler : public QObject { Q_OBJECT public: virtual ~ExternalAppHandler(); static ExternalAppHandler *instance(); enum Types { EMAIL = 0, PHONE = 1, SMS = 2, FAX = 3, PAGER = 4, SIP = 5 }; enum Availability { UNDEFINED = -1, UNAVAILABLE = 0, AVAILABLE = 1 }; //calls the emailapplication with a number of attachments that need to be send. //either parameter can be left empty. bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); //calls the emailapplication and creates a mail with parameter emailadress as recipients bool mailToOneContact( const QString& name, const QString& emailadress ); //calls the emailapplication and creates a mail with parameter as recipients // parameters format is // NAME <EMAIL>:SUBJECT bool mailToOneContact( const QString& adressline ); //calls the phoneapplication with the number bool callByPhone( const QString& phonenumber ); //calls the smsapplication with the number bool callBySMS( const QString& phonenumber ); //calls the pagerapplication with the number bool callByPager( const QString& pagernumber ); //calls the faxapplication with the number bool callByFax( const QString& faxnumber ); //calls the sipapplication with the number bool callBySIP( const QString& sipnumber ); bool isEmailAppAvailable(); bool isSMSAppAvailable(); bool isPhoneAppAvailable(); bool isFaxAppAvailable(); bool isPagerAppAvailable(); bool isSIPAppAvailable(); //Call this method on the source when you want to select names from the addressbook by using QCop bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); //Call this method on the target when you want to return the name/email map to the source (client). bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList); //loadConfig clears the cache and checks again if the applications are available or not void loadConfig(); - QList<DefaultAppItem> getAvailableDefaultItems(Types); + Q3PtrList<DefaultAppItem> getAvailableDefaultItems(Types); DefaultAppItem* getDefaultItem(Types, int); public slots: - void appMessage( const QCString& msg, const QByteArray& data ); + void appMessage( const Q3CString& msg, const QByteArray& data ); signals: void callContactdialog(); void nextView(); void doRingSync(); // Emmitted when the target app receives a request from the source app void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi // The first parameter is a uniqueid. It can be used to identify the event void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); // Emmitted when the target app receives a request from the source app void requestForBirthdayList(const QString& sourceChannel, const QString& uid); // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi // The first parameter is a uniqueid. It can be used to identify the event void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, const QStringList& anniversaryList, const QStringList& realNameList, const QStringList& emailList, const QStringList& assembledNameList, const QStringList& uidList); private: ExternalAppHandler(); - QList<DefaultAppItem> mDefaultItems; + Q3PtrList<DefaultAppItem> mDefaultItems; Availability mEmailAppAvailable; Availability mPhoneAppAvailable; Availability mFaxAppAvailable; Availability mSMSAppAvailable; Availability mPagerAppAvailable; Availability mSIPAppAvailable; QCopListTransferItem* mNameEmailUidListFromKAPITransfer; QCopListTransferItem* mFindByEmailFromKAPITransfer; QCopTransferItem* mDisplayDetails; QCopListTransferItem* mBirthdayListFromKAPITransfer; void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; static ExternalAppHandler *sInstance; private slots: void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); }; #endif diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp index 5094830..9f47766 100644 --- a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp +++ b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp @@ -1,80 +1,82 @@ /* This file is part of KDEPim/Pi. Copyright (c) 2004 Ulf Schenk 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qlayout.h> +//Added by qt3to4: +#include <Q3VBoxLayout> #include <kdebug.h> //#include <klocale.h> //#include <stdlib.h> #include "kdepimconfigwidget.h" #include "kcmkdepimconfig.h" #include "kprefs.h" #include "kpimglobalprefs.h" #ifndef _WIN32_ extern "C" { KCModule *create_kdepimconfig(QWidget *parent, const char * ) { return new KCMKdePimConfig(parent, "kcmkdepimconfig" ); } } #endif KCMKdePimConfig::KCMKdePimConfig(QWidget *parent, const char *name ) : KCModule( KPimGlobalPrefs::instance(), parent, name ) { //abort(); - QVBoxLayout *layout = new QVBoxLayout( this ); + Q3VBoxLayout *layout = new Q3VBoxLayout( this ); mConfigWidget = new KDEPIMConfigWidget( (KPimGlobalPrefs*)getPreferences(), this, "KDEPIMConfigWidget" ); layout->addWidget( mConfigWidget ); layout->setSpacing( 0 ); layout->setMargin( 0 ); connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); } void KCMKdePimConfig::load() { mConfigWidget->readConfig(); } void KCMKdePimConfig::save() { mConfigWidget->writeConfig(); } void KCMKdePimConfig::defaults() { qDebug("KCMKdePimConfig::defaults()"); mConfigWidget->setDefaults(); } diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp index 292951b..11a2b45 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp @@ -1,810 +1,815 @@ /* This file is part of KdePim/Pi. Copyright (c) 2004 Ulf Schenk 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qlayout.h> #include <qtabwidget.h> #include <qcombobox.h> -#include <qgroupbox.h> +#include <q3groupbox.h> #include <qlabel.h> #include <qlineedit.h> -#include <qbuttongroup.h> +#include <q3buttongroup.h> #include <qcheckbox.h> #include <qfile.h> -#include <qvbox.h> +#include <q3vbox.h> #include <qdir.h> #include <qregexp.h> #include <qspinbox.h> +#include <QDesktopWidget> +//Added by qt3to4: +#include <Q3HBoxLayout> +#include <Q3GridLayout> +#include <Q3VBoxLayout> #include <kdialog.h> #include <kprefsdialog.h> #include <klocale.h> #include <kglobalsettings.h> #include <kdateedit.h> #include <kglobal.h> #include <stdlib.h> /*US #include <qcheckbox.h> #include <qframe.h> #include <qpushbutton.h> #include <qcombobox.h> #include <qlineedit.h> #include <qlabel.h> #include <qfile.h> #include <kconfig.h> #include <kdebug.h> #include <kdialog.h> #include <klistview.h> #include <klocale.h> #include <kglobal.h> #include <kmessagebox.h> #include <kstandarddirs.h> #ifndef KAB_EMBEDDED #include <ktrader.h> #else // KAB_EMBEDDED #include <mergewidget.h> #include <distributionlistwidget.h> #endif // KAB_EMBEDDED #include "addresseewidget.h" #include "extensionconfigdialog.h" #include "extensionwidget.h" */ #include "qapplication.h" #include "kpimglobalprefs.h" #include "kdepimconfigwidget.h" #include <kprefs.h> #include <kmessagebox.h> KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) : KPrefsWidget(prefs, parent, name ) { mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); - QVBoxLayout *topLayout = new QVBoxLayout( this, 0, + Q3VBoxLayout *topLayout = new Q3VBoxLayout( this, 0, KDialog::spacingHint() ); tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); setupLocaleTab(); setupLocaleDateTab(); setupTimeZoneTab(); setupExternalAppTab(); setupStoreTab(); setupBackupTab(); } void KDEPIMConfigWidget::showTimeZoneTab() { tabWidget->setCurrentPage ( 3 ) ; } void KDEPIMConfigWidget::setupBackupTab() { - QVBox *colorPage = new QVBox( this ); + Q3VBox *colorPage = new Q3VBox( this ); tabWidget->addTab( colorPage, i18n( "Backup" ) ); QWidget* topFrame = new QWidget( colorPage ); - QVBoxLayout *topLayout = new QVBoxLayout(topFrame); + Q3VBoxLayout *topLayout = new Q3VBoxLayout(topFrame); KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); topLayout->addWidget((QWidget*)sb->checkBox()); QWidget* bupFrame = new QWidget( topFrame ); topLayout->addWidget((bupFrame)); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); - QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); + Q3VBoxLayout *bupLayout = new Q3VBoxLayout(bupFrame); sb = addWidBool(i18n("Use standard backup dir"), &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); bupLayout->addWidget((QWidget*)sb->checkBox()); mBackupUrl = new KURLRequester( bupFrame ); mBackupUrl->setPathIsDir(); mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); bupLayout->addWidget( mBackupUrl ); mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); - QHBox *dummy = new QHBox(bupFrame); + Q3HBox *dummy = new Q3HBox(bupFrame); new QLabel(i18n("Number of Backups:"),dummy); mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); - dummy = new QHBox(bupFrame); + dummy = new Q3HBox(bupFrame); new QLabel(i18n("Make backup every "),dummy); mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); new QLabel(i18n(" days"),dummy); new QLabel(i18n(" "),dummy); bupLayout->addWidget( dummy ); QString localKdeDir; localKdeDir = readEnvPath("LOCALMICROKDEHOME"); if ( ! localKdeDir.isEmpty() ) { sb->checkBox()->setEnabled( false ); sb->checkBox()->setChecked( true ); mBackupUrl->setEnabled( false ); KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; } } void KDEPIMConfigWidget::setupStoreTab() { - QVBox *colorPage = new QVBox( this ); + Q3VBox *colorPage = new Q3VBox( this ); tabWidget->addTab( colorPage, i18n( "Colors" ) ); QWidget* cw = new QWidget( colorPage ); KPrefsWidColor *holidayColor = addWidColor(i18n("Alternating background of list views"), &(KPimGlobalPrefs::instance()->mAlternateColor),cw); - QHBoxLayout *topLayout = new QHBoxLayout(cw); + Q3HBoxLayout *topLayout = new Q3HBoxLayout(cw); topLayout->addWidget(holidayColor->label()); topLayout->addWidget( (QWidget* )holidayColor->button()); - QVBox *storePage = new QVBox( this ); + Q3VBox *storePage = new Q3VBox( this ); if ( QApplication::desktop()->height() > 240 ) new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); mStoreUrl = new KURLRequester( storePage ); mStoreUrl->setPathIsDir(); mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); #ifdef DESKTOP_VERSION QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( fi.exists() ) { KConfig cfg ( confFile ); cfg.setGroup("Global"); QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); if ( localKdeDir != "x_x_x" ) { mStoreUrl->setURL( localKdeDir ); qDebug("Reading config from %s ", confFile.latin1()); } } #endif new QLabel( i18n("New dirs are created automatically"), storePage ); - QHBox *bb = new QHBox( storePage ); + Q3HBox *bb = new Q3HBox( storePage ); QPushButton * pb; if ( QApplication::desktop()->width() < 640 ) pb = new QPushButton ( i18n("Save"), bb ); else pb = new QPushButton ( i18n("Save settings"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); pb = new QPushButton ( i18n("Save standard"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); #ifdef DESKTOP_VERSION pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); #endif new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage ); mDataStoragePath = new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage ); tabWidget->addTab( storePage, i18n( "Data storage path" ) ); #ifdef DESKTOP_VERSION if ( mStoreUrl->url().startsWith( "LOCAL:" ) ) { mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( qApp->applicationDirPath ()+"/.microkdehome" )); } #endif } void KDEPIMConfigWidget::setLocalStore() { mStoreUrl->setURL( "LOCAL:kdepimpi" ); saveStoreSettings(); QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data."); KMessageBox::information( this, message); } void KDEPIMConfigWidget::setStandardStore() { mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); saveStoreSettings(); } void KDEPIMConfigWidget::saveStoreSettings() { #ifdef DESKTOP_VERSION if ( !mStoreUrl->url().startsWith( "LOCAL:" ) ) { QString file = qApp->applicationDirPath ()+"/.microkdehome"; QFileInfo fi ( file ); if ( fi.exists() ) { bool res = QFile::remove( file ); if ( ! res ) KMessageBox::information( this, i18n("ERROR: Cannot remove file\n%1\nPlease remove it manually.").arg( file )); } } #endif if ( !mStoreUrl->url().isEmpty() ) { QString path = QDir::homeDirPath(); QString url = mStoreUrl->url(); #ifdef DESKTOP_VERSION if ( url.startsWith( "LOCAL:" ) ) { path = qApp->applicationDirPath () ; } #endif KConfig cfg ( path + "/.microkdehome" ); cfg.setGroup("Global"); cfg.writeEntry( "MICROKDEHOME", url ); qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1()); cfg.sync(); mDataStoragePath->setText( i18n("Settings are stored in\n%1").arg( path+"/.microkdehome" )); } else { mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); saveStoreSettings(); } } void KDEPIMConfigWidget::setupExternalAppTab() { QWidget *externalAppsPage = new QWidget( this ); - QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), + Q3VBoxLayout* layout = new Q3VBoxLayout( externalAppsPage, KDialog::marginHintSmall(), KDialog::spacingHintSmall() ); mExternalApps = new QComboBox( externalAppsPage ); QMap<ExternalAppHandler::Types, QString>::Iterator it; for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) mExternalApps->insertItem( it.data(), it.key() ); layout->addWidget( mExternalApps ); connect( mExternalApps, SIGNAL( activated( int ) ), this, SLOT (externalapp_changed( int ) ) ); - mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); - QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); + mExternalAppGroupBox = new Q3GroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); + Q3GridLayout *boxLayout = new Q3GridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); mExternalAppGroupBox->layout()->setMargin(4); mClient = new QComboBox( mExternalAppGroupBox ); boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); connect( mClient, SIGNAL( activated( int ) ), this, SLOT (client_changed( int ) ) ); QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 1, 0 ); mChannel = new QLineEdit(mExternalAppGroupBox); mChannel->setReadOnly(true); boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 3, 0 ); mMessage = new QLineEdit(mExternalAppGroupBox); mMessage->setReadOnly(true); boxLayout->addWidget( mMessage , 4, 0); lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 3, 1 ); mParameters = new QLineEdit(mExternalAppGroupBox); mParameters->setReadOnly(true); boxLayout->addWidget( mParameters, 4, 1 ); lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); if ( QApplication::desktop()->height() > 240 ) { lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 6, 0 ); mMessage2 = new QLineEdit(mExternalAppGroupBox); mMessage2->setReadOnly(true); boxLayout->addWidget( mMessage2 , 7, 0); lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); boxLayout->addWidget( lab, 6, 1 ); mParameters2 = new QLineEdit(mExternalAppGroupBox); mParameters2->setReadOnly(true); boxLayout->addWidget( mParameters2, 7, 1 ); lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); } else { mMessage2 = 0; mParameters2 = 0; } connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); layout->addWidget( mExternalAppGroupBox ); tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); } void KDEPIMConfigWidget::setupLocaleDateTab() { QWidget *topFrame = new QWidget( this ); - QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); + Q3GridLayout *topLayout = new Q3GridLayout( topFrame, 3, 2); topLayout->setSpacing(KDialog::spacingHintSmall()); topLayout->setMargin(KDialog::marginHintSmall()); int iii = 0; KPrefsWidRadios *syncPrefsGroup = addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); QString format; if ( QApplication::desktop()->width() < 480 ) format = "(%d.%m.%Y)"; else format = "(%d.%m.%Y|%A %d %B %Y)"; syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%m.%d.%Y)"; else format = "(%m.%d.%Y|%A %B %d %Y)"; syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%Y-%m-%d)"; else format = "(%Y-%m-%d|%A %Y %B %d)"; syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); syncPrefsGroup->addRadio(i18n("User defined")); if ( QApplication::desktop()->width() < 480 ) { syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); } topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; ++iii; QLabel * lab; mUserDateFormatLong = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatLong,iii,1); ++iii; mUserDateFormatShort = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatShort,iii,1); ++iii; lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() ); if ( QApplication::desktop()->height() > 240 ) { lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; } connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); tabWidget->addTab( topFrame, i18n( "Date Format" ) ); } void KDEPIMConfigWidget::setupLocaleTab() { QWidget *topFrame = new QWidget( this ); - QGridLayout *topLayout = new QGridLayout(topFrame,4,2); + Q3GridLayout *topLayout = new Q3GridLayout(topFrame,4,2); topLayout->setSpacing(KDialog::spacingHint()); topLayout->setMargin(KDialog::marginHint()); int iii = 0; KPrefsWidRadios *syncPrefsGroup = addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); syncPrefsGroup->addRadio(i18n("English")); syncPrefsGroup->addRadio(i18n("German")); syncPrefsGroup->addRadio(i18n("French")); syncPrefsGroup->addRadio(i18n("Italian")); syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); if ( QApplication::desktop()->width() < 300 ) { syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); } topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; tabWidget->addTab( topFrame, i18n( "Language" ) ); topFrame = new QWidget( this ); - topLayout = new QGridLayout(topFrame,4,2); + topLayout = new Q3GridLayout(topFrame,4,2); topLayout->setSpacing(KDialog::spacingHint()); topLayout->setMargin(KDialog::marginHint()); iii = 0; syncPrefsGroup = addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); if ( QApplication::desktop()->width() > 300 ) syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); syncPrefsGroup->addRadio(i18n("24:00")); syncPrefsGroup->addRadio(i18n("12:00am")); syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); ++iii; tabWidget->addTab( topFrame, i18n( "Time Format" ) ); } void KDEPIMConfigWidget::setupTimeZoneTab() { QWidget *topFrame; - QGridLayout *topLayout ; + Q3GridLayout *topLayout ; topFrame = new QWidget( this ); - topLayout = new QGridLayout( topFrame, 5, 2); + topLayout = new Q3GridLayout( topFrame, 5, 2); topLayout->setSpacing(KDialog::spacingHintSmall()); topLayout->setMargin(KDialog::marginHintSmall()); - QHBox *timeZoneBox = new QHBox( topFrame ); + Q3HBox *timeZoneBox = new Q3HBox( topFrame ); topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); new QLabel( i18n("Timezone:"), timeZoneBox ); mTimeZoneCombo = new QComboBox( timeZoneBox ); if ( QApplication::desktop()->width() < 300 ) { mTimeZoneCombo->setMaximumWidth(150); } QStringList list; list = KGlobal::locale()->timeZoneList(); mTimeZoneCombo->insertStringList(list); // find the currently set time zone and select it QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; int nCurrentlySet = 11; for (int i = 0; i < mTimeZoneCombo->count(); i++) { if (mTimeZoneCombo->text(i) == sCurrentlySet) { nCurrentlySet = i; break; } } mTimeZoneCombo->setCurrentItem(nCurrentlySet); int iii = 1; KPrefsWidBool *sb = addWidBool(i18n("Add 30 min to selected Timezone"), &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame); topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); ++iii; sb = addWidBool(i18n("Timezone has daylight saving"), &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); ++iii; QLabel* lab; lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); topLayout->addMultiCellWidget(lab, iii,iii,0,1); ++iii; lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); topLayout->addMultiCellWidget(lab, iii,iii,0,1); ++iii; lab = new QLabel( i18n("Daylight start:"), topFrame ); topLayout->addWidget(lab, iii,0); mStartDateSavingEdit = new KDateEdit(topFrame); topLayout->addWidget(mStartDateSavingEdit, iii,1); ++iii; lab = new QLabel( i18n("Daylight end:"), topFrame ); topLayout->addWidget(lab, iii,0); mEndDateSavingEdit = new KDateEdit(topFrame); topLayout->addWidget(mEndDateSavingEdit, iii,1); ++iii; QDate current ( 2001, 1,1); mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); topFrame = new QWidget( this ); - topLayout = new QGridLayout( topFrame, 3, 2); + topLayout = new Q3GridLayout( topFrame, 3, 2); topLayout->setSpacing(KDialog::spacingHintSmall()); topLayout->setMargin(KDialog::marginHintSmall()); tabWidget->addTab( topFrame, i18n( "Fonts" ) ); QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame ); topLayout->addMultiCellWidget(labb,0,0,0,2); int i = 1; KPrefsWidFont *timeLabelsFont = addWidFont(i18n("Kx/Pi"),i18n("Application Font"), &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame); topLayout->addWidget(timeLabelsFont->label(),i,0); topLayout->addWidget(timeLabelsFont->preview(),i,1); topLayout->addWidget(timeLabelsFont->button(),i,2); } void KDEPIMConfigWidget::externalapp_changed( int newApp ) { // first store the current data saveEditFieldSettings(); // set mCurrentApp mCurrentApp = (ExternalAppHandler::Types)newApp; // set mCurrentClient switch(mCurrentApp) { case(ExternalAppHandler::EMAIL): mCurrentClient = mEmailClient; break; case(ExternalAppHandler::PHONE): mCurrentClient = mPhoneClient; break; case(ExternalAppHandler::SMS): mCurrentClient = mSMSClient; break; case(ExternalAppHandler::FAX): mCurrentClient = mFaxClient; break; case(ExternalAppHandler::PAGER): mCurrentClient = mPagerClient; break; case(ExternalAppHandler::SIP): mCurrentClient = mSipClient; break; default: return; } // and at last update the widgets updateClientWidgets(); } void KDEPIMConfigWidget::client_changed( int newClient ) { if (newClient == mCurrentClient) return; // first store the current data saveEditFieldSettings(); //then reset the clientvariable mCurrentClient = newClient; // and at last update the widgets updateClientWidgets(); KPrefsWidget::modified(); } void KDEPIMConfigWidget::saveEditFieldSettings() { switch(mCurrentApp) { case(ExternalAppHandler::EMAIL): mEmailClient = mClient->currentItem(); break; case(ExternalAppHandler::PHONE): mPhoneClient= mClient->currentItem(); break; case(ExternalAppHandler::SMS): mSMSClient = mClient->currentItem(); break; case(ExternalAppHandler::FAX): mFaxClient = mClient->currentItem(); break; case(ExternalAppHandler::PAGER): mPagerClient = mClient->currentItem(); break; case(ExternalAppHandler::SIP): mSipClient = mClient->currentItem(); break; default: return; } //store the current data back to the apropriate membervariables if we had set it to "other" if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) { mEmailOtherChannel = mChannel->text(); mEmailOtherMessage = mMessage->text(); mEmailOtherMessageParameters = mParameters->text(); if ( mMessage2 ) mEmailOtherMessage2 = mMessage2->text(); if ( mParameters2 ) mEmailOtherMessageParameters2 = mParameters2->text(); } else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) { mPhoneOtherChannel = mChannel->text(); mPhoneOtherMessage = mMessage->text(); mPhoneOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) { mSMSOtherChannel = mChannel->text(); mSMSOtherMessage = mMessage->text(); mSMSOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) { mFaxOtherChannel = mChannel->text(); mFaxOtherMessage = mMessage->text(); mFaxOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) { mPagerOtherChannel = mChannel->text(); mPagerOtherMessage = mMessage->text(); mPagerOtherMessageParameters = mParameters->text(); } else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) { mSipOtherChannel = mChannel->text(); mSipOtherMessage = mMessage->text(); mSipOtherMessageParameters = mParameters->text(); } } void KDEPIMConfigWidget::updateClientWidgets() { bool blocked = signalsBlocked(); blockSignals( true ); // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); if (it == mExternalAppsMap.end()) return; // update group box mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); //update the entries in the client combobox mClient->clear(); - QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); + Q3PtrList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); DefaultAppItem* dai; for ( dai=items.first(); dai != 0; dai=items.next() ) { mClient->insertItem( i18n(dai->_label), dai->_id ); if (dai->_id == mCurrentClient) { //restore the edit fields with the data of the local membervariables if we had set it to "other". //Otherwise take the default data from externalapphandler. mChannel->setText(dai->_channel); mMessage->setText(dai->_message); mParameters->setText(dai->_parameters); if ( mMessage2 ) mMessage2->setText(dai->_message2); if ( mParameters2 ) mParameters2->setText(dai->_parameters2); if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) { mChannel->setText(mEmailOtherChannel); mMessage->setText(mEmailOtherMessage); mParameters->setText(mEmailOtherMessageParameters); if ( mMessage2 ) mMessage2->setText(mEmailOtherMessage2); if ( mParameters2 ) mParameters2->setText(mEmailOtherMessageParameters2); } else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) { mChannel->setText(mPhoneOtherChannel); mMessage->setText(mPhoneOtherMessage); mParameters->setText(mPhoneOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) { mChannel->setText(mSMSOtherChannel); mMessage->setText(mSMSOtherMessage); mParameters->setText(mSMSOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) { mChannel->setText(mFaxOtherChannel); mMessage->setText(mFaxOtherMessage); mParameters->setText(mFaxOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) { mChannel->setText(mPagerOtherChannel); mMessage->setText(mPagerOtherMessage); mParameters->setText(mPagerOtherMessageParameters); } else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) { mChannel->setText(mSipOtherChannel); mMessage->setText(mSipOtherMessage); mParameters->setText(mSipOtherMessageParameters); } } } bool readonly; bool enabled; if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) { readonly = false; } else { readonly = true; } if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) { enabled = false; } else { enabled = true; } mChannel->setReadOnly(readonly); mMessage->setReadOnly(readonly); mParameters->setReadOnly(readonly); diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.h b/libkdepim/kcmconfigs/kdepimconfigwidget.h index 824ef79..d693015 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.h +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.h @@ -1,163 +1,165 @@ /* This file is part of KDEPim/Pi. Copyright (c) 2004 Ulf Schenk 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KDEPIMCONFIGWIDGET_H #define KDEPIMCONFIGWIDGET_H #include <kprefswidget.h> #include <kio/kfile/kurlrequester.h> #include <qmap.h> +//Added by qt3to4: +#include <QLabel> #include "externalapphandler.h" class QComboBox; class QLineEdit; class KPimGlobalPrefs; -class QGroupBox; +class Q3GroupBox; class QTabWidget; class KDateEdit; class KDEPIMConfigWidget : public KPrefsWidget { Q_OBJECT public: KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name = 0 ); public slots: void textChanged( const QString& text ); void showTimeZoneTab(); protected: /** Implement this to read custom configuration widgets. */ virtual void usrReadConfig(); /** Implement this to write custom configuration widgets. */ virtual void usrWriteConfig(); private slots: // void configureExtension(); // void selectionChanged( QListViewItem* ); // void itemClicked( QListViewItem* ); void client_changed( int newClient ); void externalapp_changed( int newApp ); void saveStoreSettings(); void setStandardStore(); void setLocalStore(); private: void setupExternalAppTab(); void setupLocaleDateTab(); void setupLocaleTab(); void setupTimeZoneTab(); void setupStoreTab(); void setupBackupTab(); KURLRequester* mStoreUrl; void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0); void saveEditFieldSettings(); void updateClientWidgets(); QTabWidget *tabWidget; QLineEdit* mUserDateFormatShort; QLineEdit* mUserDateFormatLong; QComboBox* mTimeZoneCombo; KDateEdit* mStartDateSavingEdit; KDateEdit* mEndDateSavingEdit; // void restoreExtensionSettings(); // void saveExtensionSettings(); // KListView *mExtensionView; // QCheckBox *mNameParsing; // QCheckBox *mViewsSingleClickBox; // QPushButton *mConfigureButton; QComboBox* mExternalApps; - QGroupBox* mExternalAppGroupBox; + Q3GroupBox* mExternalAppGroupBox; QComboBox* mClient; QLineEdit* mChannel; QLineEdit* mMessage; QLineEdit* mParameters; QLineEdit* mMessage2; QLineEdit* mParameters2; ExternalAppHandler::Types mCurrentApp; int mCurrentClient; int mEmailClient; QString mEmailOtherChannel; QString mEmailOtherMessage; QString mEmailOtherMessageParameters; QString mEmailOtherMessage2; QString mEmailOtherMessageParameters2; int mPhoneClient; QString mPhoneOtherChannel; QString mPhoneOtherMessage; QString mPhoneOtherMessageParameters; int mFaxClient; QString mFaxOtherChannel; QString mFaxOtherMessage; QString mFaxOtherMessageParameters; int mSMSClient; QString mSMSOtherChannel; QString mSMSOtherMessage; QString mSMSOtherMessageParameters; int mPagerClient; QString mPagerOtherChannel; QString mPagerOtherMessage; QString mPagerOtherMessageParameters; int mSipClient; QString mSipOtherChannel; QString mSipOtherMessage; QString mSipOtherMessageParameters; QLabel* mDataStoragePath; KURLRequester* mBackupUrl; QSpinBox* mBackupDayCountSpin, *mBackupNumbersSpin ; QMap<ExternalAppHandler::Types, QString> mExternalAppsMap; // AddresseeWidget *mAddresseeWidget; }; #endif diff --git a/libkdepim/kdateedit.cpp b/libkdepim/kdateedit.cpp index bf38479..28c88d4 100644 --- a/libkdepim/kdateedit.cpp +++ b/libkdepim/kdateedit.cpp @@ -1,475 +1,479 @@ /* 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. */ #include <qapplication.h> #include <qevent.h> #include <qlineedit.h> #include <qpixmap.h> #include <qpushbutton.h> +//Added by qt3to4: +#include <Q3Frame> +#include <QKeyEvent> #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 <QDesktopWidget> #include "kdateedit.h" //#include "kdateedit.moc" KDateEdit::KDateEdit(QWidget *parent, const char *name, bool withoutDP ) - : QHBox(parent, name) + : Q3HBox(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); QPixmap pixmap2 = SmallIcon("today_small"); QPushButton* nowButton = new QPushButton(this); nowButton->setPixmap(pixmap2); - mDateFrame = new QVBox(0,0,WType_Popup); + mDateFrame = new Q3VBox(0,0,Qt::WType_Popup); // mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); - mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); + mDateFrame->setFrameStyle( Q3Frame::WinPanel |Q3Frame::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())); connect(nowButton,SIGNAL(clicked()),SLOT(goToNow())); - mDateButton->setFocusPolicy( QWidget::NoFocus ); + mDateButton->setFocusPolicy( Qt::NoFocus ); mDateButton->setAutoDefault( false ); //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::goToNow() { setDate(QDate::currentDate() ); emit setTimeTo( QTime::currentTime() ); } 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) { + if(key == Qt::Key_Up) { setDate( date.addDays( 1 ) ); } - else if(key == Key_Down) { + else if(key == Qt::Key_Down) { setDate( date.addDays( -1 ) ); } maxDay = readDate().day(); break; case 'm': case 'b': case 'B': - if(key == Key_Up) { + if(key == Qt::Key_Up) { int year = ((date.month()+1)>12)?date.year()+1:date.year(); int month = ((date.month()+1)>12)?1:date.month()+1; int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; setDate( QDate( year, month, day ) ); - } else if(key == Key_Down) { + } else if(key == Qt::Key_Down) { int year = ((date.month()-1)<1)?date.year()-1:date.year(); int month = ((date.month()-1)<1)?12:date.month()-1; int day = (QDate(year,month,1).daysInMonth()<maxDay)?QDate(year,month,1).daysInMonth():maxDay; setDate( QDate( year, month, day ) ); } break; case 'y': case 'Y': - if(key == Key_Up) { + if(key == Qt::Key_Up) { setDate( QDate( date.year() + 1, date.month() , date.day()) ); } - else if(key == Key_Down) { + else if(key == Qt::Key_Down) { setDate( QDate( date.year() - 1, date.month() , date.day()) ); } break; /* default: if(key == Key_Up) { setDate( date.addDays( 1 ) ); } else if(key == Key_Down) { setDate( date.addDays( -1 ) ); } break;*/ } date = readDate(); begin = dateForm.find("%"); int allSelectStrLength = 0; int selectStrLength = 0; // set selection do new date an set cursor at end of selection for(int i = 0; i < repeat; i++){ switch ( dateForm.at(begin + 1).latin1() ) { case 'd':// 16 (month day) selectStrLength = 2; //Ok break; case 'm':// 01 (month) selectStrLength = 2; //Ok break; case 'a':// Mon (Weekday short) selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), true).length(); break; case 'A':// Monday (Weekday) selectStrLength = KGlobal::locale()->weekDayName(date.dayOfWeek(), false).length(); break; case 'b':// Jan (monthName short) selectStrLength = KGlobal::locale()->monthName(date.month(), true).length(); break; case 'B':// January (monthName) selectStrLength = KGlobal::locale()->monthName(date.month(), false).length(); break; case 'y':// 04 (year short) selectStrLength = 2; //Ok break; case 'Y':// 2004 (year) selectStrLength = 4; //Ok break; default: break; } space = begin - (i * 2); allSelectStrLength += selectStrLength; begin = dateForm.find("%", begin +1); } // set selection from begin of date setSelect( space + allSelectStrLength - selectStrLength , selectStrLength); *cpos = space + allSelectStrLength; emit(dateChanged(date)); return; } void KDateEdit::setHandleInvalid(bool handleInvalid) { mHandleInvalid = handleInvalid; } void KDateEdit::setEnabled(bool on) { mDateEdit->setEnabled(on); mDateButton->setEnabled(on); } QDate KDateEdit::date() const { QDate date = readDate(); if (date.isValid() || mHandleInvalid) { return date; } else { KNotifyClient::beep(); return QDate::currentDate(); } } void KDateEdit::keyPressEvent(QKeyEvent *e) { QDate date = readDate(); int cpos = mDateEdit->cursorPosition(); switch(e->key()) { - case Key_Escape: + case Qt::Key_Escape: mDateEdit->deselect(); - case Key_Tab: - QHBox::keyPressEvent(e); + case Qt::Key_Tab: + Q3HBox::keyPressEvent(e); break; - case Key_Up: + case Qt::Key_Up: // when date invalid then set to currend and return if(!date.isValid()) { date = QDate::currentDate(); setDate(date); mDateEdit->setCursorPosition(cpos); emit(dateChanged(date)); QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); KMessageBox::information( 0, text ); return; } - setDate(date, &cpos, Key_Up, dateFormShort); + setDate(date, &cpos, Qt::Key_Up, dateFormShort); break; - case Key_Down: + case Qt::Key_Down: // when date invalid then set to current and return if(!date.isValid()) { date = QDate::currentDate(); setDate(date); mDateEdit->setCursorPosition(cpos); emit(dateChanged(date)); QString text = i18n( "You entered an invalid date!\n Date changed to current date." ); KMessageBox::information( 0, text ); return; } - setDate(date, &cpos, Key_Down, dateFormShort); + setDate(date, &cpos, Qt::Key_Down, dateFormShort); break; default: - QHBox::keyPressEvent(e); + Q3HBox::keyPressEvent(e); break; } // switch mDateEdit->setCursorPosition(cpos); } 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 ( isVisible() ) 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) ) diff --git a/libkdepim/kdateedit.h b/libkdepim/kdateedit.h index 2d8c452..38eacde 100644 --- a/libkdepim/kdateedit.h +++ b/libkdepim/kdateedit.h @@ -1,143 +1,146 @@ /* 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 <q3hbox.h> +#include <q3vbox.h> #include <qdatetime.h> #include <qmap.h> +//Added by qt3to4: +#include <QKeyEvent> +#include <QEvent> 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 +class KDateEdit : public Q3HBox { 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(); void setTimeTo( QTime ); 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 &); void goToNow(); 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; + Q3VBox *mDateFrame; int maxDay; bool withoutDp; protected: virtual void keyPressEvent(QKeyEvent *qke); void setSelect ( int, int ); bool dateFormShort; char lengthMonthName; }; #endif diff --git a/libkdepim/kdatepicker.cpp b/libkdepim/kdatepicker.cpp index 68ef943..28b65cf 100644 --- a/libkdepim/kdatepicker.cpp +++ b/libkdepim/kdatepicker.cpp @@ -1,139 +1,143 @@ /* -*- C++ -*- This file is part of the KDE libraries Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) (C) 1998-2001 Mirko Boehm (mirko@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 "kdatepicker.h" #include <kglobal.h> #include <kapplication.h> #include <klocale.h> #include <kiconloader.h> -#include <qframe.h> +#include <q3frame.h> #include <qpainter.h> #include <qdialog.h> #include <qtoolbutton.h> #include <qfont.h> #include <qapplication.h> #include <qlineedit.h> #include <qvalidator.h> +//Added by qt3to4: +#include <QResizeEvent> +#include <QKeyEvent> +#include <QDesktopWidget> #include <kdebug.h> #include <knotifyclient.h> #include <kglobalsettings.h> #include "kdatetbl.h" #include "kdateedit.h" //#include "kdatepicker.moc" KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) - : QFrame(parent,name), + : Q3Frame(parent,name), yearForward(new QToolButton(this)), yearBackward(new QToolButton(this)), monthForward(new QToolButton(this)), monthBackward(new QToolButton(this)), selectMonth(new QToolButton(this)), selectYear(new QToolButton(this)), todayBut(new QToolButton(this)), //line(new QLineEdit(this)), val(new KDateValidator(this)) //table(new KDateTable(this)), //fontsize(1) { QFont fo = KGlobalSettings::generalFont(); int add = 2; if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) add += 4; fo.setPointSize(fo.pointSize()+add ); setFont( fo ); table = new KDateTable(this); setFontSize(font().pointSize()); //line->setValidator(val); lineDate = new KDateEdit( this, "dateediipicker", true ); yearForward->setPixmap(SmallIcon("3rightarrowB")); yearBackward->setPixmap(SmallIcon("3leftarrowB")); monthForward->setPixmap(SmallIcon("2rightarrowB")); monthBackward->setPixmap(SmallIcon("2leftarrowB")); todayBut->setPixmap(SmallIcon("today")); setDate(dt); // set button texts connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); connect(todayBut, SIGNAL(clicked()), SLOT(goToday())); //connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); connect(lineDate, SIGNAL(dateChanged(QDate)), SLOT(slotSetDate(QDate))); connect(lineDate, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); table->setFocus(); } KDatePicker::~KDatePicker() { } void KDatePicker::resizeEvent(QResizeEvent*) { QWidget *buttons[] = { yearBackward, monthBackward, selectMonth, selectYear, monthForward, yearForward }; const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); QSize sizes[NoOfButtons]; int buttonHeight=0; int count; int w; int x=0; // ----- calculate button row height: for(count=0; count<NoOfButtons; ++count) { int xS = buttons[count]->sizeHint().width(); int yS = buttons[count]->sizeHint().height(); if ( QApplication::desktop()->width() < 320 ) sizes[count]=QSize ( xS+4, yS ); else sizes[count]=QSize ( xS+10, yS ); buttonHeight=QMAX(buttonHeight, sizes[count].height()); } buttonHeight += 10; // ----- calculate size of the month button: w=0; for(count=0; count<NoOfButtons; ++count) { if(buttons[count]!=selectMonth) { w+=sizes[count].width(); } else { x=count; } } sizes[x].setWidth(width()-w); // stretch the month button // ----- place the buttons: x=0; for(count=0; count<NoOfButtons; ++count) { w=sizes[count].width(); buttons[count]->setGeometry(x, 0, w, buttonHeight); x+=w; } // ----- place the line edit for direct input: diff --git a/libkdepim/kdatepicker.h b/libkdepim/kdatepicker.h index 3db9a89..4d904da 100644 --- a/libkdepim/kdatepicker.h +++ b/libkdepim/kdatepicker.h @@ -1,147 +1,150 @@ /* -*- C++ -*- This file is part of the KDE libraries Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) (C) 1998-2001 Mirko Boehm (mirko@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. */ #ifndef MICROKDE_KDATEPICKER_H #define MICROKDE_KDATEPICKER_H #include <qdatetime.h> -#include <qframe.h> +#include <q3frame.h> #include <qevent.h> +//Added by qt3to4: +#include <QResizeEvent> +#include <QKeyEvent> class QLineEdit; class QToolButton; class KDateValidator; class KDateTable; class KDateEdit; /** * Provides a widget for calendar date input. * * Different from the * previous versions, it now emits two types of signals, either * @ref dateSelected() or @ref dateEntered() (see documentation for both * signals). * * A line edit has been added in the newer versions to allow the user * to select a date directly by entering numbers like 19990101 * or 990101. * * @image kdatepicker.png KDatePicker * * @version $Id$ * @author Tim Gilman, Mirko Boehm * * @short A date selection widget. **/ -class KDatePicker: public QFrame +class KDatePicker: public Q3Frame { Q_OBJECT public: /** The usual constructor. The given date will be displayed * initially. **/ KDatePicker(QWidget *parent=0, QDate=QDate::currentDate(), const char *name=0); /** * The destructor. **/ virtual ~KDatePicker(); /** The size hint for date pickers. The size hint recommends the * minimum size of the widget so that all elements may be placed * without clipping. This sometimes looks ugly, so when using the * size hint, try adding 28 to each of the reported numbers of * pixels. **/ QSize sizeHint() const; /** * Sets the date. * * @returns @p false and does not change anything * if the date given is invalid. **/ bool setDate(const QDate&); /** * Returns the selected date. * @deprecated **/ const QDate& getDate() const; /** * @returns the selected date. */ const QDate &date() const; /** * Enables or disables the widget. **/ void setEnabled(bool); /** * Sets the font size of the widgets elements. **/ void setFontSize(int); /** * Returns the font size of the widget elements. */ int fontSize() const { return fontsize; } protected: /// the resize event void resizeEvent(QResizeEvent*); QToolButton *todayBut; /// the year forward button QToolButton *yearForward; /// the year backward button QToolButton *yearBackward; /// the month forward button QToolButton *monthForward; /// the month backward button QToolButton *monthBackward; /// the button for selecting the month directly QToolButton *selectMonth; /// the button for selecting the year directly QToolButton *selectYear; /// the line edit to enter the date directly //QLineEdit *line; KDateEdit *lineDate; /// the validator for the line edit: KDateValidator *val; /// the date table KDateTable *table; /// the size calculated during resize events // QSize sizehint; /// the widest month string in pixels: QSize maxMonthRect; protected slots: void dateChangedSlot(QDate); void tableClickedSlot(); void monthForwardClicked(); void monthBackwardClicked(); void yearForwardClicked(); void yearBackwardClicked(); void selectMonthClicked(); void selectYearClicked(); void lineEnterPressed(); void slotSetDate(QDate); void goToday(); signals: /** This signal is emitted each time the selected date is changed. diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 9c28425..3677e87 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp @@ -1,229 +1,229 @@ /* 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., 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include <kglobalsettings.h> #include <kstaticdeleter.h> #include <qregexp.h> #include <qfile.h> #include <stdlib.h> -#include <qtextstream.h> +#include <q3textstream.h> #include <qapplication.h> #include "kpimglobalprefs.h" KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) : KPrefs("microkdeglobalrc") { mLocaleDict = 0; KPrefs::setCurrentGroup("Fonts"); addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() ); KPrefs::setCurrentGroup("Locale"); addItemInt("PreferredLanguage",&mPreferredLanguage,0); addItemInt("PreferredTime",&mPreferredTime,0); addItemInt("PreferredDate",&mPreferredDate,0); addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y"); addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); KPrefs::setCurrentGroup("Colors"); addItemColor("AlternateBGcolor",&mAlternateColor,KGlobalSettings::alternateBackgroundColor()); KPrefs::setCurrentGroup("Time & Date"); addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); KPrefs::setCurrentGroup( "ExternalApplications" ); addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); addItemString( "EmailChannel", &mEmailOtherChannel, "" ); addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); addItemString( "FaxChannel", &mFaxOtherChannel, "" ); addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); addItemString( "SMSChannel", &mSMSOtherChannel, "" ); addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); addItemString( "PagerChannel", &mPagerOtherChannel, "" ); addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); addItemString( "SIPChannel", &mSipOtherChannel, "" ); addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); KPrefs::setCurrentGroup( "PhoneAccess" ); addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); KPrefs::setCurrentGroup( "BackupSettings" ); addItemString("BackupDatadir",&mBackupDatadir,KGlobalSettings::backupDataDir()); addItemInt( "BackupNumbers", &mBackupNumbers, 3 ); addItemInt( "BackupDayCount", &mBackupDayCount, 2 ); addItemBool( "BackupUseDefaultDir",&mBackupUseDefaultDir, true ); addItemBool( "BackupEnabled",&mBackupEnabled, false ); } void KPimGlobalPrefs::setGlobalConfig() { if ( mLocaleDict == 0 ) { QString fileName ; QString name = KGlobal::getAppName() +"/"; #ifndef DESKTOP_VERSION fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; #else fileName = qApp->applicationDirPath () + "/kdepim/"+ name; #endif mLocaleDict = 0; if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { if ( mPreferredLanguage == 1 ) fileName = fileName+"germantranslation.txt"; else if ( mPreferredLanguage == 4 ) fileName = fileName+"usertranslation.txt"; else if ( mPreferredLanguage == 2 ) fileName = fileName+"frenchtranslation.txt"; else if ( mPreferredLanguage == 3 ) fileName = fileName+"italiantranslation.txt"; QFile file( fileName ); - if (file.open( IO_ReadOnly ) ) { - QTextStream ts( &file ); - ts.setEncoding( QTextStream::Latin1 ); + if (file.open( QIODevice::ReadOnly ) ) { + Q3TextStream ts( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); //ts.setCodec( QTextCodec::latin1 ); QString text = ts.read(); file.close(); text.replace( QRegExp("\\\\n"), "\n" ); QString line; QString we; QString wt; int br = 0; int nbr; nbr = text.find ( "},", br ); line = text.mid( br, nbr - br ); br = nbr+1; int se, ee, st, et; - mLocaleDict = new QDict<QString>; + mLocaleDict = new Q3Dict<QString>; mLocaleDict->setAutoDelete( true ); QString end = "{ \"\",\"\" }"; while ( (line != end) && (br > 1) ) { //qDebug("%d *%s* ", br, line.latin1()); se = line.find("\"")+1; et = line.findRev("\"",-1); ee = line.find("\",\""); st = ee+3; we = line.mid( se, ee-se ); if ( mPreferredLanguage == 4 ) wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); else wt = line.mid( st, et-st ); //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); mLocaleDict->insert( we, new QString (wt) ); nbr = text.find ( "}", br ); line = text.mid( br, nbr - br ); br = nbr+1; } //qDebug("end *%s* ", end.latin1()); setLocaleDict( mLocaleDict ); } else { qDebug("KO: Cannot find translation file %s",fileName.latin1() ); } } } KGlobal::locale()->setHore24Format( !mPreferredTime ); KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); KGlobal::locale()->setLanguage( mPreferredLanguage ); QString dummy = mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = mUserDateFormatShort; KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, mDaylightsavingStart, mDaylightsavingEnd ); KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); QString localKdeDir; localKdeDir = readEnvPath("LOCALMICROKDEHOME"); if ( ! localKdeDir.isEmpty() ) { mBackupUseDefaultDir = true; mBackupDatadir = KGlobalSettings::backupDataDir(); } } KPimGlobalPrefs::~KPimGlobalPrefs() { if (sInstance == this) sInstance = staticDeleterGP.setObject(0); else qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); if ( mLocaleDict ) delete mLocaleDict; } KPimGlobalPrefs *KPimGlobalPrefs::instance() { if ( !sInstance ) { sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); sInstance->readConfig(); } return sInstance; } diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h index 94ac8ae..01f5ab0 100644 --- a/libkdepim/kpimglobalprefs.h +++ b/libkdepim/kpimglobalprefs.h @@ -1,151 +1,151 @@ /* This file is part of libkdepim. Copyright (c) 2004 Ulf Schenk 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. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KPIMGLOBALPREFS_H #define KPIMGLOBALPREFS_H #include "kprefs.h" -#include <qdict.h> +#include <q3dict.h> class KPimGlobalPrefs : public KPrefs { public: void setGlobalConfig(); static KPimGlobalPrefs *instance(); virtual ~KPimGlobalPrefs(); enum EMailClients { NONE_EMC = 0, OTHER_EMC = 1, OMPI_EMC = 2, QTOPIA_EMC = 3, OPIE_EMC = 4, OPIE_MAILIT_EMC = 5 }; enum PhoneClients { NONE_PHC = 0, OTHER_PHC = 1, KPPI_PHC = 2 }; enum FaxClients { NONE_FAC = 0, OTHER_FAC = 1 }; enum SMSClients { NONE_SMC = 0, OTHER_SMC = 1 }; enum PagerClients { NONE_PAC = 0, OTHER_PAC = 1 }; enum SIPClients { NONE_SIC = 0, OTHER_SIC = 1, KPPI_SIC = 2 }; private: KPimGlobalPrefs( const QString &name = QString::null ); static KPimGlobalPrefs *sInstance; - QDict<QString> *mLocaleDict; + Q3Dict<QString> *mLocaleDict; public: //US I copied the following "locale" settings from KOPrefs int mPreferredDate; QString mUserDateFormatLong; QString mUserDateFormatShort; int mPreferredLanguage; int mPreferredTime; bool mWeekStartsOnSunday; QString mTimeZoneId; bool mUseDaylightsaving; int mDaylightsavingStart; int mDaylightsavingEnd; bool mTimeZoneAdd30min; QFont mApplicationFont; QColor mAlternateColor; int mEmailClient; QString mEmailOtherChannel; QString mEmailOtherMessage; QString mEmailOtherMessageParameters; QString mEmailOtherMessage2; QString mEmailOtherMessageParameters2; int mPhoneClient; QString mPhoneOtherChannel; QString mPhoneOtherMessage; QString mPhoneOtherMessageParameters; int mFaxClient; QString mFaxOtherChannel; QString mFaxOtherMessage; QString mFaxOtherMessageParameters; int mSMSClient; QString mSMSOtherChannel; QString mSMSOtherMessage; QString mSMSOtherMessageParameters; int mPagerClient; QString mPagerOtherChannel; QString mPagerOtherMessage; QString mPagerOtherMessageParameters; int mSipClient; QString mSipOtherChannel; QString mSipOtherMessage; QString mSipOtherMessageParameters; QString mEx2PhoneDevice; QString mEx2PhoneConnection; QString mEx2PhoneModel; bool mBackupEnabled; QString mBackupDatadir; bool mBackupUseDefaultDir; int mBackupNumbers; int mBackupDayCount; }; #endif diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp index 6dc741d..358acbd 100644 --- a/libkdepim/kprefsdialog.cpp +++ b/libkdepim/kprefsdialog.cpp @@ -1,323 +1,324 @@ /* This file is part of KOrganizer. Copyright (c) 2001 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., 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. */ // $Id$ #include <qlayout.h> #include <qlabel.h> -#include <qgroupbox.h> -#include <qbuttongroup.h> +#include <q3groupbox.h> +#include <q3buttongroup.h> #include <qlineedit.h> #include <qfont.h> #include <qslider.h> #include <qfile.h> -#include <qtextstream.h> -#include <qvbox.h> -#include <qhbox.h> +#include <q3textstream.h> +#include <q3vbox.h> +#include <q3hbox.h> #include <qspinbox.h> #include <qdatetime.h> -#include <qframe.h> +#include <q3frame.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qapplication.h> +#include <QDesktopWidget> #include <kcolorbutton.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kglobalsettings.h> #include <kfontdialog.h> #include <kmessagebox.h> #include <kcolordialog.h> #include <kiconloader.h> #include "kprefs.h" #include "kpimglobalprefs.h" #include "kprefsdialog.h" //#include "kprefsdialog.moc" KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, QWidget *parent) { mReference = reference; mCheck = new QCheckBox(text,parent); } void KPrefsDialogWidBool::readConfig() { mCheck->setChecked(*mReference); } void KPrefsDialogWidBool::writeConfig() { *mReference = mCheck->isChecked(); } QCheckBox *KPrefsDialogWidBool::checkBox() { return mCheck; } KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, QWidget *parent) { mReference = reference; mButton = new KColorButton(parent); mLabel = new QLabel(mButton, text, parent); mButton->setColor( *mReference ); mButton->setColor( Qt::red ); } KPrefsDialogWidColor::~KPrefsDialogWidColor() { // kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; } void KPrefsDialogWidColor::readConfig() { mButton->setColor(*mReference); } void KPrefsDialogWidColor::writeConfig() { *mReference = mButton->color(); } QLabel *KPrefsDialogWidColor::label() { return mLabel; } KColorButton *KPrefsDialogWidColor::button() { return mButton; } KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, QFont *reference,QWidget *parent) { mReference = reference; mLabel = new QLabel(labelText, parent); mPreview = new QLabel(sampleText,parent); - mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); + mPreview->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken); mButton = new QPushButton(i18n("Choose..."), parent); connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); } KPrefsDialogWidFont::~KPrefsDialogWidFont() { } void KPrefsDialogWidFont::readConfig() { mPreview->setFont(*mReference); } void KPrefsDialogWidFont::writeConfig() { *mReference = mPreview->font(); } QLabel *KPrefsDialogWidFont::label() { return mLabel; } QLabel *KPrefsDialogWidFont::preview() { return mPreview; } QPushButton *KPrefsDialogWidFont::button() { return mButton; } void KPrefsDialogWidFont::selectFont() { QFont myFont(mPreview->font()); bool ok; myFont = KFontDialog::getFont(myFont, ok); if ( ok ) { mPreview->setFont(myFont); } } KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, QWidget *parent) { mReference = reference; mLabel = new QLabel(text,parent); mSpin = new QSpinBox(0,23,1,parent); mSpin->setSuffix(":00"); } void KPrefsDialogWidTime::readConfig() { mSpin->setValue(*mReference); } void KPrefsDialogWidTime::writeConfig() { *mReference = mSpin->value(); } QLabel *KPrefsDialogWidTime::label() { return mLabel; } QSpinBox *KPrefsDialogWidTime::spinBox() { return mSpin; } KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, QWidget *parent) { mReference = reference; - mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); + mBox = new Q3ButtonGroup(1,Qt::Horizontal,text,parent); } KPrefsDialogWidRadios::~KPrefsDialogWidRadios() { } void KPrefsDialogWidRadios::addRadio(const QString &text) { new QRadioButton(text,mBox); } -QButtonGroup *KPrefsDialogWidRadios::groupBox() +Q3ButtonGroup *KPrefsDialogWidRadios::groupBox() { return mBox; } void KPrefsDialogWidRadios::readConfig() { mBox->setButton(*mReference); } void KPrefsDialogWidRadios::writeConfig() { *mReference = mBox->id(mBox->selected()); } KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, QWidget *parent, QLineEdit::EchoMode echomode) { mReference = reference; mLabel = new QLabel(text,parent); mEdit = new QLineEdit(parent); mEdit->setEchoMode( echomode ); } KPrefsDialogWidString::~KPrefsDialogWidString() { } void KPrefsDialogWidString::readConfig() { mEdit->setText(*mReference); } void KPrefsDialogWidString::writeConfig() { *mReference = mEdit->text(); } QLabel *KPrefsDialogWidString::label() { return mLabel; } QLineEdit *KPrefsDialogWidString::lineEdit() { return mEdit; } KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, name,modal,true) { mPrefs = prefs; // This seems to cause a crash on exit. Investigate later. mPrefsWids.setAutoDelete(true); connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); } KPrefsDialog::~KPrefsDialog() { } void KPrefsDialog::addWid(KPrefsDialogWid *wid) { mPrefsWids.append(wid); } KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) { KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); addWid(w); return w; } KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) { KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); addWid(w); return w; } KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) { KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); addWid(w); return w; } KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) { diff --git a/libkdepim/kprefsdialog.h b/libkdepim/kprefsdialog.h index 52ec809..cc95dd4 100644 --- a/libkdepim/kprefsdialog.h +++ b/libkdepim/kprefsdialog.h @@ -1,135 +1,137 @@ /* This file is part of KOrganizer. Copyright (c) 2001 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., 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. */ #ifndef _KPREFSDIALOG_H #define _KPREFSDIALOG_H // $Id$ -#include <qptrlist.h> +#include <q3ptrlist.h> #include <qlineedit.h> +//Added by qt3to4: +#include <QLabel> #include <kdialogbase.h> class KPrefs; class KPrefsDialog; class KColorButton; class QCheckBox; class QLabel; class QSpinBox; -class QButtonGroup; +class Q3ButtonGroup; /** @short Base class for widgets used by @ref KPrefsDialog. @author Cornelius Schumacher @see KPrefsDialog This class provides the interface for the preferences widgets used by KPrefsDialog. */ class KPrefsDialogWid : public QObject { public: /** This function is called to read value of the setting from the stored configuration and display it in the widget. */ virtual void readConfig() = 0; /** This function is called to write the current setting of the widget to the stored configuration. */ virtual void writeConfig() = 0; }; /** @short Widget for bool settings in @ref KPrefsDialog. This class provides a widget for configuring bool values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsDialogWidBool : public KPrefsDialogWid { public: /** Create a bool widget consisting of a QCheckbox. @param text Text of QCheckBox. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsDialogWidBool(const QString &text,bool *reference,QWidget *parent); /** Return the QCheckbox used by this widget. */ QCheckBox *checkBox(); void readConfig(); void writeConfig(); private: bool *mReference; QCheckBox *mCheck; }; /** @short Widget for time settings in @ref KPrefsDialog. This class provides a widget for configuring time values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsDialogWidTime : public KPrefsDialogWid { public: /** Create a time widget consisting of a label and a spinbox. @param text Text of Label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsDialogWidTime(const QString &text,int *reference,QWidget *parent); /** Return QLabel used by this widget. */ QLabel *label(); /** Return QSpinBox used by this widget. */ QSpinBox *spinBox(); void readConfig(); void writeConfig(); private: int *mReference; QLabel *mLabel; QSpinBox *mSpin; }; /** @short Widget for color settings in @ref KPrefsDialog. @@ -165,307 +167,307 @@ class KPrefsDialogWidColor : public KPrefsDialogWid void readConfig(); void writeConfig(); private: QColor *mReference; QLabel *mLabel; KColorButton *mButton; }; /** @short Widget for font settings in @ref KPrefsDialog. This class provides a widget for configuring font values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsDialogWidFont : public KPrefsDialogWid { Q_OBJECT public: /** Create a font widget consisting of a test field and a button for opening a font dialog. @param label Text of label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, QFont *reference,QWidget *parent); /** Destruct font setting widget. */ ~KPrefsDialogWidFont(); /** Return label. */ QLabel *label(); /** Return QFrame used as preview field. */ QLabel *preview(); /** Return button opening the font dialog. */ QPushButton *button(); void readConfig(); void writeConfig(); protected slots: void selectFont(); private: QFont *mReference; QLabel *mLabel; QLabel *mPreview; QPushButton *mButton; }; /** @short Widget for settings represented by a group of radio buttons in @ref KPrefsDialog. This class provides a widget for configuring selections. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. The setting is interpreted as an int value, corresponding to the position of the radio button. The position of the button is defined by the sequence of @ref addRadio() calls, starting with 0. */ class KPrefsDialogWidRadios : public KPrefsDialogWid { public: /** Create a widget for selection of an option. It consists of a box with several radio buttons. @param text Text of main box. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsDialogWidRadios(const QString &text,int *reference,QWidget *parent); virtual ~KPrefsDialogWidRadios(); /** Add a radio button. @param text Text of the button. */ void addRadio(const QString &text); /** Return the box widget used by this widget. */ - QButtonGroup *groupBox(); + Q3ButtonGroup *groupBox(); void readConfig(); void writeConfig(); private: int *mReference; - QButtonGroup *mBox; + Q3ButtonGroup *mBox; }; /** @short Widget for string settings in @ref KPrefsDialog. This class provides a widget for configuring string values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsDialogWidString : public KPrefsDialogWid { public: /** Create a string widget consisting of a test label and a line edit. @param text Text of label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsDialogWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); /** Destructor. */ virtual ~KPrefsDialogWidString(); /** Return label used by this widget. */ QLabel *label(); /** Return QLineEdit used by this widget. */ QLineEdit *lineEdit(); void readConfig(); void writeConfig(); private: QString *mReference; QLabel *mLabel; QLineEdit *mEdit; }; /** @short Base class for a preferences dialog. This class provides the framework for a preferences dialog. You have to subclass it and add the code to create the actual configuration widgets and do the layout management. KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For these widgets the reading, writing and setting to default values is handled automatically. Custom widgets have to be handled in the functions @ref usrReadConfig() and @ref usrWriteConfig(). */ class KPrefsDialog : public KDialogBase { Q_OBJECT public: /** Create a KPrefsDialog for a KPrefs object. @param prefs KPrefs object used to access te configuration. @param parent Parent widget. @param name Widget name. @param modal true, if dialog has to be modal, false for non-modal. */ KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false); /** Destructor. */ virtual ~KPrefsDialog(); /** Register a custom KPrefsDialogWid object. */ void addWid(KPrefsDialogWid *); /** Register a @ref KPrefsDialogWidBool object. @param text Text of bool widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); /** Register a @ref KPrefsDialogWidTime object. @param text Text of time widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); /** Register a @ref KPrefsDialogWidColor object. @param text Text of color widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); /** Register a @ref KPrefsDialogWidRadios object. @param text Text of radio button box widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); /** Register a @ref KPrefsDialogWidString object. @param text Text of string widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent); /** Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password. @param text Text of string widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); /** Register a @ref KPrefsDialogWidFont object. @param sampleText Sample text of font widget. @param buttonText Button text of font widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText, QFont *reference,QWidget *parent); public slots: /** Set all widgets to default values. */ void setDefaults(); /** Read preferences from config file. */ void readConfig(); /** Write preferences to config file. */ void writeConfig(); signals: /** Emitted when the a changed configuration has been stored. */ void configChanged(); protected slots: /** Apply changes to preferences */ void slotApply(); void accept(); /** Accept changes to preferences and close dialog */ void slotOk(); /** Set preferences to default values */ void slotDefault(); protected: /** Implement this to read custom configuration widgets. */ virtual void usrReadConfig() {} /** Implement this to write custom configuration widgets. */ virtual void usrWriteConfig() {} private: KPrefs *mPrefs; - QPtrList<KPrefsDialogWid> mPrefsWids; + Q3PtrList<KPrefsDialogWid> mPrefsWids; }; #include "kcmconfigs/kdepimconfigwidget.h" class KPimPrefsGlobalDialog : public KPrefsDialog { Q_OBJECT public: KPimPrefsGlobalDialog(QWidget *parent=0,char *name=0,bool modal=true); /** Destructor. */ void showTZconfig(); public slots: signals: protected slots: protected: void usrReadConfig(); virtual void usrWriteConfig() ; private: KDEPIMConfigWidget* kdelibcfg; }; #endif diff --git a/libkdepim/kprefswidget.cpp b/libkdepim/kprefswidget.cpp index f6a0b38..51431e2 100644 --- a/libkdepim/kprefswidget.cpp +++ b/libkdepim/kprefswidget.cpp @@ -1,330 +1,331 @@ /* This file is part of KOrganizer. Copyright (c) 2001 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., 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. */ // $Id$ #include <qlayout.h> #include <qlabel.h> -#include <qgroupbox.h> -#include <qbuttongroup.h> +#include <q3groupbox.h> +#include <q3buttongroup.h> #include <qlineedit.h> #include <qfont.h> #include <qslider.h> #include <qfile.h> -#include <qtextstream.h> -#include <qvbox.h> -#include <qhbox.h> +#include <q3textstream.h> +#include <q3vbox.h> +#include <q3hbox.h> #include <qspinbox.h> #include <qdatetime.h> -#include <qframe.h> +#include <q3frame.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qapplication.h> +#include <QDesktopWidget> #include <kcolorbutton.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kfontdialog.h> #include <kmessagebox.h> #include <kcolordialog.h> #include <kiconloader.h> #include "kprefs.h" #include "kprefswidget.h" //#include "kprefsdialog.moc" KPrefsWidBool::KPrefsWidBool(const QString &text,bool *reference, QWidget *parent) { mReference = reference; mCheck = new QCheckBox(text,parent); connect( mCheck, SIGNAL( toggled( bool ) ), SIGNAL( modified() ) ); } void KPrefsWidBool::readConfig() { mCheck->setChecked(*mReference); } void KPrefsWidBool::writeConfig() { *mReference = mCheck->isChecked(); } QCheckBox *KPrefsWidBool::checkBox() { return mCheck; } KPrefsWidColor::KPrefsWidColor(const QString &text,QColor *reference, QWidget *parent) { mReference = reference; mButton = new KColorButton(parent); mLabel = new QLabel(mButton, text, parent); mButton->setColor( *mReference ); mButton->setColor( Qt::red ); connect( mButton, SIGNAL( changed(const QColor &)), SIGNAL( modified() ) ); } KPrefsWidColor::~KPrefsWidColor() { // kdDebug(5300) << "KPrefsWidColor::~KPrefsWidColor()" << endl; } void KPrefsWidColor::readConfig() { mButton->setColor(*mReference); } void KPrefsWidColor::writeConfig() { *mReference = mButton->color(); } QLabel *KPrefsWidColor::label() { return mLabel; } KColorButton *KPrefsWidColor::button() { return mButton; } KPrefsWidFont::KPrefsWidFont(const QString &sampleText,const QString &labelText, QFont *reference,QWidget *parent) { mReference = reference; mLabel = new QLabel(labelText, parent); mPreview = new QLabel(sampleText,parent); - mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); + mPreview->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken); mButton = new QPushButton(i18n("Choose..."), parent); connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); } KPrefsWidFont::~KPrefsWidFont() { } void KPrefsWidFont::readConfig() { mPreview->setFont(*mReference); } void KPrefsWidFont::writeConfig() { *mReference = mPreview->font(); } QLabel *KPrefsWidFont::label() { return mLabel; } QLabel *KPrefsWidFont::preview() { return mPreview; } QPushButton *KPrefsWidFont::button() { return mButton; } void KPrefsWidFont::selectFont() { QFont myFont(mPreview->font()); bool ok; myFont = KFontDialog::getFont(myFont, ok); if ( ok ) { mPreview->setFont(myFont); emit modified(); } } KPrefsWidTime::KPrefsWidTime(const QString &text,int *reference, QWidget *parent) { mReference = reference; mLabel = new QLabel(text,parent); mSpin = new QSpinBox(0,23,1,parent); mSpin->setSuffix(":00"); connect( mSpin, SIGNAL( valueChanged(int)), SIGNAL( modified() ) ); } void KPrefsWidTime::readConfig() { mSpin->setValue(*mReference); } void KPrefsWidTime::writeConfig() { *mReference = mSpin->value(); } QLabel *KPrefsWidTime::label() { return mLabel; } QSpinBox *KPrefsWidTime::spinBox() { return mSpin; } KPrefsWidRadios::KPrefsWidRadios(const QString &text,int *reference, QWidget *parent) { mReference = reference; - mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); + mBox = new Q3ButtonGroup(1,Qt::Horizontal,text,parent); connect( mBox, SIGNAL( clicked(int)), SIGNAL( modified() ) ); } KPrefsWidRadios::~KPrefsWidRadios() { } void KPrefsWidRadios::addRadio(const QString &text) { new QRadioButton(text,mBox); } -QButtonGroup *KPrefsWidRadios::groupBox() +Q3ButtonGroup *KPrefsWidRadios::groupBox() { return mBox; } void KPrefsWidRadios::readConfig() { mBox->setButton(*mReference); } void KPrefsWidRadios::writeConfig() { *mReference = mBox->id(mBox->selected()); } KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, QWidget *parent, QLineEdit::EchoMode echomode) { mReference = reference; mLabel = new QLabel(text,parent); mEdit = new QLineEdit(parent); mEdit->setEchoMode( echomode ); connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); } KPrefsWidString::~KPrefsWidString() { } void KPrefsWidString::readConfig() { mEdit->setText(*mReference); } void KPrefsWidString::writeConfig() { *mReference = mEdit->text(); } QLabel *KPrefsWidString::label() { return mLabel; } QLineEdit *KPrefsWidString::lineEdit() { return mEdit; } KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : QWidget(parent, name ) { mPrefs = prefs; mPrefsWids.setAutoDelete( true ); } KPrefsWidget::~KPrefsWidget() { } void KPrefsWidget::addWid(KPrefsWid *wid) { mPrefsWids.append(wid); connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); } KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) { KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); addWid(w); return w; } KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) { KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); addWid(w); return w; } KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) { KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); addWid(w); return w; } KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) { KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); addWid(w); return w; diff --git a/libkdepim/kprefswidget.h b/libkdepim/kprefswidget.h index 8543a39..9de1be5 100644 --- a/libkdepim/kprefswidget.h +++ b/libkdepim/kprefswidget.h @@ -1,136 +1,138 @@ /* This file is part of KOrganizer. Copyright (c) 2001 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., 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. */ // $Id$ #ifndef _KPREFSWIDGET_H #define _KPREFSWIDGET_H -#include <qptrlist.h> +#include <q3ptrlist.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qwidget.h> +//Added by qt3to4: +#include <QLabel> class KPrefs; class KColorButton; class QCheckBox; class QLabel; class QSpinBox; -class QButtonGroup; +class Q3ButtonGroup; /** @short Base class for widgets used by @ref KPrefsDialog. @author Cornelius Schumacher @see KPrefsDialog This class provides the interface for the preferences widgets used by KPrefsDialog. */ class KPrefsWid : public QObject { Q_OBJECT public: /** This function is called to read value of the setting from the stored configuration and display it in the widget. */ virtual void readConfig() = 0; /** This function is called to write the current setting of the widget to the stored configuration. */ virtual void writeConfig() = 0; //connect to this signal if you want to be notified of changes signals: void modified(); }; /** @short Widget for bool settings in @ref KPrefsDialog. This class provides a widget for configuring bool values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsWidBool : public KPrefsWid { public: /** Create a bool widget consisting of a QCheckbox. @param text Text of QCheckBox. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsWidBool(const QString &text,bool *reference,QWidget *parent); /** Return the QCheckbox used by this widget. */ QCheckBox *checkBox(); void readConfig(); void writeConfig(); private: bool *mReference; QCheckBox *mCheck; }; /** @short Widget for time settings in @ref KPrefsDialog. This class provides a widget for configuring time values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsWidTime : public KPrefsWid { public: /** Create a time widget consisting of a label and a spinbox. @param text Text of Label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsWidTime(const QString &text,int *reference,QWidget *parent); /** Return QLabel used by this widget. */ QLabel *label(); /** Return QSpinBox used by this widget. */ QSpinBox *spinBox(); void readConfig(); void writeConfig(); private: int *mReference; QLabel *mLabel; @@ -172,284 +174,284 @@ class KPrefsWidColor : public KPrefsWid void readConfig(); void writeConfig(); private: QColor *mReference; QLabel *mLabel; KColorButton *mButton; }; /** @short Widget for font settings in @ref KPrefsDialog. This class provides a widget for configuring font values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsWidFont : public KPrefsWid { Q_OBJECT public: /** Create a font widget consisting of a test field and a button for opening a font dialog. @param label Text of label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsWidFont(const QString &sampleText,const QString &labelText, QFont *reference,QWidget *parent); /** Destruct font setting widget. */ ~KPrefsWidFont(); /** Return label. */ QLabel *label(); /** Return QFrame used as preview field. */ QLabel *preview(); /** Return button opening the font dialog. */ QPushButton *button(); void readConfig(); void writeConfig(); protected slots: void selectFont(); private: QFont *mReference; QLabel *mLabel; QLabel *mPreview; QPushButton *mButton; }; /** @short Widget for settings represented by a group of radio buttons in @ref KPrefsDialog. This class provides a widget for configuring selections. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. The setting is interpreted as an int value, corresponding to the position of the radio button. The position of the button is defined by the sequence of @ref addRadio() calls, starting with 0. */ class KPrefsWidRadios : public KPrefsWid { public: /** Create a widget for selection of an option. It consists of a box with several radio buttons. @param text Text of main box. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsWidRadios(const QString &text,int *reference,QWidget *parent); virtual ~KPrefsWidRadios(); /** Add a radio button. @param text Text of the button. */ void addRadio(const QString &text); /** Return the box widget used by this widget. */ - QButtonGroup *groupBox(); + Q3ButtonGroup *groupBox(); void readConfig(); void writeConfig(); private: int *mReference; - QButtonGroup *mBox; + Q3ButtonGroup *mBox; }; /** @short Widget for string settings in @ref KPrefsDialog. This class provides a widget for configuring string values. It is meant to be used by KPrefsDialog. The user is responsible for the layout management. */ class KPrefsWidString : public KPrefsWid { public: /** Create a string widget consisting of a test label and a line edit. @param text Text of label. @param reference Pointer to variable read and written by this widget. @param parent Parent widget. */ KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); /** Destructor. */ virtual ~KPrefsWidString(); /** Return label used by this widget. */ QLabel *label(); /** Return QLineEdit used by this widget. */ QLineEdit *lineEdit(); void readConfig(); void writeConfig(); private: QString *mReference; QLabel *mLabel; QLineEdit *mEdit; }; /** @short Base class for a preferences widget. This class provides the framework for a preferences widget. You have to subclass it and add the code to create the actual configuration widgets and do the layout management. KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For these widgets the reading, writing and setting to default values is handled automatically. Custom widgets have to be handled in the functions @ref usrReadConfig() and @ref usrWriteConfig(). */ class KPrefsWidget : public QWidget { Q_OBJECT public: /** Create a KPrefsDialog for a KPrefs object. @param prefs KPrefs object used to access te configuration. @param parent Parent widget. @param name Widget name. */ KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0); /** Destructor. */ virtual ~KPrefsWidget(); /** Register a custom KPrefsWid object. */ void addWid(KPrefsWid *); /** Register a @ref KPrefsWidBool object. @param text Text of bool widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); /** Register a @ref KPrefsWidTime object. @param text Text of time widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); /** Register a @ref KPrefsWidColor object. @param text Text of color widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); /** Register a @ref KPrefsWidRadios object. @param text Text of radio button box widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); /** Register a @ref KPrefsWidString object. @param text Text of string widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent); /** Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password. @param text Text of string widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); /** Register a @ref KPrefsWidFont object. @param sampleText Sample text of font widget. @param buttonText Button text of font widget. @param reference Reference to variable storing the setting. @param parent Parent widget. */ KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText, QFont *reference,QWidget *parent); public slots: /** Set all widgets to default values. */ void setDefaults(); /** Read preferences from config file. */ void readConfig(); /** Write preferences to config file. */ void writeConfig(); /** connect this slot to all UI elements */ void modified(); signals: /** Emitted when the a changed configuration has been stored. */ //US void configChanged(); void changed( bool ); protected slots: /** Apply changes to preferences */ //US void slotApply(); //US void accept(); /** Accept changes to preferences and close dialog */ //US void slotOk(); /** Set preferences to default values */ //US void slotDefault(); protected: /** Implement this to read custom configuration widgets. */ virtual void usrReadConfig() {} /** Implement this to write custom configuration widgets. */ virtual void usrWriteConfig() {} private: KPrefs *mPrefs; - QPtrList<KPrefsWid> mPrefsWids; + Q3PtrList<KPrefsWid> mPrefsWids; }; #endif diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 5708dfc..c844627 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -1,188 +1,191 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2004 Ulf Schenk 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. */ // $Id$ #include "ksyncmanager.h" #include <stdlib.h> #ifndef _WIN32_ #include <unistd.h> #endif #include "ksyncprofile.h" #include "ksyncprefsdialog.h" #include "kpimprefs.h" #include <kmessagebox.h> #include <qdir.h> -#include <qprogressbar.h> -#include <qpopupmenu.h> +#include <q3progressbar.h> +#include <q3popupmenu.h> #include <qpushbutton.h> #include <qradiobutton.h> -#include <qbuttongroup.h> +#include <q3buttongroup.h> #include <qtimer.h> #include <qmessagebox.h> #include <qapplication.h> #include <qlineedit.h> #include <qdialog.h> #include <qlayout.h> #include <qtextcodec.h> #include <qlabel.h> #include <qcheckbox.h> #include <qapplication.h> +#include <QDesktopWidget> +//Added by qt3to4: +#include <Q3VBoxLayout> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kfiledialog.h> QDateTime KSyncManager::mRequestedSyncEvent; -KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) +KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu) : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) { mServerSocket = 0; - bar = new QProgressBar ( 1, 0 ); + bar = new Q3ProgressBar ( 1, 0 ); bar->setCaption (""); mWriteBackInPast = 2; } KSyncManager::~KSyncManager() { delete bar; } void KSyncManager::setDefaultFileName( QString s) { mDefFileName = s ; if ( mPrefs->mPassiveSyncAutoStart ) enableQuick( false ); } void KSyncManager::fillSyncMenu() { if ( mSyncMenu->count() ) mSyncMenu->clear(); mSyncMenu->insertItem( i18n("Configure..."), 0 ); mSyncMenu->insertSeparator(); - QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); + Q3PopupMenu *clearMenu = new Q3PopupMenu ( mSyncMenu ); mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); clearMenu->insertItem( i18n("For all profiles"), 1 ); clearMenu->insertSeparator(); connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); mSyncMenu->insertSeparator(); if ( mServerSocket == 0 ) { mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); } else { mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); } mSyncMenu->insertSeparator(); mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); mSyncMenu->insertSeparator(); KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); config.setGroup("General"); QStringList prof = config.readListEntry("SyncProfileNames"); mLocalMachineName = config.readEntry("LocalMachineName","undefined"); if ( prof.count() < 2 ) { prof.clear(); QString externalName; #ifdef DESKTOP_VERSION #ifdef _WIN32_ externalName = "OutLook"; #else externalName = "KDE_Desktop"; #endif #else externalName = "Sharp_DTM"; #endif prof << externalName; prof << i18n("Local_file"); prof << i18n("Last_file"); KSyncProfile* temp = new KSyncProfile (); temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); config.writeEntry("ExternSyncProfiles",externalName); config.sync(); delete temp; } mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); mSyncProfileNames = prof; unsigned int i; for ( i = 0; i < prof.count(); ++i ) { QString insertText = prof[i]; if ( i == 0 ) { #ifdef DESKTOP_VERSION #ifdef _WIN32_ insertText = "OutLook"; #else insertText = "KDE_Desktop"; #endif #else insertText = "Sharp_DTM"; #endif } mSyncMenu->insertItem( insertText, 1000+i ); clearMenu->insertItem( insertText, 1000+i ); if ( i == 2 ) mSyncMenu->insertSeparator(); } QDir app_dir; //US do not display SharpDTM if app is pwmpi, or no sharpfiles available if ( mTargetApp == PWMPI) { mSyncMenu->removeItem( 1000 ); clearMenu->removeItem( 1000 ); } #ifndef DESKTOP_VERSION else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { mSyncMenu->removeItem( 1000 ); clearMenu->removeItem( 1000 ); } #endif mSyncMenu->removeItem( 1002 ); clearMenu->removeItem( 1002 ); } void KSyncManager::slotClearMenu( int action ) { QString syncDevice; if ( action > 999 ) { syncDevice = mSyncProfileNames[action - 1000] ; } int result = 0; QString sd; if ( syncDevice.isEmpty() ) sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); else sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); @@ -262,193 +265,193 @@ void KSyncManager::slotSyncMenu( int action ) mIsKapiFile = temp->getIsKapiFile(); mWriteBackInFuture = 0; if ( temp->getWriteBackFuture() ) { mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); mWriteBackInPast = temp->getWriteBackPastWeeks( ); } mFilterInCal = temp->getFilterInCal(); mFilterOutCal = temp->getFilterOutCal(); mFilterInAB = temp->getFilterInAB(); mFilterOutAB = temp->getFilterOutAB(); if ( action == 1000 ) { mIsKapiFile = false; #ifdef DESKTOP_VERSION syncKDE(); #else syncSharp(); #endif } else if ( action == 1001 ) { syncLocalFile(); } else if ( action == 1002 ) { mWriteBackFile = false; mAskForPreferences = false; mShowSyncSummary = false; mSyncAlgoPrefs = 3; quickSyncLocalFile(); } else if ( action >= 1003 ) { if ( temp->getIsLocalFileSync() ) { switch(mTargetApp) { case (KAPI): if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); break; case (KOPI): if ( syncWithFile( temp->getRemoteFileName( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); break; case (PWMPI): if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); break; default: qDebug("KSM::slotSyncMenu: invalid apptype selected"); break; } } else { if ( temp->getIsPhoneSync() ) { mPhoneDevice = temp->getPhoneDevice( ) ; mPhoneConnection = temp->getPhoneConnection( ); mPhoneModel = temp->getPhoneModel( ); syncPhone(); } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { mSpecificResources.clear(); if ( mTargetApp == KAPI ) { if ( temp->getIsPiSyncSpec() ) mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); mPassWordPiSync = temp->getRemotePwAB(); mActiveSyncPort = temp->getRemotePortAB(); mActiveSyncIP = temp->getRemoteIPAB(); } else if ( mTargetApp == KOPI ) { if ( temp->getIsPiSyncSpec() ) mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); mPassWordPiSync = temp->getRemotePw(); mActiveSyncPort = temp->getRemotePort(); mActiveSyncIP = temp->getRemoteIP(); } else { mPassWordPiSync = temp->getRemotePwPWM(); mActiveSyncPort = temp->getRemotePortPWM(); mActiveSyncIP = temp->getRemoteIPPWM(); } syncPi(); while ( !mPisyncFinished ) { //qDebug("waiting "); qApp->processEvents(); } } else syncRemote( temp ); } } delete temp; setBlockSave(false); } void KSyncManager::enableQuick( bool ask ) { bool autoStart; bool changed = false; if ( ask ) { QDialog dia ( 0, "input-dialog", true ); QLineEdit lab ( &dia ); - QVBoxLayout lay( &dia ); + Q3VBoxLayout lay( &dia ); lab.setText( mPrefs->mPassiveSyncPort ); lay.setMargin(7); lay.setSpacing(7); int po = 9197+mTargetApp; QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); lay.addWidget( &label); lay.addWidget( &lab); QLineEdit lepw ( &dia ); lepw.setText( mPrefs->mPassiveSyncPw ); QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); lay.addWidget( &label2); lay.addWidget( &lepw); QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); lay.addWidget( &autostart); autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); #ifdef DESKTOP_VERSION #ifdef _WIN32_ QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); syncdesktop.hide();// not implemented! #else QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); #endif lay.addWidget( &syncdesktop); #else mPrefs->mPassiveSyncWithDesktop = false; QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); syncdesktop.hide(); #endif syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.resize( 230,120 ); dia.setCaption( i18n("Enter port for Pi-Sync") ); dia.show(); #ifndef DESKTOP_VERSION int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); #endif if ( ! dia.exec() ) return; dia.hide(); qApp->processEvents(); if ( mPrefs->mPassiveSyncPw != lepw.text() ) { changed = true; mPrefs->mPassiveSyncPw = lepw.text(); } if ( mPrefs->mPassiveSyncPort != lab.text() ) { mPrefs->mPassiveSyncPort = lab.text(); changed = true; } autoStart = autostart.isChecked(); if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { changed = true; mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); } } else autoStart = mPrefs->mPassiveSyncAutoStart; if ( autoStart != mPrefs->mPassiveSyncAutoStart ) changed = true; bool ok; mPrefs->mPassiveSyncAutoStart = false; Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); if ( ! ok || port_t > 65535 ) { KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); return; } Q_UINT16 port = port_t; //qDebug("port %d ", port); mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); mServerSocket->setFileName( defaultFileName() );//bbb if ( !mServerSocket->ok() ) { QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); delete mServerSocket; mServerSocket = 0; return; } mPrefs->mPassiveSyncAutoStart = autoStart; if ( changed ) { mPrefs->writeConfig(); } //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); } void KSyncManager::displayErrorPort() { KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); } void KSyncManager::syncLocalFile() { @@ -711,280 +714,280 @@ int KSyncManager::ringSync() void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) { QString question; if ( ask ) { question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; if ( QMessageBox::information( mParent, i18n("Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) return; } QString preCommand; QString localTempFile; QString postCommand; switch(mTargetApp) { case (KAPI): preCommand = prof->getPreSyncCommandAB(); postCommand = prof->getPostSyncCommandAB(); localTempFile = prof->getLocalTempFileAB(); break; case (KOPI): preCommand = prof->getPreSyncCommand(); postCommand = prof->getPostSyncCommand(); localTempFile = prof->getLocalTempFile(); break; case (PWMPI): preCommand = prof->getPreSyncCommandPWM(); postCommand = prof->getPostSyncCommandPWM(); localTempFile = prof->getLocalTempFilePWM(); break; default: qDebug("KSM::syncRemote: invalid apptype selected"); break; } int fi; if ( (fi = preCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); } int maxlen = 30; if ( QApplication::desktop()->width() > 320 ) maxlen += 25; mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); int result = system ( preCommand ); // 0 : okay // 256: no such file or dir // qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); if ( result != 0 ) { unsigned int len = maxlen; while ( len < preCommand.length() ) { preCommand.insert( len , "\n" ); len += maxlen +2; } question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; QMessageBox::information( mParent, i18n("Sync - ERROR"), question, i18n("Okay!")) ; mParent->topLevelWidget()->setCaption ("KDE-Pim"); return; } mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); if ( syncWithFile( localTempFile, true ) ) { if ( mWriteBackFile ) { int fi; if ( (fi = postCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); } mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); result = system ( postCommand ); qDebug("KSM::Sync:Writing back file result: %d ", result); if ( result != 0 ) { mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); return; } else { mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); } } } return; } bool KSyncManager::edit_pisync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); - QVBoxLayout lay ( &dia ); + Q3VBoxLayout lay ( &dia ); lay.setSpacing( 5 ); lay.setMargin( 3 ); QLabel lab1 ( i18n("Password for remote access:"), &dia); lay.addWidget( &lab1 ); QLineEdit le1 (&dia ); lay.addWidget( &le1 ); QLabel lab2 ( i18n("Remote IP address:"), &dia); lay.addWidget( &lab2 ); QLineEdit le2 (&dia ); lay.addWidget( &le2 ); QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); lay.addWidget( &lab3 ); QLineEdit le3 (&dia ); lay.addWidget( &le3 ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); le1.setText( mPassWordPiSync ); le2.setText( mActiveSyncIP ); le3.setText( mActiveSyncPort ); if ( dia.exec() ) { mPassWordPiSync = le1.text(); mActiveSyncPort = le3.text(); mActiveSyncIP = le2.text(); return true; } return false; } bool KSyncManager::edit_sync_options() { QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); - QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); - QVBoxLayout lay ( &dia ); + Q3ButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); + Q3VBoxLayout lay ( &dia ); lay.setSpacing( 2 ); lay.setMargin( 3 ); lay.addWidget(&gr); QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); //QRadioButton both( i18n("Take both on conflict"), &gr ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); switch ( mSyncAlgoPrefs ) { case 0: loc.setChecked( true); break; case 1: rem.setChecked( true ); break; case 2: newest.setChecked( true); break; case 3: ask.setChecked( true); break; case 4: f_loc.setChecked( true); break; case 5: f_rem.setChecked( true); break; case 6: // both.setChecked( true); break; default: break; } if ( dia.exec() ) { mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; return true; } return false; } QString KSyncManager::getPassword( ) { QString retfile = ""; QDialog dia ( mParent, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); - QVBoxLayout lay( &dia ); + Q3VBoxLayout lay( &dia ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); dia.setFixedSize( 230,50 ); dia.setCaption( i18n("Enter password") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); int res = dia.exec(); if ( res ) retfile = lab.text(); dia.hide(); qApp->processEvents(); return retfile; } void KSyncManager::confSync() { static KSyncPrefsDialog* sp = 0; if ( ! sp ) { sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); } sp->usrReadConfig(); #ifndef DESKTOP_VERSION sp->showMaximized(); #else sp->show(); #endif sp->exec(); QStringList oldSyncProfileNames = mSyncProfileNames; mSyncProfileNames = sp->getSyncProfileNames(); mLocalMachineName = sp->getLocalMachineName (); uint ii; for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); } QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); } void KSyncManager::syncOL() { mSyncWithDesktop = true; emit save(); switch(mTargetApp) { case (KAPI): { syncExternalApplication("ol"); } break; case (KOPI): { #ifdef DESKTOP_VERSION QString command = "kdecaldump33"; QString commandfile = "kdecaldump33"; QString commandpath = qApp->applicationDirPath () + "/"; #else QString command = "kdecaldump33"; QString commandfile = "kdecaldump33"; QString commandpath = QDir::homeDirPath ()+"/"; #endif if ( ! QFile::exists ( commandpath+commandfile ) ) command = commandfile; else command = commandpath+commandfile; QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; int result = system ( command.latin1()); qDebug("Cal dump 33 command call result result: %d ", result); if ( result != 0 ) { qDebug("Calling CAL dump version 33 failed. Trying 34... "); commandfile = "kdecaldump34"; if ( ! QFile::exists ( commandpath+commandfile ) ) command = commandfile; else command = commandpath+commandfile; result = system ( command.latin1()); qDebug("Cal dump 34 command call result result: %d ", result); if ( result != 0 ) { KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); return; } } if ( syncWithFile( fileName,true ) ) { if ( mWriteBackFile ) { command += " --read"; system ( command.latin1()); } } } break; case (PWMPI): @@ -1241,643 +1244,643 @@ void KSyncManager::syncPi() } if ( startLocal+1 < mSpecificResources.count()/2 ) { mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); QTime timer; timer.start(); while ( timer.elapsed () < 1000 ) { qApp->processEvents(); } } } ++startRemote; ++startLocal; mAskForPreferences = false; } mPisyncFinished = true; mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") ); } else { KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); commandSocket->readFile( syncFileName() ); } } void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) { //enum { success, errorW, errorR, quiet }; if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { if ( state == KCommandSocket::errorPW ) mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); else if ( state == KCommandSocket::errorCA ) mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); else if ( state == KCommandSocket::errorFI ) mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); else if ( state == KCommandSocket::errorED ) mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); else if ( state == KCommandSocket::errorUN ) mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); delete s; if ( state == KCommandSocket::errorR ) { KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); commandSocket->sendStop(); } mPisyncFinished = true; return; } else if ( state == KCommandSocket::errorW ) { mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); mPisyncFinished = true; } else if ( state == KCommandSocket::successR ) { QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); } else if ( state == KCommandSocket::successW ) { mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); mPisyncFinished = true; } else if ( state == KCommandSocket::quiet ){ qDebug("KSS: quiet "); mPisyncFinished = true; } else { qDebug("KSS: Error: unknown state: %d ", state); mPisyncFinished = true; } delete s; } void KSyncManager::readFileFromSocket() { QString fileName = syncFileName(); bool syncOK = true; mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); syncOK = false; } KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); if ( mWriteBackFile && syncOK ) { mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); commandSocket->writeFile( fileName ); } else { commandSocket->sendStop(); if ( syncOK ) mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); mPisyncFinished = true; } } -KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) +KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : Q3ServerSocket( port, backlog, parent, name ) { mPendingConnect = 0; mPassWord = pw; mSocket = 0; mSyncActionDialog = 0; blockRC = false; mErrorMessage = 0; } void KServerSocket::waitForSocketFinish() { if ( mSocket ) { //qDebug("KSS:: waiting for finish operation"); QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); return; } - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( mPendingConnect ); mPendingConnect = 0; } void KServerSocket::newConnection ( int socket ) { // qDebug("KServerSocket:New connection %d ", socket); if ( mPendingConnect ) { qDebug("KSS::Error : new Connection"); return; } if ( mSocket ) { mPendingConnect = socket; QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); return; qDebug("KSS::newConnection Socket deleted! "); delete mSocket; mSocket = 0; } mPendingConnect = 0; - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KServerSocket::deleteSocket() { //qDebug("KSS::deleteSocket"); if ( mSocket ) { delete mSocket; mSocket = 0; } if ( mErrorMessage ) QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); } void KServerSocket::readClient() { if ( blockRC ) return; if ( mSocket == 0 ) { qDebug("ERROR::KSS::readClient(): mSocket == 0 "); return; } if ( mErrorMessage ) { mErrorMessage = 999; error_connect("ERROR_ED\r\n\r\n"); return; } mResource = ""; mErrorMessage = 0; //qDebug("KServerSocket::readClient()"); if ( mSocket->canReadLine() ) { QString line = mSocket->readLine(); //qDebug("KServerSocket readline: %s ", line.latin1()); QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) { //emit sendFile( mSocket ); bool ok = false; QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); if ( ok ) { KSyncManager::mRequestedSyncEvent = dt; } else KSyncManager::mRequestedSyncEvent = QDateTime(); mResource =tokens[3]; send_file(); } else { mErrorMessage = 1; error_connect("ERROR_PW\r\n\r\n"); } } if ( tokens[0] == "PUT" ) { if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); blockRC = true; mResource =tokens[2]; get_file(); } else { mErrorMessage = 2; error_connect("ERROR_PW\r\n\r\n"); end_connect(); } } if ( tokens[0] == "STOP" ) { //emit endConnect(); end_connect(); } } } void KServerSocket::displayErrorMessage() { if ( mErrorMessage == 1 ) { KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); mErrorMessage = 0; } else if ( mErrorMessage == 2 ) { KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); mErrorMessage = 0; } } void KServerSocket::error_connect( QString errmess ) { - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); os << errmess ; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) { + if ( mSocket->state() == Q3Socket::Idle ) { QTimer::singleShot( 0, this , SLOT ( discardClient())); } } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } void KServerSocket::send_file() { //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("Received sync request")); QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); label->setAlignment ( Qt::AlignHCenter ); - QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); + Q3VBoxLayout* lay = new Q3VBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); if ( KSyncManager::mRequestedSyncEvent.isValid() ) { int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); //secs = 333; if ( secs < 0 ) secs = secs * (-1); if ( secs > 30 ) //if ( true ) { QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); QLabel* label = new QLabel( warning, mSyncActionDialog ); label->setAlignment ( Qt::AlignHCenter ); lay->addWidget( label); if ( secs > 180 ) { if ( secs > 300 ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { qDebug("KSS::Sync cancelled ,cs"); mErrorMessage = 0; end_connect(); error_connect("ERROR_CA\r\n\r\n"); return ; } } QFont f = label->font(); f.setPointSize ( f.pointSize() *2 ); f. setBold (true ); QLabel* label = new QLabel( warning, mSyncActionDialog ); label->setFont( f ); warning = i18n("ADJUST\nYOUR\nCLOCKS!"); label->setText( warning ); label->setAlignment ( Qt::AlignHCenter ); lay->addWidget( label); mSyncActionDialog->setFixedSize( 230, 300); } else { mSyncActionDialog->setFixedSize( 230, 200); } } else { mSyncActionDialog->setFixedSize( 230, 120); } } else mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); mSyncActionDialog->raise(); emit request_file(mResource); //emit request_file(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); - if (!file.open( IO_ReadOnly ) ) { + if (!file.open( QIODevice::ReadOnly ) ) { mErrorMessage = 0; end_connect(); error_connect("ERROR_FI\r\n\r\n"); return ; } mSyncActionDialog->setCaption( i18n("Sending file...") ); - QTextStream ts( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\r\n"; } os << "\r\n"; //os << ts.read(); file.close(); mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::get_file() { mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); piTime.start(); piFileString = ""; QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); } void KServerSocket::readBackFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); while ( mSocket->canReadLine () ) { piTime.restart(); QString line = mSocket->readLine (); piFileString += line; //qDebug("readline: %s ", line.latin1()); mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); } if ( piTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS:Error open read back file "); piFileString = ""; emit file_received( false, mResource); emit file_received( false); blockRC = false; return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); - QTextStream ts ( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts ( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); piFileString = ""; emit file_received( true, mResource ); emit file_received( true); delete mSyncActionDialog; mSyncActionDialog = 0; blockRC = false; } KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) { mRemoteResource = remres; if ( mRemoteResource.isEmpty() ) mRemoteResource = "ALL"; else mRemoteResource.replace (QRegExp (" "),"_" ); mPassWord = password; mSocket = 0; mFirst = false; mFirstLine = true; mPort = port; mHost = host; tlw = cap; mRetVal = quiet; mTimerSocket = new QTimer ( this ); connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); mConnectProgress.setCaption( i18n("Pi-Sync") ); connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); mConnectCount = -1; } void KCommandSocket::sendFileRequest() { if ( tlw ) tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); mConnectProgress.hide(); mConnectCount = 300;mConnectMax = 300; mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); mTimerSocket->start( 100, true ); - QTextStream os( mSocket ); - os.setEncoding( QTextStream::Latin1 ); + Q3TextStream os( mSocket ); + os.setEncoding( Q3TextStream::Latin1 ); QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; } void KCommandSocket::readFile( QString fn ) { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); //qDebug("KCS: read file - new socket"); connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); } mFileString = ""; mFileName = fn; mFirst = true; if ( tlw ) tlw->setCaption( i18n("Trying to connect to remote...") ); mConnectCount = 30;mConnectMax = 30; mTimerSocket->start( 1000, true ); mSocket->connectToHost( mHost, mPort ); //qDebug("KCS: Waiting for connection"); } void KCommandSocket::updateConnectDialog() { if ( mConnectCount == mConnectMax ) { //qDebug("MAXX %d", mConnectMax); mConnectProgress.setTotalSteps ( 30 ); mConnectProgress.show(); mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); } //qDebug("updateConnectDialog() %d", mConnectCount); mConnectProgress.raise(); mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); --mConnectCount; if ( mConnectCount > 0 ) mTimerSocket->start( 1000, true ); else deleteSocket(); } void KCommandSocket::writeFile( QString fileName ) { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); } mFileName = fileName ; mConnectCount = 30;mConnectMax = 30; mTimerSocket->start( 1000, true ); mSocket->connectToHost( mHost, mPort ); } void KCommandSocket::writeFileToSocket() { mTimerSocket->stop(); QFile file2( mFileName ); - if (!file2.open( IO_ReadOnly ) ) { + if (!file2.open( QIODevice::ReadOnly ) ) { mConnectProgress.hide(); mConnectCount = -1; mRetVal= errorW; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); return ; } mConnectProgress.setTotalSteps ( file2.size() ); mConnectProgress.show(); int count = 0; mConnectProgress.setLabelText( i18n("Sending back synced file...") ); mConnectProgress.setProgress( count ); mConnectProgress.blockSignals( true ); - QTextStream ts2( &file2 ); - ts2.setEncoding( QTextStream::Latin1 ); - QTextStream os2( mSocket ); - os2.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts2( &file2 ); + ts2.setEncoding( Q3TextStream::Latin1 ); + Q3TextStream os2( mSocket ); + os2.setEncoding( Q3TextStream::Latin1 ); os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; int byteCount = 0; int byteMax = file2.size()/53; while ( ! ts2.atEnd() ) { qApp->processEvents(); if ( byteCount > byteMax ) { byteCount = 0; mConnectProgress.setProgress( count ); } QString temp = ts2.readLine(); count += temp.length(); byteCount += temp.length(); os2 << temp << "\r\n"; } file2.close(); mConnectProgress.hide(); mConnectCount = -1; os2 << "\r\n"; mRetVal= successW; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); mConnectProgress.blockSignals( false ); } void KCommandSocket::sendStop() { if ( !mSocket ) { - mSocket = new QSocket( this ); + mSocket = new Q3Socket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mSocket->connectToHost( mHost, mPort ); - QTextStream os2( mSocket ); - os2.setEncoding( QTextStream::Latin1 ); + Q3TextStream os2( mSocket ); + os2.setEncoding( Q3TextStream::Latin1 ); os2 << "STOP\r\n\r\n"; mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::startReadFileFromSocket() { if ( ! mFirst ) return; mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); mFirst = false; mFileString = ""; mTime.start(); mFirstLine = true; QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); } void KCommandSocket::readFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); while ( mSocket->canReadLine () ) { mTime.restart(); QString line = mSocket->readLine (); if ( mFirstLine ) { mFirstLine = false; if ( line.left( 6 ) == "ERROR_" ) { mTimerSocket->stop(); mConnectCount = -1; if ( line.left( 8 ) == "ERROR_PW" ) { mRetVal = errorPW; deleteSocket(); return ; } if ( line.left( 8 ) == "ERROR_CA" ) { mRetVal = errorCA; deleteSocket(); return ; } if ( line.left( 8 ) == "ERROR_FI" ) { mRetVal = errorFI; deleteSocket(); return ; } if ( line.left( 8 ) == "ERROR_ED" ) { mRetVal = errorED; deleteSocket(); return ; } mRetVal = errorUN; deleteSocket(); return ; } } mFileString += line; //qDebug("readline: %s ", line.latin1()); } if ( mTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); return; } mTimerSocket->stop(); mConnectCount = -1; mConnectProgress.hide(); QString fileName = mFileName; QFile file ( fileName ); - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { mFileString = ""; mRetVal = errorR; qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); deleteSocket(); return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); - QTextStream ts ( &file ); - ts.setEncoding( QTextStream::Latin1 ); + Q3TextStream ts ( &file ); + ts.setEncoding( Q3TextStream::Latin1 ); ts << mFileString; file.close(); mFileString = ""; mRetVal = successR; mSocket->close(); // if state is not idle, deleteSocket(); is called via // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); - if ( mSocket->state() == QSocket::Idle ) + if ( mSocket->state() == Q3Socket::Idle ) deleteSocket(); } void KCommandSocket::deleteSocket() { //qDebug("KCommandSocket::deleteSocket() "); mConnectProgress.hide(); if ( mConnectCount >= 0 ) { mTimerSocket->stop(); mRetVal = errorTO; qDebug("KCS::Connection to remote host timed out"); if ( mSocket ) { mSocket->close(); //if ( mSocket->state() == QSocket::Idle ) // deleteSocket(); delete mSocket; mSocket = 0; } if ( mConnectCount == 0 ) KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); else if ( tlw ) tlw->setCaption( i18n("Connection to remote host cancelled!") ); emit commandFinished( this, mRetVal ); return; } //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); if ( mSocket) delete mSocket; mSocket = 0; //qDebug("commandFinished "); emit commandFinished( this, mRetVal ); } diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 71d17e9..32c6557 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -1,248 +1,250 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2004 Ulf Schenk 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. $Id$ */ #ifndef _KSYNCMANAGER_H #define _KSYNCMANAGER_H #include <qobject.h> #include <qstring.h> -#include <qsocket.h> +#include <q3socket.h> #include <qdatetime.h> -#include <qserversocket.h> -#include <qtextstream.h> +#include <q3serversocket.h> +#include <q3textstream.h> #include <qregexp.h> -#include <qprogressdialog.h> +#include <q3progressdialog.h> +//Added by qt3to4: +#include <Q3PopupMenu> #include <kdialog.h> -class QPopupMenu; +class Q3PopupMenu; class KSyncProfile; class KPimPrefs; class QWidget; class KSyncManager; class KSyncInterface; -class QProgressBar; +class Q3ProgressBar; -class KServerSocket : public QServerSocket +class KServerSocket : public Q3ServerSocket { Q_OBJECT public: KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); void newConnection ( int socket ) ; void setFileName( QString fn ) {mFileName = fn;}; signals: void file_received( bool ); void request_file(); void file_received( bool, const QString &); void request_file(const QString &); void saveFile(); void endConnect(); private slots: void waitForSocketFinish(); void discardClient(); void deleteSocket(); void readClient(); void displayErrorMessage(); void readBackFileFromSocket(); private : int mPendingConnect; QString mResource; int mErrorMessage; bool blockRC; void send_file(); void get_file(); void end_connect(); void error_connect( QString ); QDialog* mSyncActionDialog; - QSocket* mSocket; + Q3Socket* mSocket; QString mPassWord; QString mFileName; QTime piTime; QString piFileString; }; class KCommandSocket : public QObject { Q_OBJECT public: enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); void readFile( QString ); void writeFile( QString ); void sendStop(); private slots : void sendFileRequest(); void updateConnectDialog(); signals: void commandFinished( KCommandSocket*, int ); private slots: void startReadFileFromSocket(); void readFileFromSocket(); void deleteSocket(); void writeFileToSocket(); private : QString mRemoteResource; int mConnectCount; int mConnectMax; KProgressDialog mConnectProgress; QWidget* tlw; - QSocket* mSocket; + Q3Socket* mSocket; QString mPassWord; Q_UINT16 mPort; QString mHost; QString mFileName; QTimer* mTimerSocket; int mRetVal; QTime mTime; QString mFileString; bool mFirst; bool mFirstLine; }; class KSyncManager : public QObject { Q_OBJECT public: enum TargetApp { KOPI = 0, KAPI = 1, PWMPI = 2 }; - KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); + KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu); ~KSyncManager() ; void multiSync( bool askforPrefs ); bool blockSave() { return mBlockSaveFlag; } void setBlockSave(bool sa) { mBlockSaveFlag = sa; } void setDefaultFileName( QString s) ; QString defaultFileName() { return mDefFileName ;} QString syncFileName(); void enableQuick( bool ask = true); bool syncWithDesktop () { return mSyncWithDesktop;} QString getCurrentSyncDevice() { return mCurrentSyncDevice; } QString getCurrentSyncName() { return mCurrentSyncName; } void showProgressBar(int percentage, QString caption = QString::null, int total=100); void hideProgressBar(); bool isProgressBarCanceled(); // sync stuff QString mLocalMachineName; QStringList mExternSyncProfiles; QStringList mSyncProfileNames; bool mAskForPreferences; bool mShowSyncSummary; bool mIsKapiFile; bool mWriteBackExistingOnly; int mSyncAlgoPrefs; bool mWriteBackFile; int mWriteBackInFuture; int mWriteBackInPast; QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; QString mPassWordPiSync; QString mActiveSyncPort; QString mActiveSyncIP ; QString mFilterInCal; QString mFilterOutCal; QString mFilterInAB; QString mFilterOutAB; static QDateTime mRequestedSyncEvent; signals: void save(); void request_file(); void getFile( bool ); void getFile( bool, const QString &); void request_file(const QString &); void multiResourceSyncStart( bool ); public slots: void slotSyncMenu( int ); void slotClearMenu( int action ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); private: void syncPi(); KServerSocket * mServerSocket; KPimPrefs* mPrefs; QString mDefFileName; QString mCurrentSyncDevice; QString mCurrentSyncName; void quickSyncLocalFile(); bool syncWithFile( QString fn , bool quick ); void syncLocalFile(); void syncPhone(); void syncSharp(); void syncKDE(); void syncOL(); bool syncExternalApplication(QString); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); bool edit_sync_options(); bool edit_pisync_options(); int ringSync(); QString getPassword( ); bool mPisyncFinished; QStringList mSpecificResources; QString mCurrentResourceLocal; QString mCurrentResourceRemote; bool mBlockSaveFlag; QWidget* mParent; KSyncInterface* mImplementation; TargetApp mTargetApp; - QPopupMenu* mSyncMenu; - QProgressBar* bar; + Q3PopupMenu* mSyncMenu; + Q3ProgressBar* bar; bool mSyncWithDesktop; private slots: void displayErrorPort(); void confSync(); }; class KSyncInterface { public : virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) { // empty implementation, because some syncable applications do not // have an external(sharpdtm) syncmode, like pwmanager. return false; } }; #endif diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 2b87298..fd5bbca 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp @@ -1,567 +1,571 @@ /* This file is part of KOrganizer. Copyright (c) 2004 Lutz Rogowski <rogowski@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., 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 <qgroupbox.h> -#include <qbuttongroup.h> +#include <q3groupbox.h> +#include <q3buttongroup.h> #include <qlineedit.h> #include <qfont.h> #include <qslider.h> #include <qfile.h> #include <qdir.h> -#include <qtextstream.h> +#include <q3textstream.h> #include <qcombobox.h> -#include <qvbox.h> -#include <qhbox.h> +#include <q3vbox.h> +#include <q3hbox.h> #include <qspinbox.h> #include <qdatetime.h> #include <qcheckbox.h> #include <qradiobutton.h> #include <qpushbutton.h> -#include <qstrlist.h> +#include <q3strlist.h> #include <qapplication.h> #include <qlayout.h> -#include <qscrollview.h> -#include <qvgroupbox.h> -#include <qhgroupbox.h> +#include <q3scrollview.h> +#include <q3vgroupbox.h> +#include <q3hgroupbox.h> +//Added by qt3to4: +#include <Q3HBoxLayout> +#include <Q3GridLayout> +#include <Q3Frame> #include <kcolorbutton.h> #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kfontdialog.h> #include <kmessagebox.h> #include <kcolordialog.h> #include <kiconloader.h> #include <kemailsettings.h> #include <kstandarddirs.h> #include <kfiledialog.h> #include <kmessagebox.h> //#include <kurlrequester.h> #include <klineedit.h> #include "ksyncprofile.h" //#include "koprefs.h" #include "ksyncprefsdialog.h" //#include "koglobals.h" KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : KDialog(parent,name,true) { setCaption( i18n("Synchronization Preferences")); mSyncProfiles.setAutoDelete( true ); setupSyncAlgTab(); } KSyncPrefsDialog::~KSyncPrefsDialog() { } void KSyncPrefsDialog::setupSyncAlgTab() { QLabel * lab; //QFrame *page = addPage(i18n("Sync Prefs"),0,0); - QVBox * mainbox = new QVBox( this ); - QScrollView* sv = new QScrollView( mainbox ); - QHBoxLayout * lay = new QHBoxLayout( this ); + Q3VBox * mainbox = new Q3VBox( this ); + Q3ScrollView* sv = new Q3ScrollView( mainbox ); + Q3HBoxLayout * lay = new Q3HBoxLayout( this ); lay->addWidget( mainbox ); - QHBox * b_box = new QHBox( mainbox ); + Q3HBox * b_box = new Q3HBox( mainbox ); QPushButton* button = new QPushButton( i18n("Ok"), b_box ); connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); button = new QPushButton( i18n("Cancel"), b_box ); connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); //QBoxLayout * sl = new QVBoxLayout(this ); //sl->addWidget ( sv ); - sv->setResizePolicy ( QScrollView::AutoOneFit ); - QFrame *topFrame = new QFrame ( sv ); + sv->setResizePolicy ( Q3ScrollView::AutoOneFit ); + Q3Frame *topFrame = new Q3Frame ( sv ); sv->addChild( topFrame ); mSetupSyncAlgTab = topFrame; - QGridLayout *topLayout = new QGridLayout(topFrame,6,2); + Q3GridLayout *topLayout = new Q3GridLayout(topFrame,6,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); int iii = 0; //topLayout->addMultiCellWidget(lab , iii,iii,0,1); //++iii; mMyMachineName = new QLineEdit(topFrame); lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mMyMachineName,iii,1); ++iii; - QHBox* buttonbox = new QHBox( topFrame); + Q3HBox* buttonbox = new Q3HBox( topFrame); topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); ++iii; button = new QPushButton( i18n("New profile"), buttonbox ); connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); button = new QPushButton( i18n("Clone profile"), buttonbox ); connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); button = new QPushButton( i18n("Delete profile"), buttonbox ); connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); mProfileBox = new QComboBox(topFrame); mProfileBox->setEditable ( true ); mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mProfileBox, iii,1); ++iii; - QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); + Q3HGroupBox *iims = new Q3HGroupBox( i18n("Multiple Sync options"), topFrame); new QLabel( i18n("Include in multiple "), iims ); mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); new QLabel( i18n(" sync"), iims ); topLayout->addMultiCellWidget(iims, iii,iii,0,1); ++iii; - QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); + Q3VGroupBox* gb0 = new Q3VGroupBox( i18n("Sync algo options"), topFrame); topLayout->addMultiCellWidget(gb0, iii,iii,0,1); ++iii; - QButtonGroup* gr; + Q3ButtonGroup* gr; { - QVGroupBox* topFrame = gb0; + Q3VGroupBox* topFrame = gb0; mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); //++iii; - gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); + gr = new Q3ButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); //topLayout->addMultiCellWidget(gr, iii,iii,0,1); //++iii; loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); // both = new QRadioButton ( i18n("Take both on conflict"), gr ); mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); //++iii; #if 0 - QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); + Q3HGroupBox* gb51 = new Q3HGroupBox( i18n("Local resources to sync with:"), topFrame); { - QVBox * fibo2 = new QVBox ( gb51 ); + Q3VBox * fibo2 = new Q3VBox ( gb51 ); new QLabel ( i18n("Calendar resources:"), fibo2 ); //mFilterInCal = new QComboBox( fibo2 ); - fibo2 = new QVBox ( gb51 ); + fibo2 = new Q3VBox ( gb51 ); new QLabel ( i18n("Addressbook resources:"), fibo2 ); //mFilterInAB = new QComboBox( fibo2 ); } #endif - QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); - QVBox * fibo2 = new QVBox ( gb5 ); + Q3HGroupBox* gb5 = new Q3HGroupBox( i18n("Apply filter when adding data to local:"), topFrame); + Q3VBox * fibo2 = new Q3VBox ( gb5 ); new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); mFilterInCal = new QComboBox( fibo2 ); - fibo2 = new QVBox ( gb5 ); + fibo2 = new Q3VBox ( gb5 ); new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); mFilterInAB = new QComboBox( fibo2 ); mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); // ++iii; - QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); + Q3VGroupBox* gb2 = new Q3VGroupBox( i18n("Write back options"), topFrame); //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); //++iii; { - QVGroupBox*topFrame = gb2; + Q3VGroupBox*topFrame = gb2; mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); - QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); - QVBox * fibo = new QVBox ( gb4 ); + Q3HGroupBox* gb4 = new Q3HGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); + Q3VBox * fibo = new Q3VBox ( gb4 ); new QLabel ( i18n("Outgoing calendar filter:"), fibo ); mFilterOutCal = new QComboBox( fibo ); - fibo = new QVBox ( gb4 ); + fibo = new Q3VBox ( gb4 ); new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); mFilterOutAB = new QComboBox( fibo ); //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); //++iii; mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); //++iii; - QVGroupBox* gb3 = new QVGroupBox( i18n("Time period"), topFrame); + Q3VGroupBox* gb3 = new Q3VGroupBox( i18n("Time period"), topFrame); connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); new QLabel( i18n("From ") , gb3 ); - QHBox * tf1 = new QHBox ( gb3 ); + Q3HBox * tf1 = new Q3HBox ( gb3 ); mWriteBackPastWeeks= new QSpinBox(1,104, 1, tf1 ); mWriteBackPastWeeks->setMaximumWidth( 100 ); new QLabel( i18n(" weeks in the past to ") ,tf1 ); - QHBox * tf2 = new QHBox ( gb3 ); + Q3HBox * tf2 = new Q3HBox ( gb3 ); mWriteBackFutureWeeks= new QSpinBox(1,104, 1, tf2); mWriteBackFutureWeeks->setMaximumWidth( 100 ); new QLabel( i18n(" weeks in the future ") , tf2 ); //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); //++iii; gb3->setEnabled( false ); connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); } connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); } - proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); + proGr = new Q3ButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); gr = proGr; topLayout->addMultiCellWidget(gr, iii,iii,0,1); ++iii; mIsLocal = new QRadioButton ( i18n("Local file"), gr ); mIsPi = new QRadioButton ( i18n("Pi-Sync - all calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); - QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); + Q3VGroupBox* gb1 = new Q3VGroupBox( i18n("Profile kind specific settings"), topFrame); topLayout->addMultiCellWidget(gb1, iii,iii,0,1); ++iii; // ****************************************** // Profile kind specific settings { // *** phone ******************************* - QVGroupBox* topFrame = gb1; - phoneWidget = new QVBox( topFrame); + Q3VGroupBox* topFrame = gb1; + phoneWidget = new Q3VBox( topFrame); //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); //++iii; mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); - QHBox* temphb = new QHBox( phoneWidget ); + Q3HBox* temphb = new Q3HBox( phoneWidget ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); button = new QPushButton( i18n("Help..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); - temphb = new QHBox( phoneWidget ); + temphb = new Q3HBox( phoneWidget ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); button = new QPushButton( i18n("Help..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); - temphb = new QHBox( phoneWidget ); + temphb = new Q3HBox( phoneWidget ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); button = new QPushButton( i18n("Help..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); // *** local******************************* - localFileWidget = new QVBox( topFrame); + localFileWidget = new Q3VBox( topFrame); //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); //++iii; - temphb = new QHBox( localFileWidget ); + temphb = new Q3HBox( localFileWidget ); lab = new QLabel( i18n("Local file Cal:"), temphb ); lab = new QLabel( i18n("Local file ABook:"), temphb ); lab = new QLabel( i18n("Local file PWMgr:"), temphb ); - temphb = new QHBox( localFileWidget ); + temphb = new Q3HBox( localFileWidget ); button = new QPushButton( i18n("Choose..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); button = new QPushButton( i18n("Choose..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); button = new QPushButton( i18n("Choose..."), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); - temphb = new QHBox( localFileWidget ); + temphb = new Q3HBox( localFileWidget ); mRemoteFile = new QLineEdit( temphb); mRemoteFileAB = new QLineEdit( temphb); mRemoteFilePWM = new QLineEdit( temphb); mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); // *** remote******************************* - remoteFileWidget = new QVBox( topFrame); + remoteFileWidget = new Q3VBox( topFrame); //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); //++iii; - temphb = new QHBox( remoteFileWidget ); + temphb = new Q3HBox( remoteFileWidget ); new QLabel( i18n("Calendar:"), temphb); new QLabel( i18n("AddressBook:"), temphb); new QLabel( i18n("PWManager:"), temphb); lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); - temphb = new QHBox( remoteFileWidget ); + temphb = new Q3HBox( remoteFileWidget ); mRemotePrecommand = new QLineEdit(temphb); mRemotePrecommandAB = new QLineEdit(temphb); mRemotePrecommandPWM = new QLineEdit(temphb); lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); - temphb = new QHBox( remoteFileWidget ); + temphb = new Q3HBox( remoteFileWidget ); mLocalTempFile = new QLineEdit(temphb); mLocalTempFileAB = new QLineEdit(temphb); mLocalTempFilePWM = new QLineEdit(temphb); lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); - temphb = new QHBox( remoteFileWidget ); + temphb = new Q3HBox( remoteFileWidget ); mRemotePostcommand = new QLineEdit(temphb ); mRemotePostcommandAB = new QLineEdit(temphb ); mRemotePostcommandPWM = new QLineEdit(temphb ); mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); - temphb = new QHBox( remoteFileWidget ); + temphb = new Q3HBox( remoteFileWidget ); button = new QPushButton( i18n("ssh/scp"), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); button = new QPushButton( i18n("ftp"), temphb ); connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); // *** pi-sync******************************* - piWidget = new QVBox( topFrame); + piWidget = new Q3VBox( topFrame); //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); //++iii; - temphb = new QHBox( piWidget ); + temphb = new Q3HBox( piWidget ); new QLabel( i18n("Calendar:"), temphb); new QLabel( i18n("AddressBook:"), temphb); new QLabel( i18n("PWManager:"), temphb); lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); - temphb = new QHBox( piWidget ); + temphb = new Q3HBox( piWidget ); mRemotePw = new QLineEdit(temphb); mRemotePwAB = new QLineEdit(temphb); mRemotePwPWM = new QLineEdit(temphb); lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); - temphb = new QHBox( piWidget ); + temphb = new Q3HBox( piWidget ); mRemoteIP = new QLineEdit(temphb); mRemoteIPAB = new QLineEdit(temphb); mRemoteIPPWM = new QLineEdit(temphb); lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); - temphb = new QHBox( piWidget ); + temphb = new Q3HBox( piWidget ); mRemotePort = new QLineEdit(temphb); mRemotePortAB = new QLineEdit(temphb); mRemotePortPWM = new QLineEdit(temphb); lab = new QLabel( i18n("Local/remote Resource sync partners (Leave empty to not sync)"), piWidget); - mTableBox = new QHBox( piWidget ); - mResTableKopi = new QTable( 1, 1, mTableBox ); - mResTableKapi = new QTable( 1, 1, mTableBox ); - mResTablePwmpi = new QTable( 1, 1, mTableBox ); + mTableBox = new Q3HBox( piWidget ); + mResTableKopi = new Q3Table( 1, 1, mTableBox ); + mResTableKapi = new Q3Table( 1, 1, mTableBox ); + mResTablePwmpi = new Q3Table( 1, 1, mTableBox ); mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); mResTableKopi->setLeftMargin( 80 ); mResTableKapi->setLeftMargin( 80 ); } // ****************************************** // Profile kind specific settings END } void KSyncPrefsDialog::readResources() { mResourcesKopi.clear(); KConfig fc(locateLocal("config","kopicalendarrc")); fc.setGroup("CC"); int numCals = fc.readNumEntry("NumberCalendars",0 ); int curCal = 1; while ( curCal <= numCals ) { QString prefix = "Cal_" +QString::number( curCal ); QString name = fc.readEntry( prefix+"_Name", "Calendar"); mResourcesKopi.append( name ); ++curCal; } mResTableKopi->setNumRows( mResourcesKopi.count() ); int i; for ( i = 0;i < mResourcesKopi.count(); ++i ) { mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); } mResourcesKapi.clear(); KConfig conf ( locateLocal("config", "kabcrc") ); conf.setGroup( "General" ); QStringList keys = conf.readListEntry( "ResourceKeys" ); //keys += conf->readListEntry( "PassiveResourceKeys" ); //QString standardKey = mConfig->readEntry( "Standard" ); for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { conf.setGroup("Resource_"+ (*it) ); QString name = conf.readEntry( "ResourceName" ); mResourcesKapi.append( name ); } mResTableKapi->setNumRows( mResourcesKapi.count() ); for ( i = 0;i < mResourcesKopi.count(); ++i ) { mResTableKapi->verticalHeader ()->setLabel( i, mResourcesKapi[i] ); } } void KSyncPrefsDialog::readFilter() { mFilterKapi.clear(); mFilterKopi.clear(); KConfig cfgko(locateLocal("config","korganizerrc")); KConfig cfgka(locateLocal("config","kaddressbookrc")); cfgko.setGroup("General"); mFilterKopi = cfgko.readListEntry("CalendarFilters"); cfgka.setGroup("Filter"); int count = cfgka.readNumEntry( "Count", 0 ); for ( int i = 0; i < count; i++ ) { cfgka.setGroup("Filter_"+QString::number( i ) ); mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); } mFilterOutCal->clear(); mFilterInCal->clear(); mFilterOutAB->clear(); mFilterInAB->clear(); QStringList temp = mFilterKopi; temp.prepend(i18n("No Filter") ); mFilterOutCal->insertStringList( temp ); mFilterInCal->insertStringList( temp ); temp = mFilterKapi; temp.prepend(i18n("No Filter") ); mFilterOutAB->insertStringList( temp ); mFilterInAB->insertStringList( temp ); } void KSyncPrefsDialog::slotOK() { if ( mMyMachineName->text() == "undefined" ) { KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); return; } int i; for (i = 0; i < mSyncProfileNames.count(); ++ i) { - if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { + if ( mSyncProfileNames.count( mSyncProfileNames[i]) > 1 ) { KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); return; } } usrWriteConfig(); QDialog::accept(); } void KSyncPrefsDialog::accept() { slotOK(); } void KSyncPrefsDialog::chooseFile() { QString fn = QDir::homeDirPath(); fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; mRemoteFile->setText( fn ); } void KSyncPrefsDialog::chooseFileAB() { QString fn = QDir::homeDirPath(); fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); if ( fn == "" ) return; mRemoteFileAB->setText( fn ); } void KSyncPrefsDialog::chooseFilePWM() { QString fn = QDir::homeDirPath(); fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); if ( fn == "" ) return; mRemoteFilePWM->setText( fn ); } void KSyncPrefsDialog::updateMyCaption() { setCaption( mProfileBox->currentText() + " : " +i18n("Synchronization Preferences")); } void KSyncPrefsDialog::textChanged( const QString & s ) { if ( mProfileBox->count() == 0 ) return; if ( currentSelection < 3 ) { //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); mProfileBox->blockSignals( true ); mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); mProfileBox->blockSignals( false ); return; } //qDebug("cur i %d ",mProfileBox-> currentItem () ); mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; prof->setName( s ); mSyncProfileNames[mProfileBox-> currentItem ()] = s; updateMyCaption(); } void KSyncPrefsDialog::profileChanged( int item ) { //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); KSyncProfile* prof; saveProfile(); readFilter(); readResources(); currentSelection = item; prof = mSyncProfiles.at(item) ; mRemotePw->setText(prof->getRemotePw()); mRemoteIP->setText(prof->getRemoteIP()); mRemotePort->setText(prof->getRemotePort()); mRemotePwAB->setText(prof->getRemotePwAB()); mRemoteIPAB->setText(prof->getRemoteIPAB()); mRemotePortAB->setText(prof->getRemotePortAB()); mRemotePwPWM->setText(prof->getRemotePwPWM()); mRemoteIPPWM->setText(prof->getRemoteIPPWM()); mRemotePortPWM->setText(prof->getRemotePortPWM()); mRemotePrecommand->setText(prof->getPreSyncCommand()); mRemotePostcommand->setText(prof->getPostSyncCommand()); mLocalTempFile->setText(prof->getLocalTempFile()); mRemoteFile->setText(prof->getRemoteFileName()) ; mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); mLocalTempFileAB->setText(prof->getLocalTempFileAB()); mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); diff --git a/libkdepim/ksyncprefsdialog.h b/libkdepim/ksyncprefsdialog.h index d8c02de..1d7503e 100644 --- a/libkdepim/ksyncprefsdialog.h +++ b/libkdepim/ksyncprefsdialog.h @@ -1,171 +1,171 @@ /* This file is part of KOrganizer. Copyright (c) 2000,2001 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., 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. */ #ifndef _KSYNCPREFSDIALOG_H #define _KSYNCPREFSDIALOG_H #include <kdialogbase.h> -#include <qptrlist.h> -#include <qtable.h> -#include <qhbox.h> +#include <q3ptrlist.h> +#include <q3table.h> +#include <q3hbox.h> //#include <libkdepim/kprefsdialog.h> class KColorButton; class QSpinBox;; class QRadioButton; class QCheckBox; class QSlider; class KURLRequester; class QComboBox; -class QButtonGroup; +class Q3ButtonGroup; class QLineEdit; -class QVBox; +class Q3VBox; class QStringList; class KSyncProfile; /** Dialog to change the korganizer configuration. */ class KSyncPrefsDialog : public KDialog { Q_OBJECT public: /** Initialize dialog and pages */ KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); ~KSyncPrefsDialog(); void usrReadConfig(); void setLocalMachineName ( const QString& name ); QString getLocalMachineName ( ); QStringList getSyncProfileNames(); public slots: protected slots: void accept(); void deleteProfile(); void newProfile(); void cloneProfile(); void kindChanged(bool); void fillSSH(); void fillFTP(); void textChanged( const QString & ); void profileChanged( int ); void chooseFile(); void chooseFileAB(); void chooseFilePWM(); void slotOK(); void helpDevice(); void helpModel(); void helpConnection(); protected: void usrWriteConfig(); void setupSyncAlgTab(); void readFilter(); void readResources(); private: void updateMyCaption(); int currentSelection; - QPtrList<KSyncProfile> mSyncProfiles; + Q3PtrList<KSyncProfile> mSyncProfiles; QStringList mSyncProfileNames; QStringList mFilterKapi; QStringList mFilterKopi; QStringList mResourcesKopi; QStringList mResourcesKapi; QLineEdit * mMyMachineName; QComboBox * mProfileBox; QRadioButton* mIsLocal; QRadioButton* mIsNotLocal; QRadioButton* mIsPhone; QRadioButton* mIsPi; QRadioButton* mIsPiSpecific; QCheckBox* mIncludeInRing; QCheckBox* mIncludeInRingAB; QCheckBox* mIncludeInRingPWM; void addProfile ( KSyncProfile* ); void insertProfiles(); void saveProfile(); - QButtonGroup* proGr; - QHBox * mTableBox; - QTable* mResTableKopi; - QTable* mResTableKapi; - QTable* mResTablePwmpi; + Q3ButtonGroup* proGr; + Q3HBox * mTableBox; + Q3Table* mResTableKopi; + Q3Table* mResTableKapi; + Q3Table* mResTablePwmpi; QComboBox * mFilterOutCal; QComboBox * mFilterInCal; QComboBox * mFilterOutAB; QComboBox * mFilterInAB; QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; QLineEdit * mRemotePostcommand; QLineEdit * mRemotePrecommand; QLineEdit * mRemoteFile; QLineEdit * mLocalTempFile; QLineEdit * mRemotePostcommandAB; QLineEdit * mRemotePrecommandAB; QLineEdit * mRemoteFileAB; QLineEdit * mLocalTempFileAB; QLineEdit * mRemotePostcommandPWM; QLineEdit * mRemotePrecommandPWM; QLineEdit * mRemoteFilePWM; QLineEdit * mLocalTempFilePWM; QLineEdit * mRemotePw; QLineEdit * mRemoteIP; QLineEdit * mRemotePort; QLineEdit * mRemotePwAB; QLineEdit * mRemoteIPAB; QLineEdit * mRemotePortAB; QLineEdit * mRemotePwPWM; QLineEdit * mRemoteIPPWM; QLineEdit * mRemotePortPWM; QLineEdit * mPhoneDevice; QLineEdit * mPhoneConnection; QLineEdit * mPhoneModel; QWidget* mSetupSyncAlgTab; - QVBox* localFileWidget; - QVBox* remoteFileWidget; - QVBox* phoneWidget; - QVBox* piWidget; + Q3VBox* localFileWidget; + Q3VBox* remoteFileWidget; + Q3VBox* phoneWidget; + Q3VBox* piWidget; QCheckBox* mWriteBackFile; QCheckBox* mWriteBackFuture; QSpinBox* mWriteBackFutureWeeks; QSpinBox* mWriteBackPastWeeks; QCheckBox* mWriteBackExisting; QCheckBox* mAskForPreferences; QCheckBox* mShowSummaryAfterSync; QCheckBox* mWriteContactToSIM; QCheckBox* mIsKapiFileL; QCheckBox* mIsKapiFileR; }; #endif diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h index 91fcfc5..1e41662 100644 --- a/libkdepim/ksyncprofile.h +++ b/libkdepim/ksyncprofile.h @@ -1,119 +1,119 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2004 Lutz Rogowski <rogowski@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. */ #ifndef _KSYNCPROFILE_H #define _KSYNCPROFILE_H -#include <qptrlist.h> +#include <q3ptrlist.h> #include <qcolor.h> #include <qfont.h> #include <qstringlist.h> #include <qobject.h> #include <qstring.h> #include <libkcal/syncdefines.h> class KConfig; class KSyncProfile : public QObject { public: KSyncProfile(); ~KSyncProfile() ; KSyncProfile* clone(); void setDefault(); void readConfig(KConfig *); void writeConfig(KConfig *); void deleteConfig(KConfig *); void setRemotePw( const QString& n ) {mRemotePw = n;} QString getRemotePw( ) { return mRemotePw; } void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} QString getRemotePwAB( ) { return mRemotePwAB; } void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} QString getRemotePwPWM( ) { return mRemotePwPWM; } void setRemoteIP( const QString& n ) {mRemoteIP = n;} QString getRemoteIP( ) { return mRemoteIP; } void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} QString getRemoteIPAB( ) { return mRemoteIPAB; } void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} QString getRemoteIPPWM( ) { return mRemoteIPPWM; } void setRemotePort( const QString& n ) {mRemotePort = n;} QString getRemotePort( ) { return mRemotePort; } void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} QString getRemotePortAB( ) { return mRemotePortAB; } void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} QString getRemotePortPWM( ) { return mRemotePortPWM; } void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} QString getPreSyncCommand( ) { return mPreSyncCommand; } void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} QString getPostSyncCommand( ) { return mPostSyncCommand;} void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} QString getLocalTempFile( ) { return mLocalTempFile;} void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} QString getRemoteFileName( ) { return mRemoteFileName;} void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} QString getLocalTempFileAB( ) { return mLocalTempFileAB;} void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} QString getPhoneDevice( ) { return mPhoneDevice;} void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} QString getPhoneConnection( ) { return mPhoneConnection;} void setPhoneModel( const QString& n ) { mPhoneModel = n;} QString getPhoneModel( ) { return mPhoneModel;} /* void set( const QString& n ) { = n;} QString get( ) { return ;} */ void setFilterInCal (const QString& n ){ mFilterInCal = n;} void setFilterOutCal (const QString& n ){ mFilterOutCal = n;} void setFilterInAB (const QString& n ){ mFilterInAB = n;} void setFilterOutAB (const QString& n ){ mFilterOutAB = n;} QString getFilterInCal () { return mFilterInCal ;} QString getFilterOutCal () { return mFilterOutCal ;} QString getFilterInAB () { return mFilterInAB ;} QString getFilterOutAB () { return mFilterOutAB ;} void setName( const QString& n ) {mName = n;} QString getName( ) { return mName;} void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index 7160d0e..fb27311 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro @@ -1,76 +1,78 @@ TEMPLATE = lib CONFIG = qt warn_on DEFINES +=KORG_NOKABC -TARGET = microkdepim +TARGET = xmicrokdepim INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. DESTDIR=../bin DEFINES += DESKTOP_VERSION include( ../variables.pri ) unix : { OBJECTS_DIR = obj/unix MOC_DIR = moc/unix } win32: { DEFINES += _WIN32_ OBJECTS_DIR = obj/win MOC_DIR = moc/win } INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ kpimprefs.h \ kpimglobalprefs.h \ kprefsdialog.h \ kprefswidget.h \ ksyncmanager.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h \ phoneaccess.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ externalapphandler.cpp \ kdateedit.cpp \ kdatepicker.cpp \ kinputdialog.cpp \ kpimprefs.cpp \ kpimglobalprefs.cpp \ kprefsdialog.cpp \ kprefswidget.cpp \ ksyncmanager.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp \ phoneaccess.cpp win32: { #olimport section importol { debug: { LIBS += mfc71ud.lib } release: { LIBS += mfc71u.lib } DEFINES += _OL_IMPORT_ HEADERS += ol_access.h SOURCES += ol_access.cpp #olimport section end } } +#The following line was inserted by qt3to4 +QT += xml qt3support diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro index f3db68e..4b42184 100644 --- a/libkdepim/libkdepimE.pro +++ b/libkdepim/libkdepimE.pro @@ -1,57 +1,57 @@ TEMPLATE = lib CONFIG += qt warn_on -TARGET = microkdepim +TARGET = xmicrokdepim INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include -LIBS += -lmicrokde -#LIBS += -lmicrokcal +LIBS += -lxmicrokde +#LIBS += -lxmicrokcal LIBS += -L$(QPEDIR)/lib OBJECTS_DIR = obj/$(PLATFORM) MOC_DIR = moc/$(PLATFORM) DESTDIR=$(QPEDIR)/lib INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ kpimprefs.h \ kpimglobalprefs.h \ kprefsdialog.h \ kprefswidget.h \ ksyncmanager.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h \ phoneaccess.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ externalapphandler.cpp \ kdateedit.cpp \ kinputdialog.cpp \ kdatepicker.cpp \ kpimprefs.cpp \ kpimglobalprefs.cpp \ kprefsdialog.cpp \ kprefswidget.cpp \ ksyncmanager.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp \ phoneaccess.cpp diff --git a/libkdepim/ol_access.cpp b/libkdepim/ol_access.cpp index 1b05693..821f148 100755 --- a/libkdepim/ol_access.cpp +++ b/libkdepim/ol_access.cpp @@ -1,272 +1,272 @@ /* This file is part of KDE-Pim/Pi. Copyright (c) 2006 Lutz Rogowski <rogowski@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., 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 <qtooltip.h> -#include <qframe.h> +#include <q3frame.h> #include <qpixmap.h> #include <qlayout.h> -#include <qprogressbar.h> -#include <qprogressdialog.h> -#include <qwidgetstack.h> +#include <q3progressbar.h> +#include <q3progressdialog.h> +#include <q3widgetstack.h> #include <qdatetime.h> #include <qdir.h> #include <qpushbutton.h> #include <qregexp.h> #include <qapplication.h> -#include <qhbox.h> -#include <qheader.h> +#include <q3hbox.h> +#include <q3header.h> #include <qdatetime.h> -#include <qlistview.h> +#include <q3listview.h> #include <kdebug.h> #include <klocale.h> #include <kstandarddirs.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <kstaticdeleter.h> #include <kdialogbase.h> #include <ol_access.h> #include "../outport/msoutl9.h" #include <ole2.h> #include <comutil.h> -class OLEListViewItem : public QCheckListItem +class OLEListViewItem : public Q3CheckListItem { public: - OLEListViewItem( QListView *parent, QString text ) : - QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; - OLEListViewItem( QListViewItem *after, QString text ) : - QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; + OLEListViewItem( Q3ListView *parent, QString text ) : + Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; }; + OLEListViewItem( Q3ListViewItem *after, QString text ) : + Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; }; ~OLEListViewItem() {}; void setData( DWORD data ) {mData= data; }; void setDataID( QString data ){ mDataID = data ;} QString dataID() { return mDataID;} DWORD data() { return mData ;}; private: DWORD mData; QString mDataID; }; class OLEFolderSelect : public KDialogBase { public: OLEFolderSelect() : KDialogBase( Plain, "", Ok | Cancel, Ok, 0, "", true, false, i18n("Import!") ) { - QHBox * mw = new QHBox( this ); + Q3HBox * mw = new Q3HBox( this ); setMainWidget( mw ); - mListView = new QListView( mw ); + mListView = new Q3ListView( mw ); mListView->addColumn(i18n("Select Folder")); mListView->addColumn(i18n("Content Type")); } - QListView* listView() { return mListView;} + Q3ListView* listView() { return mListView;} private: - QListView* mListView; + Q3ListView* mListView; }; OL_access *OL_access::sInstance = 0; static KStaticDeleter<OL_access> staticDeleterPim; OL_access *OL_access::instance() { if ( !sInstance ) { sInstance = staticDeleterPim.setObject( new OL_access() ); } return sInstance; } OL_access::OL_access() { mErrorInit = true; SCODE sc = ::OleInitialize(NULL); if ( FAILED ( sc ) ) { KMessageBox::information( 0 ,i18n("OLE initialisation failed" )); return; } if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ KMessageBox::information( 0, i18n("Sorry, cannot access Outlook") ); return ; } mErrorInit = false; } OL_access::~OL_access() { if (sInstance == this) sInstance = staticDeleterPim.setObject(0); } KABC::Addressee::List OL_access::importOLcontacts() { KABC::Addressee::List retval; if ( mErrorInit ) return retval; QStringList folderList = getFolderSelection( OL_CONTACT_DATA , i18n("Select Folders to import")); int numFolders = folderList.count()/2; int i; for ( i = 0; i < numFolders; ++i ) { readContactData( getFolderFromID( 0, folderList[(i*2)+1] ) , &retval, false ); } KMessageBox::information( 0, i18n("%1 contacts read").arg( retval.count() ) ); return retval; } void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode ) { dispItem->AddRef(); MAPIFolder mf(dispItem); mf.m_lpDispatch->AddRef(); _Items folderItems; _variant_t indx((long)0); LPDISPATCH itm; int i; folderItems = mf.GetItems(); QString cap = i18n("Importing contact data"); if ( syncMode ) { cap = i18n("Reading contact data..."); } - QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); + Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); bar.setCaption (i18n("Accessing OL") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _ContactItem * pItem = (_ContactItem *)&itm; list->append( ol2kapiContact( pItem, syncMode ) ); itm->Release(); } } QStringList OL_access::getFolderSelection( int type , QString caption ) { OLEFolderSelect folder_dialog; - QListView * listView = folder_dialog.listView(); + Q3ListView * listView = folder_dialog.listView(); MAPIFolder mfInbox; MAPIFolder mfRoot; CString szName; _NameSpace olNS; olNS = gOlAppAB.GetNamespace(_T("MAPI")); mfInbox = olNS.GetDefaultFolder(6); mfRoot = mfInbox.GetParent(); szName = mfRoot.GetName(); long iType = mfRoot.GetDefaultItemType(); QString mes; mes = QString::fromUcs2( szName.GetBuffer() ); OLEListViewItem * root = new OLEListViewItem( listView, mes ); mfRoot.m_lpDispatch->AddRef(); addFolder( root, mfRoot.m_lpDispatch, type ); root->setOpen( true ); listView->setSortColumn( 0 ); listView->sort( ); folder_dialog.setCaption( caption ); QStringList retval; folder_dialog.resize( folder_dialog.sizeHint().width()+50, folder_dialog.sizeHint().height()+50 ); if ( folder_dialog.exec() ) { OLEListViewItem* child = (OLEListViewItem*) listView->firstChild(); while ( child ) { if ( child->isOn() && ! child->firstChild() ) { retval << child->text( 0 ); retval << child->dataID(); } child = (OLEListViewItem*) child->itemBelow(); } //KMessageBox::information(0,retval.join(" \n ")); } return retval; } void OL_access::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType) { MAPIFolder mfParent(dispParent), mfChild; _Folders folders; _variant_t fndx((long)0); CString szName; long iType; OLEListViewItem* hChild; folders = mfParent.GetFolders(); for(int i=1; i <= folders.GetCount(); ++i) { iParent->setEnabled( true ); fndx = (long)i; mfChild = folders.Item(fndx.Detach()); mfChild.m_lpDispatch->AddRef(); szName = mfChild.GetName(); iType = mfChild.GetDefaultItemType(); hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); if ( iType != fType) hChild->setEnabled( false ); QString ts; switch( iType ) { case 0: ts = i18n("Mail"); break; case 1: ts = i18n("Calendar"); break; case 2: ts = i18n("Contacts"); break; case 3: ts = i18n("Todos"); break; case 4: ts = i18n("Journals"); break; case 5: ts = i18n("Notes"); break; default: ts = i18n("Unknown"); } hChild->setText( 1,ts); hChild->setData( (DWORD) mfChild.m_lpDispatch ); mfChild.m_lpDispatch->AddRef(); addFolder(hChild, mfChild.m_lpDispatch, fType); } } void OL_access::deleteAddressee( KABC::Addressee a ) { LPDISPATCH itm = getOLcontactItemFromUid ( a.originalExternalUID() ); _ContactItem* cItem = (_ContactItem *)&itm; if ( cItem != 0 ) { //KMessageBox::information(0,"delete: item found " + a.formattedName() + QString::fromUcs2(cItem->GetLastName().GetBuffer())); cItem->Delete(); } } KABC::Addressee OL_access::changeAddressee( KABC::Addressee a ) { @@ -1042,361 +1042,361 @@ KABC::Addressee OL_access::ol2kapiContact( _ContactItem * aItem , bool syncMode) additionalInfo += i18n("\nLanguage: "); additionalInfo += tempAdd; } tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nHobby: "); additionalInfo += tempAdd;; } tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nHomepage: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nBilling information: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nCustomer ID: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser1: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser2: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser3: "); additionalInfo += tempAdd;; } tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer()); phoneS.replace( QRegExp("\\r"), ""); if ( ! tempAdd.isEmpty() ) { additionalInfo += i18n("\nUser4: "); additionalInfo += tempAdd;; } if (!additionalInfo.isEmpty() && ! syncMode ) { tempAdd = notesStr; notesStr = "+++++++++++++++++++++++++++\n"; notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:"); notesStr += additionalInfo; notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n"); notesStr += "+++++++++++++++++++++++++++\n"; notesStr += tempAdd; } addressee.setNote( notesStr ); #if 0 // pending - IM address: no clue where to get info about the helper ID -custom fields: difficult to implement - not implemented -keys: makes no sense #endif return addressee; } #if 0 QDateTime mDdate2Qdtr( DATE dt) { COleDateTime odt; SYSTEMTIME st; odt = dt; if ( odt.GetStatus() != 0 ) return QDateTime(); odt.GetAsSystemTime(st); if ( st.wYear > 4000 ) // this program as a year 4000 bug! return QDateTime(); // it seems so, that 1.1.4501 indicates: DATE invalid QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); return qdt; } DATE Qdt2date( QDateTime dt ) { DATE ddd; COleDateTime odt; odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); ddd = odt; return ddd; } -class OLEListViewItem : public QCheckListItem +class OLEListViewItem : public Q3CheckListItem { public: - OLEListViewItem( QListView *parent, QString text ) : - QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; - OLEListViewItem( QListViewItem *after, QString text ) : - QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; + OLEListViewItem( Q3ListView *parent, QString text ) : + Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; }; + OLEListViewItem( Q3ListViewItem *after, QString text ) : + Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; }; ~OLEListViewItem() {}; void setData( DWORD data ) {mData= data; }; void setDataID( QString data ){ mDataID = data ;} QString dataID() { return mDataID;} DWORD data() { return mData ;}; private: DWORD mData; QString mDataID; }; bool KAImportOLdialog::sOLDispatch = false; KAImportOLdialog::KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, QWidget *parent ) : KDialogBase( Plain, caption, User1 | Close, Ok, parent, caption, true, false, i18n("Import!") ) { mSyncMode = false; - QHBox * mw = new QHBox( this ); + Q3HBox * mw = new Q3HBox( this ); setMainWidget( mw ); - mListView = new QListView( mw ); + mListView = new Q3ListView( mw ); mListView->addColumn(i18n("Select Folder")); mListView->addColumn(i18n("Content Type")); mABook = aBook; connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); setupFolderView(); resize( sizeHint().width()+50, sizeHint().height()+50 ); } KAImportOLdialog::~KAImportOLdialog() { } void KAImportOLdialog::setSyncMode() { mSyncMode = true; findButton( User1 )->setText( i18n("Synchronize!") ); } KABC::Addressee::List KAImportOLdialog::getAddressList() { return mAList; } void KAImportOLdialog::setupFolderView() { SCODE sc = ::OleInitialize(NULL); if ( FAILED ( sc ) ) { KMessageBox::information(this,"OLE initialisation failed"); return; } if( ! KAImportOLdialog::sOLDispatch ) { if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){ KMessageBox::information(this,"Sorry, cannot access Outlook"); return ; } KAImportOLdialog::sOLDispatch = true; } MAPIFolder mfInbox; MAPIFolder mfRoot; CString szName; _NameSpace olNS; olNS = gOlAppAB.GetNamespace(_T("MAPI")); mfInbox = olNS.GetDefaultFolder(6); mfRoot = mfInbox.GetParent(); szName = mfRoot.GetName(); long iType = mfRoot.GetDefaultItemType(); QString mes; mes = QString::fromUcs2( szName.GetBuffer() ); OLEListViewItem * root = new OLEListViewItem( mListView, mes ); mfRoot.m_lpDispatch->AddRef(); addFolder( root, mfRoot.m_lpDispatch ); root->setOpen( true ); mListView->setSortColumn( 0 ); mListView->sort( ); } void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent) { MAPIFolder mfParent(dispParent), mfChild; _Folders folders; _variant_t fndx((long)0); CString szName; long iType; OLEListViewItem* hChild; folders = mfParent.GetFolders(); for(int i=1; i <= folders.GetCount(); ++i) { fndx = (long)i; mfChild = folders.Item(fndx.Detach()); mfChild.m_lpDispatch->AddRef(); szName = mfChild.GetName(); iType = mfChild.GetDefaultItemType(); hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); hChild->setDataID( QString::fromUcs2(mfChild.GetEntryID().GetBuffer()) ); if ( iType != 2) hChild->setEnabled( false ); QString ts; switch( iType ) { case 0: ts = i18n("Mail"); break; case 1: ts = i18n("Calendar"); break; case 2: ts = i18n("Contacts"); break; case 3: ts = i18n("Todos"); break; case 4: ts = i18n("Journals"); break; case 5: ts = i18n("Notes"); break; default: ts = i18n("Unknown"); } hChild->setText( 1,ts); hChild->setData( (DWORD) mfChild.m_lpDispatch ); mfChild.m_lpDispatch->AddRef(); addFolder(hChild, mfChild.m_lpDispatch); } } void KAImportOLdialog::slotApply() { importedItems = 0; OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); while ( child ) { if ( child->isOn() ) { readContactData( child->data() ); if ( mSyncMode ) { mSelectedFolderID = child->dataID(); accept(); return; } } child = (OLEListViewItem*) child->itemBelow(); } QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); KMessageBox::information(this,mes); } void KAImportOLdialog::readContactData( DWORD folder ) { LPDISPATCH dispItem = (LPDISPATCH)folder; dispItem->AddRef(); MAPIFolder mf(dispItem); mf.m_lpDispatch->AddRef(); _Items folderItems; _variant_t indx((long)0); LPDISPATCH itm; int i; folderItems = mf.GetItems(); QString cap = i18n("Importing contact data"); if ( mSyncMode ) { cap = i18n("Reading contact data..."); } - QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); + Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); bar.setCaption (i18n("Accessing OL") ); int h = bar.sizeHint().height() ; int w = 300; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); for(i=1; i <= folderItems.GetCount(); ++i) { qApp->processEvents(); if ( ! bar.isVisible() ) return ; bar.setProgress( i ); indx = (long)i; itm = folderItems.Item(indx.Detach()); _ContactItem * pItem = (_ContactItem *)&itm; if ( addAddressee( ol2kapiContact( pItem, mSyncMode ) )) ++importedItems; itm->Release(); } } void KAImportOLdialog::slotOk() { QDialog::accept(); } KABC::Addressee KAImportOLdialog::ol2kapiContact( _ContactItem * aItem , bool syncMode) { KABC::Addressee addressee; addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); //GetLastModificationTime() //addressee.setName( const QString &name ); addressee.setFormattedName( QString::fromUcs2(aItem->GetFileAs().GetBuffer()) ); addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); if ( dtb.isValid() ) addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); //QString::fromUcs2(aItem->.GetBuffer()) //addressee.setMailer( const QString &mailer ); //addressee.setTimeZone( const TimeZone &timeZone ); //addressee.setGeo( const Geo &geo ); //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") ); QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer()); notesStr.replace( QRegExp("\\r"), ""); addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); //addressee.setRevision( const QDateTime &revision ); // addressee.setSortString( const QString &sortString ); addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); QString tempS; tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer());//+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); if ( tempS.length() > 12 ) addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), ""); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); if ( !tempS.isEmpty() ) addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); dtb = mDdate2Qdtr(aItem->GetAnniversary()); if (dtb.isValid() ) { QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); } int sec = aItem->GetSensitivity() ; if ( sec > 1 )// mapping pers -> private --sec; addressee.setSecrecy( sec ); //addressee.setLogo( const Picture &logo ); //addressee.setPhoto( const Picture &photo ); //addressee.setSound( const Sound &sound ); //addressee.setAgent( const Agent &agent ); QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), ""); cat = cat.replace( QRegExp("; "), ";"); diff --git a/libkdepim/ol_access.h b/libkdepim/ol_access.h index 85dbc6c..3422f65 100755 --- a/libkdepim/ol_access.h +++ b/libkdepim/ol_access.h @@ -1,174 +1,174 @@ /* This file is part of KDE/Pim-Pi Copyright (c) 2006 Lutz Rogowski 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. */ #ifndef OL_ACCESS_H #define OL_ACCESS_H #include <qstring.h> #include <kdialogbase.h> #include <kabc/addressee.h> #include <kabc/addressbook.h> #include <afxdisp.h> #include "../outport/msoutl9.h" #define OL_CONTACT_DATA 2 #define OL_CALENDAR_DATA 1 //pending is this the right number class QDateTime; -class QListView; +class Q3ListView; class OLEListViewItem; class _ContactItem; class OL_access : public QObject { Q_OBJECT public: static OL_access *instance(); ~OL_access(); //static converter methods static QDateTime mDdate2Qdtr( DATE dt); static DATE Qdt2date( QDateTime dt ); static KABC::Addressee ol2kapiContact( _ContactItem * aItem , bool syncMode); static void writeData2OLitem( KABC::Addressee addressee, _ContactItem * aItem ); KABC::Addressee::List importOLcontacts(); QStringList getFolderSelection( int type, QString caption ); void readContactData( LPDISPATCH folder, KABC::Addressee::List* list, bool syncMode ); LPDISPATCH getFolderFromID( LPDISPATCH parentFolder, QString selectedFolderID ); bool setSelectedFolder( QString folderID ); //call setSelectedFolder() before using the next methods: void deleteAddressee( KABC::Addressee a ); KABC::Addressee changeAddressee( KABC::Addressee a ); KABC::Addressee addAddressee( KABC::Addressee a ); public slots: signals: protected slots: protected: private: _Application gOlAppAB; bool mErrorInit; void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent, long fType); LPDISPATCH getOLcontactItemFromUid( QString uid ); QString mSelectedFolderID; LPDISPATCH mSelectedFolder; _Items mFolderItems; OL_access(); static OL_access *sInstance; }; #if 0 //using namespace KABC; //class KABC::AddressBook; /** This is the base class for the calendar component editors. */ class KAImportOLdialog : public KDialogBase { Q__OBJECT public: /** Construct new IncidenceEditor. */ KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook, QWidget *parent ); ~KAImportOLdialog(); /** Initialize editor. This function creates the tab widgets. */ void init(); void setSyncMode(); KABC::Addressee::List getAddressList(); QString selectedFolderID() {return mSelectedFolderID;} static KABC::Addressee ol2kapiContact( _ContactItem * , bool syncMode ); static bool sOLDispatch; pub_lic sl_ots: sign_als: prote_cted slo_ts: void slotApply(); void slotOk(); void slotCancel(); protected: void setupFolderView(); void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent); void readContactData( DWORD folder ); KABC::AddressBook * mABook; - QListView * mListView; + Q3ListView * mListView; KABC::Addressee::List mAList; bool addAddressee( KABC::Addressee a ); private: int importedItems; bool mSyncMode; QString mSelectedFolderID; }; class KAwritebackOL : public QObject { Q__OBJECT public: KAwritebackOL( const QString &olFolderID ); ~KAwritebackOL(); bool init(); void deleteAddressee( KABC::Addressee a ); KABC::Addressee changeAddressee( KABC::Addressee a ); KABC::Addressee addAddressee( KABC::Addressee a ); public sl_ots: signals: protected sl_ots: protected: LPDISPATCH getFolderFromID( LPDISPATCH parentFolder ); LPDISPATCH getOLitemFromUid( QString uid ); void writeData2OLitem( KABC::Addressee a, _ContactItem * olitem ); private: QString mSelectedFolderID; LPDISPATCH mSelectedFolder; _Items mFolderItems; }; #endif #endif diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index 89db22b..0ea73f5 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp @@ -1,216 +1,219 @@ /* This file is part of libkdepim. Copyright (c) 2004 Lutz Rogowski <rogowski@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 <qstring.h> #include <qapplication.h> -#include <qptrlist.h> +#include <QDesktopWidget> +#include <q3ptrlist.h> #include <qregexp.h> #include <qfile.h> #include <qlabel.h> -#include <qtextstream.h> +#include <q3textstream.h> #include <qtextcodec.h> #include <qdir.h> #include <kmessagebox.h> #include <stdlib.h> #include "phoneaccess.h" void PhoneAccess::writeConfig( QString device, QString connection, QString model ) { #ifdef _WIN32_ QString fileName = qApp->applicationDirPath () +"\\gammurc"; #else QString fileName = QDir::homeDirPath() +"/.gammurc"; #endif //qDebug("save %d ", load ); QString content = "[gammu]\n";; bool write = false; bool addPort = true, addConnection = true, addModel = true; QFile file( fileName ); if ( QFile::exists( fileName) ) { - if (!file.open( IO_ReadOnly ) ) { + if (!file.open( QIODevice::ReadOnly ) ) { qDebug("Error: cannot open %s ", fileName.latin1() ); return; } QString line; - while ( file.readLine( line, 1024 ) > 0 ) { + char tmp[1024]; + while ( file.readLine( tmp, 1024 ) > 0 ) { + line = tmp; //qDebug("*%s* ", line.latin1() ); if ( line.left(7 ) == "[gammu]" ) { ; } else if ( line.left(4 ) == "port" ) { if ( line == "port = " + device+"\n" ) { content += line ; addPort = false; //qDebug("port found" ); } } else if ( line.left(5 ) == "model" ) { if ( line == "model = " + model +"\n") { content += line ; addModel = false; //qDebug("model found" ); } } else if ( line.left( 10 ) == "connection" ) { if ( line == "connection = " + connection +"\n") { addConnection = false; content += line ; //qDebug("con found" ); } } else { content += line ; } } file.close(); } else { if ( ! connection.isEmpty() ) { addConnection = true; } if ( ! device.isEmpty() ) { addPort = true; } if ( ! model.isEmpty() ) { addModel = true; } } if ( addConnection ) { write = true; content += "connection = "; content += connection; content += "\n"; } if ( addPort ) { write = true; content += "port = "; content += device; content += "\n"; } if ( addModel ) { write = true; content += "model = "; content += model; content += "\n"; } if ( write ) { - if (!file.open( IO_WriteOnly ) ) { + if (!file.open( QIODevice::WriteOnly ) ) { qDebug("Error: cannot write file %s ", fileName.latin1() ); return; } qDebug("Writing file %s ", fileName.latin1() ); - QTextStream ts( &file ); + Q3TextStream ts( &file ); ts << content ; file.close(); } } bool PhoneAccess::writeToPhone( QString fileName) { #ifdef DESKTOP_VERSION #ifdef _WIN32_ QString command ="kammu --restore " + fileName ; #else QString command ="./kammu --restore " + fileName ; #endif #else QString command ="kammu --restore " + fileName ; #endif int ret = 1; while ( ret != 0 ) { QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); int w = 235; int h = status->sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); if ( dw > 310 ) w = 310; status->setCaption(i18n("Writing to phone...") ); status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status->show(); status->raise(); status->update(); qApp->processEvents(); status->update(); qApp->processEvents(); ret = system ( command.latin1()); delete status; qApp->processEvents(); if ( ret ) { qDebug("Error S::command returned %d.", ret); int retval = KMessageBox::warningContinueCancel(0, i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); if ( retval != KMessageBox::Continue ) return false; } } return true; } bool PhoneAccess::readFromPhone( QString fileName) { #ifdef DESKTOP_VERSION #ifdef _WIN32_ QString command ="kammu --backup " + fileName + " -yes" ; #else QString command ="./kammu --backup " + fileName + " -yes" ; #endif #else QString command ="kammu --backup " + fileName + " -yes" ; #endif int ret = 1; while ( ret != 0 ) { QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); int w = 235; int h = status->sizeHint().height()+20 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); if ( dw > 310 ) w = 310; status->setCaption(i18n("Reading from phone...") ); status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); status->show(); status->raise(); status->update(); qApp->processEvents(); status->update(); qApp->processEvents(); ret = system ( command.latin1() ); delete status; qApp->processEvents(); if ( ret ) { qDebug("Error reading from phone:Command returned %d", ret); int retval = KMessageBox::warningContinueCancel(0, i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); if ( retval != KMessageBox::Continue ) return false; } } qApp->processEvents(); return true; } |