Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 2eb9ddf..93581e8 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -58,36 +58,24 @@ | |||
58 | #include <qtoolbutton.h> | 58 | #include <qtoolbutton.h> |
59 | #include <qwhatsthis.h> | 59 | #include <qwhatsthis.h> |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | 66 | ||
67 | #include <qdatetime.h> | 67 | #include <qdatetime.h> |
68 | 68 | ||
69 | #include "picker.h" | 69 | #include "picker.h" |
70 | static QString addressbookOldXMLFilename() | ||
71 | { | ||
72 | QString filename = QPEApplication::documentDir() + "addressbook.xml"; | ||
73 | return filename; | ||
74 | } | ||
75 | |||
76 | static QString addressbookXMLFilename() | ||
77 | { | ||
78 | QString filename = Global::applicationFileName("addressbook", | ||
79 | "addressbook.xml"); | ||
80 | return filename; | ||
81 | } | ||
82 | 70 | ||
83 | static QString addressbookPersonalVCardName() | 71 | static QString addressbookPersonalVCardName() |
84 | { | 72 | { |
85 | QString filename = Global::applicationFileName("addressbook", | 73 | QString filename = Global::applicationFileName("addressbook", |
86 | "businesscard.vcf"); | 74 | "businesscard.vcf"); |
87 | return filename; | 75 | return filename; |
88 | } | 76 | } |
89 | 77 | ||
90 | 78 | ||
91 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 79 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
92 | WFlags f ) | 80 | WFlags f ) |
93 | : QMainWindow( parent, name, f ), | 81 | : QMainWindow( parent, name, f ), |
@@ -193,57 +181,38 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
193 | 181 | ||
194 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 182 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
195 | actionPersonal = a; | 183 | actionPersonal = a; |
196 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 184 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
197 | a->addTo( edit ); | 185 | a->addTo( edit ); |
198 | 186 | ||
199 | 187 | ||
200 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 188 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
201 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 189 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
202 | a->addTo( edit ); | 190 | a->addTo( edit ); |
203 | 191 | ||
204 | // Create Views | 192 | // Create Views |
205 | |||
206 | // This is safe to call without checking to see if it exists... | ||
207 | // not to mention it also does the necessary stuff for the | ||
208 | // journaling... | ||
209 | QString str = addressbookXMLFilename(); | ||
210 | if ( str.isNull() ) { | ||
211 | QMessageBox::warning( | ||
212 | this, | ||
213 | tr("Out of Space"), | ||
214 | tr("There is not enough space to create\n" | ||
215 | "neccessary startup files.\n" | ||
216 | "\nFree up some space before\nentering data!") | ||
217 | ); | ||
218 | } | ||
219 | |||
220 | listContainer = new QWidget( this ); | 193 | listContainer = new QWidget( this ); |
221 | 194 | ||
222 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 195 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
223 | 196 | ||
224 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 197 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
225 | vb->addWidget(abList); | 198 | vb->addWidget(abList); |
226 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 199 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
227 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); | 200 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
228 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); | 201 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
229 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); | 202 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
230 | 203 | ||
231 | mView = 0; | 204 | mView = 0; |
232 | 205 | ||
233 | abList->load( addressbookXMLFilename() ); | 206 | abList->load(); |
234 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | ||
235 | abList->load( addressbookOldXMLFilename() ); | ||
236 | QFile::remove(addressbookOldXMLFilename()); | ||
237 | } | ||
238 | 207 | ||
239 | pLabel = new LetterPicker( listContainer ); | 208 | pLabel = new LetterPicker( listContainer ); |
240 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 209 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
241 | vb->addWidget(pLabel); | 210 | vb->addWidget(pLabel); |
242 | catMenu = new QPopupMenu( this ); | 211 | catMenu = new QPopupMenu( this ); |
243 | catMenu->setCheckable( TRUE ); | 212 | catMenu->setCheckable( TRUE ); |
244 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 213 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
245 | populateCategories(); | 214 | populateCategories(); |
246 | 215 | ||
247 | mbList->insertItem( tr("View"), catMenu ); | 216 | mbList->insertItem( tr("View"), catMenu ); |
248 | // setCentralWidget( listContainer ); | 217 | // setCentralWidget( listContainer ); |
249 | 218 | ||
@@ -700,31 +669,31 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
700 | 669 | ||
701 | void AddressbookWindow::listIsEmpty( bool empty ) | 670 | void AddressbookWindow::listIsEmpty( bool empty ) |
702 | { | 671 | { |
703 | if ( !empty ) { | 672 | if ( !empty ) { |
704 | deleteButton->setEnabled( TRUE ); | 673 | deleteButton->setEnabled( TRUE ); |
705 | } | 674 | } |
706 | } | 675 | } |
707 | 676 | ||
708 | void AddressbookWindow::reload() | 677 | void AddressbookWindow::reload() |
709 | { | 678 | { |
710 | syncing = FALSE; | 679 | syncing = FALSE; |
711 | abList->clear(); | 680 | abList->clear(); |
712 | abList->load( addressbookXMLFilename() ); | 681 | abList->reload(); |
713 | } | 682 | } |
714 | 683 | ||
715 | void AddressbookWindow::flush() | 684 | void AddressbookWindow::flush() |
716 | { | 685 | { |
717 | syncing = TRUE; | 686 | syncing = TRUE; |
718 | abList->save( addressbookXMLFilename() ); | 687 | abList->save(); |
719 | } | 688 | } |
720 | 689 | ||
721 | 690 | ||
722 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 691 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
723 | { | 692 | { |
724 | if ( centralWidget() == mView ) { | 693 | if ( centralWidget() == mView ) { |
725 | if (actionPersonal->isOn()) { | 694 | if (actionPersonal->isOn()) { |
726 | // pretend we clicked it off | 695 | // pretend we clicked it off |
727 | actionPersonal->setOn(FALSE); | 696 | actionPersonal->setOn(FALSE); |
728 | slotPersonalView(); | 697 | slotPersonalView(); |
729 | } else { | 698 | } else { |
730 | showList(); | 699 | showList(); |
@@ -746,51 +715,36 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
746 | if ( save() ) | 715 | if ( save() ) |
747 | e->accept(); | 716 | e->accept(); |
748 | else | 717 | else |
749 | e->ignore(); | 718 | e->ignore(); |
750 | } | 719 | } |
751 | 720 | ||
752 | /* | 721 | /* |
753 | Returns TRUE if it is OK to exit | 722 | Returns TRUE if it is OK to exit |
754 | */ | 723 | */ |
755 | 724 | ||
756 | bool AddressbookWindow::save() | 725 | bool AddressbookWindow::save() |
757 | { | 726 | { |
758 | QString str = addressbookXMLFilename(); | 727 | if ( !abList->save() ) { |
759 | if ( str.isNull() ) { | 728 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
760 | if ( QMessageBox::critical( 0, tr("Out of space"), | ||
761 | tr("Unable to save information.\n" | 729 | tr("Unable to save information.\n" |
762 | "Free up some space\n" | 730 | "Free up some space\n" |
763 | "and try again.\n" | 731 | "and try again.\n" |
764 | "\nQuit anyway?"), | 732 | "\nQuit anyway?"), |
765 | QMessageBox::Yes|QMessageBox::Escape, | 733 | QMessageBox::Yes|QMessageBox::Escape, |
766 | QMessageBox::No|QMessageBox::Default ) | 734 | QMessageBox::No|QMessageBox::Default ) |
767 | != QMessageBox::No ) | 735 | != QMessageBox::No ) |
768 | return TRUE; | 736 | return TRUE; |
769 | else | 737 | else |
770 | return FALSE; | 738 | return FALSE; |
771 | } else { | ||
772 | if ( !abList->save( str ) ) { | ||
773 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | ||
774 | tr("Unable to save information.\n" | ||
775 | "Free up some space\n" | ||
776 | "and try again.\n" | ||
777 | "\nQuit anyway?"), | ||
778 | QMessageBox::Yes|QMessageBox::Escape, | ||
779 | QMessageBox::No|QMessageBox::Default ) | ||
780 | != QMessageBox::No ) | ||
781 | return TRUE; | ||
782 | else | ||
783 | return FALSE; | ||
784 | } | ||
785 | } | 739 | } |
786 | return TRUE; | 740 | return TRUE; |
787 | } | 741 | } |
788 | 742 | ||
789 | void AddressbookWindow::slotSettings() | 743 | void AddressbookWindow::slotSettings() |
790 | { | 744 | { |
791 | AddressSettings frmSettings( this ); | 745 | AddressSettings frmSettings( this ); |
792 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 746 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
793 | frmSettings.showMaximized(); | 747 | frmSettings.showMaximized(); |
794 | #endif | 748 | #endif |
795 | 749 | ||
796 | if ( frmSettings.exec() ) { | 750 | if ( frmSettings.exec() ) { |