1bb02e0acSNicolas Bonnefon /* 2bb02e0acSNicolas Bonnefon * Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Bonnefon 3bb02e0acSNicolas Bonnefon * and other contributors 4bb02e0acSNicolas Bonnefon * 5bb02e0acSNicolas Bonnefon * This file is part of glogg. 6bb02e0acSNicolas Bonnefon * 7bb02e0acSNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 8bb02e0acSNicolas Bonnefon * it under the terms of the GNU General Public License as published by 9bb02e0acSNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 10bb02e0acSNicolas Bonnefon * (at your option) any later version. 11bb02e0acSNicolas Bonnefon * 12bb02e0acSNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 13bb02e0acSNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 14bb02e0acSNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15bb02e0acSNicolas Bonnefon * GNU General Public License for more details. 16bb02e0acSNicolas Bonnefon * 17bb02e0acSNicolas Bonnefon * You should have received a copy of the GNU General Public License 18bb02e0acSNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 19bb02e0acSNicolas Bonnefon */ 20bb02e0acSNicolas Bonnefon 21bb02e0acSNicolas Bonnefon #ifndef ABSTRACTLOGVIEW_H 22bb02e0acSNicolas Bonnefon #define ABSTRACTLOGVIEW_H 23bb02e0acSNicolas Bonnefon 24bb02e0acSNicolas Bonnefon #include <QAbstractScrollArea> 25bb02e0acSNicolas Bonnefon #include <QBasicTimer> 26bb02e0acSNicolas Bonnefon 278bda3285SNicolas Bonnefon #ifdef GLOGG_PERF_MEASURE_FPS 28045703daSNicolas Bonnefon # include "perfcounter.h" 298bda3285SNicolas Bonnefon #endif 30045703daSNicolas Bonnefon 31bb02e0acSNicolas Bonnefon #include "selection.h" 32bb02e0acSNicolas Bonnefon #include "quickfind.h" 33bb02e0acSNicolas Bonnefon #include "overviewwidget.h" 34bb02e0acSNicolas Bonnefon #include "quickfindmux.h" 350b05c6eaSNicolas Bonnefon #include "viewtools.h" 36bb02e0acSNicolas Bonnefon 37bb02e0acSNicolas Bonnefon class QMenu; 38bb02e0acSNicolas Bonnefon class QAction; 39bb02e0acSNicolas Bonnefon class AbstractLogData; 40bb02e0acSNicolas Bonnefon 41bb02e0acSNicolas Bonnefon class LineChunk 42bb02e0acSNicolas Bonnefon { 43bb02e0acSNicolas Bonnefon public: 44bb02e0acSNicolas Bonnefon enum ChunkType { 45bb02e0acSNicolas Bonnefon Normal, 46bb02e0acSNicolas Bonnefon Highlighted, 47bb02e0acSNicolas Bonnefon Selected, 48bb02e0acSNicolas Bonnefon }; 49bb02e0acSNicolas Bonnefon 50bb02e0acSNicolas Bonnefon LineChunk( int first_col, int end_col, ChunkType type ); 51bb02e0acSNicolas Bonnefon 52bb02e0acSNicolas Bonnefon int start() const { return start_; } 53bb02e0acSNicolas Bonnefon int end() const { return end_; } 54bb02e0acSNicolas Bonnefon ChunkType type() const { return type_; } 55bb02e0acSNicolas Bonnefon 56bb02e0acSNicolas Bonnefon // Returns 'true' if the selection is part of this chunk 57bb02e0acSNicolas Bonnefon // (at least partially), if so, it should be replaced by the list returned 58bb02e0acSNicolas Bonnefon QList<LineChunk> select( int selection_start, int selection_end ) const; 59bb02e0acSNicolas Bonnefon 60bb02e0acSNicolas Bonnefon private: 61bb02e0acSNicolas Bonnefon int start_; 62bb02e0acSNicolas Bonnefon int end_; 63bb02e0acSNicolas Bonnefon ChunkType type_; 64bb02e0acSNicolas Bonnefon }; 65bb02e0acSNicolas Bonnefon 66bb02e0acSNicolas Bonnefon // Utility class for syntax colouring. 67bb02e0acSNicolas Bonnefon // It stores the chunks of line to draw 68bb02e0acSNicolas Bonnefon // each chunk having a different colour 69bb02e0acSNicolas Bonnefon class LineDrawer 70bb02e0acSNicolas Bonnefon { 71bb02e0acSNicolas Bonnefon public: 72bb02e0acSNicolas Bonnefon LineDrawer( const QColor& back_color) : 73bb02e0acSNicolas Bonnefon list(), backColor_( back_color ) { }; 74bb02e0acSNicolas Bonnefon 75bb02e0acSNicolas Bonnefon // Add a chunk of line using the given colours. 76bb02e0acSNicolas Bonnefon // Both first_col and last_col are included 77bb02e0acSNicolas Bonnefon // An empty chunk will be ignored. 78bb02e0acSNicolas Bonnefon // the first column will be set to 0 if negative 79bb02e0acSNicolas Bonnefon // The column are relative to the screen 80bb02e0acSNicolas Bonnefon void addChunk( int first_col, int last_col, QColor fore, QColor back ); 81bb02e0acSNicolas Bonnefon void addChunk( const LineChunk& chunk, QColor fore, QColor back ); 82bb02e0acSNicolas Bonnefon 83bb02e0acSNicolas Bonnefon // Draw the current line of text using the given painter, 84bb02e0acSNicolas Bonnefon // in the passed block (in pixels) 85bb02e0acSNicolas Bonnefon // The line must be cut to fit on the screen. 86bb02e0acSNicolas Bonnefon // leftExtraBackgroundPx is the an extra margin to start drawing 87bb02e0acSNicolas Bonnefon // the coloured // background, going all the way to the element 88bb02e0acSNicolas Bonnefon // left of the line looks better. 89bb02e0acSNicolas Bonnefon void draw( QPainter& painter, int xPos, int yPos, 90bb02e0acSNicolas Bonnefon int line_width, const QString& line, 91bb02e0acSNicolas Bonnefon int leftExtraBackgroundPx ); 92bb02e0acSNicolas Bonnefon 93bb02e0acSNicolas Bonnefon private: 94bb02e0acSNicolas Bonnefon class Chunk { 95bb02e0acSNicolas Bonnefon public: 96bb02e0acSNicolas Bonnefon // Create a new chunk 97bb02e0acSNicolas Bonnefon Chunk( int start, int length, QColor fore, QColor back ) 98bb02e0acSNicolas Bonnefon : start_( start ), length_( length ), 99bb02e0acSNicolas Bonnefon foreColor_ ( fore ), backColor_ ( back ) { }; 100bb02e0acSNicolas Bonnefon 101bb02e0acSNicolas Bonnefon // Accessors 102bb02e0acSNicolas Bonnefon int start() const { return start_; } 103bb02e0acSNicolas Bonnefon int length() const { return length_; } 104bb02e0acSNicolas Bonnefon const QColor& foreColor() const { return foreColor_; } 105bb02e0acSNicolas Bonnefon const QColor& backColor() const { return backColor_; } 106bb02e0acSNicolas Bonnefon 107bb02e0acSNicolas Bonnefon private: 108bb02e0acSNicolas Bonnefon int start_; 109bb02e0acSNicolas Bonnefon int length_; 110bb02e0acSNicolas Bonnefon QColor foreColor_; 111bb02e0acSNicolas Bonnefon QColor backColor_; 112bb02e0acSNicolas Bonnefon }; 113bb02e0acSNicolas Bonnefon QList<Chunk> list; 114bb02e0acSNicolas Bonnefon QColor backColor_; 115bb02e0acSNicolas Bonnefon }; 116bb02e0acSNicolas Bonnefon 117bb02e0acSNicolas Bonnefon 118bb02e0acSNicolas Bonnefon // Utility class representing a buffer for number entered on the keyboard 119bb02e0acSNicolas Bonnefon // The buffer keep at most 7 digits, and reset itself after a timeout. 120bb02e0acSNicolas Bonnefon class DigitsBuffer : public QObject 121bb02e0acSNicolas Bonnefon { 122bb02e0acSNicolas Bonnefon Q_OBJECT 123bb02e0acSNicolas Bonnefon 124bb02e0acSNicolas Bonnefon public: 125bb02e0acSNicolas Bonnefon DigitsBuffer(); 126bb02e0acSNicolas Bonnefon 127bb02e0acSNicolas Bonnefon // Reset the buffer. 128bb02e0acSNicolas Bonnefon void reset(); 129bb02e0acSNicolas Bonnefon // Add a single digit to the buffer (discarded if it's not a digit), 130bb02e0acSNicolas Bonnefon // the timeout timer is reset. 131bb02e0acSNicolas Bonnefon void add( char character ); 132bb02e0acSNicolas Bonnefon // Get the content of the buffer (0 if empty) and reset it. 133bb02e0acSNicolas Bonnefon int content(); 134bb02e0acSNicolas Bonnefon 135bb02e0acSNicolas Bonnefon protected: 136bb02e0acSNicolas Bonnefon void timerEvent( QTimerEvent* event ); 137bb02e0acSNicolas Bonnefon 138bb02e0acSNicolas Bonnefon private: 139bb02e0acSNicolas Bonnefon // Duration of the timeout in milliseconds. 140bb02e0acSNicolas Bonnefon static const int timeout_; 141bb02e0acSNicolas Bonnefon 142bb02e0acSNicolas Bonnefon QString digits_; 143bb02e0acSNicolas Bonnefon 144bb02e0acSNicolas Bonnefon QBasicTimer timer_; 145bb02e0acSNicolas Bonnefon }; 146bb02e0acSNicolas Bonnefon 147bb02e0acSNicolas Bonnefon class Overview; 148bb02e0acSNicolas Bonnefon 149bb02e0acSNicolas Bonnefon // Base class representing the log view widget. 150bb02e0acSNicolas Bonnefon // It can be either the top (full) or bottom (filtered) view. 151bb02e0acSNicolas Bonnefon class AbstractLogView : 152bb02e0acSNicolas Bonnefon public QAbstractScrollArea, public SearchableWidgetInterface 153bb02e0acSNicolas Bonnefon { 154bb02e0acSNicolas Bonnefon Q_OBJECT 155bb02e0acSNicolas Bonnefon 156bb02e0acSNicolas Bonnefon public: 157bb02e0acSNicolas Bonnefon // Constructor of the widget, the data set is passed. 158bb02e0acSNicolas Bonnefon // The caller retains ownership of the data set. 159bb02e0acSNicolas Bonnefon // The pointer to the QFP is used for colouring and QuickFind searches 160bb02e0acSNicolas Bonnefon AbstractLogView( const AbstractLogData* newLogData, 161bb02e0acSNicolas Bonnefon const QuickFindPattern* const quickFind, QWidget* parent=0 ); 162bb02e0acSNicolas Bonnefon ~AbstractLogView(); 163bb02e0acSNicolas Bonnefon 164bb02e0acSNicolas Bonnefon // Refresh the widget when the data set has changed. 165bb02e0acSNicolas Bonnefon void updateData(); 166bb02e0acSNicolas Bonnefon // Instructs the widget to update it's content geometry, 167bb02e0acSNicolas Bonnefon // used when the font is changed. 168bb02e0acSNicolas Bonnefon void updateDisplaySize(); 169bb02e0acSNicolas Bonnefon // Return the line number of the top line of the view 170bb02e0acSNicolas Bonnefon int getTopLine() const; 171bb02e0acSNicolas Bonnefon // Return the text of the current selection. 172bb02e0acSNicolas Bonnefon QString getSelection() const; 173bb02e0acSNicolas Bonnefon // Instructs the widget to select the whole text. 174bb02e0acSNicolas Bonnefon void selectAll(); 175bb02e0acSNicolas Bonnefon 176bb02e0acSNicolas Bonnefon protected: 1771853a1fdSNicolas Bonnefon virtual void mousePressEvent( QMouseEvent* mouseEvent ); 1781853a1fdSNicolas Bonnefon virtual void mouseMoveEvent( QMouseEvent* mouseEvent ); 1791853a1fdSNicolas Bonnefon virtual void mouseReleaseEvent( QMouseEvent* ); 1801853a1fdSNicolas Bonnefon virtual void mouseDoubleClickEvent( QMouseEvent* mouseEvent ); 1811853a1fdSNicolas Bonnefon virtual void timerEvent( QTimerEvent* timerEvent ); 1821853a1fdSNicolas Bonnefon virtual void changeEvent( QEvent* changeEvent ); 1831853a1fdSNicolas Bonnefon virtual void paintEvent( QPaintEvent* paintEvent ); 1841853a1fdSNicolas Bonnefon virtual void resizeEvent( QResizeEvent* resizeEvent ); 1851853a1fdSNicolas Bonnefon virtual void scrollContentsBy( int dx, int dy ); 1861853a1fdSNicolas Bonnefon virtual void keyPressEvent( QKeyEvent* keyEvent ); 1871853a1fdSNicolas Bonnefon virtual void wheelEvent( QWheelEvent* wheelEvent ); 1881853a1fdSNicolas Bonnefon virtual bool event( QEvent * e ); 189bb02e0acSNicolas Bonnefon 190bb02e0acSNicolas Bonnefon // Must be implemented to return wether the line number is 191bb02e0acSNicolas Bonnefon // a match, a mark or just a normal line (used for coloured bullets) 192bb02e0acSNicolas Bonnefon enum LineType { Normal, Marked, Match }; 193bb02e0acSNicolas Bonnefon virtual LineType lineType( int lineNumber ) const = 0; 194bb02e0acSNicolas Bonnefon 195bb02e0acSNicolas Bonnefon // Line number to display for line at the given index 196bb02e0acSNicolas Bonnefon virtual qint64 displayLineNumber( int lineNumber ) const; 197bb02e0acSNicolas Bonnefon virtual qint64 maxDisplayLineNumber() const; 198bb02e0acSNicolas Bonnefon 199bb02e0acSNicolas Bonnefon // Get the overview associated with this view, or NULL if there is none 200bb02e0acSNicolas Bonnefon Overview* getOverview() const { return overview_; } 201bb02e0acSNicolas Bonnefon // Set the Overview and OverviewWidget 202bb02e0acSNicolas Bonnefon void setOverview( Overview* overview, OverviewWidget* overview_widget ); 203bb02e0acSNicolas Bonnefon 204bb02e0acSNicolas Bonnefon signals: 205bb02e0acSNicolas Bonnefon // Sent when a new line has been selected by the user. 206bb02e0acSNicolas Bonnefon void newSelection(int line); 207b297d2f4SNicolas Bonnefon // Sent up to the MainWindow to enable/disable the follow mode 208b297d2f4SNicolas Bonnefon void followModeChanged( bool enabled ); 209bb02e0acSNicolas Bonnefon // Sent when the view wants the QuickFind widget pattern to change. 210bb02e0acSNicolas Bonnefon void changeQuickFind( const QString& newPattern, 211bb02e0acSNicolas Bonnefon QuickFindMux::QFDirection newDirection ); 212bb02e0acSNicolas Bonnefon // Sent up when the current line number is updated 213bb02e0acSNicolas Bonnefon void updateLineNumber( int line ); 214bb02e0acSNicolas Bonnefon // Sent up when quickFind wants to show a message to the user. 215bb02e0acSNicolas Bonnefon void notifyQuickFind( const QFNotification& message ); 216bb02e0acSNicolas Bonnefon // Sent up when quickFind wants to clear the notification. 217bb02e0acSNicolas Bonnefon void clearQuickFindNotification(); 218bb02e0acSNicolas Bonnefon // Sent when the view ask for a line to be marked 219bb02e0acSNicolas Bonnefon // (click in the left margin). 220bb02e0acSNicolas Bonnefon void markLine( qint64 line ); 221bb02e0acSNicolas Bonnefon // Sent up when the user wants to add the selection to the search 222bb02e0acSNicolas Bonnefon void addToSearch( const QString& selection ); 223bb02e0acSNicolas Bonnefon // Sent up when the mouse is hovered over a line's margin 224bb02e0acSNicolas Bonnefon void mouseHoveredOverLine( qint64 line ); 225bb02e0acSNicolas Bonnefon // Sent up when the mouse leaves a line's margin 226bb02e0acSNicolas Bonnefon void mouseLeftHoveringZone(); 227bb02e0acSNicolas Bonnefon // Sent up for view initiated quickfind searches 228bb02e0acSNicolas Bonnefon void searchNext(); 229bb02e0acSNicolas Bonnefon void searchPrevious(); 23045ef183cSNicolas Bonnefon // Sent up when the user has moved within the view 23145ef183cSNicolas Bonnefon void activity(); 232bb02e0acSNicolas Bonnefon 233bb02e0acSNicolas Bonnefon public slots: 234bb02e0acSNicolas Bonnefon // Makes the widget select and display the passed line. 235bb02e0acSNicolas Bonnefon // Scrolling as necessary 236bb02e0acSNicolas Bonnefon void selectAndDisplayLine( int line ); 237bb02e0acSNicolas Bonnefon 238bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the next match. 239bb02e0acSNicolas Bonnefon virtual void searchForward(); 240bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the previous match. 241bb02e0acSNicolas Bonnefon virtual void searchBackward(); 242bb02e0acSNicolas Bonnefon 243bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the next match (incremental) 244bb02e0acSNicolas Bonnefon virtual void incrementallySearchForward(); 245bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the previous match (incremental) 246bb02e0acSNicolas Bonnefon virtual void incrementallySearchBackward(); 247bb02e0acSNicolas Bonnefon // Stop the current incremental search (typically when user press return) 248bb02e0acSNicolas Bonnefon virtual void incrementalSearchStop(); 249bb02e0acSNicolas Bonnefon // Abort the current incremental search (typically when user press esc) 250bb02e0acSNicolas Bonnefon virtual void incrementalSearchAbort(); 251bb02e0acSNicolas Bonnefon 252bb02e0acSNicolas Bonnefon // Signals the follow mode has been enabled. 253bb02e0acSNicolas Bonnefon void followSet( bool checked ); 254bb02e0acSNicolas Bonnefon 255bb02e0acSNicolas Bonnefon // Signal the on/off status of the overview has been changed. 256bb02e0acSNicolas Bonnefon void refreshOverview(); 257bb02e0acSNicolas Bonnefon 258bb02e0acSNicolas Bonnefon // Make the view jump to the specified line, regardless of weither it 259bb02e0acSNicolas Bonnefon // is on the screen or not. 260bb02e0acSNicolas Bonnefon // (does NOT emit followDisabled() ) 261bb02e0acSNicolas Bonnefon void jumpToLine( int line ); 262bb02e0acSNicolas Bonnefon 263bb02e0acSNicolas Bonnefon // Configure the setting of whether to show line number margin 264bb02e0acSNicolas Bonnefon void setLineNumbersVisible( bool lineNumbersVisible ); 265bb02e0acSNicolas Bonnefon 2665fa25391SNicolas Bonnefon // Force the next refresh to fully redraw the view by invalidating the cache. 2675fa25391SNicolas Bonnefon // To be used if the data might have changed. 2685fa25391SNicolas Bonnefon void forceRefresh(); 2695fa25391SNicolas Bonnefon 270bb02e0acSNicolas Bonnefon private slots: 271bb02e0acSNicolas Bonnefon void handlePatternUpdated(); 272bb02e0acSNicolas Bonnefon void addToSearch(); 273bb02e0acSNicolas Bonnefon void findNextSelected(); 274bb02e0acSNicolas Bonnefon void findPreviousSelected(); 275bb02e0acSNicolas Bonnefon void copy(); 276bb02e0acSNicolas Bonnefon 277bb02e0acSNicolas Bonnefon private: 278c7ef2b85SNicolas Bonnefon // Graphic parameters 279c7ef2b85SNicolas Bonnefon static constexpr int OVERVIEW_WIDTH = 27; 280ecd5e5f0SNicolas Bonnefon static constexpr int HOOK_THRESHOLD = 600; 281c7ef2b85SNicolas Bonnefon static constexpr int PULL_TO_FOLLOW_HOOKED_HEIGHT = 10; 282bb02e0acSNicolas Bonnefon 283bb02e0acSNicolas Bonnefon // Width of the bullet zone, including decoration 284bb02e0acSNicolas Bonnefon int bulletZoneWidthPx_; 285bb02e0acSNicolas Bonnefon 286bb02e0acSNicolas Bonnefon // Total size of all margins and decorations in pixels 287bb02e0acSNicolas Bonnefon int leftMarginPx_; 288bb02e0acSNicolas Bonnefon 289bb02e0acSNicolas Bonnefon // Digits buffer (for numeric keyboard entry) 290bb02e0acSNicolas Bonnefon DigitsBuffer digitsBuffer_; 291bb02e0acSNicolas Bonnefon 292bb02e0acSNicolas Bonnefon // Follow mode 293bb02e0acSNicolas Bonnefon bool followMode_; 294bb02e0acSNicolas Bonnefon 2950b05c6eaSNicolas Bonnefon // ElasticHook for follow mode 2960b05c6eaSNicolas Bonnefon ElasticHook followElasticHook_; 2970b05c6eaSNicolas Bonnefon 298bb02e0acSNicolas Bonnefon // Whether to show line numbers or not 299bb02e0acSNicolas Bonnefon bool lineNumbersVisible_; 300bb02e0acSNicolas Bonnefon 301bb02e0acSNicolas Bonnefon // Pointer to the CrawlerWidget's data set 302bb02e0acSNicolas Bonnefon const AbstractLogData* logData; 303bb02e0acSNicolas Bonnefon 304bb02e0acSNicolas Bonnefon // Pointer to the Overview object 305bb02e0acSNicolas Bonnefon Overview* overview_; 306bb02e0acSNicolas Bonnefon 307bb02e0acSNicolas Bonnefon // Pointer to the OverviewWidget, this class doesn't own it, 308bb02e0acSNicolas Bonnefon // but is responsible for displaying it (for purely aesthetic 309bb02e0acSNicolas Bonnefon // reasons). 310bb02e0acSNicolas Bonnefon OverviewWidget* overviewWidget_; 311bb02e0acSNicolas Bonnefon 312bb02e0acSNicolas Bonnefon bool selectionStarted_; 313bb02e0acSNicolas Bonnefon // Start of the selection (characters) 314bb02e0acSNicolas Bonnefon QPoint selectionStartPos_; 315bb02e0acSNicolas Bonnefon // Current end of the selection (characters) 316bb02e0acSNicolas Bonnefon QPoint selectionCurrentEndPos_; 317bb02e0acSNicolas Bonnefon QBasicTimer autoScrollTimer_; 318bb02e0acSNicolas Bonnefon 319bb02e0acSNicolas Bonnefon // Hovering state 320bb02e0acSNicolas Bonnefon // Last line that has been hoovered on, -1 if none 321bb02e0acSNicolas Bonnefon qint64 lastHoveredLine_; 322bb02e0acSNicolas Bonnefon 323bb02e0acSNicolas Bonnefon // Marks (left margin click) 324bb02e0acSNicolas Bonnefon bool markingClickInitiated_; 325bb02e0acSNicolas Bonnefon qint64 markingClickLine_; 326bb02e0acSNicolas Bonnefon 327bb02e0acSNicolas Bonnefon Selection selection_; 328*9f0249b2SNicolas Bonnefon 329*9f0249b2SNicolas Bonnefon // Position of the view, those are crucial to control drawing 330*9f0249b2SNicolas Bonnefon // firstLine gives the position of the view, 331*9f0249b2SNicolas Bonnefon // lastLineAligned == true make the bottom of the last line aligned 332*9f0249b2SNicolas Bonnefon // rather than the top of the top one. 3332493b508SNicolas Bonnefon LineNumber firstLine; 334*9f0249b2SNicolas Bonnefon bool lastLineAligned; 335bb02e0acSNicolas Bonnefon int firstCol; 336bb02e0acSNicolas Bonnefon 337bb02e0acSNicolas Bonnefon // Text handling 338bb02e0acSNicolas Bonnefon int charWidth_; 339bb02e0acSNicolas Bonnefon int charHeight_; 340bb02e0acSNicolas Bonnefon 341bb02e0acSNicolas Bonnefon // Popup menu 342bb02e0acSNicolas Bonnefon QMenu* popupMenu_; 343bb02e0acSNicolas Bonnefon QAction* copyAction_; 344bb02e0acSNicolas Bonnefon QAction* findNextAction_; 345bb02e0acSNicolas Bonnefon QAction* findPreviousAction_; 346bb02e0acSNicolas Bonnefon QAction* addToSearchAction_; 347bb02e0acSNicolas Bonnefon 348bb02e0acSNicolas Bonnefon // Pointer to the CrawlerWidget's QFP object 349bb02e0acSNicolas Bonnefon const QuickFindPattern* const quickFindPattern_; 350bb02e0acSNicolas Bonnefon // Our own QuickFind object 351bb02e0acSNicolas Bonnefon QuickFind quickFind_; 352bb02e0acSNicolas Bonnefon 3538bda3285SNicolas Bonnefon #ifdef GLOGG_PERF_MEASURE_FPS 354045703daSNicolas Bonnefon // Performance measurement 355045703daSNicolas Bonnefon PerfCounter perfCounter_; 3568bda3285SNicolas Bonnefon #endif 357045703daSNicolas Bonnefon 3582493b508SNicolas Bonnefon // Current "pull to follow" bar height 3592493b508SNicolas Bonnefon int pullToFollowHeight_; 3602493b508SNicolas Bonnefon 361a9448ba0SNicolas Bonnefon // Cache pixmap and associated info 362a9448ba0SNicolas Bonnefon struct TextAreaCache { 363a9448ba0SNicolas Bonnefon QPixmap pixmap_; 364a9448ba0SNicolas Bonnefon bool invalid_; 365a9448ba0SNicolas Bonnefon int first_line_; 366a9448ba0SNicolas Bonnefon int last_line_; 367a9448ba0SNicolas Bonnefon int first_column_; 368a9448ba0SNicolas Bonnefon }; 369ac6602a5SNicolas Bonnefon struct PullToFollowCache { 370ac6602a5SNicolas Bonnefon QPixmap pixmap_; 371ac6602a5SNicolas Bonnefon int nb_columns_; 372ac6602a5SNicolas Bonnefon }; 373ac6602a5SNicolas Bonnefon TextAreaCache textAreaCache_ = { {}, true, 0, 0, 0 }; 374ac6602a5SNicolas Bonnefon PullToFollowCache pullToFollowCache_ = { {}, 0 }; 375a9448ba0SNicolas Bonnefon 3762493b508SNicolas Bonnefon LineNumber getNbVisibleLines() const; 377bb02e0acSNicolas Bonnefon int getNbVisibleCols() const; 378bb02e0acSNicolas Bonnefon QPoint convertCoordToFilePos( const QPoint& pos ) const; 379bb02e0acSNicolas Bonnefon int convertCoordToLine( int yPos ) const; 380bb02e0acSNicolas Bonnefon int convertCoordToColumn( int xPos ) const; 3812493b508SNicolas Bonnefon void displayLine( LineNumber line ); 382bb02e0acSNicolas Bonnefon void moveSelection( int y ); 383bb02e0acSNicolas Bonnefon void jumpToStartOfLine(); 384bb02e0acSNicolas Bonnefon void jumpToEndOfLine(); 385bb02e0acSNicolas Bonnefon void jumpToRightOfScreen(); 386bb02e0acSNicolas Bonnefon void jumpToTop(); 387bb02e0acSNicolas Bonnefon void jumpToBottom(); 388bb02e0acSNicolas Bonnefon void selectWordAtPosition( const QPoint& pos ); 389bb02e0acSNicolas Bonnefon 390bb02e0acSNicolas Bonnefon void createMenu(); 391bb02e0acSNicolas Bonnefon 392bb02e0acSNicolas Bonnefon void considerMouseHovering( int x_pos, int y_pos ); 393bb02e0acSNicolas Bonnefon 394bb02e0acSNicolas Bonnefon // Search functions (for n/N) 395bb02e0acSNicolas Bonnefon void searchUsingFunction( qint64 (QuickFind::*search_function)() ); 396bb02e0acSNicolas Bonnefon 3970b05c6eaSNicolas Bonnefon void updateScrollBars(); 3980b05c6eaSNicolas Bonnefon 399ac6602a5SNicolas Bonnefon void drawTextArea( QPaintDevice* paint_device, int32_t delta_y ); 400ac6602a5SNicolas Bonnefon QPixmap drawPullToFollowBar( int width, float pixel_ratio ); 401a9448ba0SNicolas Bonnefon 402b297d2f4SNicolas Bonnefon void disableFollow(); 403b297d2f4SNicolas Bonnefon 404bb02e0acSNicolas Bonnefon // Utils functions 405bb02e0acSNicolas Bonnefon bool isCharWord( char c ); 406bb02e0acSNicolas Bonnefon void updateGlobalSelection(); 407bb02e0acSNicolas Bonnefon }; 408bb02e0acSNicolas Bonnefon 409bb02e0acSNicolas Bonnefon #endif 410