1 /****************************************************************************
2 **
3 ** Copyright (C) 2008-2010 Andrey Rijov <ANDron142@yandex.ru>
4 **
5 ** This file is part of AQEMU.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 ** Boston, MA  02110-1301, USA.
20 **
21 ****************************************************************************/
22 
23 #ifndef DEVICE_MANAGER_WIDGET_H
24 #define DEVICE_MANAGER_WIDGET_H
25 
26 #include "VM.h"
27 #include "Add_New_Device_Window.h"
28 #include "Properties_Window.h"
29 #include "ui_Device_Manager_Widget.h"
30 #include "HDD_Image_Info.h"
31 
32 class Device_Manager_Widget: public QWidget
33 {
34     friend class Folder_Sharing_Widget;
35     friend class Ports_Tab_Widget;
36 
37 	Q_OBJECT
38 
39 	public:
40 		Device_Manager_Widget( QWidget *parent = 0 );
41 		~Device_Manager_Widget();
42 		void Set_VM( const Virtual_Machine &vm );
43 
44 		void Set_Enabled( bool on );
45 
46 		VM_Storage_Device Floppy1; // FD0
47 		VM_Storage_Device Floppy2; // FD1
48 		VM_Storage_Device CD_ROM; // cdrom device ide2
49 		VM_HDD HDA; // ide0
50 		VM_HDD HDB; // ide1
51 		VM_HDD HDC; // ide2 if cdrom is enabled, hdc be disibled
52 		VM_HDD HDD; // ide3
53 
54 		QList<VM_Nativ_Storage_Device> Storage_Devices;
55 
56 	public slots:
57 		void Update_Enabled_Actions();
58 		void Update_List_Mode();
59 
60 	signals:
61 		void Device_Changed();
62 
63 	private slots:
64 		// For Context Menu
65 		void on_Devices_List_customContextMenuRequested( const QPoint &pos );
66 		void on_Devices_List_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
67 		void on_Devices_List_itemDoubleClicked( QListWidgetItem *item );
68 
69 		void on_actionAdd_Floppy_triggered();
70 		void on_actionAdd_CD_ROM_triggered();
71 		void on_actionAdd_HDD_triggered();
72 		void on_actionAdd_Device_triggered();
73 		void on_actionProperties_triggered();
74 		void on_actionDelete_triggered();
75 		void on_actionFormat_HDD_triggered();
76 		void on_actionQuick_Format_triggered();
77 		void on_actionIcon_Mode_triggered();
78 		void on_actionList_Mode_triggered();
79 
80 		void Update_Icons();
81 		void Update_HDA( bool ok );
82 		void Update_HDB( bool ok );
83 		void Update_HDC( bool ok );
84 		void Update_HDD( bool ok );
85 
86 	private:
87         void Add_Floppy(VM_Storage_Device&,int);
88         void Add_HDD(VM_HDD&,QString);
89 
90 		bool Enabled;
91 
92 		Properties_Window *pw;
93 		Ui::Device_Manager_Widget ui;
94 		QMenu *Context_Menu;
95 
96 		HDD_Image_Info* HDA_Info;
97 		HDD_Image_Info* HDB_Info;
98 		HDD_Image_Info* HDC_Info;
99 		HDD_Image_Info* HDD_Info;
100 
101 		const Available_Devices *Current_Machine_Devices;
102 };
103 
104 #endif
105