WSF
PasteContext.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11#ifndef PASTECONTEXT_HPP
12#define PASTECONTEXT_HPP
13
14#include <string>
15
16#include <QString>
17
18#include "UtLatPos.hpp"
19#include "UtLonPos.hpp"
20#include "ViExport.hpp"
21#include "WsfPProxyNode.hpp"
22
23class QWidget;
24class QMimeData;
25
26namespace wizard
27{
31{
32public:
33 explicit PasteContext(const std::string& aContextName);
34
35 bool Exec() const;
36
37 bool Exec(const QMimeData* data) const;
38
39 void SetDropOperation() { mIsDropOperation = true; }
40 bool IsDropOperation() const { return mIsDropOperation; }
41 void SetWidget(QWidget* aWidgetPtr) { mWidgetPtr = aWidgetPtr; }
42 // The widget being pasted to
43 QWidget* GetWidget() const { return mWidgetPtr; }
44 // A name for the context. eg: "map", "text-editor", etc...
45 std::string GetContextName() const { return mContextName; }
46 void SetPosition(const UtLatPos& aLat, const UtLonPos& aLon);
47 bool HasPosition() const { return mHasPosition; }
48 const UtLatPos& GetLat() const { return mLat; }
49 const UtLonPos& GetLon() const { return mLon; }
50 void SetFile(const std::string& aFilePath);
51 std::string GetFilePath() const;
52 // The proxy node being pasted-to
53 WsfPProxyNode GetProxyNode() const;
54 void SetProxyNode(const WsfPProxyNode& aNode);
55
56 // Add an available paste option.
57 // If aIsGrouped is 'true' for all options,
58 // the paste will be seen as a single action to the user.
59 // If aIsGrouped is 'false', then this action will appear as an independent action
60 // available from a subsequent popup-menu.
61 // Label should refer to the object being pasted, paste labels are combined when aIsGrouped=true
62 // resulting in 'Paste platform(5), zone(2)...'
63 void AddAvailableAction(const std::string& aName, QString aLabel, bool aIsGrouped = true) const;
64 // Returns 'true' if the named action was chosen.
65 bool IsActionChosen(const std::string& aName) const;
66
67 bool ApplyToTextImmediately() const { return mApplyToTextImmediately; }
68 void ApplyToTextImmediately(bool aApplyNow) { mApplyToTextImmediately = aApplyNow; }
69
70private:
71 struct PasteAction
72 {
73 std::string mName;
74 QString mLabel;
75 bool mIsGrouped;
76 bool mIsChosen;
77 };
78
79 mutable std::vector<PasteAction> mActionList;
80 QWidget* mWidgetPtr;
81 std::string mContextName;
82 WsfPProxyNode mNode;
83 bool mHasPosition;
84 bool mIsDropOperation;
85 bool mApplyToTextImmediately;
86 UtLatPos mLat;
87 UtLonPos mLon;
88 std::string mFilePath;
89};
90} // namespace wizard
91#endif
#define VI_EXPORT
Definition ViExport.hpp:38
Definition WsfPProxyNode.hpp:60
QWidget * GetWidget() const
Definition PasteContext.hpp:43
const UtLatPos & GetLat() const
Definition PasteContext.hpp:48
void ApplyToTextImmediately(bool aApplyNow)
Definition PasteContext.hpp:68
void SetDropOperation()
Definition PasteContext.hpp:39
bool ApplyToTextImmediately() const
Definition PasteContext.hpp:67
std::string GetContextName() const
Definition PasteContext.hpp:45
bool HasPosition() const
Definition PasteContext.hpp:47
PasteContext(const std::string &aContextName)
Definition PasteContext.cpp:51
void SetWidget(QWidget *aWidgetPtr)
Definition PasteContext.hpp:41
bool Exec() const
Definition PasteContext.cpp:59
bool IsDropOperation() const
Definition PasteContext.hpp:40
const UtLonPos & GetLon() const
Definition PasteContext.hpp:49
Definition Runner.hpp:22
Copyrights Multiple, All Rights Reserved