~ubuntu-branches/ubuntu/natty/digikam/natty

« back to all changes in this revision

Viewing changes to libs/widgets/common/modelcompletion.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-08-26 19:25:16 UTC
  • mfrom: (1.2.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100826192516-mkbdww0h5v2x4yoy
Tags: 2:1.4.0-0ubuntu1
* New upstream bugfix release (LP: #626751)
* Install the file NEWS as upstream changelog because "ChangeLog" is
  too verbose.
* Don't copy the desktop .pot file to imageplugins, not needed anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2010-06-13
 
7
 * Description : A KCompletion for AbstractAlbumModels
 
8
 *
 
9
 * Copyright (C) 2007-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2009-2010 by Johannes Wienke <languitar at semipol dot de>
 
11
 * Copyright (C) 2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
12
 *
 
13
 * This program is free software; you can redistribute it
 
14
 * and/or modify it under the terms of the GNU General
 
15
 * Public License as published by the Free Software Foundation;
 
16
 * either version 2, or (at your option)
 
17
 * any later version.
 
18
 *
 
19
 * This program is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 * GNU General Public License for more details.
 
23
 *
 
24
 * ============================================================ */
 
25
 
 
26
#ifndef ALBUMMODELCOMPLETION_H
 
27
#define ALBUMMODELCOMPLETION_H
 
28
 
 
29
// QT includes
 
30
 
 
31
#include <qabstractitemmodel.h>
 
32
 
 
33
// KDE includes
 
34
 
 
35
#include <kcompletion.h>
 
36
 
 
37
// Local includes
 
38
 
 
39
#include "digikam_export.h"
 
40
 
 
41
namespace Digikam
 
42
{
 
43
 
 
44
class ModelCompletionPriv;
 
45
 
 
46
class DIGIKAM_EXPORT ModelCompletion : public KCompletion
 
47
{
 
48
    Q_OBJECT
 
49
 
 
50
public:
 
51
 
 
52
    ModelCompletion();
 
53
    ~ModelCompletion();
 
54
 
 
55
    /**
 
56
     * If the given model is != null, the model is used to populate the
 
57
     * completion for this text field.
 
58
     *
 
59
     * @param model to fill from or null for manual mode
 
60
     * @param uniqueIdRole a role for which the model will return a unique integer for each entry
 
61
     * @param displayRole the role to retrieve the text for completion, default is Qt::DisplayRole.
 
62
     */
 
63
    void setModel(QAbstractItemModel *model, int uniqueIdRole, int displayRole = Qt::DisplayRole);
 
64
    QAbstractItemModel *model() const;
 
65
 
 
66
private Q_SLOTS:
 
67
 
 
68
    void slotRowsInserted(const QModelIndex &parent, int start, int end);
 
69
    void slotRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
 
70
    void slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 
71
    void slotModelReset();
 
72
 
 
73
private:
 
74
 
 
75
    void connectToModel(QAbstractItemModel *model);
 
76
    void disconnectFromModel(QAbstractItemModel *model);
 
77
    void sync(QAbstractItemModel *model);
 
78
    void sync(QAbstractItemModel *model, const QModelIndex &index);
 
79
 
 
80
private:
 
81
 
 
82
    ModelCompletionPriv* const d;
 
83
};
 
84
 
 
85
}  // namespace Digikam
 
86
 
 
87
#endif /* ALBUMMODELCOMPLETION_H */