1 /* 2 * Copyright (C) 2011, 2012, 2013 Nicolas Bonnefon and other contributors 3 * 4 * This file is part of glogg. 5 * 6 * glogg is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * glogg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef OVERVIEWWIDGET_H 21 #define OVERVIEWWIDGET_H 22 23 #include <QWidget> 24 #include <QBasicTimer> 25 26 class Overview; 27 28 class OverviewWidget : public QWidget 29 { 30 Q_OBJECT 31 32 public: 33 OverviewWidget( QWidget* parent = 0 ); 34 35 // Associate the widget with an Overview object. 36 void setOverview( Overview* overview ) { overview_ = overview; } 37 38 public slots: 39 // Sent when a match at the line passed must be highlighted in 40 // the overview 41 void highlightLine( qint64 line ); 42 void removeHighlight(); 43 44 protected: 45 void paintEvent( QPaintEvent* paintEvent ); 46 void mousePressEvent( QMouseEvent* mouseEvent ); 47 void mouseMoveEvent( QMouseEvent* mouseEvent ); 48 void timerEvent( QTimerEvent* event ); 49 50 signals: 51 // Sent when the user click on a line in the Overview. 52 void lineClicked( int line ); 53 54 private: 55 // Constants 56 static const int LINE_MARGIN; 57 static const int STEP_DURATION_MS; 58 static const int INITIAL_TTL_VALUE; 59 60 Overview* overview_; 61 62 // Highlight: 63 // Which line is higlighted, or -1 if none 64 int highlightedLine_; 65 // Number of step until the highlight become static 66 int highlightedTTL_; 67 68 QBasicTimer highlightTimer_; 69 70 void handleMousePress( int position ); 71 }; 72 73 #endif 74