mainwindow.h 3.24 KB
Newer Older
1 2 3 4
#ifndef ABAKUS_MAINWINDOW_H
#define ABAKUS_MAINWINDOW_H
/*
 * mainwindow.h - part of abakus
5
 * Copyright (C) 2004, 2005, 2007 Michael Pyne <michael.pyne@kdemail.net>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

22
#include <kxmlguiwindow.h>
23 24 25 26

#include "numerictypes.h"

class QPoint;
27
class QLineEdit;
28 29 30 31 32 33
class QCheckBox;
class QRadioButton;
class QBoxLayout;
class QListViewItem;
class QSplitter;
class QTimer;
34
class QMenu;
35
class QModelIndex;
36
class QAction;
37 38

//class KComboBox;
39 40 41
//class Editor;
class KVBox;

42 43
class ResultModel;
class ListView;
44 45 46

class AbakusIface;

47 48 49 50
namespace Ui {
    class MainWindow;
}

51
// Main window class, handles events and layout and stuff
52
class MainWindow : public KXmlGuiWindow
53 54 55 56 57 58 59 60
{
    Q_OBJECT
    public:
    MainWindow();

    bool inRPNMode() const;

    protected:
61
    virtual void contextMenuEvent(QContextMenuEvent *);
62 63 64
    virtual bool queryExit();

    private slots:
65
    void slotTextChanged(const QString &);
66 67 68 69 70 71 72 73 74 75 76 77 78 79
    void slotEvaluate();

    void slotPrecisionAuto();
    void slotPrecision3();
    void slotPrecision8();
    void slotPrecision15();
    void slotPrecision50();
    void slotPrecisionCustom();

    void slotUpdateSize();

    void slotDegrees();
    void slotRadians();

80
    void itemClicked(const QModelIndex &);
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    void slotEntrySelected(const QString &text);
    void slotResultSelected(const QString &text);

    void slotToggleMenuBar();
    void slotToggleFunctionList();
    void slotToggleVariableList();
    void slotToggleHistoryList();
    void slotToggleCompactMode();
    void slotToggleExpressionMode();

    void slotNewValue(const QString &name, Abakus::number_t value);
    void slotChangeValue(const QString &name, Abakus::number_t value);
    void slotRemoveValue(const QString &name);

    void slotNewFunction(const QString &name);
    void slotRemoveFunction(const QString &name);

    private:
    int getParenthesesLevel(const QString &str);

    void redrawResults();
    void selectCorrectPrecisionAction();

    void loadConfig();
    void saveConfig();
    void setupLayout();
    void populateListViews();
108
    QString interpolateExpression(const QString &text);
109 110

    // Donated via JuK
111
    QAction *action(const char *key) const;
112 113 114

    template <class T> T *action(const char *key) const
    {
115
        return dynamic_cast<T *>(action(key));
116 117 118
    }

    private:
119
    Ui::MainWindow *m_ui;
120
    QMenu *m_popup;
121
    ResultModel *m_resultItemModel;
122 123 124
    QString m_lastError;
    QSize m_newSize, m_oldSize;

125
//    AbakusIface *m_dcopInterface;
126 127 128 129 130 131 132 133

    bool m_wasFnShown, m_wasVarShown, m_wasHistoryShown;
    bool m_compactMode;

    bool m_insert;
};

#endif
134 135

// vim: set et ts=8 sw=4: