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 17678dc0425SNicolas Bonnefon bool isFollowEnabled() const { return followMode_; } 17778dc0425SNicolas Bonnefon 178bb02e0acSNicolas Bonnefon protected: 1791853a1fdSNicolas Bonnefon virtual void mousePressEvent( QMouseEvent* mouseEvent ); 1801853a1fdSNicolas Bonnefon virtual void mouseMoveEvent( QMouseEvent* mouseEvent ); 1811853a1fdSNicolas Bonnefon virtual void mouseReleaseEvent( QMouseEvent* ); 1821853a1fdSNicolas Bonnefon virtual void mouseDoubleClickEvent( QMouseEvent* mouseEvent ); 1831853a1fdSNicolas Bonnefon virtual void timerEvent( QTimerEvent* timerEvent ); 1841853a1fdSNicolas Bonnefon virtual void changeEvent( QEvent* changeEvent ); 1851853a1fdSNicolas Bonnefon virtual void paintEvent( QPaintEvent* paintEvent ); 1861853a1fdSNicolas Bonnefon virtual void resizeEvent( QResizeEvent* resizeEvent ); 1871853a1fdSNicolas Bonnefon virtual void scrollContentsBy( int dx, int dy ); 1881853a1fdSNicolas Bonnefon virtual void keyPressEvent( QKeyEvent* keyEvent ); 1891853a1fdSNicolas Bonnefon virtual void wheelEvent( QWheelEvent* wheelEvent ); 1901853a1fdSNicolas Bonnefon virtual bool event( QEvent * e ); 191bb02e0acSNicolas Bonnefon 192bb02e0acSNicolas Bonnefon // Must be implemented to return wether the line number is 193bb02e0acSNicolas Bonnefon // a match, a mark or just a normal line (used for coloured bullets) 194bb02e0acSNicolas Bonnefon enum LineType { Normal, Marked, Match }; 195bb02e0acSNicolas Bonnefon virtual LineType lineType( int lineNumber ) const = 0; 196bb02e0acSNicolas Bonnefon 197bb02e0acSNicolas Bonnefon // Line number to display for line at the given index 198bb02e0acSNicolas Bonnefon virtual qint64 displayLineNumber( int lineNumber ) const; 199bb02e0acSNicolas Bonnefon virtual qint64 maxDisplayLineNumber() const; 200bb02e0acSNicolas Bonnefon 201bb02e0acSNicolas Bonnefon // Get the overview associated with this view, or NULL if there is none 202bb02e0acSNicolas Bonnefon Overview* getOverview() const { return overview_; } 203bb02e0acSNicolas Bonnefon // Set the Overview and OverviewWidget 204bb02e0acSNicolas Bonnefon void setOverview( Overview* overview, OverviewWidget* overview_widget ); 205bb02e0acSNicolas Bonnefon 206bb02e0acSNicolas Bonnefon signals: 207bb02e0acSNicolas Bonnefon // Sent when a new line has been selected by the user. 208bb02e0acSNicolas Bonnefon void newSelection(int line); 209b297d2f4SNicolas Bonnefon // Sent up to the MainWindow to enable/disable the follow mode 210b297d2f4SNicolas Bonnefon void followModeChanged( bool enabled ); 211bb02e0acSNicolas Bonnefon // Sent when the view wants the QuickFind widget pattern to change. 212bb02e0acSNicolas Bonnefon void changeQuickFind( const QString& newPattern, 213bb02e0acSNicolas Bonnefon QuickFindMux::QFDirection newDirection ); 214bb02e0acSNicolas Bonnefon // Sent up when the current line number is updated 215bb02e0acSNicolas Bonnefon void updateLineNumber( int line ); 216bb02e0acSNicolas Bonnefon // Sent up when quickFind wants to show a message to the user. 217bb02e0acSNicolas Bonnefon void notifyQuickFind( const QFNotification& message ); 218bb02e0acSNicolas Bonnefon // Sent up when quickFind wants to clear the notification. 219bb02e0acSNicolas Bonnefon void clearQuickFindNotification(); 220bb02e0acSNicolas Bonnefon // Sent when the view ask for a line to be marked 221bb02e0acSNicolas Bonnefon // (click in the left margin). 222bb02e0acSNicolas Bonnefon void markLine( qint64 line ); 223bb02e0acSNicolas Bonnefon // Sent up when the user wants to add the selection to the search 224bb02e0acSNicolas Bonnefon void addToSearch( const QString& selection ); 225bb02e0acSNicolas Bonnefon // Sent up when the mouse is hovered over a line's margin 226bb02e0acSNicolas Bonnefon void mouseHoveredOverLine( qint64 line ); 227bb02e0acSNicolas Bonnefon // Sent up when the mouse leaves a line's margin 228bb02e0acSNicolas Bonnefon void mouseLeftHoveringZone(); 229bb02e0acSNicolas Bonnefon // Sent up for view initiated quickfind searches 230bb02e0acSNicolas Bonnefon void searchNext(); 231bb02e0acSNicolas Bonnefon void searchPrevious(); 23245ef183cSNicolas Bonnefon // Sent up when the user has moved within the view 23345ef183cSNicolas Bonnefon void activity(); 234bb02e0acSNicolas Bonnefon 235bb02e0acSNicolas Bonnefon public slots: 236bb02e0acSNicolas Bonnefon // Makes the widget select and display the passed line. 237bb02e0acSNicolas Bonnefon // Scrolling as necessary 238bb02e0acSNicolas Bonnefon void selectAndDisplayLine( int line ); 239bb02e0acSNicolas Bonnefon 240bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the next match. 241bb02e0acSNicolas Bonnefon virtual void searchForward(); 242bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the previous match. 243bb02e0acSNicolas Bonnefon virtual void searchBackward(); 244bb02e0acSNicolas Bonnefon 245bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the next match (incremental) 246bb02e0acSNicolas Bonnefon virtual void incrementallySearchForward(); 247bb02e0acSNicolas Bonnefon // Use the current QFP to go and select the previous match (incremental) 248bb02e0acSNicolas Bonnefon virtual void incrementallySearchBackward(); 249bb02e0acSNicolas Bonnefon // Stop the current incremental search (typically when user press return) 250bb02e0acSNicolas Bonnefon virtual void incrementalSearchStop(); 251bb02e0acSNicolas Bonnefon // Abort the current incremental search (typically when user press esc) 252bb02e0acSNicolas Bonnefon virtual void incrementalSearchAbort(); 253bb02e0acSNicolas Bonnefon 254bb02e0acSNicolas Bonnefon // Signals the follow mode has been enabled. 255bb02e0acSNicolas Bonnefon void followSet( bool checked ); 256bb02e0acSNicolas Bonnefon 257bb02e0acSNicolas Bonnefon // Signal the on/off status of the overview has been changed. 258bb02e0acSNicolas Bonnefon void refreshOverview(); 259bb02e0acSNicolas Bonnefon 260bb02e0acSNicolas Bonnefon // Make the view jump to the specified line, regardless of weither it 261bb02e0acSNicolas Bonnefon // is on the screen or not. 262bb02e0acSNicolas Bonnefon // (does NOT emit followDisabled() ) 263bb02e0acSNicolas Bonnefon void jumpToLine( int line ); 264bb02e0acSNicolas Bonnefon 265bb02e0acSNicolas Bonnefon // Configure the setting of whether to show line number margin 266bb02e0acSNicolas Bonnefon void setLineNumbersVisible( bool lineNumbersVisible ); 267bb02e0acSNicolas Bonnefon 2685fa25391SNicolas Bonnefon // Force the next refresh to fully redraw the view by invalidating the cache. 2695fa25391SNicolas Bonnefon // To be used if the data might have changed. 2705fa25391SNicolas Bonnefon void forceRefresh(); 2715fa25391SNicolas Bonnefon 272bb02e0acSNicolas Bonnefon private slots: 273bb02e0acSNicolas Bonnefon void handlePatternUpdated(); 274bb02e0acSNicolas Bonnefon void addToSearch(); 275bb02e0acSNicolas Bonnefon void findNextSelected(); 276bb02e0acSNicolas Bonnefon void findPreviousSelected(); 277bb02e0acSNicolas Bonnefon void copy(); 278bb02e0acSNicolas Bonnefon 279bb02e0acSNicolas Bonnefon private: 280c7ef2b85SNicolas Bonnefon // Graphic parameters 281c7ef2b85SNicolas Bonnefon static constexpr int OVERVIEW_WIDTH = 27; 282ecd5e5f0SNicolas Bonnefon static constexpr int HOOK_THRESHOLD = 600; 283c7ef2b85SNicolas Bonnefon static constexpr int PULL_TO_FOLLOW_HOOKED_HEIGHT = 10; 284bb02e0acSNicolas Bonnefon 285bb02e0acSNicolas Bonnefon // Width of the bullet zone, including decoration 286bb02e0acSNicolas Bonnefon int bulletZoneWidthPx_; 287bb02e0acSNicolas Bonnefon 288bb02e0acSNicolas Bonnefon // Total size of all margins and decorations in pixels 289bb02e0acSNicolas Bonnefon int leftMarginPx_; 290bb02e0acSNicolas Bonnefon 291bb02e0acSNicolas Bonnefon // Digits buffer (for numeric keyboard entry) 292bb02e0acSNicolas Bonnefon DigitsBuffer digitsBuffer_; 293bb02e0acSNicolas Bonnefon 294bb02e0acSNicolas Bonnefon // Follow mode 295bb02e0acSNicolas Bonnefon bool followMode_; 296bb02e0acSNicolas Bonnefon 2970b05c6eaSNicolas Bonnefon // ElasticHook for follow mode 2980b05c6eaSNicolas Bonnefon ElasticHook followElasticHook_; 2990b05c6eaSNicolas Bonnefon 300bb02e0acSNicolas Bonnefon // Whether to show line numbers or not 301bb02e0acSNicolas Bonnefon bool lineNumbersVisible_; 302bb02e0acSNicolas Bonnefon 303bb02e0acSNicolas Bonnefon // Pointer to the CrawlerWidget's data set 304bb02e0acSNicolas Bonnefon const AbstractLogData* logData; 305bb02e0acSNicolas Bonnefon 306bb02e0acSNicolas Bonnefon // Pointer to the Overview object 307bb02e0acSNicolas Bonnefon Overview* overview_; 308bb02e0acSNicolas Bonnefon 309bb02e0acSNicolas Bonnefon // Pointer to the OverviewWidget, this class doesn't own it, 310bb02e0acSNicolas Bonnefon // but is responsible for displaying it (for purely aesthetic 311bb02e0acSNicolas Bonnefon // reasons). 312bb02e0acSNicolas Bonnefon OverviewWidget* overviewWidget_; 313bb02e0acSNicolas Bonnefon 314bb02e0acSNicolas Bonnefon bool selectionStarted_; 315bb02e0acSNicolas Bonnefon // Start of the selection (characters) 316bb02e0acSNicolas Bonnefon QPoint selectionStartPos_; 317bb02e0acSNicolas Bonnefon // Current end of the selection (characters) 318bb02e0acSNicolas Bonnefon QPoint selectionCurrentEndPos_; 319bb02e0acSNicolas Bonnefon QBasicTimer autoScrollTimer_; 320bb02e0acSNicolas Bonnefon 321bb02e0acSNicolas Bonnefon // Hovering state 322bb02e0acSNicolas Bonnefon // Last line that has been hoovered on, -1 if none 323bb02e0acSNicolas Bonnefon qint64 lastHoveredLine_; 324bb02e0acSNicolas Bonnefon 325bb02e0acSNicolas Bonnefon // Marks (left margin click) 326bb02e0acSNicolas Bonnefon bool markingClickInitiated_; 327bb02e0acSNicolas Bonnefon qint64 markingClickLine_; 328bb02e0acSNicolas Bonnefon 329bb02e0acSNicolas Bonnefon Selection selection_; 3309f0249b2SNicolas Bonnefon 3319f0249b2SNicolas Bonnefon // Position of the view, those are crucial to control drawing 3329f0249b2SNicolas Bonnefon // firstLine gives the position of the view, 3339f0249b2SNicolas Bonnefon // lastLineAligned == true make the bottom of the last line aligned 3349f0249b2SNicolas Bonnefon // rather than the top of the top one. 3352493b508SNicolas Bonnefon LineNumber firstLine; 3369f0249b2SNicolas Bonnefon bool lastLineAligned; 337bb02e0acSNicolas Bonnefon int firstCol; 338bb02e0acSNicolas Bonnefon 339bb02e0acSNicolas Bonnefon // Text handling 340bb02e0acSNicolas Bonnefon int charWidth_; 341bb02e0acSNicolas Bonnefon int charHeight_; 342bb02e0acSNicolas Bonnefon 343bb02e0acSNicolas Bonnefon // Popup menu 344bb02e0acSNicolas Bonnefon QMenu* popupMenu_; 345bb02e0acSNicolas Bonnefon QAction* copyAction_; 346bb02e0acSNicolas Bonnefon QAction* findNextAction_; 347bb02e0acSNicolas Bonnefon QAction* findPreviousAction_; 348bb02e0acSNicolas Bonnefon QAction* addToSearchAction_; 349bb02e0acSNicolas Bonnefon 350bb02e0acSNicolas Bonnefon // Pointer to the CrawlerWidget's QFP object 351bb02e0acSNicolas Bonnefon const QuickFindPattern* const quickFindPattern_; 352bb02e0acSNicolas Bonnefon // Our own QuickFind object 353bb02e0acSNicolas Bonnefon QuickFind quickFind_; 354bb02e0acSNicolas Bonnefon 3558bda3285SNicolas Bonnefon #ifdef GLOGG_PERF_MEASURE_FPS 356045703daSNicolas Bonnefon // Performance measurement 357045703daSNicolas Bonnefon PerfCounter perfCounter_; 3588bda3285SNicolas Bonnefon #endif 359045703daSNicolas Bonnefon 360*257b1c50SNicolas Bonnefon // Vertical offset (in pixels) at which the first line of text is written 361*257b1c50SNicolas Bonnefon int drawingTopOffset_ = 0; 3622493b508SNicolas Bonnefon 363a9448ba0SNicolas Bonnefon // Cache pixmap and associated info 364a9448ba0SNicolas Bonnefon struct TextAreaCache { 365a9448ba0SNicolas Bonnefon QPixmap pixmap_; 366a9448ba0SNicolas Bonnefon bool invalid_; 367a9448ba0SNicolas Bonnefon int first_line_; 368a9448ba0SNicolas Bonnefon int last_line_; 369a9448ba0SNicolas Bonnefon int first_column_; 370a9448ba0SNicolas Bonnefon }; 371ac6602a5SNicolas Bonnefon struct PullToFollowCache { 372ac6602a5SNicolas Bonnefon QPixmap pixmap_; 373ac6602a5SNicolas Bonnefon int nb_columns_; 374ac6602a5SNicolas Bonnefon }; 375ac6602a5SNicolas Bonnefon TextAreaCache textAreaCache_ = { {}, true, 0, 0, 0 }; 376ac6602a5SNicolas Bonnefon PullToFollowCache pullToFollowCache_ = { {}, 0 }; 377a9448ba0SNicolas Bonnefon 3782493b508SNicolas Bonnefon LineNumber getNbVisibleLines() const; 379bb02e0acSNicolas Bonnefon int getNbVisibleCols() const; 380bb02e0acSNicolas Bonnefon QPoint convertCoordToFilePos( const QPoint& pos ) const; 381bb02e0acSNicolas Bonnefon int convertCoordToLine( int yPos ) const; 382bb02e0acSNicolas Bonnefon int convertCoordToColumn( int xPos ) const; 3832493b508SNicolas Bonnefon void displayLine( LineNumber line ); 384bb02e0acSNicolas Bonnefon void moveSelection( int y ); 385bb02e0acSNicolas Bonnefon void jumpToStartOfLine(); 386bb02e0acSNicolas Bonnefon void jumpToEndOfLine(); 387bb02e0acSNicolas Bonnefon void jumpToRightOfScreen(); 388bb02e0acSNicolas Bonnefon void jumpToTop(); 389bb02e0acSNicolas Bonnefon void jumpToBottom(); 390bb02e0acSNicolas Bonnefon void selectWordAtPosition( const QPoint& pos ); 391bb02e0acSNicolas Bonnefon 392bb02e0acSNicolas Bonnefon void createMenu(); 393bb02e0acSNicolas Bonnefon 394bb02e0acSNicolas Bonnefon void considerMouseHovering( int x_pos, int y_pos ); 395bb02e0acSNicolas Bonnefon 396bb02e0acSNicolas Bonnefon // Search functions (for n/N) 397bb02e0acSNicolas Bonnefon void searchUsingFunction( qint64 (QuickFind::*search_function)() ); 398bb02e0acSNicolas Bonnefon 3990b05c6eaSNicolas Bonnefon void updateScrollBars(); 4000b05c6eaSNicolas Bonnefon 401ac6602a5SNicolas Bonnefon void drawTextArea( QPaintDevice* paint_device, int32_t delta_y ); 402ac6602a5SNicolas Bonnefon QPixmap drawPullToFollowBar( int width, float pixel_ratio ); 403a9448ba0SNicolas Bonnefon 404b297d2f4SNicolas Bonnefon void disableFollow(); 405b297d2f4SNicolas Bonnefon 406bb02e0acSNicolas Bonnefon // Utils functions 407bb02e0acSNicolas Bonnefon bool isCharWord( char c ); 408bb02e0acSNicolas Bonnefon void updateGlobalSelection(); 409bb02e0acSNicolas Bonnefon }; 410bb02e0acSNicolas Bonnefon 411bb02e0acSNicolas Bonnefon #endif 412