summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abview.h
blob: 07b6b28f03569d938338b3b068ec37511ad4b2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _ABVIEW_H_
#define _ABVIEW_H_

#include <opie2/opimcontact.h>
#include <opie2/ocontactaccess.h>

#include <qpe/categories.h>

#include <qwidget.h>
#include <qwidgetstack.h>

#include "contacteditor.h"
#include "abtable.h"
#include "ablabel.h"
#include "abconfig.h"

class AbView: public QWidget
{
    Q_OBJECT

public:
    enum Views{ TableView=0, CardView, PersonalView };

    AbView( QWidget* parent, const QValueList<int>& ordered );
    ~AbView();

    bool save();
    void load();
    void reload();
    void clear();

    void setView( Views view );
    void showPersonal( bool personal );
    void setCurrentUid( int uid );
    void setShowByCategory( const QString& cat );
    void setShowToView( Views view );
    void setShowByLetter( char c, AbConfig::LPSearchMode mode = AbConfig::LastName );
    void setListOrder( const QValueList<int>& ordered );

    // Add Entry and put to current
    void addEntry( const Opie::OPimContact &newContact );
    void removeEntry( const int UID );
    void replaceEntry( const Opie::OPimContact &contact );
    Opie::OPimContact currentEntry();

    void inSearch()  { m_inSearch = true; }
    void offSearch();

    QString showCategory() const;
    QStringList categories();

signals:
	void signalNotFound();
	void signalClearLetterPicker();
	void signalViewSwitched ( int );

public slots:
    void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
		     bool backwards, QString category = QString::null );
    void slotSwitch();
    void slotSetSortOrder( bool order );

private:
    void updateListinViews();
    void updateView( bool newdata = false );
    void clearForCategory();
    bool contactCompare( const Opie::OPimContact &cnt, int category );
    void parseName( const QString& name, QString *first, QString *middle,
		    QString * last );

    Categories mCat;
    bool m_inSearch;
    bool m_inPersonal;
    bool m_sortOrder;
    int m_curr_category;
    Views m_curr_View;
    Views m_prev_View;
    int m_curr_Contact;

    Opie::OPimContactAccess* m_contactdb;
    Opie::OPimContactAccess* m_storedDB;
    Opie::OPimContactAccess::List m_list;

    QWidgetStack* m_viewStack;
    AbTable* m_abTable;
    AbLabel* m_ablabel;

    QValueList<int> m_orderedFields;
};


#endif