VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMListBox.h@ 1287

Last change on this file since 1287 was 1121, checked in by vboxsync, 18 years ago

FE/Qt: Doubleclicking a VM in the Selector window will switch to an existing VM window if the VM is already running and there is a visual representation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxVMListBox, VBoxVMListBoxItem class declarations
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifndef __VBoxVMListBox_h__
24#define __VBoxVMListBox_h__
25
26#include "COMDefs.h"
27
28#include "VBoxSelectorWnd.h"
29#include "VBoxGlobal.h"
30
31#include <qlistbox.h>
32#include <qfont.h>
33#include <qdatetime.h>
34
35struct QUuid;
36class QColorGroup;
37
38class VBoxVMListBoxTip;
39class VBoxVMListBoxItem;
40
41/**
42 *
43 * The VBoxVMListBox class is a visual representation of the list of
44 * existing VMs in the VBox GUI.
45 *
46 * Every item in the list box is an instance of the VBoxVMListBoxItem
47 * class.
48 */
49class VBoxVMListBox : public QListBox
50{
51public:
52
53 VBoxVMListBox (QWidget *aParent = 0, const char *aName = NULL,
54 WFlags aFlags = 0);
55
56 virtual ~VBoxVMListBox();
57
58 QFont nameFont() const { return mNameFont; }
59
60 QFont shotFont() const { return mShotFont; }
61
62 QFont stateFont (CEnums::SessionState aS) const
63 {
64 return aS == CEnums::SessionClosed ? font() : mStateBusyFont;
65 }
66
67 int margin() const { return mMargin; }
68
69 void refresh();
70 void refresh (const QUuid &aID);
71
72 VBoxVMListBoxItem *item (const QUuid &aID);
73
74 const QColorGroup &activeColorGroup() const;
75
76protected:
77
78 virtual void focusInEvent (QFocusEvent *aE);
79 virtual void focusOutEvent (QFocusEvent *aE);
80
81private:
82
83 CVirtualBox mVBox;
84 QFont mNameFont;
85 QFont mShotFont;
86 QFont mStateBusyFont;
87 int mMargin;
88
89 VBoxVMListBoxTip *mToolTip;
90 bool mGaveFocusToPopup;
91};
92
93/**
94 *
95 * The VBoxVMListBoxItem class is a visual representation of the virtual
96 * machine in the VBoxVMListBox widget.
97 *
98 * It holds a CMachine instance (passed to the constructor) to
99 * get an access to various VM data.
100 */
101class VBoxVMListBoxItem : public QListBoxItem
102{
103public:
104
105 VBoxVMListBoxItem (VBoxVMListBox *aLB, const CMachine &aM);
106 virtual ~VBoxVMListBoxItem();
107
108 QString text() const { return mName; }
109
110 VBoxVMListBox *vmListBox() const
111 {
112 return static_cast <VBoxVMListBox *> (listBox());
113 }
114
115 CMachine machine() const { return mMachine; }
116 void setMachine (const CMachine &aM);
117
118 void recache();
119
120 QString toolTipText() const;
121
122 int height (const QListBox *) const;
123 int width (const QListBox *) const;
124
125 QUuid id() const { return mId; }
126 bool accessible() const { return mAccessible; }
127 const CVirtualBoxErrorInfo &accessError() const { return mAccessError; }
128 QString name() const { return mName; }
129 CEnums::MachineState state() const { return mState; }
130 CEnums::SessionState sessionState() const { return mSessionState; }
131 ULONG snapshotCount() const { return mSnapshotCount; }
132
133 bool canSwitchTo() const { return mWinId != (WId) ~0; }
134 bool switchTo();
135
136protected:
137
138 void paint (QPainter *aP);
139
140private:
141
142 CMachine mMachine;
143
144 /* cached machine data (to minimize server requests) */
145
146 QUuid mId;
147 QString mSettingsFile;
148
149 bool mAccessible;
150 CVirtualBoxErrorInfo mAccessError;
151
152 QString mName;
153 QString mSnapshotName;
154 CEnums::MachineState mState;
155 QDateTime mLastStateChange;
156 CEnums::SessionState mSessionState;
157 QString mOSType;
158 ULONG mSnapshotCount;
159
160 ULONG mPid;
161 WId mWinId;
162};
163
164#endif // __VBoxVMListItem_h__
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette