summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abtable.h
blob: 84aef1e0fe1fa4fb6573895b3af397766c1e68c2 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**********************************************************************
** Copyright (C) 2000 Trolltech AS.  All rights reserved.
**
** This file is part of Qt Palmtop Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#ifndef ABTABLE_H
#define ABTABLE_H

#include <qpe/categories.h>
#include <opie/ocontact.h>

#include <qmap.h>
#include <qtable.h>
#include <qstringlist.h>
#include <qcombobox.h>

#include <opie/ocontactaccess.h>

class AbTableItem : public QTableItem
{
public:
    AbTableItem( QTable *t, EditType et, const QString &s,
		 const QString &secondSortKey);
    QString entryKey() const;
    void setEntryKey( const QString & k );
    virtual int alignment() const;
    virtual QString key() const;
    void setItem( const QString &txt, const QString &secondKey );

private:
    QString sortKey;
};

class AbPickItem : public QTableItem
{
public:
    AbPickItem( QTable *t );

    QWidget *createEditor() const;
    void setContentFromEditor( QWidget *w );

private:
    QGuardedPtr<QComboBox> cb;
};

class AbTable : public QTable
{
    Q_OBJECT

public:
    AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 );
    ~AbTable();
    // NEW
    void addEntry( const OContact &newContact );
    OContact currentEntry();
    void replaceCurrentEntry( const OContact &newContact );

    void init();

    void deleteCurrentEntry();
    void clear();
    void clearFindRow() { currFindRow = -2; }
    void loadFields();
    void refresh();
    bool save( const QString &fn );
    void load( const QString &fn );

    // addresspicker mode
    void setChoiceNames( const QStringList& list);
    QStringList choiceNames() const;
    void setChoiceSelection(int index, const QStringList& list);
    QStringList choiceSelection(int index) const;
    void setShowCategory( const QString &b, const QString &c );
    void setShowByLetter( char c );
    QString showCategory() const;
    QStringList categories();

    void resizeRows();

    void show();
    void setPaintingEnabled( bool e );

    QString showBook() const;

public slots:
    void slotDoFind( const QString &str, bool caseSensitive, bool backwards,
                     int category );
signals:
    void empty( bool );
    void details();
    void signalNotFound();
    void signalWrapAround();

protected:
    virtual void keyPressEvent( QKeyEvent *e );

//     int rowHeight( int ) const;
//     int rowPos( int row ) const;
//     virtual int rowAt( int pos ) const;


protected slots:
    void moveTo( char );
    virtual void columnClicked( int col );
    void itemClicked(int,int col);
    void rowHeightChanged( int row );

private:
    void loadFile( const QString &strFile, bool journalFile );
    void fitColumns();
    void resort();
    void updateJournal( const OContact &contact, OContact::journal_action action,
			int row = -1 );
    void insertIntoTable( const OContact &contact, int row );
    QString findContactName( const OContact &entry );
    QString findContactContact( const OContact &entry, int row );
    void journalFreeReplace( const OContact &cnt, int row );
    void journalFreeRemove( int row );
    void realignTable( int );
    void updateVisible();
    int lastSortCol;
    bool asc;
    char showChar;
    QMap<AbTableItem*, OContact> contactList;
    const QValueList<int> *intFields;
    int currFindRow;
    QString showCat;
    QStringList choicenames;
    bool enablePainting;
    Categories mCat;

    QString showBk;
    bool columnVisible;

    OContactAccess m_contactdb;

};
#endif // ABTABLE_H