summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseditwidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/addresseditwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/addresseditwidget.cpp55
1 files changed, 31 insertions, 24 deletions
diff --git a/kaddressbook/addresseditwidget.cpp b/kaddressbook/addresseditwidget.cpp
index 3dcd592..83908d0 100644
--- a/kaddressbook/addresseditwidget.cpp
+++ b/kaddressbook/addresseditwidget.cpp
@@ -9,99 +9,106 @@
(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 <qbuttongroup.h>
+#include <q3buttongroup.h>
#include <qcheckbox.h>
-#include <qhbox.h>
+#include <q3hbox.h>
#include <qlabel.h>
#include <qlayout.h>
-#include <qlistbox.h>
-#include <qlistview.h>
+#include <q3listbox.h>
+#include <q3listview.h>
#include <qpushbutton.h>
-#include <qsignal.h>
+#include <q3signal.h>
#include <qstring.h>
#include <qapplication.h>
+#include <QDesktopWidget>
+
+#include <Q3VBoxLayout>
+#include <Q3GridLayout>
#ifndef KAB_EMBEDDED
-#include <qtextedit.h>
+#include <q3textedit.h>
+//Added by qt3to4:
+#include <Q3ValueList>
+#include <Q3VBoxLayout>
#include <kaccelmanager.h>
#include <kbuttonbox.h>
#else //KAB_EMBEDDED
-#include <qmultilineedit.h>
+#include <q3multilineedit.h>
#endif //KAB_EMBEDDED
#include <qtoolbutton.h>
#include <qtooltip.h>
#include <kapplication.h>
#include <kcombobox.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kdialog.h>
#include <kiconloader.h>
#include <klineedit.h>
#include <klistview.h>
#include <klocale.h>
#include <kglobal.h>
#include <kmessagebox.h>
#include <kseparator.h>
#include "addresseditwidget.h"
AddressEditWidget::AddressEditWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
mConfig = AddresseeConfig::instance();
- QVBoxLayout *layout = new QVBoxLayout( this );
+ Q3VBoxLayout *layout = new Q3VBoxLayout( this );
layout->setSpacing( KDialog::spacingHintSmall() );
- QHBox *b1 = new QHBox( this);
+ Q3HBox *b1 = new Q3HBox( this);
//QLabel * label = new QLabel( b1 );
//label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
//label->setAlignment( AlignCenter);
layout->addWidget( b1 );
mTypeCombo = new AddressTypeCombo( mAddressList, b1 );
QPushButton *editButton = new QPushButton( i18n( "&Edit Addresses..." ),
b1 );
connect( mTypeCombo, SIGNAL( activated( int ) ),
SLOT( updateAddressEdit() ) );
// layout->addWidget( mTypeCombo );
#ifndef KAB_EMBEDDED
- mAddressTextEdit = new QTextEdit( this );
+ mAddressTextEdit = new Q3TextEdit( this );
mAddressTextEdit->setReadOnly( true );
mAddressTextEdit->setMinimumHeight( 20 );
#else //KAB_EMBEDDED
- mAddressTextEdit = new QMultiLineEdit( this );
+ mAddressTextEdit = new Q3MultiLineEdit( this );
mAddressTextEdit->setReadOnly( true );
mAddressTextEdit->setMinimumHeight( 20 );
#endif //KAB_EMBEDDED
layout->addWidget( mAddressTextEdit );
connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
}
AddressEditWidget::~AddressEditWidget()
{
}
KABC::Address::List AddressEditWidget::addresses()
@@ -113,39 +120,39 @@ KABC::Address::List AddressEditWidget::addresses()
if ( !(*it).isEmpty() )
retList.append( *it );
return retList;
}
void AddressEditWidget::setAddresses( const KABC::Addressee &addr,
const KABC::Address::List &list )
{
mAddressee = addr;
mAddressList.clear();
// Insert types for existing numbers.
mTypeCombo->insertTypeList( list );
- QValueList<int> defaultTypes;
+ Q3ValueList<int> defaultTypes;
defaultTypes << KABC::Address::Home;
defaultTypes << KABC::Address::Work;
mConfig->setUid( mAddressee.uid() );
- QValueList<int> configList = mConfig->noDefaultAddrTypes();
- QValueList<int>::ConstIterator it;
+ Q3ValueList<int> configList = mConfig->noDefaultAddrTypes();
+ Q3ValueList<int>::ConstIterator it;
for ( it = configList.begin(); it != configList.end(); ++it )
defaultTypes.remove( *it );
// Insert default types.
// Doing this for mPrefCombo is enough because the list is shared by all
// combos.
for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
if ( !mTypeCombo->hasType( *it ) )
mTypeCombo->insertType( list, *it, Address( *it ) );
}
mTypeCombo->updateTypes();
// find preferred address which will be shown
int preferred = KABC::Address::Home; // default if no preferred address set
uint i;
@@ -168,33 +175,33 @@ void AddressEditWidget::edit()
mAddressList = dialog.addresses();
bool hasHome = false, hasWork = false;
KABC::Address::List::Iterator it;
for ( it = mAddressList.begin(); it != mAddressList.end(); ++it ) {
if ( (*it).type() == KABC::Address::Home ) {
if ( !(*it).isEmpty() )
hasHome = true;
}
if ( (*it).type() == KABC::Address::Work ) {
if ( !(*it).isEmpty() )
hasWork = true;
}
}
mConfig->setUid( mAddressee.uid() );
- QValueList<int> configList;
+ Q3ValueList<int> configList;
if ( !hasHome ) {
configList << KABC::Address::Home;
}
if ( !hasWork ) {
configList << KABC::Address::Work;
}
mConfig->setNoDefaultAddrTypes( configList );
mTypeCombo->updateTypes();
updateAddressEdit();
emit modified();
}
}
}
void AddressEditWidget::updateAddressEdit()
@@ -242,46 +249,46 @@ void AddressEditWidget::updateAddressEdit()
}
blockSignals( block );
}
AddressEditDialog::AddressEditDialog( const KABC::Address::List &list,
int selected, QWidget *parent,
const char *name )
: KDialogBase( Plain, i18n( "Edit Address" ), Ok | Cancel, Ok,
parent, name, true, true ),
mPreviousAddress( 0 )
{
mAddressList = list;
QWidget *page = plainPage();
- QGridLayout *topLayout = new QGridLayout( page, 8, 2 );
+ Q3GridLayout *topLayout = new Q3GridLayout( page, 8, 2 );
topLayout->setSpacing( spacingHintSmall() );
mTypeCombo = new AddressTypeCombo( mAddressList, page );
topLayout->addMultiCellWidget( mTypeCombo, 0, 0, 0, 1 );
QLabel *label = new QLabel( i18n( "Street:" ), page );
label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
topLayout->addWidget( label, 1, 0 );
#ifndef KAB_EMBEDDED
- mStreetTextEdit = new QTextEdit( page );
+ mStreetTextEdit = new Q3TextEdit( page );
#else //KAB_EMBEDDED
- mStreetTextEdit = new QMultiLineEdit( page );
+ mStreetTextEdit = new Q3MultiLineEdit( page );
//US qDebug("AddressEditDialog::AddressEditDialog has to be changed");
#endif //KAB_EMBEDDED
label->setBuddy( mStreetTextEdit );
topLayout->addWidget( mStreetTextEdit, 1, 1 );
label = new QLabel( i18n( "Post office box:" ), page );
topLayout->addWidget( label, 2 , 0 );
mPOBoxEdit = new KLineEdit( page );
label->setBuddy( mPOBoxEdit );
topLayout->addWidget( mPOBoxEdit, 2, 1 );
int maxwid = QApplication::desktop()->width();
maxwid -= (spacingHintSmall()+label->sizeHint().width() );
label = new QLabel( i18n( "Locality:" ), page );
topLayout->addWidget( label, 3, 0 );
mLocalityEdit = new KLineEdit( page );
@@ -298,40 +305,40 @@ AddressEditDialog::AddressEditDialog( const KABC::Address::List &list,
topLayout->addWidget( label, 5, 0 );
mPostalCodeEdit = new KLineEdit( page );
label->setBuddy( mPostalCodeEdit );
topLayout->addWidget( mPostalCodeEdit, 5, 1 );
label = new QLabel( i18n( "Country:" ), page );
topLayout->addWidget( label, 6, 0 );
mCountryCombo = new KComboBox( page );
mCountryCombo->setMaximumWidth( maxwid -10 );
mCountryCombo->setEditable( true );
mCountryCombo->setDuplicatesEnabled( false );
mCountryCombo->setAutoCompletion( true );
fillCountryCombo();
label->setBuddy( mCountryCombo );
topLayout->addWidget( mCountryCombo, 6, 1 );
- mCountryCombo->setSizeLimit( 8);
+ mCountryCombo->setMaxVisibleItems( 8);
mPreferredCheckBox = new QCheckBox( i18n( "This is the preferred address" ), page );
topLayout->addMultiCellWidget( mPreferredCheckBox, 7, 7, 0, 1 );
/*
KSeparator *sep = new KSeparator( KSeparator::HLine, page );
topLayout->addMultiCellWidget( sep, 8, 8, 0, 1 );
*/
- QHBox *buttonBox = new QHBox( page );
+ Q3HBox *buttonBox = new Q3HBox( page );
buttonBox->setSpacing( spacingHint() );
topLayout->addMultiCellWidget( buttonBox, 9, 9, 0, 1 );
QPushButton *addButton = new QPushButton( i18n( "New..." ), buttonBox );
connect( addButton, SIGNAL( clicked() ), SLOT( addAddress() ) );
mRemoveButton = new QPushButton( i18n( "Remove" ), buttonBox );
connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeAddress() ) );
mChangeTypeButton = new QPushButton( i18n( "Change Type" ), buttonBox );
connect( mChangeTypeButton, SIGNAL( clicked() ), SLOT( changeType() ) );
mTypeCombo->updateTypes();
mTypeCombo->setCurrentItem( selected );
updateAddressEdits();
@@ -570,53 +577,53 @@ void AddressEditDialog::fillCountryCombo()
QStringList countries;
for ( int i = 0; !country[ i ].isEmpty(); ++i )
countries.append( country[ i ] );
countries.sort();
mCountryCombo->insertStringList( countries );
}
AddressTypeDialog::AddressTypeDialog( int type, QWidget *parent )
: KDialogBase( Plain, i18n( "Edit Address Type" ), Ok | Cancel, Ok,
parent, "AddressTypeDialog" )
{
QWidget *page = plainPage();
- QVBoxLayout *layout = new QVBoxLayout( page );
+ Q3VBoxLayout *layout = new Q3VBoxLayout( page );
- mGroup = new QButtonGroup( 2, Horizontal, i18n( "Address Types" ), page );
+ mGroup = new Q3ButtonGroup( 2, Qt::Horizontal, i18n( "Address Types" ), page );
layout->addWidget( mGroup );
mTypeList = KABC::Address::typeList();
mTypeList.remove( KABC::Address::Pref );
KABC::Address::TypeList::Iterator it;
for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
new QCheckBox( KABC::Address::typeLabel( *it ), mGroup );
for ( int i = 0; i < mGroup->count(); ++i ) {
QCheckBox *box = (QCheckBox*)mGroup->find( i );
box->setChecked( type & mTypeList[ i ] );
}
}
AddressTypeDialog::~AddressTypeDialog()
{
}
int AddressTypeDialog::type() const
{
int type = 0;
for ( int i = 0; i < mGroup->count(); ++i ) {
QCheckBox *box = (QCheckBox*)mGroup->find( i );
if ( box->isChecked() )
type += mTypeList[ i ];
}
return type;
}
-#ifndef KAB_EMBEDDED
-#include "addresseditwidget.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_addresseditwidget.cpp"
#endif //KAB_EMBEDDED