- Timestamp:
- Oct 24, 2009 2:51:38 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 53913
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/QITreeWidget.h
r13580 r24054 6 6 7 7 /* 8 * Copyright (C) 2008 Sun Microsystems, Inc.8 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 #define __QITreeWidget_h__ 25 25 26 /* Global includes */ 26 27 #include <QTreeWidget> 27 28 … … 35 36 public: 36 37 37 /*38 * There are two allowed QTreeWidgetItem types which may be used with39 * QITreeWidget: basic and complex.40 * Complex type used in every place where the particular item have to41 * be separately repainted with it's own content.42 * Basic are used in all other places.43 */44 enum45 {46 BasicItemType = QTreeWidgetItem::UserType + 1,47 ComplexItemType = QTreeWidgetItem::UserType + 248 };49 50 38 QITreeWidget (QWidget *aParent = 0); 51 52 void setSupportedDropActions (Qt::DropActions aAction);53 39 54 40 void addTopBottomMarginToItems (int aMargin); … … 56 42 signals: 57 43 44 void painted (QTreeWidgetItem *aItem, QPainter *aPainter); 58 45 void resized (const QSize &aSize, const QSize &aOldSize); 59 46 60 47 protected: 61 48 62 virtual Qt::DropActions supportedDropActions () const; 63 64 void paintEvent (QPaintEvent *); 65 void resizeEvent (QResizeEvent *); 66 67 /* Protected member vars */ 68 Qt::DropActions mSupportedDropActions; 69 }; 70 71 /* 72 * Interface for more complex items which requires special repainting 73 * routine inside QITreeWidget's viewport. 74 */ 75 class ComplexTreeWidgetItem : public QTreeWidgetItem 76 { 77 public: 78 79 ComplexTreeWidgetItem (QTreeWidget *aParent) 80 : QTreeWidgetItem (aParent, QITreeWidget::ComplexItemType) {} 81 82 virtual void paintItem (QPainter *aPainter) = 0; 49 void paintEvent (QPaintEvent *aEvent); 50 void resizeEvent (QResizeEvent *aEvent); 83 51 }; 84 52 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGLSettingsLanguage.h
r10212 r24054 51 51 private slots: 52 52 53 void mTwLanguageChanged (QTreeWidgetItem *aCurr, QTreeWidgetItem *aPrev); 53 void mTwItemPainted (QTreeWidgetItem *aItem, QPainter *aPainter); 54 void mTwLanguageChanged (QTreeWidgetItem *aItem); 54 55 55 56 private: -
trunk/src/VBox/Frontends/VirtualBox/src/QITreeWidget.cpp
r13580 r24054 6 6 7 7 /* 8 * Copyright (C) 2008 Sun Microsystems, Inc.8 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 #include "QITreeWidget.h" 24 23 /* Global includes */ 25 24 #include <QPainter> 26 25 #include <QResizeEvent> 26 27 /* Local includes */ 28 #include "QITreeWidget.h" 27 29 28 30 QITreeWidget::QITreeWidget (QWidget *aParent) … … 31 33 } 32 34 33 void QITreeWidget::setSupportedDropActions (Qt::DropActions aAction)34 {35 mSupportedDropActions = aAction;36 }37 38 Qt::DropActions QITreeWidget::supportedDropActions() const39 {40 return mSupportedDropActions;41 }42 43 35 void QITreeWidget::paintEvent (QPaintEvent *aEvent) 44 36 { 45 /* Painter for items */ 46 QPainter painter (viewport()); 37 /* Opens Items Painter */ 38 QPainter painter; 39 painter.begin (viewport()); 47 40 48 /* Here we let the items make some painting inside the viewport.*/41 /* Notify connected objects about painting */ 49 42 QTreeWidgetItemIterator it (this); 50 43 while (*it) 51 44 { 52 switch ((*it)->type()) 53 { 54 case ComplexItemType: 55 { 56 /* Let the ComplexItem paint itself */ 57 ComplexTreeWidgetItem *i = static_cast<ComplexTreeWidgetItem*> (*it); 58 i->paintItem (&painter); 59 break; 60 } 61 case BasicItemType: 62 { 63 /* Do nothing for BasicItem */ 64 break; 65 } 66 default: 67 { 68 /* Wrong item is used */ 69 break; 70 } 71 } 45 emit painted (*it, &painter); 72 46 ++ it; 73 47 } 48 49 /* Close Items Painter */ 74 50 painter.end(); 75 51 52 /* Base-class paint-event */ 76 53 QTreeWidget::paintEvent (aEvent); 77 54 } … … 79 56 void QITreeWidget::resizeEvent (QResizeEvent *aEvent) 80 57 { 58 /* Base-class resize-event */ 81 59 QTreeWidget::resizeEvent (aEvent); 60 61 /* Notify connected objects about resize */ 82 62 emit resized (aEvent->size(), aEvent->oldSize()); 83 63 } … … 85 65 void QITreeWidget::addTopBottomMarginToItems (int aMargin) 86 66 { 87 for (int i =0; i < topLevelItemCount(); ++i)67 for (int i = 0; i < topLevelItemCount(); ++ i) 88 68 { 89 69 QTreeWidgetItem *item = topLevelItem (i); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGLSettingsLanguage.cpp
r24002 r24054 40 40 extern const char *gVBoxBuiltInLangName; 41 41 42 class LanguageItem : public ComplexTreeWidgetItem42 class LanguageItem : public QTreeWidgetItem 43 43 { 44 44 public: 45 46 enum { LanguageItemType = QTreeWidgetItem::UserType + 1 }; 45 47 46 48 LanguageItem (QTreeWidget *aParent, const QTranslator &aTranslator, 47 49 const QString &aId, bool aBuiltIn = false) 48 : ComplexTreeWidgetItem (aParent), mBuiltIn (aBuiltIn)50 : QTreeWidgetItem (aParent, LanguageItemType), mBuiltIn (aBuiltIn) 49 51 { 50 52 Assert (!aId.isEmpty()); … … 107 109 * file is missing or corrupt). */ 108 110 LanguageItem (QTreeWidget *aParent, const QString &aId) 109 : ComplexTreeWidgetItem (aParent), mBuiltIn (false)111 : QTreeWidgetItem (aParent, LanguageItemType), mBuiltIn (false) 110 112 { 111 113 Assert (!aId.isEmpty()); … … 125 127 * to QString::null) */ 126 128 LanguageItem (QTreeWidget *aParent) 127 : ComplexTreeWidgetItem (aParent), mBuiltIn (false)129 : QTreeWidgetItem (aParent, LanguageItemType), mBuiltIn (false) 128 130 { 129 131 setText (0, VBoxGLSettingsLanguage::tr ("Default", "Language")); … … 134 136 setText (3, " "); 135 137 } 138 139 bool isBuiltIn() const { return mBuiltIn; } 136 140 137 141 bool operator< (const QTreeWidgetItem &aOther) const … … 145 149 if (mBuiltIn) 146 150 return true; 147 if (aOther.type() == QITreeWidget::ComplexItemType && 148 ((LanguageItem*) &aOther)->mBuiltIn) 151 if (aOther.type() == LanguageItemType && ((LanguageItem*) &aOther)->mBuiltIn) 149 152 return false; 150 return ComplexTreeWidgetItem::operator< (aOther);153 return QTreeWidgetItem::operator< (aOther); 151 154 } 152 155 … … 163 166 } 164 167 165 void paintItem (QPainter *aPainter)166 {167 if (mBuiltIn)168 {169 QRect rect = treeWidget()->visualItemRect (this);170 aPainter->setPen (treeWidget()->palette().color (QPalette::Mid));171 aPainter->drawLine (rect.x(), rect.y() + rect.height() - 1,172 rect.x() + rect.width(), rect.y() + rect.height() - 1);173 }174 }175 176 168 bool mBuiltIn : 1; 177 169 }; … … 190 182 191 183 /* Setup Connections */ 184 connect (mTwLanguage, SIGNAL (painted (QTreeWidgetItem *, QPainter *)), 185 this, SLOT (mTwItemPainted (QTreeWidgetItem *, QPainter *))); 192 186 connect (mTwLanguage, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), 193 this, SLOT (mTwLanguageChanged (QTreeWidgetItem * , QTreeWidgetItem *)));187 this, SLOT (mTwLanguageChanged (QTreeWidgetItem *))); 194 188 195 189 /* Applying language settings */ … … 197 191 } 198 192 199 void VBoxGLSettingsLanguage::getFrom (const CSystemProperties &, 200 const VBoxGlobalSettings &aGs) 193 void VBoxGLSettingsLanguage::getFrom (const CSystemProperties & /* aProps */, const VBoxGlobalSettings &aGs) 201 194 { 202 195 reload (aGs.languageId()); … … 204 197 } 205 198 206 void VBoxGLSettingsLanguage::putBackTo (CSystemProperties &, 207 VBoxGlobalSettings &aGs) 199 void VBoxGLSettingsLanguage::putBackTo (CSystemProperties & /* aProps */, VBoxGlobalSettings &aGs) 208 200 { 209 201 QTreeWidgetItem *curItem = mTwLanguage->currentItem(); … … 296 288 } 297 289 298 void VBoxGLSettingsLanguage::mTwLanguageChanged (QTreeWidgetItem *aCurItem, 299 QTreeWidgetItem *) 300 { 301 if (!aCurItem) return; 290 void VBoxGLSettingsLanguage::mTwItemPainted (QTreeWidgetItem *aItem, QPainter *aPainter) 291 { 292 if (aItem && aItem->type() == LanguageItem::LanguageItemType) 293 { 294 LanguageItem *item = static_cast <LanguageItem*> (aItem); 295 if (item->isBuiltIn()) 296 { 297 QRect rect = mTwLanguage->visualItemRect (item); 298 aPainter->setPen (mTwLanguage->palette().color (QPalette::Mid)); 299 aPainter->drawLine (rect.x(), rect.y() + rect.height() - 1, 300 rect.x() + rect.width(), rect.y() + rect.height() - 1); 301 } 302 } 303 } 304 305 void VBoxGLSettingsLanguage::mTwLanguageChanged (QTreeWidgetItem *aItem) 306 { 307 if (!aItem) return; 302 308 303 309 /* Disable labels for the Default language item */ 304 bool enabled = !a CurItem->text (1).isNull();310 bool enabled = !aItem->text (1).isNull(); 305 311 306 312 mTxName->setEnabled (enabled); … … 310 316 "</table>") 311 317 .arg (tr ("Language:")) 312 .arg (a CurItem->text (2))318 .arg (aItem->text (2)) 313 319 .arg (tr ("Author(s):")) 314 .arg (a CurItem->text (3)));320 .arg (aItem->text (3))); 315 321 316 322 mLanguageChanged = true; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r23982 r24054 63 63 public: 64 64 65 enum { MediaItemType = QTreeWidgetItem::UserType + 1 }; 66 65 67 MediaItem (MediaItem *aParent, const VBoxMedium &aMedium, const VBoxMediaManagerDlg *aManager) 66 : QTreeWidgetItem (aParent, QITreeWidget::BasicItemType)68 : QTreeWidgetItem (aParent, MediaItemType) 67 69 , mMedium (aMedium) 68 70 , mManager (aManager) … … 70 72 71 73 MediaItem (QTreeWidget *aParent, const VBoxMedium &aMedium, const VBoxMediaManagerDlg *aManager) 72 : QTreeWidgetItem (aParent, QITreeWidget::BasicItemType)74 : QTreeWidgetItem (aParent, MediaItemType) 73 75 , mMedium (aMedium) 74 76 , mManager (aManager) … … 145 147 { 146 148 QTreeWidgetItem *item = QTreeWidgetItemIterator::operator*(); 147 return item && item->type() == QITreeWidget::BasicItemType ?149 return item && item->type() == MediaItem::MediaItemType ? 148 150 static_cast <MediaItem*> (item) : 0; 149 151 } … … 227 229 mTwHD->header()->setStretchLastSection (false); 228 230 mTwHD->setSortingEnabled (true); 229 mTwHD->setSupportedDropActions (Qt::LinkAction);230 231 mTwHD->installEventFilter (this); 231 232 connect (mTwHD, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), … … 245 246 mTwCD->header()->setStretchLastSection (false); 246 247 mTwCD->setSortingEnabled (true); 247 mTwCD->setSupportedDropActions (Qt::LinkAction);248 248 mTwCD->installEventFilter (this); 249 249 connect (mTwCD, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), … … 263 263 mTwFD->header()->setStretchLastSection (false); 264 264 mTwFD->setSortingEnabled (true); 265 mTwFD->setSupportedDropActions (Qt::LinkAction);266 265 mTwFD->installEventFilter (this); 267 266 connect (mTwFD, SIGNAL (currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), … … 1312 1311 /* Convert the QTreeWidgetItem to a MediaItem if it is valid. */ 1313 1312 MediaItem *item = 0; 1314 if (aItem && aItem->type() == QITreeWidget::BasicItemType)1313 if (aItem && aItem->type() == MediaItem::MediaItemType) 1315 1314 item = static_cast <MediaItem*> (aItem); 1316 1315 return item;
Note:
See TracChangeset
for help on using the changeset viewer.