File: project_local_settings.cpp

package info (click to toggle)
kicad 9.0.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 770,320 kB
  • sloc: cpp: 961,692; ansic: 121,001; xml: 66,428; python: 18,387; sh: 1,010; awk: 301; asm: 292; makefile: 227; javascript: 167; perl: 10
file content (578 lines) | stat: -rw-r--r-- 23,934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2020 CERN
 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
 * @author Jon Evans <jon@craftyjon.com>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <lset.h>
#include <project.h>
#include <project/project_local_settings.h>
#include <settings/layer_settings_utils.h>
#include <settings/json_settings_internals.h>
#include <settings/parameters.h>

const int projectLocalSettingsVersion = 5;


PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxString& aFilename ) :
        JSON_SETTINGS( aFilename, SETTINGS_LOC::PROJECT, projectLocalSettingsVersion,
                       /* aCreateIfMissing = */ true, /* aCreateIfDefault = */ false,
                       /* aWriteFile = */ true ),
        m_ActiveLayer( UNDEFINED_LAYER ),
        m_ContrastModeDisplay( HIGH_CONTRAST_MODE::NORMAL ),
        m_NetColorMode( NET_COLOR_MODE::RATSNEST ),
        m_AutoTrackWidth( true ),
        m_ZoneDisplayMode( ZONE_DISPLAY_MODE::SHOW_FILLED ),
        m_TrackOpacity( 1.0 ),
        m_ViaOpacity( 1.0 ),
        m_PadOpacity( 1.0 ),
        m_ZoneOpacity( 0.6 ),
        m_ShapeOpacity( 1.0 ),
        m_ImageOpacity( 0.6 ),
        m_PcbSelectionFilter(),
        m_project( aProject ),
        m_wasMigrated( false )
{
    // Keep old files around
    m_deleteLegacyAfterMigration = false;

    m_params.emplace_back( new PARAM_LAMBDA<std::string>( "board.visible_layers",
            [&]() -> std::string
            {
                return m_VisibleLayers.FmtHex();
            },
            [&]( const std::string& aString )
            {
                m_VisibleLayers.ParseHex( aString );
            },
            LSET::AllLayersMask().FmtHex() ) );

    m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "board.visible_items",
            [&]() -> nlohmann::json
            {
                nlohmann::json ret = nlohmann::json::array();

                for( GAL_LAYER_ID l : m_VisibleItems.Seq() )
                {
                    if( std::optional<VISIBILITY_LAYER> vl = VisibilityLayerFromRenderLayer( l ) )
                        ret.push_back( VisibilityLayerToString( *vl ) );
                }

                // Explicit marker to tell apart a wiped-out array from the user hiding everything
                if( ret.empty() )
                    ret.push_back( "none" );

                return ret;
            },
            [&]( const nlohmann::json& aVal )
            {
                if( !aVal.is_array() || aVal.empty() )
                {
                    m_VisibleItems |= UserVisbilityLayers();
                    return;
                }

                m_VisibleItems &= ~UserVisbilityLayers();
                GAL_SET visible;
                bool none = false;

                for( const nlohmann::json& entry : aVal )
                {
                    try
                    {
                        std::string vs = entry.get<std::string>();

                        if( std::optional<GAL_LAYER_ID> l = RenderLayerFromVisbilityString( vs ) )
                            visible.set( *l );
                        else if( vs == "none" )
                            none = true;
                    }
                    catch( ... )
                    {
                        // Unknown entry (possibly the settings file was re-saved by an old version
                        // of kicad that used numeric entries, or is a future format)
                    }
                }

                // Restore corrupted state
                if( !visible.any() && !none )
                    m_VisibleItems |= UserVisbilityLayers();
                else
                    m_VisibleItems |= UserVisbilityLayers() & visible;
            },
            {} ) );

    m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "board.selection_filter",
            [&]() -> nlohmann::json
            {
                nlohmann::json ret;

                ret["lockedItems"] = m_PcbSelectionFilter.lockedItems;
                ret["footprints"]  = m_PcbSelectionFilter.footprints;
                ret["text"]        = m_PcbSelectionFilter.text;
                ret["tracks"]      = m_PcbSelectionFilter.tracks;
                ret["vias"]        = m_PcbSelectionFilter.vias;
                ret["pads"]        = m_PcbSelectionFilter.pads;
                ret["graphics"]    = m_PcbSelectionFilter.graphics;
                ret["zones"]       = m_PcbSelectionFilter.zones;
                ret["keepouts"]    = m_PcbSelectionFilter.keepouts;
                ret["dimensions"]  = m_PcbSelectionFilter.dimensions;
                ret["otherItems"]  = m_PcbSelectionFilter.otherItems;

                return ret;
            },
            [&]( const nlohmann::json& aVal )
            {
                if( aVal.empty() || !aVal.is_object() )
                    return;

                SetIfPresent( aVal, "lockedItems", m_PcbSelectionFilter.lockedItems );
                SetIfPresent( aVal, "footprints", m_PcbSelectionFilter.footprints );
                SetIfPresent( aVal, "text", m_PcbSelectionFilter.text );
                SetIfPresent( aVal, "tracks", m_PcbSelectionFilter.tracks );
                SetIfPresent( aVal, "vias", m_PcbSelectionFilter.vias );
                SetIfPresent( aVal, "pads", m_PcbSelectionFilter.pads );
                SetIfPresent( aVal, "graphics", m_PcbSelectionFilter.graphics );
                SetIfPresent( aVal, "zones", m_PcbSelectionFilter.zones );
                SetIfPresent( aVal, "keepouts", m_PcbSelectionFilter.keepouts );
                SetIfPresent( aVal, "dimensions", m_PcbSelectionFilter.dimensions );
                SetIfPresent( aVal, "otherItems", m_PcbSelectionFilter.otherItems );
            },
            {
                { "lockedItems", false },
                { "footprints", true },
                { "text", true },
                { "tracks", true },
                { "vias", true },
                { "pads", true },
                { "graphics", true },
                { "zones", true },
                { "keepouts", true },
                { "dimensions", true },
                { "otherItems", true }
            } ) );

    m_params.emplace_back( new PARAM_ENUM<PCB_LAYER_ID>( "board.active_layer",
                           &m_ActiveLayer, F_Cu, PCBNEW_LAYER_ID_START, F_Fab ) );

    m_params.emplace_back( new PARAM<wxString>( "board.active_layer_preset",
                           &m_ActiveLayerPreset, "" ) );

    m_params.emplace_back( new PARAM_ENUM<HIGH_CONTRAST_MODE>( "board.high_contrast_mode",
                           &m_ContrastModeDisplay, HIGH_CONTRAST_MODE::NORMAL,
                           HIGH_CONTRAST_MODE::NORMAL, HIGH_CONTRAST_MODE::HIDDEN ) );

    m_params.emplace_back( new PARAM<double>( "board.opacity.tracks", &m_TrackOpacity, 1.0 ) );
    m_params.emplace_back( new PARAM<double>( "board.opacity.vias", &m_ViaOpacity, 1.0 ) );
    m_params.emplace_back( new PARAM<double>( "board.opacity.pads", &m_PadOpacity, 1.0 ) );
    m_params.emplace_back( new PARAM<double>( "board.opacity.zones", &m_ZoneOpacity, 0.6 ) );
    m_params.emplace_back( new PARAM<double>( "board.opacity.images", &m_ImageOpacity, 0.6 ) );
    m_params.emplace_back( new PARAM<double>( "board.opacity.shapes", &m_ShapeOpacity, 1.0 ) );

    m_params.emplace_back( new PARAM_LIST<wxString>( "board.hidden_nets", &m_HiddenNets, {} ) );

    m_params.emplace_back( new PARAM_SET<wxString>( "board.hidden_netclasses",
                                                     &m_HiddenNetclasses, {} ) );

    m_params.emplace_back( new PARAM_ENUM<NET_COLOR_MODE>( "board.net_color_mode",
                           &m_NetColorMode, NET_COLOR_MODE::RATSNEST, NET_COLOR_MODE::OFF,
                           NET_COLOR_MODE::ALL ) );

    m_params.emplace_back( new PARAM<bool>( "board.auto_track_width",
                           &m_AutoTrackWidth, true ) );

    m_params.emplace_back( new PARAM_ENUM<ZONE_DISPLAY_MODE>( "board.zone_display_mode",
                           &m_ZoneDisplayMode,
                           ZONE_DISPLAY_MODE::SHOW_FILLED, ZONE_DISPLAY_MODE::SHOW_FILLED,
                           ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) );

    m_params.emplace_back( new PARAM<wxString>( "git.repo_username", &m_GitRepoUsername, "" ) );

    m_params.emplace_back( new PARAM<wxString>( "git.repo_type", &m_GitRepoType, "" ) );

    m_params.emplace_back( new PARAM<wxString>( "git.ssh_key", &m_GitSSHKey, "" ) );

    m_params.emplace_back( new PARAM<wxString>( "net_inspector_panel.filter_text",
                                                &m_NetInspectorPanel.filter_text, "" ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.filter_by_net_name",
                                            &m_NetInspectorPanel.filter_by_net_name, true ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.filter_by_netclass",
                                            &m_NetInspectorPanel.filter_by_netclass, true ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.group_by_netclass",
                                            &m_NetInspectorPanel.group_by_netclass, false ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.group_by_constraint",
                                            &m_NetInspectorPanel.group_by_constraint, false ) );
    m_params.emplace_back( new PARAM_LIST<wxString>( "net_inspector_panel.custom_group_rules",
                                                     &m_NetInspectorPanel.custom_group_rules,
                                                     {} ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.show_zero_pad_nets",
                                            &m_NetInspectorPanel.show_zero_pad_nets, false ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.show_unconnected_nets",
                                            &m_NetInspectorPanel.show_unconnected_nets, false ) );
    m_params.emplace_back( new PARAM<int>( "net_inspector_panel.sorting_column",
                                           &m_NetInspectorPanel.sorting_column, -1 ) );
    m_params.emplace_back( new PARAM<bool>( "net_inspector_panel.sort_ascending",
                                            &m_NetInspectorPanel.sort_order_asc, true ) );
    m_params.emplace_back( new PARAM_LIST<int>( "net_inspector_panel.col_order",
                                                &m_NetInspectorPanel.col_order, {} ) );
    m_params.emplace_back( new PARAM_LIST<int>( "net_inspector_panel.col_widths",
                                                &m_NetInspectorPanel.col_widths, {} ) );
    m_params.emplace_back( new PARAM_LIST<bool>( "net_inspector_panel.col_hidden",
                                                 &m_NetInspectorPanel.col_hidden, {} ) );
    m_params.emplace_back( new PARAM_LIST<wxString>( "net_inspector_panel.expanded_rows",
                                                     &m_NetInspectorPanel.expanded_rows, {} ) );

    m_params.emplace_back( new PARAM_LIST<wxString>( "open_jobsets", &m_OpenJobSets, {} ) );

    m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "project.files",
            [&]() -> nlohmann::json
            {
                nlohmann::json ret = nlohmann::json::array();

                for( PROJECT_FILE_STATE& fileState : m_files )
                {
                    nlohmann::json file;
                    file["name"] = fileState.fileName;
                    file["open"] = fileState.open;

                    nlohmann::json window;
                    window["maximized"] = fileState.window.maximized;
                    window["size_x"]    = fileState.window.size_x;
                    window["size_y"]    = fileState.window.size_y;
                    window["pos_x"]     = fileState.window.pos_x;
                    window["pos_y"]     = fileState.window.pos_y;
                    window["display"]   = fileState.window.display;

                    file["window"] = window;

                    ret.push_back( file );
                }

                return ret;
            },
            [&]( const nlohmann::json& aVal )
            {
                if( !aVal.is_array() || aVal.empty() )
                    return;

                m_files.clear();

                for( const nlohmann::json& file : aVal )
                {
                    PROJECT_FILE_STATE fileState;

                    try
                    {
                        SetIfPresent( file, "name", fileState.fileName );
                        SetIfPresent( file, "open", fileState.open );
                        SetIfPresent( file, "window.size_x", fileState.window.size_x );
                        SetIfPresent( file, "window.size_y", fileState.window.size_y );
                        SetIfPresent( file, "window.pos_x", fileState.window.pos_x );
                        SetIfPresent( file, "window.pos_y", fileState.window.pos_y );
                        SetIfPresent( file, "window.maximized", fileState.window.maximized );
                        SetIfPresent( file, "window.display", fileState.window.display );

                        m_files.push_back( fileState );
                    }
                    catch( ... )
                    {
                        // Non-integer or out of range entry in the array; ignore
                    }
                }

            },
            {
            } ) );

    m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( "schematic.selection_filter",
            [&]() -> nlohmann::json
            {
                nlohmann::json ret;

                ret["lockedItems"] = m_SchSelectionFilter.lockedItems;
                ret["symbols"]     = m_SchSelectionFilter.symbols;
                ret["text"]        = m_SchSelectionFilter.text;
                ret["wires"]       = m_SchSelectionFilter.wires;
                ret["labels"]      = m_SchSelectionFilter.labels;
                ret["pins"]        = m_SchSelectionFilter.pins;
                ret["graphics"]    = m_SchSelectionFilter.graphics;
                ret["images"]      = m_SchSelectionFilter.images;
                ret["otherItems"]  = m_SchSelectionFilter.otherItems;

                return ret;
            },
            [&]( const nlohmann::json& aVal )
            {
                if( aVal.empty() || !aVal.is_object() )
                    return;

                SetIfPresent( aVal, "lockedItems", m_SchSelectionFilter.lockedItems );
                SetIfPresent( aVal, "symbols", m_SchSelectionFilter.symbols );
                SetIfPresent( aVal, "text", m_SchSelectionFilter.text );
                SetIfPresent( aVal, "wires", m_SchSelectionFilter.wires );
                SetIfPresent( aVal, "labels", m_SchSelectionFilter.labels );
                SetIfPresent( aVal, "pins", m_SchSelectionFilter.pins );
                SetIfPresent( aVal, "graphics", m_SchSelectionFilter.graphics );
                SetIfPresent( aVal, "images", m_SchSelectionFilter.images );
                SetIfPresent( aVal, "otherItems", m_SchSelectionFilter.otherItems );
            },
            {
                { "lockedItems", false },
                { "symbols", true },
                { "text", true },
                { "wires", true },
                { "labels", true },
                { "pins", true },
                { "graphics", true },
                { "images", true },
                { "otherItems", true }
            } ) );

    registerMigration( 1, 2,
            [&]()
            {
                /**
                 * Schema version 1 to 2:
                 * LAYER_PADS and LAYER_ZONES added to visibility controls
                 */

                std::string ptr( "board.visible_items" );

                if( Contains( ptr ) )
                {
                    if( At( ptr ).is_array() )
                    {
                        At( ptr ).push_back( LAYER_PADS - GAL_LAYER_ID_START );
                        At( ptr ).push_back( LAYER_ZONES - GAL_LAYER_ID_START );
                    }
                    else
                    {
                        At( "board" ).erase( "visible_items" );
                    }

                    m_wasMigrated = true;
                }

                return true;
            } );

    registerMigration( 2, 3,
            [&]()
            {
                /**
                 * Schema version 2 to 3:
                 * Fix issue with object visibility not migrating from legacy, which required
                 * remapping of GAL_LAYER_ID to match the legacy bitmask ordering.
                 */

                /// Stores a mapping from old to new enum offset
                const std::map<int, int> offsets = {
                        { 22, 34 },    // LAYER_PAD_HOLEWALLS
                        { 23, 22 },    // LAYER_VIA_HOLES
                        { 24, 35 },    // LAYER_VIA_HOLEWALLS
                        { 25, 23 },    // LAYER_DRC_ERROR
                        { 26, 36 },    // LAYER_DRC_WARNING
                        { 27, 37 },    // LAYER_DRC_EXCLUSION
                        { 28, 38 },    // LAYER_MARKER_SHADOWS
                        { 29, 24 },    // LAYER_DRAWINGSHEET
                        { 30, 25 },    // LAYER_GP_OVERLAY
                        { 31, 26 },    // LAYER_SELECT_OVERLAY
                        { 32, 27 },    // LAYER_PCB_BACKGROUND
                        { 33, 28 },    // LAYER_CURSOR
                        { 34, 29 },    // LAYER_AUX_ITEM
                        { 35, 30 },    // LAYER_DRAW_BITMAPS
                        { 39, 32 },    // LAYER_PADS
                        { 40, 33 },    // LAYER_ZONES
                    };

                std::string ptr( "board.visible_items" );

                if( Contains( ptr ) && At( ptr ).is_array() )
                {
                    nlohmann::json visible = nlohmann::json::array();

                    for( const nlohmann::json& val : At( ptr ) )
                    {
                        try
                        {
                            int layer = val.get<int>();

                            if( offsets.count( layer ) )
                                visible.push_back( offsets.at( layer ) );
                            else
                                visible.push_back( layer );
                        }
                        catch( ... )
                        {
                            // skip invalid value
                        }
                    }

                    At( "board" )["visible_items"] = visible;
                    m_wasMigrated = true;
                }

                return true;
            } );

    registerMigration( 3, 4,
            [&]()
            {
                // Schema version 3 to 4: LAYER_FILLED_SHAPES added to visibility controls

                std::string ptr( "board.visible_items" );

                if( Contains( ptr ) )
                {
                    if( At( ptr ).is_array() && !At( ptr ).empty() )
                        At( ptr ).push_back( LAYER_FILLED_SHAPES - GAL_LAYER_ID_START );
                    else
                        At( "board" ).erase( "visible_items" );

                    m_wasMigrated = true;
                }

                return true;
            } );

    registerMigration( 4, 5,
            [&]()
            {
                // Schema version 5: use named render layers

                std::string ptr( "board.visible_items" );

                if( Contains( ptr ) && At( ptr ).is_array() )
                {
                    std::vector<std::string> newLayers;

                    for( nlohmann::json& entry : At( ptr ) )
                    {
                        if( !entry.is_number_integer() )
                            continue;

                        if( std::optional<VISIBILITY_LAYER> vl =
                            VisibilityLayerFromRenderLayer( GAL_LAYER_ID_START + entry.get<int>() ) )
                        {
                            newLayers.emplace_back( VisibilityLayerToString( *vl ) );
                        }
                    }

                    At( ptr ) = newLayers;
                    m_wasMigrated = true;
                }

                return true;
            } );
}


