SpeedCrunch  0.11
/usr/src/RPM/BUILD/speedcrunch-0.11/src/gui/resultdisplay.h
Go to the documentation of this file.
00001 // This file is part of the SpeedCrunch project
00002 // Copyright (C) 2009, 2011, 2013, 2014 Helder Correia <helder.pereira.correia@gmail.com>
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; see the file COPYING.  If not, write to
00016 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017 // Boston, MA 02110-1301, USA.
00018 
00019 #ifndef GUI_RESULTDISPLAY_H
00020 #define GUI_RESULTDISPLAY_H
00021 
00022 #include <QBasicTimer>
00023 #include <QPlainTextEdit>
00024 
00025 class HNumber;
00026 class SyntaxHighlighter;
00027 
00028 class ResultDisplay : public QPlainTextEdit
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     explicit ResultDisplay(QWidget* parent = 0);
00034 
00035     void append(const QString& expr, const HNumber& value);
00036     void appendHistory(const QStringList& expressions, const QStringList& results);
00037     int count() const;
00038     bool isEmpty() const { return m_count == 0; }
00039 
00040 signals:
00041     void shiftWheelDown();
00042     void shiftWheelUp();
00043     void shiftControlWheelDown();
00044     void shiftControlWheelUp();
00045     void expressionSelected(const QString&);
00046 
00047 public slots:
00048     void clear();
00049     void decreaseFontPointSize();
00050     void increaseFontPointSize();
00051     void rehighlight();
00052     void refresh();
00053     void scrollLines(int);
00054     void scrollLineUp();
00055     void scrollLineDown();
00056     void scrollPageUp();
00057     void scrollPageDown();
00058     void scrollToBottom();
00059     void scrollToTop();
00060 
00061 protected:
00062     virtual void mouseDoubleClickEvent(QMouseEvent*);
00063     virtual void wheelEvent(QWheelEvent*);
00064     virtual void timerEvent(QTimerEvent*);
00065     void fullContentScrollEvent();
00066     float linesPerPage() { return static_cast<float>(viewport()->height()) / fontMetrics().height(); }
00067     void pageScrollEvent();
00068     void scrollToDirection(int);
00069     void stopActiveScrollingAnimation();
00070     void updateScrollBarStyleSheet();
00071 
00072 private:
00073     Q_DISABLE_COPY(ResultDisplay)
00074 
00075     int m_count;
00076     QStringList m_expressions;
00077     SyntaxHighlighter* m_highlighter;
00078     QStringList m_results;
00079     QBasicTimer m_scrollTimer;
00080     int m_scrolledLines;
00081     int m_scrollDirection;
00082     bool m_isScrollingPageOnly;
00083 };
00084 
00085 #endif