1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
4 | * UIMachineSettingsSF class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2008-2011 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __UIMachineSettingsSF_h__
|
---|
20 | #define __UIMachineSettingsSF_h__
|
---|
21 |
|
---|
22 | /* Local includes */
|
---|
23 | #include "UISettingsPage.h"
|
---|
24 | #include "UIMachineSettingsSF.gen.h"
|
---|
25 |
|
---|
26 | /* Local forwards */
|
---|
27 | class SFTreeViewItem;
|
---|
28 |
|
---|
29 | enum UISharedFolderType { MachineType, ConsoleType };
|
---|
30 | typedef QPair <QString, UISharedFolderType> SFolderName;
|
---|
31 | typedef QList <SFolderName> SFoldersNameList;
|
---|
32 |
|
---|
33 | /* Machine settings / Shared Folders page / Shared Folder data: */
|
---|
34 | struct UIDataSettingsSharedFolder
|
---|
35 | {
|
---|
36 | /* Default constructor: */
|
---|
37 | UIDataSettingsSharedFolder()
|
---|
38 | : m_type(MachineType)
|
---|
39 | , m_strName(QString())
|
---|
40 | , m_strHostPath(QString())
|
---|
41 | , m_fAutoMount(false)
|
---|
42 | , m_fWritable(false) {}
|
---|
43 | /* Functions: */
|
---|
44 | bool equal(const UIDataSettingsSharedFolder &other) const
|
---|
45 | {
|
---|
46 | return (m_type == other.m_type) &&
|
---|
47 | (m_strName == other.m_strName) &&
|
---|
48 | (m_strHostPath == other.m_strHostPath) &&
|
---|
49 | (m_fAutoMount == other.m_fAutoMount) &&
|
---|
50 | (m_fWritable == other.m_fWritable);
|
---|
51 | }
|
---|
52 | /* Operators: */
|
---|
53 | bool operator==(const UIDataSettingsSharedFolder &other) const { return equal(other); }
|
---|
54 | bool operator!=(const UIDataSettingsSharedFolder &other) const { return !equal(other); }
|
---|
55 | /* Variables: */
|
---|
56 | UISharedFolderType m_type;
|
---|
57 | QString m_strName;
|
---|
58 | QString m_strHostPath;
|
---|
59 | bool m_fAutoMount;
|
---|
60 | bool m_fWritable;
|
---|
61 | };
|
---|
62 | typedef UISettingsCache<UIDataSettingsSharedFolder> UICacheSettingsSharedFolder;
|
---|
63 |
|
---|
64 | /* Machine settings / Shared Folders page / Shared Folders data: */
|
---|
65 | struct UIDataSettingsSharedFolders
|
---|
66 | {
|
---|
67 | /* Default constructor: */
|
---|
68 | UIDataSettingsSharedFolders() {}
|
---|
69 | /* Operators: */
|
---|
70 | bool operator==(const UIDataSettingsSharedFolders& /* other */) const { return true; }
|
---|
71 | bool operator!=(const UIDataSettingsSharedFolders& /* other */) const { return false; }
|
---|
72 | };
|
---|
73 | typedef UISettingsCachePool<UIDataSettingsSharedFolders, UICacheSettingsSharedFolder> UICacheSettingsSharedFolders;
|
---|
74 |
|
---|
75 | class UIMachineSettingsSF : public UISettingsPageMachine,
|
---|
76 | public Ui::UIMachineSettingsSF
|
---|
77 | {
|
---|
78 | Q_OBJECT;
|
---|
79 |
|
---|
80 | public:
|
---|
81 |
|
---|
82 | UIMachineSettingsSF();
|
---|
83 |
|
---|
84 | protected:
|
---|
85 |
|
---|
86 | /* Load data to cashe from corresponding external object(s),
|
---|
87 | * this task COULD be performed in other than GUI thread: */
|
---|
88 | void loadToCacheFrom(QVariant &data);
|
---|
89 | void loadToCacheFrom(UISharedFolderType sharedFoldersType);
|
---|
90 | /* Load data to corresponding widgets from cache,
|
---|
91 | * this task SHOULD be performed in GUI thread only: */
|
---|
92 | void getFromCache();
|
---|
93 |
|
---|
94 | /* Save data from corresponding widgets to cache,
|
---|
95 | * this task SHOULD be performed in GUI thread only: */
|
---|
96 | void putToCache();
|
---|
97 | /* Save data from cache to corresponding external object(s),
|
---|
98 | * this task COULD be performed in other than GUI thread: */
|
---|
99 | void saveFromCacheTo(QVariant &data);
|
---|
100 | void saveFromCacheTo(UISharedFolderType sharedFoldersType);
|
---|
101 |
|
---|
102 | void setOrderAfter (QWidget *aWidget);
|
---|
103 |
|
---|
104 | void retranslateUi();
|
---|
105 |
|
---|
106 | private slots:
|
---|
107 |
|
---|
108 | void addTriggered();
|
---|
109 | void edtTriggered();
|
---|
110 | void delTriggered();
|
---|
111 |
|
---|
112 | void processCurrentChanged (QTreeWidgetItem *aCurrentItem);
|
---|
113 | void processDoubleClick (QTreeWidgetItem *aItem);
|
---|
114 | void showContextMenu (const QPoint &aPos);
|
---|
115 |
|
---|
116 | void adjustList();
|
---|
117 | void adjustFields();
|
---|
118 |
|
---|
119 | private:
|
---|
120 |
|
---|
121 | void resizeEvent (QResizeEvent *aEvent);
|
---|
122 |
|
---|
123 | void showEvent (QShowEvent *aEvent);
|
---|
124 |
|
---|
125 | SFTreeViewItem* root(UISharedFolderType type);
|
---|
126 | SFoldersNameList usedList (bool aIncludeSelected);
|
---|
127 |
|
---|
128 | bool isSharedFolderTypeSupported(UISharedFolderType sharedFolderType) const;
|
---|
129 | void updateRootItemsVisibility();
|
---|
130 | void setRootItemVisible(UISharedFolderType sharedFolderType, bool fVisible);
|
---|
131 |
|
---|
132 | void polishPage();
|
---|
133 |
|
---|
134 | CSharedFolderVector getSharedFolders(UISharedFolderType sharedFoldersType);
|
---|
135 |
|
---|
136 | bool removeSharedFolder(const UICacheSettingsSharedFolder &folderCache);
|
---|
137 | bool createSharedFolder(const UICacheSettingsSharedFolder &folderCache);
|
---|
138 |
|
---|
139 | QAction *mNewAction;
|
---|
140 | QAction *mEdtAction;
|
---|
141 | QAction *mDelAction;
|
---|
142 | QString mTrFull;
|
---|
143 | QString mTrReadOnly;
|
---|
144 | QString mTrYes;
|
---|
145 |
|
---|
146 | /* Cache: */
|
---|
147 | UICacheSettingsSharedFolders m_cache;
|
---|
148 | };
|
---|
149 |
|
---|
150 | #endif // __UIMachineSettingsSF_h__
|
---|
151 |
|
---|