summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index beb953a..8229212 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -169,106 +169,106 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
a->addTo( edit );
a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( edit );
// Create Views
// This is safe to call without checking to see if it exists...
// not to mention it also does the necessary stuff for the
// journaling...
QString str = addressbookXMLFilename();
if ( str.isNull() ) {
QMessageBox::warning( this, tr("Out of Space"),
tr("There is not enough space to create\n"
"neccessary startup files.\n"
"\nFree up some space before\nentering data!")
);
}
listContainer = new QWidget( this );
-
+
QVBoxLayout *vb = new QVBoxLayout( listContainer );
-
+
abList = new AbTable( &orderedFields, listContainer, "table" );
vb->addWidget(abList);
abList->setHScrollBarMode( QScrollView::AlwaysOff );
connect( abList, SIGNAL( empty( bool ) ),
this, SLOT( listIsEmpty( bool ) ) );
connect( abList, SIGNAL( details() ),
this, SLOT( slotListView() ) );
connect( abList, SIGNAL(currentChanged(int,int)),
this, SLOT(slotUpdateToolbar()) );
mView = 0;
abList->load( addressbookXMLFilename() );
if ( QFile::exists(addressbookOldXMLFilename()) ) {
abList->load( addressbookOldXMLFilename() );
QFile::remove(addressbookOldXMLFilename());
}
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
vb->addWidget(pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
mbList->insertItem( tr("View"), catMenu );
setCentralWidget( listContainer );
fontMenu = new QPopupMenu(this);
fontMenu->setCheckable( true );
connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
fontMenu->insertItem(tr( "Small" ), 0);
fontMenu->insertItem(tr( "Normal" ), 1);
fontMenu->insertItem(tr( "Large" ), 2);
defaultFont = new QFont( abList->font() );
slotSetFont(startFontSize);
-
+
mbList->insertItem( tr("Font"), fontMenu);
setCentralWidget(listContainer);
// qDebug("adressbook contrsuction: t=%d", t.elapsed() );
}
void AddressbookWindow::slotSetFont( int size ) {
if (size > 2 || size < 0)
size = 1;
startFontSize = size;
QFont *currentFont;
-
+
switch (size) {
case 0:
fontMenu->setItemChecked(0, true);
fontMenu->setItemChecked(1, false);
fontMenu->setItemChecked(2, false);
abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
break;
case 1:
fontMenu->setItemChecked(0, false);
fontMenu->setItemChecked(1, true);
fontMenu->setItemChecked(2, false);
abList->setFont( *defaultFont );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
break;
case 2:
fontMenu->setItemChecked(0, false);
fontMenu->setItemChecked(1, false);
fontMenu->setItemChecked(2, true);
abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
@@ -450,81 +450,81 @@ void AddressbookWindow::beamDone( Ir *ir )
static void parseName( const QString& name, QString *first, QString *middle,
QString * last )
{
int comma = name.find ( "," );
QString rest;
if ( comma > 0 ) {
*last = name.left( comma );
comma++;
while ( comma < int(name.length()) && name[comma] == ' ' )
comma++;
rest = name.mid( comma );
} else {
int space = name.findRev( ' ' );
*last = name.mid( space+1 );
rest = name.left( space );
}
int space = rest.find( ' ' );
if ( space <= 0 ) {
*first = rest;
} else {
*first = rest.left( space );
*middle = rest.mid( space+1 );
}
-
+
}
void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
{
if (msg == "editPersonal()") {
editPersonal();
} else if (msg == "editPersonalAndClose()") {
editPersonal();
close();
} else if ( msg == "addContact(QString,QString)" ) {
QDataStream stream(data,IO_ReadOnly);
QString name, email;
stream >> name >> email;
Contact cnt;
QString fn, mn, ln;
parseName( name, &fn, &mn, &ln );
// qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
cnt.setFirstName( fn );
cnt.setMiddleName( mn );
cnt.setLastName( ln );
cnt.setEmails( email );
cnt.setDefaultEmail( email );
cnt.setFileAs();
if ( bAbEditFirstTime ) {
abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields,
this, "editor" );
bAbEditFirstTime = FALSE;
} else {
- abEditor->setEntry( cnt );
+ abEditor->setEntry( cnt );
}
abView()->init( cnt );
editEntry( NewEntry );
}
#if 0
else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
QDataStream stream(data,IO_ReadOnly);
QCString ch,m;
QStringList types;
stream >> ch >> m >> types;
AddressPicker picker(abList,this,0,TRUE);
picker.showMaximized();
picker.setChoiceNames(types);
int i=0;
for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
QStringList sel;
stream >> sel;
picker.setSelection(i++,sel);
}
picker.showMaximized();
picker.exec();
@@ -773,49 +773,49 @@ void AddressbookWindow::initFields()
for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
allFields.append( i + 3 );
}
cfg.setGroup( "Version" );
version = cfg.readNumEntry( "version" );
i = 0;
startFontSize = 1;
if ( version >= ADDRESSVERSION ) {
cfg.setGroup( "ImportantCategory" );
zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
while ( !zn.isNull() ) {
if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) {
slOrderedFields.clear();
break;
}
slOrderedFields.append( zn );
zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
}
cfg.setGroup( "Font" );
startFontSize = cfg.readNumEntry( "fontSize", 1 );
-
+
} else {
QString str;
str = getenv("HOME");
str += "/Settings/AddressBook.conf";
QFile::remove( str );
}
if ( slOrderedFields.count() > 0 ) {
for( QStringList::ConstIterator it = slOrderedFields.begin();
it != slOrderedFields.end(); ++it ) {
QValueList<int>::ConstIterator itVl;
QStringList::ConstIterator itVis;
itVl = allFields.begin();
for ( itVis = visibleFields.begin();
itVis != visibleFields.end() && itVl != allFields.end();
++itVis, ++itVl ) {
if ( *it == *itVis && itVl != allFields.end() ) {
orderedFields.append( *itVl );
}
}
}
} else {
QValueList<int>::ConstIterator it;
for ( it = allFields.begin(); it != allFields.end(); ++it )
@@ -838,86 +838,87 @@ void AddressbookWindow::initFields()
slOrderedFields.remove( tr("File As") );
slOrderedFields.remove( tr("Default Email") );
slOrderedFields.remove( tr("Notes") );
slOrderedFields.remove( tr("Gender") );
}
}
AbLabel *AddressbookWindow::abView()
{
if ( !mView ) {
mView = new AbLabel( this, "viewer" );
mView->init( Contact() );
connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
}
return mView;
}
void AddressbookWindow::slotFind()
{
#ifndef MAKE_FOR_SHARP_ROM
if ( centralWidget() == abView() )
showList();
-
+
FindDialog frmFind( "Contacts", this );
QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int)));
QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
-
+
frmFind.exec();
-
+
if ( abList->numSelections() )
abList->clearSelection();
abList->clearFindRow();
#endif
}
void AddressbookWindow::slotSetCategory( int c )
{
if ( c <= 0 )
return;
for ( unsigned int i = 1; i < catMenu->count(); i++ )
catMenu->setItemChecked( i, c == (int)i );
if ( c == 1 ) {
abList->setShowCategory( QString::null );
setCaption( tr("Contacts") + " - " + tr ( "All" ) );
} else if ( c == (int)catMenu->count() ) {
abList->setShowCategory( tr( "Unfiled" ) );
setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
} else {
QString cat = abList->categories()[c - 2];
abList->setShowCategory( cat );
setCaption( tr("Contacts") + " - " + cat );
}
}
void AddressbookWindow::slotSetLetter( char c ) {
abList->setShowByLetter( c );
}
void AddressbookWindow::populateCategories()
{
catMenu->clear();
int id,
rememberId;
id = 1;
+ rememberId = 0;
catMenu->insertItem( tr( "All" ), id++ );
QStringList categories = abList->categories();
categories.append( tr( "Unfiled" ) );
for ( QStringList::Iterator it = categories.begin();
it != categories.end(); ++it ) {
catMenu->insertItem( *it, id );
if ( *it == abList->showCategory() )
rememberId = id;
++id;
}
if ( abList->showCategory().isEmpty() )
slotSetCategory( 1 );
else
slotSetCategory( rememberId );
}