summaryrefslogtreecommitdiff
authoreilers <eilers>2002-12-16 14:24:22 (UTC)
committer eilers <eilers>2002-12-16 14:24:22 (UTC)
commite555812af7b4183a9b6d276d0b9ac7f01b62eb2f (patch) (unidiff)
tree471979f5d8c35c9eddc89479f223da14140c0f14
parentd1d849bab2d54b1e9144bca1f30786882be9a464 (diff)
downloadopie-e555812af7b4183a9b6d276d0b9ac7f01b62eb2f.zip
opie-e555812af7b4183a9b6d276d0b9ac7f01b62eb2f.tar.gz
opie-e555812af7b4183a9b6d276d0b9ac7f01b62eb2f.tar.bz2
Improvement of previous bugfix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp13
-rw-r--r--core/pim/addressbook/addressbook.h4
2 files changed, 12 insertions, 5 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index c2cce92..12dc24e 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -620,221 +620,232 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
620 } else if ( msg == "addContact(QString,QString)" ) { 620 } else if ( msg == "addContact(QString,QString)" ) {
621 QDataStream stream(data,IO_ReadOnly); 621 QDataStream stream(data,IO_ReadOnly);
622 QString name, email; 622 QString name, email;
623 stream >> name >> email; 623 stream >> name >> email;
624 624
625 OContact cnt; 625 OContact cnt;
626 QString fn, mn, ln; 626 QString fn, mn, ln;
627 parseName( name, &fn, &mn, &ln ); 627 parseName( name, &fn, &mn, &ln );
628 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 628 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
629 cnt.setFirstName( fn ); 629 cnt.setFirstName( fn );
630 cnt.setMiddleName( mn ); 630 cnt.setMiddleName( mn );
631 cnt.setLastName( ln ); 631 cnt.setLastName( ln );
632 cnt.insertEmails( email ); 632 cnt.insertEmails( email );
633 cnt.setDefaultEmail( email ); 633 cnt.setDefaultEmail( email );
634 cnt.setFileAs(); 634 cnt.setFileAs();
635 635
636 m_abView -> addEntry( cnt ); 636 m_abView -> addEntry( cnt );
637 637
638 // :SXm_abView()->init( cnt ); 638 // :SXm_abView()->init( cnt );
639 editEntry( EditEntry ); 639 editEntry( EditEntry );
640 640
641 641
642 642
643 } 643 }
644#if 0 644#if 0
645 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 645 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
646 QDataStream stream(data,IO_ReadOnly); 646 QDataStream stream(data,IO_ReadOnly);
647 QCString ch,m; 647 QCString ch,m;
648 QStringList types; 648 QStringList types;
649 stream >> ch >> m >> types; 649 stream >> ch >> m >> types;
650 AddressPicker picker(abList,this,0,TRUE); 650 AddressPicker picker(abList,this,0,TRUE);
651 picker.showMaximized(); 651 picker.showMaximized();
652 picker.setChoiceNames(types); 652 picker.setChoiceNames(types);
653 int i=0; 653 int i=0;
654 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 654 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
655 QStringList sel; 655 QStringList sel;
656 stream >> sel; 656 stream >> sel;
657 picker.setSelection(i++,sel); 657 picker.setSelection(i++,sel);
658 } 658 }
659 picker.showMaximized(); 659 picker.showMaximized();
660 picker.exec(); 660 picker.exec();
661 661
662 // ###### note: contacts may have been added - save here! 662 // ###### note: contacts may have been added - save here!
663 663
664 setCentralWidget(abList); 664 setCentralWidget(abList);
665 QCopEnvelope e(ch,m); 665 QCopEnvelope e(ch,m);
666 i=0; 666 i=0;
667 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 667 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
668 QStringList sel = picker.selection(i++); 668 QStringList sel = picker.selection(i++);
669 e << sel; 669 e << sel;
670 } 670 }
671 } 671 }
672#endif 672#endif
673 673
674} 674}
675 675
676void AddressbookWindow::editEntry( EntryMode entryMode ) 676void AddressbookWindow::editEntry( EntryMode entryMode )
677{ 677{
678 OContact entry; 678 OContact entry;
679 if ( !abEditor ) { 679 if ( !abEditor ) {
680 abEditor = new ContactEditor( entry, this, "editor" ); 680 abEditor = new ContactEditor( entry, this, "editor" );
681 } 681 }
682 if ( entryMode == EditEntry ) 682 if ( entryMode == EditEntry )
683 abEditor->setEntry( m_abView -> currentEntry() ); 683 abEditor->setEntry( m_abView -> currentEntry() );
684 else if ( entryMode == NewEntry ) 684 else if ( entryMode == NewEntry )
685 abEditor->setEntry( entry ); 685 abEditor->setEntry( entry );
686 // other things may change the caption. 686 // other things may change the caption.
687 abEditor->setCaption( tr("Edit Address") ); 687 abEditor->setCaption( tr("Edit Address") );
688 688
689#if defined(Q_WS_QWS) || defined(_WS_QWS_) 689#if defined(Q_WS_QWS) || defined(_WS_QWS_)
690 abEditor->showMaximized(); 690 abEditor->showMaximized();
691#endif 691#endif
692 // fix the foxus... 692 // fix the foxus...
693 abEditor->setNameFocus(); 693 abEditor->setNameFocus();
694 if ( abEditor->exec() ) { 694 if ( abEditor->exec() ) {
695 setFocus(); 695 setFocus();
696 if ( entryMode == NewEntry ) { 696 if ( entryMode == NewEntry ) {
697 OContact insertEntry = abEditor->entry(); 697 OContact insertEntry = abEditor->entry();
698 insertEntry.assignUid(); 698 insertEntry.assignUid();
699 m_abView -> addEntry( insertEntry ); 699 m_abView -> addEntry( insertEntry );
700 } else { 700 } else {
701 OContact replEntry = abEditor->entry(); 701 OContact replEntry = abEditor->entry();
702 702
703 if ( !replEntry.isValidUid() ) 703 if ( !replEntry.isValidUid() )
704 replEntry.assignUid(); 704 replEntry.assignUid();
705 705
706 m_abView -> replaceEntry( replEntry ); 706 m_abView -> replaceEntry( replEntry );
707 } 707 }
708 } 708 }
709 // populateCategories(); 709 // populateCategories();
710 710
711} 711}
712 712
713void AddressbookWindow::editPersonal() 713void AddressbookWindow::editPersonal()
714{ 714{
715 OContact entry; 715 OContact entry;
716
717 // Switch to personal view if not selected
718 // but take care of the menu, too
719 if ( ! actionPersonal->isOn() ){
720 qWarning("*** ++++");
721 actionPersonal->setOn( true );
722 slotPersonalView();
723 }
724
716 if ( !abEditor ) { 725 if ( !abEditor ) {
717 abEditor = new ContactEditor( entry, this, "editor" ); 726 abEditor = new ContactEditor( entry, this, "editor" );
718 } 727 }
719 728
720 m_abView->showPersonal( true );
721 abEditor->setCaption(tr("Edit My Personal Details")); 729 abEditor->setCaption(tr("Edit My Personal Details"));
722 abEditor->setPersonalView( true ); 730 abEditor->setPersonalView( true );
723 editEntry( EditEntry ); 731 editEntry( EditEntry );
724 abEditor->setPersonalView( false ); 732 abEditor->setPersonalView( false );
725 733
726} 734}
727 735
728 736
729void AddressbookWindow::slotPersonalView() 737void AddressbookWindow::slotPersonalView()
730{ 738{
739 qWarning("slotPersonalView()");
731 if (!actionPersonal->isOn()) { 740 if (!actionPersonal->isOn()) {
732 // we just turned it off 741 // we just turned it off
742 qWarning("slotPersonalView()-> OFF");
733 setCaption( tr("Contacts") ); 743 setCaption( tr("Contacts") );
734 actionNew->setEnabled(TRUE); 744 actionNew->setEnabled(TRUE);
735 actionTrash->setEnabled(TRUE); 745 actionTrash->setEnabled(TRUE);
736 actionFind->setEnabled(TRUE); 746 actionFind->setEnabled(TRUE);
737 actionMail->setEnabled(TRUE); 747 actionMail->setEnabled(TRUE);
738 // slotUpdateToolbar(); 748 // slotUpdateToolbar();
739 749
740 m_abView->showPersonal( false ); 750 m_abView->showPersonal( false );
741 751
742 return; 752 return;
743 } 753 }
744 754
755 qWarning("slotPersonalView()-> ON");
745 // XXX need to disable some QActions. 756 // XXX need to disable some QActions.
746 actionNew->setEnabled(FALSE); 757 actionNew->setEnabled(FALSE);
747 actionTrash->setEnabled(FALSE); 758 actionTrash->setEnabled(FALSE);
748 actionFind->setEnabled(FALSE); 759 actionFind->setEnabled(FALSE);
749 actionMail->setEnabled(FALSE); 760 actionMail->setEnabled(FALSE);
750 761
751 setCaption( tr("Contacts - My Personal Details") ); 762 setCaption( tr("Contacts - My Personal Details") );
752 763
753 m_abView->showPersonal( true ); 764 m_abView->showPersonal( true );
754 765
755} 766}
756 767
757 768
758void AddressbookWindow::listIsEmpty( bool empty ) 769void AddressbookWindow::listIsEmpty( bool empty )
759{ 770{
760 if ( !empty ) { 771 if ( !empty ) {
761 deleteButton->setEnabled( TRUE ); 772 deleteButton->setEnabled( TRUE );
762 } 773 }
763} 774}
764 775
765void AddressbookWindow::reload() 776void AddressbookWindow::reload()
766{ 777{
767 syncing = FALSE; 778 syncing = FALSE;
768 m_abView->clear(); 779 m_abView->clear();
769 m_abView->reload(); 780 m_abView->reload();
770} 781}
771 782
772void AddressbookWindow::flush() 783void AddressbookWindow::flush()
773{ 784{
774 syncing = TRUE; 785 syncing = TRUE;
775 m_abView->save(); 786 m_abView->save();
776} 787}
777 788
778 789
779void AddressbookWindow::closeEvent( QCloseEvent *e ) 790void AddressbookWindow::closeEvent( QCloseEvent *e )
780{ 791{
781 if(active_view == AbView::CardView){ 792 if(active_view == AbView::CardView){
782 slotViewSwitched( AbView::TableView ); 793 slotViewSwitched( AbView::TableView );
783 e->ignore(); 794 e->ignore();
784 return; 795 return;
785 } 796 }
786 if(syncing) { 797 if(syncing) {
787 /* shouldn't we save, I hear you say? well its already been set 798 /* shouldn't we save, I hear you say? well its already been set
788 so that an edit can not occur during a sync, and we flushed 799 so that an edit can not occur during a sync, and we flushed
789 at the start of the sync, so there is no need to save 800 at the start of the sync, so there is no need to save
790 Saving however itself would cause problems. */ 801 Saving however itself would cause problems. */
791 e->accept(); 802 e->accept();
792 return; 803 return;
793 } 804 }
794 //################## shouldn't always save 805 //################## shouldn't always save
795 // True, but the database handles this automatically ! (se) 806 // True, but the database handles this automatically ! (se)
796 if ( save() ) 807 if ( save() )
797 e->accept(); 808 e->accept();
798 else 809 else
799 e->ignore(); 810 e->ignore();
800} 811}
801 812
802/* 813/*
803 Returns TRUE if it is OK to exit 814 Returns TRUE if it is OK to exit
804*/ 815*/
805 816
806bool AddressbookWindow::save() 817bool AddressbookWindow::save()
807{ 818{
808 if ( !m_abView->save() ) { 819 if ( !m_abView->save() ) {
809 if ( QMessageBox::critical( 0, tr( "Out of space" ), 820 if ( QMessageBox::critical( 0, tr( "Out of space" ),
810 tr("Unable to save information.\n" 821 tr("Unable to save information.\n"
811 "Free up some space\n" 822 "Free up some space\n"
812 "and try again.\n" 823 "and try again.\n"
813 "\nQuit anyway?"), 824 "\nQuit anyway?"),
814 QMessageBox::Yes|QMessageBox::Escape, 825 QMessageBox::Yes|QMessageBox::Escape,
815 QMessageBox::No|QMessageBox::Default ) 826 QMessageBox::No|QMessageBox::Default )
816 != QMessageBox::No ) 827 != QMessageBox::No )
817 return TRUE; 828 return TRUE;
818 else 829 else
819 return FALSE; 830 return FALSE;
820 } 831 }
821 return TRUE; 832 return TRUE;
822} 833}
823 834
824#ifdef __DEBUG_RELEASE 835#ifdef __DEBUG_RELEASE
825void AddressbookWindow::slotSave() 836void AddressbookWindow::slotSave()
826{ 837{
827 save(); 838 save();
828} 839}
829#endif 840#endif
830 841
831 842
832void AddressbookWindow::slotNotFound() 843void AddressbookWindow::slotNotFound()
833{ 844{
834 qWarning("Got notfound signal!"); 845 qWarning("Got notfound signal!");
835 QMessageBox::information( this, tr( "Not Found" ), 846 QMessageBox::information( this, tr( "Not Found" ),
836 tr( "Unable to find a contact for this \n search pattern!" ) ); 847 tr( "Unable to find a contact for this \n search pattern!" ) );
837 848
838 849
839} 850}
840void AddressbookWindow::slotWrapAround() 851void AddressbookWindow::slotWrapAround()
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 2bedc0b..69fe2f8 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -6,134 +6,130 @@
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef Addressbook_H 20#ifndef Addressbook_H
21#define Addressbook_H 21#define Addressbook_H
22 22
23// Remove this for OPIE releae 1.0 ! 23// Remove this for OPIE releae 1.0 !
24#define __DEBUG_RELEASE 24#define __DEBUG_RELEASE
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qvaluelist.h> 27#include <qvaluelist.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include "ofloatbar.h" 30#include "ofloatbar.h"
31#include "abview.h" 31#include "abview.h"
32#include "abconfig.h" 32#include "abconfig.h"
33 33
34class ContactEditor; 34class ContactEditor;
35class AbLabel; 35class AbLabel;
36class AbTable; 36class AbTable;
37class QPEToolBar; 37class QPEToolBar;
38class QPopupMenu; 38class QPopupMenu;
39class QToolButton; 39class QToolButton;
40class QDialog; 40class QDialog;
41class Ir; 41class Ir;
42class QAction; 42class QAction;
43class LetterPicker; 43class LetterPicker;
44 44
45class AddressbookWindow: public QMainWindow 45class AddressbookWindow: public QMainWindow
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48public: 48public:
49 enum EntryMode { NewEntry=0, EditEntry }; 49 enum EntryMode { NewEntry=0, EditEntry };
50 50
51 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 51 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
52 ~AddressbookWindow(); 52 ~AddressbookWindow();
53 53
54protected: 54protected:
55 void resizeEvent( QResizeEvent * e ); 55 void resizeEvent( QResizeEvent * e );
56 56
57 void editPersonal(); 57 void editPersonal();
58 void editEntry( EntryMode ); 58 void editEntry( EntryMode );
59 void closeEvent( QCloseEvent *e ); 59 void closeEvent( QCloseEvent *e );
60 bool save(); 60 bool save();
61 61
62public slots: 62public slots:
63 void flush(); 63 void flush();
64 void reload(); 64 void reload();
65 void appMessage(const QCString &, const QByteArray &); 65 void appMessage(const QCString &, const QByteArray &);
66 void setDocument( const QString & ); 66 void setDocument( const QString & );
67#ifdef __DEBUG_RELEASE 67#ifdef __DEBUG_RELEASE
68 void slotSave(); 68 void slotSave();
69#endif 69#endif
70 70
71private slots: 71private slots:
72 void importvCard(); 72 void importvCard();
73 void slotListNew(); 73 void slotListNew();
74 /* void slotListView(); */ 74 /* void slotListView(); */
75 void slotListDelete(); 75 void slotListDelete();
76 void slotViewBack(); 76 void slotViewBack();
77 void slotViewEdit(); 77 void slotViewEdit();
78 void slotPersonalView(); 78 void slotPersonalView();
79 void listIsEmpty( bool ); 79 void listIsEmpty( bool );
80 /* void slotSettings(); */ 80 /* void slotSettings(); */
81 void writeMail(); 81 void writeMail();
82 void slotBeam(); 82 void slotBeam();
83 void beamDone( Ir * ); 83 void beamDone( Ir * );
84 void slotSetCategory( int ); 84 void slotSetCategory( int );
85 void slotSetLetter( char ); 85 void slotSetLetter( char );
86 void slotUpdateToolbar(); 86 void slotUpdateToolbar();
87 void slotSetFont(int); 87 void slotSetFont(int);
88 88
89 void slotFindOpen(); 89 void slotFindOpen();
90 void slotFindClose(); 90 void slotFindClose();
91 void slotFind(); 91 void slotFind();
92 void slotNotFound(); 92 void slotNotFound();
93 void slotWrapAround(); 93 void slotWrapAround();
94 94
95 void slotViewSwitched( int ); 95 void slotViewSwitched( int );
96 void slotListView(); 96 void slotListView();
97 void slotCardView(); 97 void slotCardView();
98 98
99 void slotConfig(); 99 void slotConfig();
100 100
101private: 101private:
102 //void initFields(); // inititialize our fields...
103 // AbLabel *abView();
104 void populateCategories(); 102 void populateCategories();
105 103
106 QPopupMenu *catMenu; 104 QPopupMenu *catMenu;
107 QPEToolBar *listTools; 105 QPEToolBar *listTools;
108 QToolButton *deleteButton; 106 QToolButton *deleteButton;
109 //QValueList<int> allFields, orderedFields;
110 //QStringList slOrderedFields;
111 enum Panes { paneList=0, paneView, paneEdit }; 107 enum Panes { paneList=0, paneView, paneEdit };
112 ContactEditor *abEditor; 108 ContactEditor *abEditor;
113 LetterPicker *pLabel; 109 LetterPicker *pLabel;
114 AbView* m_abView; 110 AbView* m_abView;
115 QWidget *listContainer; 111 QWidget *listContainer;
116 112
117 // Searching stuff 113 // Searching stuff
118 OFloatBar* searchBar; 114 OFloatBar* searchBar;
119 QLineEdit* searchEdit; 115 QLineEdit* searchEdit;
120 116
121 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; 117 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail;
122 118
123 int viewMargin; 119 int viewMargin;
124 120
125 bool syncing; 121 bool syncing;
126 QFont *defaultFont; 122 QFont *defaultFont;
127 int m_curFontSize; 123 int m_curFontSize;
128 124
129 bool isLoading; 125 bool isLoading;
130 126
131 AbConfig m_config; 127 AbConfig m_config;
132 128
133 QAction* m_tableViewButton; 129 QAction* m_tableViewButton;
134 QAction* m_cardViewButton; 130 QAction* m_cardViewButton;
135 131
136 int active_view; 132 int active_view;
137}; 133};
138 134
139#endif 135#endif