Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
drag-drop.hxx
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21
22#include "main.h"
23#include <wx/dnd.h>
24#include "antares/study/study.h"
25#include "../../toolbox/dispatcher/study.h"
26#include <ui/common/lock.h>
27
28using namespace Yuni;
29
30namespace Antares
31{
32namespace Forms
33{
34class StudyDrop final : public wxFileDropTarget
35{
36public:
37 StudyDrop() : wxFileDropTarget()
38 {
39 }
40
41 virtual ~StudyDrop()
42 {
43 }
44
45 virtual bool OnDropFiles(wxCoord /*x*/, wxCoord /*y*/, const wxArrayString& filenames) override
46 {
47 if (IsGUIAboutToQuit() or GUIIsLock())
48 return false;
49
50 String filename;
51 String folder;
52 String title;
53
54 for (uint i = 0; i != (uint)filenames.size(); ++i)
55 {
56 wxStringToString(filenames[i], filename);
57 if (not Data::Study::IsInsideStudyFolder(filename, folder, title))
58 folder.clear();
59 }
60
61 if (not folder.empty())
62 {
63 // opening the study
64 Dispatcher::StudyOpen(folder);
65 }
66 else
67 logs.warning() << "The folder provided by drag & drop is not a valid study: "
68 << filename;
69
70 return true;
71 }
72
73}; // class StudyDrop
74
75} // namespace Forms
76} // namespace Antares
static bool IsInsideStudyFolder(const AnyString &path, YString &location, YString &title)
Check if a path is within a study folder.
Definition study.extra.cpp:114
Definition drag-drop.hxx:35