bool PROJECT_LOCAL_SETTINGS::MigrateFromLegacy( wxConfigBase* aLegacyConfig )
{
    /**
     * The normal legacy migration code won't be used for this because the only legacy
     * information stored here was stored in board files, so we do that migration when loading
     * the board.
     */
    return true;
}


bool PROJECT_LOCAL_SETTINGS::SaveToFile( const wxString& aDirectory, bool aForce )
{
    wxASSERT( m_project );

    Set( "meta.filename",
         m_project->GetProjectName() + "." + FILEEXT::ProjectLocalSettingsFileExtension );

    // Even if parameters were not modified, we should resave after migration
    bool force = aForce || m_wasMigrated;

    // If we're actually going ahead and doing the save, the flag that keeps code from doing the
    // save should be cleared at this point.
    m_wasMigrated = false;

    return JSON_SETTINGS::SaveToFile( aDirectory, force );
}


bool PROJECT_LOCAL_SETTINGS::SaveAs( const wxString& aDirectory, const wxString& aFile )
{
    Set( "meta.filename", aFile + "." + FILEEXT::ProjectLocalSettingsFileExtension );
    SetFilename( aFile );

    // If we're actually going ahead and doing the save, the flag that keeps code from doing the
    // save should be cleared at this point.
    m_wasMigrated = false;

    return JSON_SETTINGS::SaveToFile( aDirectory, true );
}


