1d96f3f21SNicolas Bonnefon /* 2d96f3f21SNicolas Bonnefon * Copyright (C) 2013 Nicolas Bonnefon and other contributors 3d96f3f21SNicolas Bonnefon * 4d96f3f21SNicolas Bonnefon * This file is part of glogg. 5d96f3f21SNicolas Bonnefon * 6d96f3f21SNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 7d96f3f21SNicolas Bonnefon * it under the terms of the GNU General Public License as published by 8d96f3f21SNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 9d96f3f21SNicolas Bonnefon * (at your option) any later version. 10d96f3f21SNicolas Bonnefon * 11d96f3f21SNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 12d96f3f21SNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 13d96f3f21SNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14d96f3f21SNicolas Bonnefon * GNU General Public License for more details. 15d96f3f21SNicolas Bonnefon * 16d96f3f21SNicolas Bonnefon * You should have received a copy of the GNU General Public License 17d96f3f21SNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18d96f3f21SNicolas Bonnefon */ 19d96f3f21SNicolas Bonnefon 20d96f3f21SNicolas Bonnefon #include "session.h" 21d96f3f21SNicolas Bonnefon 22*039481acSNicolas Bonnefon #include <QFileInfo> 23*039481acSNicolas Bonnefon 24d96f3f21SNicolas Bonnefon #include "viewinterface.h" 25*039481acSNicolas Bonnefon #include "data/logdata.h" 26*039481acSNicolas Bonnefon #include "data/logfiltereddata.h" 27d96f3f21SNicolas Bonnefon 28d96f3f21SNicolas Bonnefon Session::Session() 29d96f3f21SNicolas Bonnefon { 30d96f3f21SNicolas Bonnefon } 31d96f3f21SNicolas Bonnefon 32d96f3f21SNicolas Bonnefon Session::~Session() 33d96f3f21SNicolas Bonnefon { 34d96f3f21SNicolas Bonnefon // FIXME Clean up all the data objects... 35d96f3f21SNicolas Bonnefon } 36f0708ca8SNicolas Bonnefon 37f0708ca8SNicolas Bonnefon ViewInterface* Session::open( const std::string& file_name, 38f0708ca8SNicolas Bonnefon std::function<ViewInterface*()> view_factory ) 39f0708ca8SNicolas Bonnefon { 40*039481acSNicolas Bonnefon ViewInterface* view = nullptr; 41*039481acSNicolas Bonnefon 42*039481acSNicolas Bonnefon QFileInfo fileInfo( file_name.c_str() ); 43*039481acSNicolas Bonnefon if ( fileInfo.isReadable() ) 44*039481acSNicolas Bonnefon { 45*039481acSNicolas Bonnefon // Create the data objects 46*039481acSNicolas Bonnefon logData_ = std::shared_ptr<LogData>( new LogData() ); 47*039481acSNicolas Bonnefon logFilteredData_ = 48*039481acSNicolas Bonnefon std::shared_ptr<LogFilteredData>( logData_->getNewFilteredData() ); 49*039481acSNicolas Bonnefon 50*039481acSNicolas Bonnefon view = view_factory(); 51*039481acSNicolas Bonnefon view->setData( logData_, logFilteredData_ ); 52*039481acSNicolas Bonnefon 53*039481acSNicolas Bonnefon // Start loading the file 54*039481acSNicolas Bonnefon logData_->attachFile( QString( file_name.c_str() ) ); 55*039481acSNicolas Bonnefon } 56*039481acSNicolas Bonnefon else { 57*039481acSNicolas Bonnefon // throw 58*039481acSNicolas Bonnefon } 59f0708ca8SNicolas Bonnefon 60f0708ca8SNicolas Bonnefon return view; 61f0708ca8SNicolas Bonnefon } 62*039481acSNicolas Bonnefon /* 63*039481acSNicolas Bonnefon void CrawlerWidget::stopLoading() 64*039481acSNicolas Bonnefon { 65*039481acSNicolas Bonnefon logFilteredData_->interruptSearch(); 66*039481acSNicolas Bonnefon logData_->interruptLoading(); 67*039481acSNicolas Bonnefon } 68*039481acSNicolas Bonnefon 69*039481acSNicolas Bonnefon void CrawlerWidget::getFileInfo( qint64* fileSize, int* fileNbLine, 70*039481acSNicolas Bonnefon QDateTime* lastModified ) const 71*039481acSNicolas Bonnefon { 72*039481acSNicolas Bonnefon *fileSize = logData_->getFileSize(); 73*039481acSNicolas Bonnefon *fileNbLine = logData_->getNbLine(); 74*039481acSNicolas Bonnefon *lastModified = logData_->getLastModifiedDate(); 75*039481acSNicolas Bonnefon } 76*039481acSNicolas Bonnefon */ 77