KTutorial  0.5.1
StepTextWidget.h
00001 /***************************************************************************
00002  *   Copyright (C) 2010 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00003  *   Copyright (C) 2011 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00004  *   Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com>     *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; If not, see <http://www.gnu.org/licenses/>.  *
00018  ***************************************************************************/
00019 
00020 #ifndef KTUTORIAL_VIEW_STEPTEXTWIDGET_H
00021 #define KTUTORIAL_VIEW_STEPTEXTWIDGET_H
00022 
00023 #include <QPointer>
00024 
00025 #include <KTextEdit>
00026 
00027 namespace ktutorial {
00028 namespace view {
00029 
00054 class StepTextWidget: public KTextEdit {
00055 Q_OBJECT
00056 public:
00057 
00063     explicit StepTextWidget(QWidget* parent = 0);
00064 
00069     virtual ~StepTextWidget();
00070 
00079     virtual bool eventFilter(QObject* watched, QEvent* event);
00080 
00087     virtual int heightForWidth(int width) const;
00088 
00096     virtual QSize minimumSizeHint() const;
00097 
00105     virtual QSize sizeHint() const;
00106 
00107 protected:
00108 
00118     virtual void contextMenuEvent(QContextMenuEvent* event);
00119 
00125     virtual void mouseMoveEvent(QMouseEvent* event);
00126 
00133     virtual void mousePressEvent(QMouseEvent* event);
00134 
00135 private:
00136 
00141     QPointer<QWidget> mLastReferencedWidget;
00142 
00146     QPointer<QWidget> mWidgetBeingHighlighted;
00147 
00159     QSize sizeForWidth(int width) const;
00160 
00169     QWidget* widgetForAnchor(const QString& anchor);
00170 
00171 private Q_SLOTS:
00172 
00177     void updateText();
00178 
00183     void highlightLastReferencedWidget();
00184 
00188     void stopHighlightingCurrentWidget();
00189 
00190 };
00191 
00192 }
00193 }
00194 
00195 #endif