~ubuntu-branches/ubuntu/oneiric/kiten/oneiric-proposed

« back to all changes in this revision

Viewing changes to lib/entrylist.h

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2011-07-10 11:23:47 UTC
  • Revision ID: james.westby@ubuntu.com-20110710112347-ykfhtvam3kgssspo
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
 * This file is part of Kiten, a KDE Japanese Reference Tool                 *
 
3
 * Copyright (C) 2001 Jason Katz-Brown <jason@katzbrown.com>                 *
 
4
 * Copyright (C) 2006 Joseph Kerian <jkerian@gmail.com>                      *
 
5
 * Copyright (C) 2006 Eric Kjeldergaard <kjelderg@gmail.com>                 *
 
6
 *                                                                           *
 
7
 * This library is free software; you can redistribute it and/or             *
 
8
 * modify it under the terms of the GNU Library General Public               *
 
9
 * License as published by the Free Software Foundation; either              *
 
10
 * version 2 of the License, or (at your option) any later version.          *
 
11
 *                                                                           *
 
12
 * This library is distributed in the hope that it will be useful,           *
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
 
15
 * Library General Public License for more details.                          *
 
16
 *                                                                           *
 
17
 * You should have received a copy of the GNU Library General Public License *
 
18
 * along with this library; see the file COPYING.LIB.  If not, write to      *
 
19
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,      *
 
20
 * Boston, MA 02110-1301, USA.                                               *
 
21
 *****************************************************************************/
 
22
 
 
23
#ifndef KITEN_ENTRYLIST_H
 
24
#define KITEN_ENTRYLIST_H
 
25
 
 
26
#include <QList>
 
27
#include <QString>
 
28
#include <QStringList>
 
29
 
 
30
#include "dictquery.h"
 
31
#include "entry.h"
 
32
#include "libkitenexport.h"
 
33
 
 
34
/**
 
35
 * EntryList is a simple container for Entry objects, and is-a QList<Entry*>
 
36
 * A few simple overrides allow you to deal with sorting and translating.
 
37
 */
 
38
class KITEN_EXPORT EntryList : public QList<Entry*>
 
39
{
 
40
  public:
 
41
    /**
 
42
     * A simple overridden iterator for working with the Entries
 
43
     */
 
44
    typedef QListIterator<Entry*> EntryIterator;
 
45
 
 
46
    /**
 
47
     * Basic constructor, create an empty EntryList
 
48
     */
 
49
    EntryList();
 
50
    /**
 
51
     * Copy constructor
 
52
     */
 
53
    EntryList( const EntryList &old );
 
54
    /**
 
55
     * Basic Destructor, does not delete Entry* objects. Please remember to call
 
56
     * deleteAll() before deleting an EntryList.
 
57
     */
 
58
    virtual ~EntryList();
 
59
    /**
 
60
     * Delete all Entry objects in our list. In the future, we'll switch to a reference
 
61
     * counting system, and this will be deprecated.
 
62
     */
 
63
    void deleteAll();
 
64
 
 
65
    /**
 
66
     * Convert every element of the EntryList to a QString and return it
 
67
     */
 
68
    QString toString() const;
 
69
    /**
 
70
     * Convert every element of the EntryList to a QString in HTML form and return it
 
71
     */
 
72
    QString toHTML() const;
 
73
 
 
74
    /**
 
75
     * Convert a given range of the EntryList to a QString and return it
 
76
     * @param start the location in the list where we should start
 
77
     * @param length the length of the list we should generate
 
78
     */
 
79
    QString toString( unsigned int start, unsigned int length ) const;
 
80
    /**
 
81
     * Convert a given range of the EntryList to a QString in HTML form and return it
 
82
     * @param start the location in the list where we should start
 
83
     * @param length the length of the list we should generate
 
84
     */
 
85
    QString toHTML( unsigned int start, unsigned int length ) const;
 
86
    /**
 
87
     * Convert the entire list to KVTML for export to a flashcard app
 
88
     * @param start the location in the list where we should start
 
89
     * @param length the length of the list we should generate
 
90
     */
 
91
    QString toKVTML( unsigned int start, unsigned int length ) const;
 
92
 
 
93
    /**
 
94
     * Sort the list according to the given fields in sortOrder, if dictionaryOrder
 
95
     * is blank, don't order the list by dictionary, otherwise items are sorted by dictionary
 
96
     * then by sortOrder aspects
 
97
     * @param sortOrder the keys to sort by, this should be a list of fields to sort by, this should
 
98
     *        be the same as the fields that are returned from dictFile::listDictDisplayOptions().
 
99
     *        "--NewLine--" entries will be ignored, "Word/Kanji", "Meaning", and "Reading" entries will
 
100
     *        be accepted. An entry which has an extended attribute is considered higher ranking (sorted to
 
101
     *        a higher position) than an entry which does not have such an attribute.
 
102
     * @param dictionaryOrder the order for the Entry objects to be sorted in, dictionary-wise. This should
 
103
     *        match the names of the dictionary objects, passed to the DictionaryManager.
 
104
     */
 
105
    void sort( QStringList &sortOrder, QStringList &dictionaryOrder );
 
106
 
 
107
    /**
 
108
     * Append another EntryList onto this one
 
109
     */
 
110
    const EntryList& operator+=( const EntryList &other );
 
111
    /**
 
112
     * Copy an entry list
 
113
     */
 
114
    const EntryList& operator=( const EntryList &other );
 
115
    /**
 
116
     * Append another EntryList onto this one
 
117
     */
 
118
    void appendList( const EntryList *other );
 
119
    /**
 
120
     * Get the query that generated this list, note that if you have appended EntryLists from
 
121
     * two different queries, the resulting DictQuery from this is undefined.
 
122
     */
 
123
    DictQuery getQuery() const;
 
124
    /**
 
125
     * Set the query for this list.  See getQuery() for a potential problem with this
 
126
     */
 
127
    void setQuery( const DictQuery &newQuery );
 
128
 
 
129
    int scrollValue() const;
 
130
    void setScrollValue( int val );
 
131
 
 
132
  private:
 
133
    class Private;
 
134
    Private* const d;
 
135
};
 
136
 
 
137
#endif