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

« back to all changes in this revision

Viewing changes to plasmoid/applet/psePlasmoid/Molmasscalculator.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 periodicTable_HEADER
 
23
#define periodicTable_HEADER
 
24
 
 
25
#include <QGraphicsGridLayout>
 
26
#include <QColor>
 
27
 
 
28
// We need the Plasma Applet headers
 
29
#include <plasma/widgets/label.h>
 
30
#include <plasma/widgets/lineedit.h>
 
31
#include <plasma/widgets/iconwidget.h>
 
32
#include <plasma/popupapplet.h>
 
33
 
 
34
#include "ui_Molmassconfig.h"
 
35
 
 
36
#include "Periodictable.h"
 
37
#include <QTimer>
 
38
 
 
39
// Define our plasma Applet
 
40
class Molmasscalculator : public Plasma::PopupApplet
 
41
{
 
42
    Q_OBJECT
 
43
public:
 
44
    // Basic Create/Destroy
 
45
    Molmasscalculator ( QObject *parent, const QVariantList &args );
 
46
    ~Molmasscalculator();
 
47
 
 
48
    /// Returns the GraphicsWidget used by the plasmoid
 
49
    QGraphicsWidget *graphicsWidget ();
 
50
 
 
51
    /// loads the settings.
 
52
    void init();
 
53
 
 
54
public slots:
 
55
    /// Appens the given String to the lineedit text and let it parse by ParseMolecule.
 
56
    void appendElement ( QString ElementSymbol );
 
57
 
 
58
    void configChanged();
 
59
 
 
60
private slots:
 
61
    ///Sends the requests to the Dataengine
 
62
    void ParseMolecule( QString molecule );
 
63
 
 
64
    ///The lineEdit Text is parsed.
 
65
    void ParseMolecule();
 
66
 
 
67
    void toggleTable();
 
68
 
 
69
protected slots:
 
70
    void configAccepted();
 
71
    
 
72
protected:
 
73
    void createConfigurationInterface (KConfigDialog* parent);
 
74
 
 
75
private:
 
76
    /// Sets the new Mass and Molecule after a calculation.
 
77
    void newCalculatedMass();
 
78
 
 
79
    ///Resets the size of the plasmoid if the periodsystem is shown or not.
 
80
    void managePeriodSystem();
 
81
 
 
82
    void saveConfig();
 
83
 
 
84
    // Configuration
 
85
    bool m_showPeriodicTable;
 
86
    bool m_copyToClipboard;
 
87
    int  m_tableType;
 
88
 
 
89
    // Widgets
 
90
    QGraphicsWidget *m_widget;
 
91
    PeriodicGrid *m_PeriodWidget;
 
92
 
 
93
    QTimer *m_triggerTimer;
 
94
 
 
95
    Plasma::LineEdit *m_lineedit;
 
96
    Plasma::Label *m_MassLabel;
 
97
    Plasma::IconWidget *m_switchButton;
 
98
 
 
99
    Plasma::DataEngine::Data m_molecule;
 
100
 
 
101
    Ui::periodicConfig m_ui;
 
102
};
 
103
 
 
104
// This is the command that links your applet to the .desktop file
 
105
K_EXPORT_PLASMA_APPLET ( Molmasscalculator, Molmasscalculator )
 
106
#endif