LCOV - code coverage report
Current view: top level - src/utils/foxtools - MFXRecentNetworks.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 80.0 % 30 24
Test Date: 2026-03-02 16:00:03 Functions: 66.7 % 6 4

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2004-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    MFXRecentNetworks.cpp
      15              : /// @author  Pablo Alvarez Lopez
      16              : /// @date    Feb 2021
      17              : ///
      18              : //
      19              : /****************************************************************************/
      20              : // ===========================================================================
      21              : // included modules
      22              : // ===========================================================================
      23              : #include <config.h>
      24              : 
      25              : #include "MFXRecentNetworks.h"
      26              : 
      27              : 
      28              : // ===========================================================================
      29              : // FOX callback mapping
      30              : // ===========================================================================
      31              : 
      32              : FXDEFMAP(MFXRecentNetworks) MFXRecentNetworksMap[] = {
      33              :     FXMAPFUNC(SEL_UPDATE,   MFXRecentNetworks::ID_NOFILES,   MFXRecentNetworks::onUpdNoFiles),
      34              :     FXMAPFUNCS(SEL_UPDATE,  FXRecentFiles::ID_FILE_1,       FXRecentFiles::ID_FILE_10,  MFXRecentNetworks::onUpdFile),
      35              : };
      36              : 
      37              : // Object implementation
      38      9894517 : FXIMPLEMENT(MFXRecentNetworks, FXRecentFiles, MFXRecentNetworksMap, ARRAYNUMBER(MFXRecentNetworksMap))
      39              : 
      40              : // ===========================================================================
      41              : // member method definitions
      42              : // ===========================================================================
      43              : 
      44            0 : MFXRecentNetworks::MFXRecentNetworks() :
      45            0 :     FXRecentFiles() {
      46            0 : }
      47              : 
      48              : 
      49        16920 : MFXRecentNetworks::MFXRecentNetworks(FXApp* a, const FXString& gp) :
      50        16920 :     FXRecentFiles(a, gp) {
      51        16920 : }
      52              : 
      53              : 
      54              : long
      55      7893859 : MFXRecentNetworks::onUpdFile(FXObject* obj, FXSelector sel, void*) {
      56              :     // get filename index
      57      7893859 :     const FXint which = FXSELID(sel) - ID_FILE_1 + 1;
      58              :     // get filename
      59      7893859 :     const FXString key = FXStringFormat("FILE%d", which);
      60      7893859 :     const FXchar* filename = getApp()->reg().readStringEntry(getGroupName().text(), key.text(), NULL);
      61              :     // update myIndexFilenames
      62      7893859 :     myIndexFilenames[which] = filename;
      63              :     // check filename
      64      7893859 :     if (filename) {
      65      7893859 :         FXString string;
      66      7893859 :         if (which < 10) {
      67      7104775 :             string.format("&%d %s", which, filename);
      68              :         } else {
      69       789084 :             string.format("1&0 %s", filename);
      70              :         }
      71      7893859 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE), (void*)&string);
      72      7893859 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
      73      7893859 :     } else {
      74            0 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
      75              :     }
      76      7893859 :     return 1;
      77      7893859 : }
      78              : 
      79              : 
      80              : long
      81       788976 : MFXRecentNetworks::onUpdNoFiles(FXObject* obj, FXSelector, void*) {
      82              :     // first disable object
      83       788976 :     obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), NULL);
      84              :     // iterate over myIndexFilenames
      85       788976 :     for (const auto& indexFilename : myIndexFilenames) {
      86              :         // if filename isn't empty, then hide object and stop
      87       788976 :         if (!indexFilename.second.empty()) {
      88       788976 :             obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
      89              :             return 1;
      90              :         }
      91              :     }
      92              :     //show object
      93            0 :     obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
      94            0 :     return 1;
      95              : }
        

Generated by: LCOV version 2.0-1