• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kalgebra

  • sources
  • kde-4.12
  • kdeedu
  • kalgebra
  • src
consolehtml.h
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2007 by Aleix Pol <aleixpol@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License *
6  * as published by the Free Software Foundation; either version 2 *
7  * of the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the Free Software *
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
17  *************************************************************************************/
18 
19 #ifndef CONSOLE_H
20 #define CONSOLE_H
21 
22 #include <QWidget>
23 #include <QWebView>
24 
25 #include <analitza/analyzer.h>
26 
27 class KUrl;
28 class InlineOptions
29 {
30  public:
31  virtual ~InlineOptions() {}
32 
33  virtual QString id() const = 0;
34  virtual QString caption() const = 0;
35  virtual bool matchesExpression(const Analitza::Expression& exp, const Analitza::ExpressionType& functype) const = 0;
36  virtual void triggerOption(const Analitza::Expression& exp) = 0;
37 };
38 
45 class ConsoleHtml : public QWebView
46 {
47  Q_OBJECT
48  public:
50  enum ConsoleMode {
51  Evaluation,
52  Calculation
53  };
54 
56  ConsoleHtml(QWidget *parent = 0);
57 
59  virtual ~ConsoleHtml();
60 
62  Analitza::Analyzer* analitza() { return &a; }
63 
65  void setMode(ConsoleMode newMode) { m_mode = newMode; }
66 
68  ConsoleMode mode() const { return m_mode; }
69 
70  void addOptionsObserver(InlineOptions* opt) { m_options += opt; }
71 
72  virtual void contextMenuEvent(QContextMenuEvent* ev);
73 
74  public slots:
76  bool addOperation(const Analitza::Expression& e, const QString& input);
77 
79  bool loadScript(const KUrl& path);
80 
82  bool saveScript(const KUrl& path) const;
83 
85  bool saveLog(const KUrl& path) const;
86 
88  void clear();
89 
91  void copy() const;
92 
93  void openClickedUrl(const QUrl& url);
94 
95  signals:
97  void status(const QString &msg);
98 
100  void changed();
101 
103  void paste(const QString& code);
104 
105  private slots:
106  void initialize();
107 
108  void modifyVariable(const QString& name, const Analitza::Expression& exp);
109  void removeVariable(const QString& name);
110  void paste();
111 
112  private:
113  QString retrieve(const KUrl& remoteUrl);
114 
115  Analitza::Analyzer a;
116  void sendStatus(const QString& msg) { emit status(msg); }
117  ConsoleMode m_mode;
118  QList<Analitza::Expression> m_script;
119  QStringList m_htmlLog;
120 
121  void updateView(const QString& newEntry, const QString& options);
122 
123  QByteArray m_css;
124  QList<InlineOptions*> m_options;
125 };
126 
127 #endif
InlineOptions::id
virtual QString id() const =0
ConsoleHtml::openClickedUrl
void openClickedUrl(const QUrl &url)
Definition: consolehtml.cpp:85
QWidget
ConsoleHtml::analitza
Analitza::Analyzer * analitza()
Retrieves a pointer to the Analitza calculator associated.
Definition: consolehtml.h:62
ConsoleHtml::~ConsoleHtml
virtual ~ConsoleHtml()
Destructor.
Definition: consolehtml.cpp:55
ConsoleHtml::addOperation
bool addOperation(const Analitza::Expression &e, const QString &input)
Adds the operation defined by the expression e.
Definition: consolehtml.cpp:97
ConsoleHtml::addOptionsObserver
void addOptionsObserver(InlineOptions *opt)
Definition: consolehtml.h:70
ConsoleHtml
The Console widget is able to receive an operation, solve it and show the value.
Definition: consolehtml.h:45
InlineOptions::~InlineOptions
virtual ~InlineOptions()
Definition: consolehtml.h:31
ConsoleHtml::setMode
void setMode(ConsoleMode newMode)
Sets a newMode console mode.
Definition: consolehtml.h:65
ConsoleHtml::status
void status(const QString &msg)
Emits a notification that tells that the widget status.
ConsoleHtml::ConsoleMode
ConsoleMode
This enumeration controles the way the console will calculate and show his results.
Definition: consolehtml.h:50
InlineOptions::matchesExpression
virtual bool matchesExpression(const Analitza::Expression &exp, const Analitza::ExpressionType &functype) const =0
ConsoleHtml::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *ev)
Definition: consolehtml.cpp:271
ConsoleHtml::changed
void changed()
Emits that something has changed.
ConsoleHtml::loadScript
bool loadScript(const KUrl &path)
Loads a script from path.
Definition: consolehtml.cpp:169
ConsoleHtml::saveLog
bool saveLog(const KUrl &path) const
Saves a log to path.
Definition: consolehtml.cpp:216
ConsoleHtml::saveScript
bool saveScript(const KUrl &path) const
Save a script yo path.
Definition: consolehtml.cpp:194
ConsoleHtml::copy
void copy() const
Copies the selected text to the clipboard.
Definition: consolehtml.cpp:266
ConsoleHtml::ConsoleHtml
ConsoleHtml(QWidget *parent=0)
Constructor.
Definition: consolehtml.cpp:44
InlineOptions::caption
virtual QString caption() const =0
InlineOptions
Definition: consolehtml.h:28
ConsoleHtml::mode
ConsoleMode mode() const
Retrieves the console mode.
Definition: consolehtml.h:68
InlineOptions::triggerOption
virtual void triggerOption(const Analitza::Expression &exp)=0
ConsoleHtml::Calculation
Calculates everything, if it finds a not defined variable shows an error.
Definition: consolehtml.h:52
ConsoleHtml::clear
void clear()
Flushes the contents.
Definition: consolehtml.cpp:286
QWebView
ConsoleHtml::Evaluation
Simplifies the expression, tries to simplify when sees a variable not defined.
Definition: consolehtml.h:51
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalgebra

Skip menu "kalgebra"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal