1*bb02e0acSNicolas Bonnefon /* 2*bb02e0acSNicolas Bonnefon * Copyright (C) 2009, 2010, 2012 Nicolas Bonnefon and other contributors 3*bb02e0acSNicolas Bonnefon * 4*bb02e0acSNicolas Bonnefon * This file is part of glogg. 5*bb02e0acSNicolas Bonnefon * 6*bb02e0acSNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 7*bb02e0acSNicolas Bonnefon * it under the terms of the GNU General Public License as published by 8*bb02e0acSNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 9*bb02e0acSNicolas Bonnefon * (at your option) any later version. 10*bb02e0acSNicolas Bonnefon * 11*bb02e0acSNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 12*bb02e0acSNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*bb02e0acSNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*bb02e0acSNicolas Bonnefon * GNU General Public License for more details. 15*bb02e0acSNicolas Bonnefon * 16*bb02e0acSNicolas Bonnefon * You should have received a copy of the GNU General Public License 17*bb02e0acSNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18*bb02e0acSNicolas Bonnefon */ 19*bb02e0acSNicolas Bonnefon 20*bb02e0acSNicolas Bonnefon // This file implements the FilteredView concrete class. 21*bb02e0acSNicolas Bonnefon // Most of the actual drawing and event management is done in AbstractLogView 22*bb02e0acSNicolas Bonnefon // Only behaviour specific to the filtered (bottom) view is implemented here. 23*bb02e0acSNicolas Bonnefon 24*bb02e0acSNicolas Bonnefon #include <cassert> 25*bb02e0acSNicolas Bonnefon 26*bb02e0acSNicolas Bonnefon #include "filteredview.h" 27*bb02e0acSNicolas Bonnefon 28*bb02e0acSNicolas Bonnefon FilteredView::FilteredView( LogFilteredData* newLogData, 29*bb02e0acSNicolas Bonnefon const QuickFindPattern* const quickFindPattern, QWidget* parent ) 30*bb02e0acSNicolas Bonnefon : AbstractLogView( newLogData, quickFindPattern, parent ) 31*bb02e0acSNicolas Bonnefon { 32*bb02e0acSNicolas Bonnefon // We keep a copy of the filtered data for fast lookup of the line type 33*bb02e0acSNicolas Bonnefon logFilteredData_ = newLogData; 34*bb02e0acSNicolas Bonnefon } 35*bb02e0acSNicolas Bonnefon 36*bb02e0acSNicolas Bonnefon void FilteredView::setVisibility( Visibility visi ) 37*bb02e0acSNicolas Bonnefon { 38*bb02e0acSNicolas Bonnefon assert( logFilteredData_ ); 39*bb02e0acSNicolas Bonnefon 40*bb02e0acSNicolas Bonnefon LogFilteredData::Visibility data_visibility = 41*bb02e0acSNicolas Bonnefon LogFilteredData::MarksAndMatches; 42*bb02e0acSNicolas Bonnefon switch ( visi ) { 43*bb02e0acSNicolas Bonnefon case MarksOnly: 44*bb02e0acSNicolas Bonnefon data_visibility = LogFilteredData::MarksOnly; 45*bb02e0acSNicolas Bonnefon break; 46*bb02e0acSNicolas Bonnefon case MatchesOnly: 47*bb02e0acSNicolas Bonnefon data_visibility = LogFilteredData::MatchesOnly; 48*bb02e0acSNicolas Bonnefon break; 49*bb02e0acSNicolas Bonnefon case MarksAndMatches: 50*bb02e0acSNicolas Bonnefon data_visibility = LogFilteredData::MarksAndMatches; 51*bb02e0acSNicolas Bonnefon break; 52*bb02e0acSNicolas Bonnefon }; 53*bb02e0acSNicolas Bonnefon 54*bb02e0acSNicolas Bonnefon logFilteredData_->setVisibility( data_visibility ); 55*bb02e0acSNicolas Bonnefon 56*bb02e0acSNicolas Bonnefon updateData(); 57*bb02e0acSNicolas Bonnefon } 58*bb02e0acSNicolas Bonnefon 59*bb02e0acSNicolas Bonnefon // For the filtered view, a line is always matching! 60*bb02e0acSNicolas Bonnefon AbstractLogView::LineType FilteredView::lineType( int lineNumber ) const 61*bb02e0acSNicolas Bonnefon { 62*bb02e0acSNicolas Bonnefon LogFilteredData::FilteredLineType type = 63*bb02e0acSNicolas Bonnefon logFilteredData_->filteredLineTypeByIndex( lineNumber ); 64*bb02e0acSNicolas Bonnefon if ( type == LogFilteredData::Mark ) 65*bb02e0acSNicolas Bonnefon return Marked; 66*bb02e0acSNicolas Bonnefon else 67*bb02e0acSNicolas Bonnefon return Match; 68*bb02e0acSNicolas Bonnefon } 69*bb02e0acSNicolas Bonnefon 70*bb02e0acSNicolas Bonnefon qint64 FilteredView::displayLineNumber( int lineNumber ) const 71*bb02e0acSNicolas Bonnefon { 72*bb02e0acSNicolas Bonnefon // Display a 1-based index 73*bb02e0acSNicolas Bonnefon return logFilteredData_->getMatchingLineNumber( lineNumber ) + 1; 74*bb02e0acSNicolas Bonnefon } 75*bb02e0acSNicolas Bonnefon 76*bb02e0acSNicolas Bonnefon qint64 FilteredView::maxDisplayLineNumber() const 77*bb02e0acSNicolas Bonnefon { 78*bb02e0acSNicolas Bonnefon return logFilteredData_->getNbTotalLines(); 79*bb02e0acSNicolas Bonnefon } 80