const PROJECT_FILE_STATE* PROJECT_LOCAL_SETTINGS::GetFileState( const wxString& aFileName )
{
    auto it = std::find_if( m_files.begin(), m_files.end(),
                            [&aFileName]( const PROJECT_FILE_STATE &a )
                            {
                                return a.fileName == aFileName;
                            } );

    if( it != m_files.end() )
    {
        return &( *it );
    }

    return nullptr;
}


void PROJECT_LOCAL_SETTINGS::SaveFileState( const wxString& aFileName,
                                            const WINDOW_SETTINGS* aWindowCfg, bool aOpen )
{
    auto it = std::find_if( m_files.begin(), m_files.end(),
                            [&aFileName]( const PROJECT_FILE_STATE& a )
                            {
                                return a.fileName == aFileName;
                            } );

    if( it == m_files.end() )
    {
        PROJECT_FILE_STATE fileState;
        fileState.fileName = aFileName;
        fileState.open = false;
        fileState.window.maximized = false;
        fileState.window.size_x = -1;
        fileState.window.size_y = -1;
        fileState.window.pos_x = -1;
        fileState.window.pos_y = -1;
        fileState.window.display = 0;

        m_files.push_back( fileState );

        it = m_files.end() - 1;
    }

    ( *it ).window = aWindowCfg->state;
    ( *it ).open   = aOpen;
}


void PROJECT_LOCAL_SETTINGS::ClearFileState()
{
    m_files.clear();
}