VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsUtils.h@ 9796

Last change on this file since 9796 was 9782, checked in by vboxsync, 17 years ago

Fe/Qt4: Some code-spelling for VMSettings to make it similar to Global Settings, VBoxWarnIconLabel moved to VBoxVMSettingUtils (will be used in global settings too).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 6.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt4 GUI ("VirtualBox"):
4 * VBoxVMSettingsUtils class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __VBoxVMSettingsUtils_h__
24#define __VBoxVMSettingsUtils_h__
25
26#include <VBoxGlobal.h>
27
28//#include <QDialog>
29//#include <QLineEdit>
30//#include <QPushButton>
31#include <QHBoxLayout>
32#include <QLabel>
33#include <QTreeWidget>
34#include <QHeaderView>
35#include <QKeyEvent>
36#include <QTableView>
37
38enum
39{
40 /* mTwSelector column numbers */
41 listView_Category = 0,
42 listView_Id = 1,
43 listView_Link = 2,
44 /* mTwUSBFilters column numbers */
45 lvUSBFilters_Name = 0,
46};
47
48/**
49 * QTreeWidget class reimplementation to use as boot items table.
50 * It has one unsorted column without header.
51 * Keymapping handlers for ctrl-up & ctrl-down are translated into
52 * boot-items up/down moving signals.
53 * Emits itemToggled() signal when the item changed.
54 */
55class BootItemsTable : public QTreeWidget
56{
57 Q_OBJECT;
58
59public:
60
61 BootItemsTable (QWidget *aParent) : QTreeWidget (aParent)
62 {
63 header()->hide();
64 connect (this, SIGNAL (itemChanged (QTreeWidgetItem *, int)),
65 this, SLOT (onItemChanged()));
66 }
67
68 ~BootItemsTable() {}
69
70signals:
71
72 void moveItemUp();
73 void moveItemDown();
74 void itemToggled();
75
76private slots:
77
78 void onItemChanged()
79 {
80 emit itemToggled();
81 }
82
83 void keyPressEvent (QKeyEvent *aEvent)
84 {
85 if (aEvent->QInputEvent::modifiers () == Qt::ControlButton)
86 {
87 switch (aEvent->key())
88 {
89 case Qt::Key_Up:
90 emit moveItemUp();
91 return;
92 case Qt::Key_Down:
93 emit moveItemDown();
94 return;
95 default:
96 break;
97 }
98 }
99 QTreeWidget::keyPressEvent (aEvent);
100 }
101};
102
103// #ifdef Q_WS_WIN
104// /**
105// * QDialog class reimplementation to use for adding network interface.
106// * It has one line-edit field for entering network interface's name and
107// * common dialog's ok/cancel buttons.
108// */
109// class VBoxAddNIDialog : public QDialog
110// {
111// Q_OBJECT
112//
113// public:
114//
115// VBoxAddNIDialog (QWidget *aParent, const QString &aIfaceName) :
116// QDialog (aParent),
117// mLeName (0)
118// {
119// setWindowTitle (tr ("Add Host Interface"));
120// QVBoxLayout *mainLayout = new QVBoxLayout (this);
121//
122// /* Setup Input layout */
123// QHBoxLayout *inputLayout = new QHBoxLayout();
124// QLabel *lbName = new QLabel (tr ("Interface Name"), this);
125// mLeName = new QLineEdit (aIfaceName, this);
126// mLeName->setWhatsThis (tr ("Descriptive name of the new "
127// "network interface"));
128// inputLayout->addWidget (lbName);
129// inputLayout->addWidget (mLeName);
130// connect (mLeName, SIGNAL (textChanged (const QString &)),
131// this, SLOT (validate()));
132// mainLayout->addLayout (inputLayout);
133//
134// /* Setup Button layout */
135// QHBoxLayout *buttonLayout = new QHBoxLayout();
136// mBtOk = new QPushButton (tr ("&OK"), this);
137// QPushButton *btCancel = new QPushButton (tr ("Cancel"), this);
138// connect (mBtOk, SIGNAL (clicked()), this, SLOT (accept()));
139// connect (btCancel, SIGNAL (clicked()), this, SLOT (reject()));
140// buttonLayout->addWidget (mBtOk);
141// buttonLayout->addStretch();
142// buttonLayout->addWidget (btCancel);
143// mainLayout->addLayout (buttonLayout);
144//
145// /* resize to fit the aIfaceName in one string */
146// int requiredWidth = mLeName->fontMetrics().width (aIfaceName) +
147// inputLayout->spacing() +
148// lbName->fontMetrics().width (lbName->text()) +
149// lbName->frameWidth() * 2 +
150// lbName->lineWidth() * 2 +
151// mainLayout->margin() * 2;
152// resize (requiredWidth, minimumHeight());
153//
154// /* Validate interface name field */
155// validate();
156// }
157//
158// ~VBoxAddNIDialog() {}
159//
160// QString getName() { return mLeName->text(); }
161//
162// private slots:
163//
164// void validate()
165// {
166// mBtOk->setEnabled (!mLeName->text().isEmpty());
167// }
168//
169// private:
170//
171// void showEvent (QShowEvent *aEvent)
172// {
173// setFixedHeight (height());
174// QDialog::showEvent (aEvent);
175// }
176//
177// QPushButton *mBtOk;
178// QLineEdit *mLeName;
179// };
180// #endif
181
182class USBListItem : public QTreeWidgetItem
183{
184public:
185
186 enum { USBListItemType = 1002 };
187
188 USBListItem (QTreeWidget *aParent)
189 : QTreeWidgetItem (aParent, QStringList (QString::null), USBListItemType)
190 , mId (-1) {}
191
192 USBListItem (QTreeWidget *aParent, QTreeWidgetItem *aPreceding)
193 : QTreeWidgetItem (aParent, aPreceding, USBListItemType)
194 , mId (-1) {}
195
196 int mId;
197};
198
199/**
200 * Table-View class reimplementation to extend standard QTableView.
201 */
202class QITableView : public QTableView
203{
204 Q_OBJECT;
205
206public:
207
208 QITableView (QWidget *aParent) : QTableView (aParent) {}
209
210signals:
211
212 void currentChanged (const QModelIndex &aCurrent);
213
214protected:
215
216 void currentChanged (const QModelIndex &aCurrent,
217 const QModelIndex &aPrevious)
218 {
219 QTableView::currentChanged (aCurrent, aPrevious);
220 emit currentChanged (aCurrent);
221 }
222};
223
224class VBoxWarnIconLabel: public QWidget
225{
226 Q_OBJECT;
227
228public:
229
230 VBoxWarnIconLabel (QWidget *aParent = NULL)
231 : QWidget (aParent)
232 {
233 QHBoxLayout *layout = new QHBoxLayout (this);
234 VBoxGlobal::setLayoutMargin (layout, 0);
235 layout->addWidget (&mIcon);
236 layout->addWidget (&mLabel);
237 }
238
239 void setWarningPixmap (const QPixmap& aPixmap) { mIcon.setPixmap (aPixmap); }
240 void setWarningText (const QString& aText) { mLabel.setText (aText); }
241
242private:
243
244 QLabel mIcon;
245 QLabel mLabel;
246};
247
248#endif // __VBoxVMSettingsUtils_h__
249
Note: See TracBrowser for help on using the repository browser.

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