~ubuntu-branches/ubuntu/precise/kalzium/precise

« back to all changes in this revision

Viewing changes to src/search.h

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-03 12:28:58 UTC
  • Revision ID: james.westby@ubuntu.com-20110703122858-q1yyxncs89e4w0hs
Tags: upstream-4.6.90+repack
Import upstream version 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2006      by Pino Toscano, toscano.pino@tiscali.it      *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef KALZIUMSEARCH_H
 
21
#define KALZIUMSEARCH_H
 
22
 
 
23
#include <QList>
 
24
#include <QObject>
 
25
 
 
26
#include "element.h"
 
27
//class Element;
 
28
 
 
29
/**
 
30
 * Represent a search.
 
31
 *
 
32
 * @author Pino Toscano
 
33
 */
 
34
class Search : public QObject
 
35
{
 
36
    Q_OBJECT
 
37
 
 
38
public:
 
39
    /**
 
40
     * The kind of search we can perform
 
41
     */
 
42
    enum SearchKind
 
43
    {
 
44
        SearchByName = 0x01,
 
45
        SearchBySymbol = 0x02,
 
46
        SearchAll = 0xFF
 
47
    };
 
48
 
 
49
    /**
 
50
     * Construct a new empty search.
 
51
     */
 
52
    Search();
 
53
 
 
54
    /**
 
55
     * @return the search text
 
56
     */
 
57
    QString searchText() const;
 
58
 
 
59
    /**
 
60
     * @return the kind of search
 
61
     */
 
62
    SearchKind searchKind() const;
 
63
 
 
64
    /**
 
65
     * is the current Search active?
 
66
     * @return whether this search is active
 
67
     */
 
68
    bool isActive() const;
 
69
 
 
70
    /**
 
71
     * @return the found elements
 
72
     */
 
73
    const QList<Element*>& foundElements() const;
 
74
 
 
75
    /**
 
76
     * @return whether the element @p el matches the search
 
77
     */
 
78
    bool matches( Element* el ) const;
 
79
 
 
80
    /**
 
81
     * @return whether the element @p el matches the search
 
82
     * overloaded function to use direct the element number.
 
83
     */
 
84
    bool matches( int el) const;
 
85
 
 
86
public slots:
 
87
    /**
 
88
     * Search the @p text by looking at the element using the
 
89
     * specified @p kind
 
90
     */
 
91
    void doSearch( const QString& text, SearchKind kind );
 
92
    /**
 
93
     * Reset the current search (and put it not active).
 
94
     */
 
95
    void resetSearch();
 
96
 
 
97
signals:
 
98
    /**
 
99
     * The current search has changed (ie the found elements have
 
100
     * changed)
 
101
     */
 
102
    void searchChanged();
 
103
    /**
 
104
     * The current search has been reset.
 
105
     */
 
106
    void searchReset();
 
107
 
 
108
private:
 
109
    bool m_isActive;
 
110
 
 
111
    QString m_searchText;
 
112
    SearchKind m_searchKind;
 
113
 
 
114
    QList<Element*> m_foundElements;
 
115
};
 
116
 
 
117
#endif // KALZIUMSEARCH_H