VirtualBox

Changeset 10109 in vbox


Ignore:
Timestamp:
Jul 2, 2008 2:15:54 PM (16 years ago)
Author:
vboxsync
Message:

FE/Qt4: Removed last Qt3 bits. If some of this classes is needed later again we have to look at subversion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxUtils.h

    r9438 r10109  
    66
    77/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2626/* Qt includes */
    2727#include <QMouseEvent>
    28 #include <Q3ListView>
    29 
    30 /**
    31  *  Simple ListView filter to disable unselecting all items by clicking in the
    32  *  unused area of the list (which is actually very annoying for the Single
    33  *  selection mode).
    34  */
    35 class QIListViewSelectionPreserver : protected QObject
    36 {
    37 public:
    38 
    39     QIListViewSelectionPreserver (QObject *parent, Q3ListView *alv)
    40         : QObject (parent), lv (alv)
    41     {
    42         lv->viewport()->installEventFilter (this);
    43     }
    44 
    45 protected:
    46 
    47     bool eventFilter (QObject * /* o */, QEvent *e)
    48     {
    49         if (e->type() == QEvent::MouseButtonPress ||
    50             e->type() == QEvent::MouseButtonRelease ||
    51             e->type() == QEvent::MouseButtonDblClick)
    52         {
    53             QMouseEvent *me = static_cast<QMouseEvent *> (e);
    54             if (!lv->itemAt (me->pos()))
    55                 return true;
    56         }
    57 
    58         return false;
    59     }
    60 
    61 private:
    62 
    63     Q3ListView *lv;
    64 };
    65 
    66 /**
    67  *  Simple class that filters out presses and releases of the given key
    68  *  directed to a widget (the widget acts like if it would never handle
    69  *  this key).
    70  */
    71 class QIKeyFilter : protected QObject
    72 {
    73 public:
    74 
    75     QIKeyFilter (QObject *aParent, Qt::Key aKey) : QObject (aParent), mKey (aKey) {}
    76 
    77     void watchOn (QObject *o) { o->installEventFilter (this); }
    78 
    79 protected:
    80 
    81     bool eventFilter (QObject * /*o*/, QEvent *e)
    82     {
    83         if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease)
    84         {
    85             QKeyEvent *ke = static_cast<QKeyEvent *> (e);
    86             if (ke->key() == mKey ||
    87                 (mKey == Qt::Key_Enter && ke->key() == Qt::Key_Return))
    88             {
    89                 ke->ignore();
    90                 return false;
    91             }
    92         }
    93 
    94         return false;
    95     }
    96 
    97     Qt::Key mKey;
    98 };
     28#include <QWidget>
    9929
    10030/**
     
    10838public:
    10939
    110     QIAltKeyFilter (QObject *aParent) : QObject (aParent) {}
     40    QIAltKeyFilter (QObject *aParent) :QObject (aParent) {}
    11141
    112     void watchOn (QObject *o) { o->installEventFilter (this); }
     42    void watchOn (QObject *aObject) { aObject->installEventFilter (this); }
    11343
    11444protected:
    11545
    116     bool eventFilter (QObject * /*o*/, QEvent *e)
     46    bool eventFilter (QObject * /* aObject */, QEvent *aEvent)
    11747    {
    118         if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease)
     48        if (aEvent->type() == QEvent::KeyPress || aEvent->type() == QEvent::KeyRelease)
    11949        {
    120             QKeyEvent *ke = static_cast<QKeyEvent *> (e);
    121             if (ke->modifiers() & Qt::AltModifier)
     50            QKeyEvent *event = static_cast<QKeyEvent *> (aEvent);
     51            if (event->modifiers() & Qt::AltModifier)
    12252                return true;
    12353        }
     
    12757
    12858/**
    129  *  Watches the given widget and makes sure the minimum widget size set by the layout
    130  *  manager does never get smaller than the previous minimum size set by the
    131  *  layout manager. This way, widgets with dynamic contents (i.e. text on some
    132  *  toggle buttons) will be able only to grow, never shrink, to avoid flicker
    133  *  during alternate contents updates (Pause -> Resume -> Pause -> ...).
    134  *
    135  *  @todo not finished
    136  */
    137 class QIConstraintKeeper : public QObject
    138 {
    139     Q_OBJECT
    140 
    141 public:
    142 
    143     QIConstraintKeeper (QWidget *aParent) : QObject (aParent)
    144     {
    145         aParent->setMinimumSize (aParent->size());
    146         aParent->installEventFilter (this);
    147     }
    148 
    149 private:
    150 
    151     bool eventFilter (QObject *aObject, QEvent *aEvent)
    152     {
    153         if (aObject == parent() && aEvent->type() == QEvent::Resize)
    154         {
    155             QResizeEvent *ev = static_cast<QResizeEvent *> (aEvent);
    156             QSize oldSize = ev->oldSize();
    157             QSize newSize = ev->size();
    158             int maxWidth = newSize.width() > oldSize.width() ?
    159                 newSize.width() : oldSize.width();
    160             int maxHeight = newSize.height() > oldSize.height() ?
    161                 newSize.height() : oldSize.height();
    162             if (maxWidth > oldSize.width() || maxHeight > oldSize.height())
    163                 qobject_cast<QWidget *> (parent())->setMinimumSize (maxWidth, maxHeight);
    164         }
    165         return QObject::eventFilter (aObject, aEvent);
    166     }
    167 };
    168 
    169 /**
    17059 *  Simple class which simulates focus-proxy rule redirecting widget
    171  *  assigned shortcur to desired widget.
     60 *  assigned shortcut to desired widget.
    17261 */
    17362class QIFocusProxy : protected QObject
Note: See TracChangeset for help on using the changeset viewer.

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