LCOV - code coverage report
Current view: top level - src/utils/foxtools - MFXRecentNetworks.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 78.6 % 28 22
Test Date: 2025-11-13 15:38:19 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-2025 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      7630377 : 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        15996 : MFXRecentNetworks::MFXRecentNetworks(FXApp* a, const FXString& gp) :
      50        15996 :     FXRecentFiles(a, gp) {
      51        15996 : }
      52              : 
      53              : 
      54              : long
      55      6026013 : MFXRecentNetworks::onUpdFile(FXObject* obj, FXSelector sel, void*) {
      56              :     // get filename index
      57      6026013 :     const FXint which = FXSELID(sel) - ID_FILE_1 + 1;
      58              :     // get filename
      59              :     const FXchar* filename;
      60              :     FXchar key[20];
      61              :     sprintf(key, "FILE%d", which);
      62      6026013 :     filename = getApp()->reg().readStringEntry(getGroupName().text(), key, NULL);
      63              :     // update myIndexFilenames
      64      6026013 :     myIndexFilenames[which] = filename;
      65              :     // check filename
      66      6026013 :     if (filename) {
      67      6026013 :         FXString string;
      68      6026013 :         if (which < 10) {
      69      5423594 :             string.format("&%d %s", which, filename);
      70              :         } else {
      71       602419 :             string.format("1&0 %s", filename);
      72              :         }
      73      6026013 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE), (void*)&string);
      74      6026013 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
      75      6026013 :     } else {
      76            0 :         obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
      77              :     }
      78      6026013 :     return 1;
      79              : }
      80              : 
      81              : 
      82              : long
      83       602350 : MFXRecentNetworks::onUpdNoFiles(FXObject* obj, FXSelector, void*) {
      84              :     // first disable object
      85       602350 :     obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), NULL);
      86              :     // iterate over myIndexFilenames
      87       602350 :     for (const auto& indexFilename : myIndexFilenames) {
      88              :         // if filename isn't empty, then hide object and stop
      89       602350 :         if (!indexFilename.second.empty()) {
      90       602350 :             obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
      91              :             return 1;
      92              :         }
      93              :     }
      94              :     //show object
      95            0 :     obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
      96            0 :     return 1;
      97              : }
        

Generated by: LCOV version 2.0-1