summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 360aa7e..e502cf6 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -54,24 +54,25 @@
54#include <qstringlist.h> 54#include <qstringlist.h>
55#include <qtoolbutton.h> 55#include <qtoolbutton.h>
56#include <qwhatsthis.h> 56#include <qwhatsthis.h>
57 57
58#include <stdlib.h> 58#include <stdlib.h>
59#include <sys/stat.h> 59#include <sys/stat.h>
60#include <sys/types.h> 60#include <sys/types.h>
61#include <fcntl.h> 61#include <fcntl.h>
62#include <unistd.h> 62#include <unistd.h>
63 63
64#include <qdatetime.h> 64#include <qdatetime.h>
65 65
66#include "picker.h"
66static QString addressbookOldXMLFilename() 67static QString addressbookOldXMLFilename()
67{ 68{
68 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 69 QString filename = QPEApplication::documentDir() + "addressbook.xml";
69 return filename; 70 return filename;
70} 71}
71 72
72static QString addressbookXMLFilename() 73static QString addressbookXMLFilename()
73{ 74{
74 QString filename = Global::applicationFileName("addressbook", 75 QString filename = Global::applicationFileName("addressbook",
75 "addressbook.xml"); 76 "addressbook.xml");
76 return filename; 77 return filename;
77} 78}
@@ -89,24 +90,25 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
89 : QMainWindow( parent, name, f ), 90 : QMainWindow( parent, name, f ),
90 abEditor(0), 91 abEditor(0),
91 bAbEditFirstTime(TRUE), 92 bAbEditFirstTime(TRUE),
92 syncing(FALSE) 93 syncing(FALSE)
93{ 94{
94 initFields(); 95 initFields();
95 96
96 setCaption( tr("Contacts") ); 97 setCaption( tr("Contacts") );
97 setIcon( Resource::loadPixmap( "AddressBook" ) ); 98 setIcon( Resource::loadPixmap( "AddressBook" ) );
98 99
99 setToolBarsMovable( FALSE ); 100 setToolBarsMovable( FALSE );
100 101
102 QBoxLayout *vb = new QVBoxLayout( this, 0, 0 );
101 // Create Toolbars 103 // Create Toolbars
102 104
103 QPEToolBar *bar = new QPEToolBar( this ); 105 QPEToolBar *bar = new QPEToolBar( this );
104 bar->setHorizontalStretchable( TRUE ); 106 bar->setHorizontalStretchable( TRUE );
105 107
106 QPEMenuBar *mbList = new QPEMenuBar( bar ); 108 QPEMenuBar *mbList = new QPEMenuBar( bar );
107 mbList->setMargin( 0 ); 109 mbList->setMargin( 0 );
108 110
109 QPopupMenu *edit = new QPopupMenu( this ); 111 QPopupMenu *edit = new QPopupMenu( this );
110 mbList->insertItem( tr( "Contact" ), edit ); 112 mbList->insertItem( tr( "Contact" ), edit );
111 113
112 listTools = new QPEToolBar( this, "list operations" ); 114 listTools = new QPEToolBar( this, "list operations" );
@@ -180,40 +182,44 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
180 // not to mention it also does the necessary stuff for the 182 // not to mention it also does the necessary stuff for the
181 // journaling... 183 // journaling...
182 QString str = addressbookXMLFilename(); 184 QString str = addressbookXMLFilename();
183 if ( str.isNull() ) { 185 if ( str.isNull() ) {
184 QMessageBox::warning( this, tr("Out of Space"), 186 QMessageBox::warning( this, tr("Out of Space"),
185 tr("There is not enough space to create\n" 187 tr("There is not enough space to create\n"
186 "neccessary startup files.\n" 188 "neccessary startup files.\n"
187 "\nFree up some space before\nentering data!") 189 "\nFree up some space before\nentering data!")
188 ); 190 );
189 } 191 }
190 192
191 abList = new AbTable( &orderedFields, this, "table" ); 193 abList = new AbTable( &orderedFields, this, "table" );
194 vb->insertWidget(0,abList);
192 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 195 abList->setHScrollBarMode( QScrollView::AlwaysOff );
193 connect( abList, SIGNAL( empty( bool ) ), 196 connect( abList, SIGNAL( empty( bool ) ),
194 this, SLOT( listIsEmpty( bool ) ) ); 197 this, SLOT( listIsEmpty( bool ) ) );
195 connect( abList, SIGNAL( details() ), 198 connect( abList, SIGNAL( details() ),
196 this, SLOT( slotListView() ) ); 199 this, SLOT( slotListView() ) );
197 connect( abList, SIGNAL(currentChanged(int,int)), 200 connect( abList, SIGNAL(currentChanged(int,int)),
198 this, SLOT(slotUpdateToolbar()) ); 201 this, SLOT(slotUpdateToolbar()) );
199 202
200 mView = 0; 203 mView = 0;
201 204
202 abList->load( addressbookXMLFilename() ); 205 abList->load( addressbookXMLFilename() );
203 if ( QFile::exists(addressbookOldXMLFilename()) ) { 206 if ( QFile::exists(addressbookOldXMLFilename()) ) {
204 abList->load( addressbookOldXMLFilename() ); 207 abList->load( addressbookOldXMLFilename() );
205 QFile::remove(addressbookOldXMLFilename()); 208 QFile::remove(addressbookOldXMLFilename());
206 } 209 }
207 210
211 pLabel = new LetterPicker( abList );
212 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
213 vb->insertWidget(1,pLabel);
208 catMenu = new QPopupMenu( this ); 214 catMenu = new QPopupMenu( this );
209 catMenu->setCheckable( TRUE ); 215 catMenu->setCheckable( TRUE );
210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 216 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
211 populateCategories(); 217 populateCategories();
212 218
213 mbList->insertItem( tr("View"), catMenu ); 219 mbList->insertItem( tr("View"), catMenu );
214 setCentralWidget( abList ); 220 setCentralWidget( abList );
215 221
216 fontMenu = new QPopupMenu(this); 222 fontMenu = new QPopupMenu(this);
217 fontMenu->setCheckable( true ); 223 fontMenu->setCheckable( true );
218 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 224 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
219 225
@@ -875,24 +881,30 @@ void AddressbookWindow::slotSetCategory( int c )
875 abList->setShowCategory( QString::null ); 881 abList->setShowCategory( QString::null );
876 setCaption( tr("Contacts") + " - " + tr ( "All" ) ); 882 setCaption( tr("Contacts") + " - " + tr ( "All" ) );
877 } else if ( c == (int)catMenu->count() ) { 883 } else if ( c == (int)catMenu->count() ) {
878 abList->setShowCategory( tr( "Unfiled" ) ); 884 abList->setShowCategory( tr( "Unfiled" ) );
879 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); 885 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
880 } else { 886 } else {
881 QString cat = abList->categories()[c - 2]; 887 QString cat = abList->categories()[c - 2];
882 abList->setShowCategory( cat ); 888 abList->setShowCategory( cat );
883 setCaption( tr("Contacts") + " - " + cat ); 889 setCaption( tr("Contacts") + " - " + cat );
884 } 890 }
885} 891}
886 892
893void AddressbookWindow::slotSetLetter( char c ) {
894
895 abList->setShowByLetter( c );
896
897}
898
887void AddressbookWindow::populateCategories() 899void AddressbookWindow::populateCategories()
888{ 900{
889 catMenu->clear(); 901 catMenu->clear();
890 902
891 int id, 903 int id,
892 rememberId; 904 rememberId;
893 id = 1; 905 id = 1;
894 catMenu->insertItem( tr( "All" ), id++ ); 906 catMenu->insertItem( tr( "All" ), id++ );
895 QStringList categories = abList->categories(); 907 QStringList categories = abList->categories();
896 categories.append( tr( "Unfiled" ) ); 908 categories.append( tr( "Unfiled" ) );
897 for ( QStringList::Iterator it = categories.begin(); 909 for ( QStringList::Iterator it = categories.begin();
898 it != categories.end(); ++it ) { 910 it != categories.end(); ++it ) {