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

« back to all changes in this revision

Viewing changes to plasmoid/applet/psePlasmoid/Periodictable.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
* Mass calculator: Plasmoid to calculate mass of a Molecule.
 
3
* Copyright (C) 2009, 2010 Etienne Rebetez, etienne.rebetez@oberwallis.ch
 
4
*
 
5
* This program is free software; you can redistribute it and/or
 
6
* modify it under the terms of the GNU General Public License
 
7
* as published by the Free Software Foundation; either version 2
 
8
* of the License, or (at your option) any later version.
 
9
*
 
10
* This program is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with this program; if not, write to the Free Software
 
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
*
 
19
***********************************************************************************/
 
20
 
 
21
// Here we avoid loading the header multiple times
 
22
#ifndef ElementWidget_HEADER
 
23
#define ElementWidget_HEADER
 
24
 
 
25
#include <QGraphicsGridLayout>
 
26
 
 
27
#include <plasma/widgets/pushbutton.h>
 
28
#include <plasma/widgets/iconwidget.h>
 
29
#include <plasma/tooltipmanager.h>
 
30
#include <Plasma/Applet>
 
31
 
 
32
class ElementLabel;
 
33
 
 
34
class PeriodicGrid : public QGraphicsWidget
 
35
{
 
36
    Q_OBJECT
 
37
public:
 
38
//         Basic Create/Destroy
 
39
    PeriodicGrid(Plasma::Applet *applet = 0);
 
40
    PeriodicGrid(int tableTyp, Plasma::Applet *applet = 0);
 
41
 
 
42
    ~PeriodicGrid();
 
43
 
 
44
    /// gets the current periodic table id.
 
45
    int getCurrentPseTyp() const;
 
46
 
 
47
    /// creates all element labels and put them in the grid.
 
48
    void create();
 
49
 
 
50
public slots:
 
51
    /// sets the new table typ and creates the table.
 
52
    void setCurrentPseTyp(int tableTyp);
 
53
 
 
54
private:
 
55
    QGraphicsGridLayout *m_actualPeriodSystem;
 
56
 
 
57
    int m_psTableType;
 
58
 
 
59
    QList<ElementLabel*>  m_elementItemList;
 
60
 
 
61
    Plasma::DataEngine::Data m_element;
 
62
    Plasma::Applet *m_applet;
 
63
};
 
64
 
 
65
class ElementLabel : public Plasma::IconWidget
 
66
{
 
67
    Q_OBJECT
 
68
public:
 
69
//         Basic Create/Destroy
 
70
    ElementLabel( int element,  Plasma::Applet *applet, QGraphicsWidget * parent = 0);
 
71
 
 
72
 
 
73
signals:
 
74
    /// emits the text string of the current element.
 
75
    void ElementAction(QString text);
 
76
 
 
77
private slots:
 
78
    /// is used to add information to the clicked() signal.
 
79
    void ElementPressed() {
 
80
        emit ElementAction(text());
 
81
    }
 
82
private:
 
83
    void drawToolTip( Plasma::DataEngine::Data &element );
 
84
};
 
85
 
 
86
#endif