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

« back to all changes in this revision

Viewing changes to src/kalziumdataobject.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
#ifndef KALZIUMDATAOBJECT_H
 
2
#define KALZIUMDATAOBJECT_H
 
3
/***************************************************************************
 
4
 *   Copyright (C) 2005, 2006 by Carsten Niehaus                                 *
 
5
 *   cniehaus@kde.org                                                      *
 
6
 *                                                                         *
 
7
 *   This program is free software; you can redistribute it and/or modify  *
 
8
 *   it under the terms of the GNU General Public License as published by  *
 
9
 *   the Free Software Foundation; either version 2 of the License, or     *
 
10
 *   (at your option) any later version.                                   *
 
11
 *                                                                         *
 
12
 *   This program 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         *
 
15
 *   GNU General Public License for more details.                          *
 
16
 *                                                                         *
 
17
 *   You should have received a copy of the GNU General Public License     *
 
18
 *   along with this program; if not, write to the                         *
 
19
 *   Free Software Foundation, Inc.,                                       *
 
20
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.          *
 
21
 ***************************************************************************/
 
22
 
 
23
#include <element.h>
 
24
#include <QHash>
 
25
#include <QPixmap>
 
26
 
 
27
class Search;
 
28
 
 
29
/**
 
30
 * @brief This class contains all Element objects
 
31
 *
 
32
 * This singleton class collects all the information about the elements of the
 
33
 * Periodic Table as list of Element.
 
34
 *
 
35
 * Use:
 
36
 * @code
 
37
 * KalziumDataObject::instance()->ElementList;
 
38
 * @endcode
 
39
 * to get the whole list of Element, while a
 
40
 * @code
 
41
 * KalziumDataObject::instance()->element( num );
 
42
 * @endcode
 
43
 * will return you the pointer to the num'th element of the Periodic Table.
 
44
 *
 
45
 * @author Carsten Niehaus
 
46
 */
 
47
class KalziumDataObject
 
48
  {
 
49
  public:
 
50
    /**
 
51
     * @return the instance of this class
 
52
     */
 
53
    static KalziumDataObject* instance();
 
54
 
 
55
    /**
 
56
     * The list of elements
 
57
     */
 
58
    QList<Element*> ElementList;
 
59
 
 
60
    /**
 
61
     * Set the main Search to @p srch
 
62
     */
 
63
    void setSearch ( Search *srch );
 
64
 
 
65
    /**
 
66
     * @return the main Search
 
67
     */
 
68
    Search* search() const;
 
69
 
 
70
    /**
 
71
     * @return the Element with the number @p number
 
72
     * @param number the number of the Element which will be returned
 
73
     */
 
74
    Element* element ( int number );
 
75
 
 
76
    /**
 
77
     * retunrs the unit symbol from the given KUnitConversion UnitId.
 
78
     * @param unit KUnitConversion UnitId
 
79
     * @return unit symbol as string.
 
80
     */
 
81
    QString unitAsString( const int unit ) const;
 
82
 
 
83
    /**
 
84
     * @return the isotopes of the Element with the number @p number
 
85
     */
 
86
    QList<Isotope*> isotopes ( int number );
 
87
 
 
88
    /**
 
89
     * @return the isotopes of the Element @p Element
 
90
     */
 
91
    QList<Isotope*> isotopes ( Element * element );
 
92
 
 
93
    /**
 
94
    * @return the Spectrum of the Element with the number @p number
 
95
     */
 
96
    Spectrum * spectrum ( int number );
 
97
 
 
98
    QPixmap pixmap ( int number );
 
99
 
 
100
    /**
 
101
     * Use this to get the number of elements we have. It is cached
 
102
     * so you are strongly suggested to use this instead of hardcode
 
103
     * the number of elements.
 
104
     * @return the number of elements we have
 
105
     */
 
106
    int numberOfElements() const { return m_numOfElements; }
 
107
 
 
108
  private:
 
109
    KalziumDataObject();
 
110
    ~KalziumDataObject();
 
111
 
 
112
    static void cleanup();
 
113
 
 
114
    void loadIconSet();
 
115
    void cleanPixmaps();
 
116
 
 
117
    QList<QPixmap> PixmapList;
 
118
 
 
119
    QHash<int, QList<Isotope*> > m_isotopes;
 
120
    QList<Spectrum*> m_spectra;
 
121
 
 
122
    /**
 
123
     * Caching the number of elements
 
124
     */
 
125
    int m_numOfElements;
 
126
 
 
127
    Search *m_search;
 
128
 
 
129
    friend class StaticKalziumDataObject;
 
130
  };
 
131
#endif // KALZIUMDATAOBJECT_H