summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/contacteditor.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp62
1 files changed, 30 insertions, 32 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index b078968..dec4c7c 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -22,25 +22,24 @@
#include "contacteditor.h"
#include "namelineedit.h"
#include <opie2/odebug.h>
#include <opie2/opimcontact.h>
#include <qpe/categoryselect.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
#include <qpe/resource.h>
#include <qlabel.h>
-#include <qtabwidget.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qtoolbutton.h>
#include <qlistbox.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <assert.h>
static inline bool containsAlphaNum( const QString &str );
static inline bool constainsWhiteSpace( const QString &str );
@@ -49,25 +48,25 @@ static inline bool constainsWhiteSpace( const QString &str );
// file format...
void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
QString &strAll );
// helper convert from file format to comma delimited...
void parseEmailTo( const QString &strDefaultEmail,
const QString &strOtherEmail, QString &strBack );
ContactEditor::ContactEditor( const Opie::OPimContact &entry,
QWidget *parent,
const char *name,
WFlags )
- : QDialog( parent, name, TRUE, WStyle_ContextHelp ),
+ : QDialog( parent, name, true, WStyle_ContextHelp ),
defaultEmailChooserPosition( -1 ),
m_personalView ( false ),
cmbDefaultEmail( 0 ),
initializing ( false )
{
initializing = true;
init();
setEntry( entry );
// cmbDefaultEmail = 0;
// defaultEmailChooserPosition = -1;
@@ -110,43 +109,42 @@ void ContactEditor::init() {
trlDynamicEntries.remove( translMap[Qtopia::Gender] );
// Last Check to be sure..
assert( slDynamicEntries.count() == trlDynamicEntries.count() );
assert( slChooserNames.count() == trlChooserNames.count() );
for (i = 0; i < slChooserNames.count(); i++)
slChooserValues.append("");
QVBoxLayout *vb = new QVBoxLayout( this );
- tabMain = new QTabWidget( this );
+ tabMain = new Opie::Ui::OTabWidget( this );
vb->addWidget( tabMain );
- QWidget *tabViewport = new QWidget ( tabMain );
+ m_generalWidget = new QWidget ( tabMain );
- vb = new QVBoxLayout( tabViewport );
+ vb = new QVBoxLayout( m_generalWidget );
- svGeneral = new QScrollView( tabViewport );
+ svGeneral = new QScrollView( m_generalWidget );
vb->addWidget( svGeneral, 0, 0 );
svGeneral->setResizePolicy( QScrollView::AutoOneFit );
// svGeneral->setHScrollBarMode( QScrollView::AlwaysOff );
// svGeneral->setVScrollBarMode( QScrollView::AlwaysOff );
svGeneral->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( svGeneral->viewport() );
svGeneral->addChild( container );
- QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
- gl->setResizeMode( QLayout::FreeResize );
+ QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 );
btnFullName = new QPushButton( tr( "Full Name..." ), container );
QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) );
gl->addWidget( btnFullName, 0, 0 );
txtFullName = new ABOOK::NameLineEdit( container );
QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) );
gl->addWidget( txtFullName, 0, 1 );
QLabel *l = new QLabel( tr( "Job Title" ), container );
QWhatsThis::add( l, tr( "The jobtitle.." ) );
gl->addWidget( l, 1, 0 );
txtJobTitle = new QLineEdit( container );
@@ -159,95 +157,95 @@ void ContactEditor::init() {
txtSuffix = new QLineEdit( container );
QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
gl->addWidget( txtSuffix, 2, 1 );
l = new QLabel( tr( "Organization" ), container );
QWhatsThis::add( l, tr( "The working place of the contact" ) );
gl->addWidget( l, 3, 0 );
txtOrganization = new QLineEdit( container );
QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
gl->addWidget( txtOrganization, 3, 1 );
// Chooser 1
- cmbChooserField1 = new QComboBox( FALSE, container );
+ cmbChooserField1 = new QComboBox( false, container );
QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
cmbChooserField1->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField1, 4, 0 );
// Textfield for chooser 1.
// Now use Widgetstack to contain the textfield and the default-email combo !
m_widgetStack1 = new QWidgetStack( container );
txtChooserField1 = new QLineEdit( m_widgetStack1 );
m_widgetStack1 -> addWidget( txtChooserField1, TextField );
gl->addWidget( m_widgetStack1, 4, 1 );
m_widgetStack1 -> raiseWidget( TextField );
// Chooser 2
- cmbChooserField2 = new QComboBox( FALSE, container );
+ cmbChooserField2 = new QComboBox( false, container );
QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) );
cmbChooserField2->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField2, 5, 0 );
// Textfield for chooser 2
// Now use WidgetStack to contain the textfield and the default-email combo!
m_widgetStack2 = new QWidgetStack( container );
txtChooserField2 = new QLineEdit( m_widgetStack2 );
m_widgetStack2 -> addWidget( txtChooserField2, TextField );
gl->addWidget( m_widgetStack2, 5, 1 );
m_widgetStack2 -> raiseWidget( TextField );
// Chooser 3
- cmbChooserField3 = new QComboBox( FALSE, container );
+ cmbChooserField3 = new QComboBox( false, container );
QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) );
cmbChooserField3->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField3, 6, 0 );
// Textfield for chooser 2
// Now use WidgetStack to contain the textfield and the default-email combo!
m_widgetStack3 = new QWidgetStack( container );
txtChooserField3 = new QLineEdit( m_widgetStack3 );
m_widgetStack3 -> addWidget( txtChooserField3, TextField );
gl->addWidget( m_widgetStack3, 6, 1 );
m_widgetStack3 -> raiseWidget( TextField );
l = new QLabel( tr( "File As" ), container );
QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) );
gl->addWidget( l, 7, 0 );
- cmbFileAs = new QComboBox( TRUE, container );
+ cmbFileAs = new QComboBox( true, container );
gl->addWidget( cmbFileAs, 7, 1 );
labCat = new QLabel( tr( "Category" ), container );
gl->addWidget( labCat, 8, 0 );
cmbCat = new CategorySelect( container );
gl->addWidget( cmbCat, 8, 1 );
labCat->show();
cmbCat->show();
- btnNote = new QPushButton( tr( "Notes..." ), container );
+ btnNote = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Notes..." ), container );
gl->addWidget( btnNote, 9, 1 );
- tabMain->insertTab( tabViewport, tr( "General" ) );
+ tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) );
- tabViewport = new QWidget ( tabMain );
+ QWidget *tabViewport = new QWidget ( tabMain );
vb = new QVBoxLayout( tabViewport );
svAddress = new QScrollView( tabViewport );
vb->addWidget( svAddress, 0, 0 );
svAddress->setResizePolicy( QScrollView::AutoOneFit );
svAddress->setFrameStyle( QFrame::NoFrame );
container = new QWidget( svAddress->viewport() );
svAddress->addChild( container );
gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
- cmbAddress = new QComboBox( FALSE, container );
+ cmbAddress = new QComboBox( false, container );
cmbAddress->insertItem( tr( "Business" ) );
cmbAddress->insertItem( tr( "Home" ) );
gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
l = new QLabel( tr( "Address" ), container );
gl->addWidget( l, 1, 0 );
txtAddress = new QLineEdit( container );
gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
l = new QLabel( tr( "City" ), container );
gl->addWidget( l, 2, 0 );
txtCity = new QLineEdit( container );
@@ -256,25 +254,25 @@ void ContactEditor::init() {
l = new QLabel( tr( "State" ), container );
gl->addWidget( l, 3, 0 );
txtState = new QLineEdit( container );
gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
l = new QLabel( tr( "Zip Code" ), container );
gl->addWidget( l, 4, 0 );
txtZip = new QLineEdit( container );
gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
l = new QLabel( tr( "Country" ), container );
gl->addWidget( l, 5, 0 );
- cmbCountry = new QComboBox( TRUE, container );
+ cmbCountry = new QComboBox( true, container );
cmbCountry->insertItem( "" );
cmbCountry->insertItem( tr ( "United States" ) );
cmbCountry->insertItem( tr ( "United Kingdom" ) );
cmbCountry->insertItem( tr ( "Afghanistan" ) );
cmbCountry->insertItem( tr ( "Albania" ) );
cmbCountry->insertItem( tr ( "Algeria" ) );
cmbCountry->insertItem( tr ( "American Samoa" ) );
cmbCountry->insertItem( tr ( "Andorra" ) );
cmbCountry->insertItem( tr ( "Angola" ) );
cmbCountry->insertItem( tr ( "Anguilla" ) );
cmbCountry->insertItem( tr ( "Antarctica" ) );
cmbCountry->insertItem( tr ( "Argentina" ) );
@@ -476,90 +474,90 @@ void ContactEditor::init() {
cmbCountry->insertItem( tr ( "Yemen" ) );
cmbCountry->insertItem( tr ( "Yugoslavia" ) );
cmbCountry->insertItem( tr ( "Zambia" ) );
cmbCountry->insertItem( tr ( "Zimbabwe" ) );
if (cmbCountry->listBox()!=0)
cmbCountry->listBox()->sort();
cmbCountry->setMaximumWidth( 135 );
gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
// Chooser 4
- cmbChooserField4 = new QComboBox( FALSE, container );
+ cmbChooserField4 = new QComboBox( false, container );
cmbChooserField4->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField4, 6, 0 );
// Textfield for chooser 2
// Now use WidgetStack to contain the textfield and the default-email combo!
m_widgetStack4 = new QWidgetStack( container );
txtChooserField4 = new QLineEdit( m_widgetStack4 );
m_widgetStack4 -> addWidget( txtChooserField4, TextField );
gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 );
m_widgetStack4 -> raiseWidget( TextField );
QSpacerItem *space = new QSpacerItem(1,1,
QSizePolicy::Maximum,
QSizePolicy::MinimumExpanding );
gl->addItem( space, 7, 0 );
- tabMain->insertTab( tabViewport, tr( "Address" ) );
+ tabMain->addTab( tabViewport, "home", tr( "Address" ) );
tabViewport = new QWidget ( tabMain );
vb = new QVBoxLayout( tabViewport );
svDetails = new QScrollView( tabViewport );
vb->addWidget( svDetails, 0, 0 );
svDetails->setResizePolicy( QScrollView::AutoOneFit );
svDetails->setFrameStyle( QFrame::NoFrame );
container = new QWidget( svDetails->viewport() );
svDetails->addChild( container );
gl = new QGridLayout( container, 1, 2, 2, 4 );
int counter = 0;
// Birthday
QHBox* hBox = new QHBox( container );
l = new QLabel( tr("Birthday"), container );
gl->addWidget( l, counter, 0 );
QPopupMenu* m1 = new QPopupMenu( container );
- birthdayPicker = new DateBookMonth( m1, 0, TRUE );
+ birthdayPicker = new DateBookMonth( m1, 0, true );
m1->insertItem( birthdayPicker );
birthdayButton= new QToolButton( hBox, "buttonStart" );
birthdayButton->setPopup( m1 );
birthdayButton->setPopupDelay(0);
QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
tr( "Delete" ),
hBox, 0 );
gl->addWidget( hBox, counter , 1 );
connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ),
this, SLOT( slotBirthdayDateChanged(int,int,int) ) );
connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
++counter;
// Anniversary
hBox = new QHBox( container );
l = new QLabel( tr("Anniversary"), container );
gl->addWidget( l, counter, 0 );
m1 = new QPopupMenu( container );
- anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
+ anniversaryPicker = new DateBookMonth( m1, 0, true );
m1->insertItem( anniversaryPicker );
anniversaryButton= new QToolButton( hBox, "buttonStart" );
anniversaryButton->setPopup( m1 );
anniversaryButton->setPopupDelay(0);
deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
tr( "Delete" ),
hBox, 0 );
gl->addWidget( hBox, counter , 1 );
connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ),
@@ -590,34 +588,34 @@ void ContactEditor::init() {
l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
listName.append( l );
gl->addWidget( l, i, 0 );
QLineEdit *e = new QLineEdit( container );
listValue.append( e );
gl->addWidget( e, i, 1);
}
// Fill labels with names..
// loadFields();
- tabMain->insertTab( tabViewport, tr( "Details" ) );
+ tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) );
- dlgNote = new QDialog( this, "Note Dialog", TRUE );
+ dlgNote = new QDialog( this, "Note Dialog", true );
dlgNote->setCaption( tr("Enter Note") );
QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
txtNote = new QMultiLineEdit( dlgNote );
vbNote->addWidget( txtNote );
connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
- dlgName = new QDialog( this, "Name Dialog", TRUE );
+ dlgName = new QDialog( this, "Name Dialog", true );
dlgName->setCaption( tr("Edit Name") );
gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
l = new QLabel( tr("First Name"), dlgName );
gl->addWidget( l, 0, 0 );
txtFirstName = new ABOOK::NameLineEdit( dlgName );
gl->addWidget( txtFirstName, 0, 1 );
l = new QLabel( tr("Middle Name"), dlgName );
gl->addWidget( l, 1, 0 );
txtMiddleName = new ABOOK::NameLineEdit( dlgName );
gl->addWidget( txtMiddleName, 1, 1 );
@@ -1084,25 +1082,25 @@ void ContactEditor::slotNote() {
}
void ContactEditor::slotName() {
QString tmpName;
txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
// txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
if ( QPEApplication::execDialog( dlgName ) ) {
- if ( txtLastName->text().contains( ' ', TRUE ) )
+ if ( txtLastName->text().contains( ' ', true ) )
tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
else
tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
txtFullName->setText( tmpName.simplifyWhiteSpace() );
slotFullNameChange( txtFullName->text() );
}
}
void ContactEditor::setNameFocus() {
@@ -1129,25 +1127,25 @@ bool ContactEditor::isEmpty() {
QString ContactEditor::parseName( const QString fullName, int type ) {
QString simplifiedName( fullName.simplifyWhiteSpace() );
QString strFirstName;
QString strMiddleName;
QString strLastName;
QString strTitle;
int commapos;
bool haveLastName = false;
odebug << "Fullname: " << simplifiedName << oendl;
- commapos = simplifiedName.find( ',', 0, TRUE);
+ commapos = simplifiedName.find( ',', 0, true);
if ( commapos >= 0 ) {
odebug << " Commapos: " << commapos << oendl;
// A comma (",") separates the lastname from one or
// many first names. Thus, remove the lastname from the
// String and parse the firstnames.
strLastName = simplifiedName.left( commapos );
simplifiedName= simplifiedName.mid( commapos + 1 );
haveLastName = true;
odebug << "Fullname without ',': " << simplifiedName << oendl;
@@ -1253,46 +1251,46 @@ void ContactEditor::cleanupFields() {
txtTmp->setText("");
txtTmp = cmbFileAs->lineEdit();
txtTmp->setText("");
}
void ContactEditor::setEntry( const Opie::OPimContact &entry ) {
initializing = true;
// Cleanup and activate the general Page ..
cleanupFields();
- tabMain->setCurrentPage( 0 );
+ tabMain->setCurrentTab( m_generalWidget );
ent = entry;
emails = QStringList(ent.emailList());
defaultEmail = ent.defaultEmail();
if (defaultEmail.isEmpty()) defaultEmail = emails[0];
odebug << "default email=" << defaultEmail << oendl;
txtFirstName->setText( ent.firstName() );
txtMiddleName->setText( ent.middleName() );
txtLastName->setText( ent.lastName() );
txtSuffix->setText( ent.suffix() );
// QString *tmpString = new QString;
// *tmpString = ent.firstName() + " " + ent.middleName() +
// + " " + ent.lastName() + " " + ent.suffix();
// txtFullName->setText( tmpString->simplifyWhiteSpace() );
if ( !ent.isEmpty() ){
// Lastnames with multiple words need to be protected by a comma !
- if ( ent.lastName().contains( ' ', TRUE ) )
+ if ( ent.lastName().contains( ' ', true ) )
txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
else
txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
}
cmbFileAs->setEditText( ent.fileAs() );
// if (hasTitle)
txtJobTitle->setText( ent.jobTitle() );
// if (hasCompany)
txtOrganization->setText( ent.company() );
@@ -1678,36 +1676,36 @@ void parseEmailTo( const QString &strDefaultEmail,
} else
foundDefault = true;
}
}
static inline bool containsAlphaNum( const QString &str )
{
int i,
count = str.length();
for ( i = 0; i < count; i++ )
if ( !str[i].isSpace() )
- return TRUE;
- return FALSE;
+ return true;
+ return false;
}
static inline bool constainsWhiteSpace( const QString &str )
{
int i,
count = str.length();
for (i = 0; i < count; i++ )
if ( str[i].isSpace() )
- return TRUE;
- return FALSE;
+ return true;
+ return false;
}
void ContactEditor::setPersonalView( bool personal )
{
m_personalView = personal;
// Currently disbled due to the fact that
// show will not work...
return;
if ( personal ){
cmbCat->hide();