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

« back to all changes in this revision

Viewing changes to src/molcalcwidget.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 MOLCALCWIDGET_H
 
2
#define MOLCALCWIDGET_H
 
3
/***************************************************************************
 
4
 *   Copyright (C) 2005, 2006, 2007 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 <QWidget>
 
24
#include "ui_molcalcwidgetbase.h"
 
25
 
 
26
#include "moleculeparser.h"
 
27
 
 
28
class QTimer;
 
29
class QKeyEvent;
 
30
 
 
31
/**
 
32
 * This widget calculates mass for molecules.
 
33
 *
 
34
 * @author Carsten Niehaus
 
35
 * @author Pino Toscano
 
36
 * @author Inge Wallin
 
37
 * @author Kashyap R Puranik
 
38
 */
 
39
class MolcalcWidget : public QWidget
 
40
{
 
41
        Q_OBJECT
 
42
        public:
 
43
                /**
 
44
                 * Constructor
 
45
                 * @param parent parent widget
 
46
                 */
 
47
                MolcalcWidget( QWidget *parent = 0 );
 
48
                void hideExtra();
 
49
                virtual ~MolcalcWidget();
 
50
                
 
51
        protected slots:
 
52
                void slotCalculate();
 
53
        
 
54
        protected:
 
55
        void keyPressEvent(QKeyEvent *e);
 
56
 
 
57
        private slots:
 
58
                void clear();
 
59
                void addAlias();
 
60
 
 
61
        private:
 
62
                /**
 
63
                 * @return the HTML code of an element symbol and its
 
64
                 * subscripted amount. Eg: Mg<sub>2</sub>
 
65
                 */
 
66
                QString compositionString( ElementCountMap &_map );
 
67
 
 
68
                /**
 
69
                 * This methods gathers all the data and updates the 
 
70
                 * contents of the widget.
 
71
                 */
 
72
                void updateUI();
 
73
 
 
74
                Ui_MolcalcWidgetBase ui;
 
75
 
 
76
        QTimer * m_timer;
 
77
 
 
78
        private:
 
79
                MoleculeParser   *m_parser;
 
80
        QSet<QString>    m_aliasList;
 
81
                double           m_mass;
 
82
                bool             m_validInput;
 
83
                ElementCountMap  m_elementMap;
 
84
};
 
85
 
 
86
 
 
87
#endif // MOLCALC_IMPL_H