00001 #ifndef _ABVIEW_H_
00002 #define _ABVIEW_H_
00003
00004 #include <opie2/opimcontact.h>
00005 #include <opie2/ocontactaccess.h>
00006
00007 #include <qpe/categories.h>
00008
00009 #include <qwidget.h>
00010 #include <qwidgetstack.h>
00011
00012 #include "contacteditor.h"
00013 #include "abtable.h"
00014 #include "ablabel.h"
00015 #include "abconfig.h"
00016
00017 class AbView: public QWidget
00018 {
00019 Q_OBJECT
00020
00021 public:
00022 enum Views{ TableView=0, CardView, PersonalView };
00023
00024 AbView( QWidget* parent, const QValueList<int>& ordered );
00025 ~AbView();
00026
00027 bool save();
00028 void load();
00029 void reload();
00030 void clear();
00031
00032 void setView( Views view );
00033 void showPersonal( bool personal );
00034 void setCurrentUid( int uid );
00035 void setShowByCategory( const QString& cat );
00036 void setShowToView( Views view );
00037 void setShowByLetter( char c, AbConfig::LPSearchMode mode = AbConfig::LastName );
00038 void setListOrder( const QValueList<int>& ordered );
00039
00040
00041 void addEntry( const Opie::OPimContact &newContact );
00042 void removeEntry( const int UID );
00043 void replaceEntry( const Opie::OPimContact &contact );
00044 Opie::OPimContact currentEntry();
00045
00046 void inSearch() { m_inSearch = true; }
00047 void offSearch();
00048
00049 QString showCategory() const;
00050 QStringList categories();
00051
00052 signals:
00053 void signalNotFound();
00054 void signalClearLetterPicker();
00055 void signalViewSwitched ( int );
00056
00057 public slots:
00058 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
00059 bool backwards, QString category = QString::null );
00060 void slotSwitch();
00061 void slotSetSortOrder( bool order );
00062
00063 private:
00064 void updateListinViews();
00065 void updateView( bool newdata = false );
00066 void clearForCategory();
00067 bool contactCompare( const Opie::OPimContact &cnt, int category );
00068 void parseName( const QString& name, QString *first, QString *middle,
00069 QString * last );
00070
00071 Categories mCat;
00072 bool m_inSearch;
00073 bool m_inPersonal;
00074 bool m_sortOrder;
00075 int m_curr_category;
00076 Views m_curr_View;
00077 Views m_prev_View;
00078 int m_curr_Contact;
00079
00080 Opie::OPimContactAccess* m_contactdb;
00081 Opie::OPimContactAccess* m_storedDB;
00082 Opie::OPimContactAccess::List m_list;
00083
00084 QWidgetStack* m_viewStack;
00085 AbTable* m_abTable;
00086 AbLabel* m_ablabel;
00087
00088 QValueList<int> m_orderedFields;
00089 };
00090
00091
00092 #endif