VBoxVMListBox.h revision b9042bb7a5efd07d617a8a7d812b669d75682779
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end/** @file
d25f483469fdeb2ca813928eec854375b2eb65cdnd *
d25f483469fdeb2ca813928eec854375b2eb65cdnd * VBox frontends: Qt GUI ("VirtualBox"):
d25f483469fdeb2ca813928eec854375b2eb65cdnd * VBoxVMListBox, VBoxVMListBoxItem class declarations
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end */
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end
db878466c5e95073429dda0bdd001f45e9486e16fielding/*
db878466c5e95073429dda0bdd001f45e9486e16fielding * Copyright (C) 2006 InnoTek Systemberatung GmbH
db878466c5e95073429dda0bdd001f45e9486e16fielding *
db878466c5e95073429dda0bdd001f45e9486e16fielding * This file is part of VirtualBox Open Source Edition (OSE), as
db878466c5e95073429dda0bdd001f45e9486e16fielding * available from http://www.virtualbox.org. This file is free software;
db878466c5e95073429dda0bdd001f45e9486e16fielding * you can redistribute it and/or modify it under the terms of the GNU
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * General Public License as published by the Free Software Foundation,
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * distribution. VirtualBox OSE is distributed in the hope that it will
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * be useful, but WITHOUT ANY WARRANTY of any kind.
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end *
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * If you received this file as part of a commercial VirtualBox
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * distribution, then only the terms of your commercial VirtualBox
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end * license agreement apply instead of the previous paragraph.
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end */
a7835c7a8cf86045fdaee65dc2839bfe6314fb1end
1cb160a981947e75a8353da3fe40a653aa87100eslive#ifndef __VBoxVMListBox_h__
1cb160a981947e75a8353da3fe40a653aa87100eslive#define __VBoxVMListBox_h__
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive#include "COMDefs.h"
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive#include "VBoxSelectorWnd.h"
1cb160a981947e75a8353da3fe40a653aa87100eslive#include "VBoxGlobal.h"
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive#include <qlistbox.h>
1cb160a981947e75a8353da3fe40a653aa87100eslive#include <qfont.h>
1cb160a981947e75a8353da3fe40a653aa87100eslive#include <qdatetime.h>
d25f483469fdeb2ca813928eec854375b2eb65cdnd
1cb160a981947e75a8353da3fe40a653aa87100eslivestruct QUuid;
1cb160a981947e75a8353da3fe40a653aa87100esliveclass QColorGroup;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100esliveclass VBoxVMListBoxTip;
1cb160a981947e75a8353da3fe40a653aa87100esliveclass VBoxVMListBoxItem;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive/**
1cb160a981947e75a8353da3fe40a653aa87100eslive *
117a9c5156c08125e2060ff892adac4634b7ad2dnd * The VBoxVMListBox class is a visual representation of the list of
1cb160a981947e75a8353da3fe40a653aa87100eslive * existing VMs in the VBox GUI.
1cb160a981947e75a8353da3fe40a653aa87100eslive *
d25f483469fdeb2ca813928eec854375b2eb65cdnd * Every item in the list box is an instance of the VBoxVMListBoxItem
1cb160a981947e75a8353da3fe40a653aa87100eslive * class.
d25f483469fdeb2ca813928eec854375b2eb65cdnd */
d25f483469fdeb2ca813928eec854375b2eb65cdndclass VBoxVMListBox : public QListBox
1cb160a981947e75a8353da3fe40a653aa87100eslive{
1cb160a981947e75a8353da3fe40a653aa87100eslivepublic:
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive VBoxVMListBox (QWidget *aParent = 0, const char *aName = NULL,
1cb160a981947e75a8353da3fe40a653aa87100eslive WFlags aFlags = 0);
9bfd8c17f5b50a894a419cd7aaf33700c48ddf7and
1cb160a981947e75a8353da3fe40a653aa87100eslive virtual ~VBoxVMListBox();
1cb160a981947e75a8353da3fe40a653aa87100eslive
97d4d9527b64d7491543a12a3d21134b857cbe4bnd QFont nameFont() const { return mNameFont; }
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive QFont stateFont (CEnums::SessionState aS) const
1cb160a981947e75a8353da3fe40a653aa87100eslive {
1cb160a981947e75a8353da3fe40a653aa87100eslive return aS == CEnums::SessionClosed ? font() : mStateBusyFont;
1cb160a981947e75a8353da3fe40a653aa87100eslive }
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive int margin() const { return mMargin; }
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive void refresh();
1cb160a981947e75a8353da3fe40a653aa87100eslive void refresh (const QUuid &aID);
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive VBoxVMListBoxItem *item (const QUuid &aID);
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive const QColorGroup &activeColorGroup() const;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100esliveprotected:
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive virtual void focusInEvent (QFocusEvent *aE);
1cb160a981947e75a8353da3fe40a653aa87100eslive virtual void focusOutEvent (QFocusEvent *aE);
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100esliveprivate:
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive CVirtualBox mVBox;
1cb160a981947e75a8353da3fe40a653aa87100eslive QFont mNameFont;
1cb160a981947e75a8353da3fe40a653aa87100eslive QFont mStateBusyFont;
1cb160a981947e75a8353da3fe40a653aa87100eslive int mMargin;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive VBoxVMListBoxTip *mToolTip;
1cb160a981947e75a8353da3fe40a653aa87100eslive bool mGaveFocusToPopup;
1cb160a981947e75a8353da3fe40a653aa87100eslive};
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive/**
1cb160a981947e75a8353da3fe40a653aa87100eslive *
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd * The VBoxVMListBoxItem class is a visual representation of the virtual
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd * machine in the VBoxVMListBox widget.
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd *
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd * It holds a CMachine instance (passed to the constructor) to
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd * get an access to various VM data.
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd */
4930be147adf9e3f6d3ca9313a6524f9bf654b2dndclass VBoxVMListBoxItem : public QListBoxItem
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd{
4930be147adf9e3f6d3ca9313a6524f9bf654b2dndpublic:
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd VBoxVMListBoxItem (VBoxVMListBox *aLB, const CMachine &aM);
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd virtual ~VBoxVMListBoxItem();
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd QString text() const { return mName; }
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd VBoxVMListBox *vmListBox() const
1cb160a981947e75a8353da3fe40a653aa87100eslive {
1cb160a981947e75a8353da3fe40a653aa87100eslive return static_cast <VBoxVMListBox *> (listBox());
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd }
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd CMachine machine() const { return mMachine; }
d25f483469fdeb2ca813928eec854375b2eb65cdnd void setMachine (const CMachine &aM);
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive QUuid id() const { return mId; }
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive void recache();
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive QString toolTipText() const;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive int height (const QListBox *) const;
1cb160a981947e75a8353da3fe40a653aa87100eslive int width (const QListBox *) const;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive bool accessible() const { return mAccessible; }
1cb160a981947e75a8353da3fe40a653aa87100eslive const CVirtualBoxErrorInfo &accessError() const { return mAccessError; }
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100esliveprotected:
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive void paint (QPainter *aP);
1cb160a981947e75a8353da3fe40a653aa87100eslive
d25f483469fdeb2ca813928eec854375b2eb65cdndprivate:
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive CMachine mMachine;
1cb160a981947e75a8353da3fe40a653aa87100eslive
d25f483469fdeb2ca813928eec854375b2eb65cdnd /* cached machine data (to minimize server requests) */
d25f483469fdeb2ca813928eec854375b2eb65cdnd
1cb160a981947e75a8353da3fe40a653aa87100eslive QUuid mId;
1cb160a981947e75a8353da3fe40a653aa87100eslive QString mSettingsFile;
1cb160a981947e75a8353da3fe40a653aa87100eslive
1cb160a981947e75a8353da3fe40a653aa87100eslive bool mAccessible;
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd CVirtualBoxErrorInfo mAccessError;
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd
4930be147adf9e3f6d3ca9313a6524f9bf654b2dnd QString mName;
1cb160a981947e75a8353da3fe40a653aa87100eslive CEnums::MachineState mState;
1cb160a981947e75a8353da3fe40a653aa87100eslive QDateTime mLastStateChange;
1cb160a981947e75a8353da3fe40a653aa87100eslive CEnums::SessionState mSessionState;
QString mOSType;
};
#endif // __VBoxVMListItem_h__