Example #1
0
ViewInterface* Session::openAlways(const QString& file_name,
        std::function<ViewInterface*()> view_factory,
        const QString& view_context )
{
    // Create the data objects
    auto log_data          = std::make_shared<LogData>();
    auto log_filtered_data =
        std::shared_ptr<LogFilteredData>( log_data->getNewFilteredData() );

    ViewInterface* view = view_factory();
    view->setData( log_data, log_filtered_data );
    view->setQuickFindPattern( quickFindPattern_ );
    view->setSavedSearches( savedSearches_ );

    if ( !view_context.isEmpty() )
        view->setViewContext( view_context );

    // Insert in the hash
    openFiles_.insert( { view,
            { file_name,
            log_data,
            log_filtered_data,
            view } } );

    // Start loading the file
    log_data->attachFile( file_name );

    return view;
}
Example #2
0
ViewInterface* Session::open( const std::string& file_name,
        std::function<ViewInterface*()> view_factory )
{
    ViewInterface* view = nullptr;

    QFileInfo fileInfo( file_name.c_str() );
    if ( fileInfo.isReadable() )
    {
        // Create the data objects
        auto log_data          = std::make_shared<LogData>();
        auto log_filtered_data =
            std::shared_ptr<LogFilteredData>( log_data->getNewFilteredData() );

        view = view_factory();
        view->setData( log_data, log_filtered_data );

        // Insert in the hash
        open_files_.insert( { view,
                { file_name,
                  log_data,
                  log_filtered_data,
                  view } } );

        // Start loading the file
        log_data->attachFile( QString( file_name.c_str() ) );
    }
    else {
        // throw
    }

    return view;
}