Changeset 563 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 2, 2007 4:44:41 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r548 r563 383 383 /** 384 384 * Emitted at the end of the enumeration process started 385 * by #startEnumeratingMedia(). 386 * @note #currentMediaList() will return an empty list 387 * when this signal is emitted, use the argument instead. 385 * by #startEnumeratingMedia(). The @a aList argument is passed for 386 * convenience, it is exactly the same as returned by #currentMediaList(). 388 387 */ 389 388 void mediaEnumFinished (const VBoxMediaList &aList); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r548 r563 1066 1066 if (media_enum_thread) 1067 1067 return; 1068 1069 /* ignore the request during application termination */ 1070 if (vboxGlobal_cleanup) 1071 return; 1068 1072 1069 1073 /* composes a list of all currently known media */ … … 1071 1075 { 1072 1076 CHardDiskEnumerator enHD = vbox.GetHardDisks().Enumerate(); 1073 while (enHD.HasMore() && !vboxGlobal_cleanup)1077 while (enHD.HasMore()) 1074 1078 { 1075 1079 CHardDisk hd = enHD.GetNext(); … … 1077 1081 } 1078 1082 CDVDImageEnumerator enCD = vbox.GetDVDImages().Enumerate(); 1079 while (enCD.HasMore() && !vboxGlobal_cleanup)1083 while (enCD.HasMore()) 1080 1084 { 1081 1085 CDVDImage cd = enCD.GetNext(); … … 1083 1087 } 1084 1088 CFloppyImageEnumerator enFD = vbox.GetFloppyImages().Enumerate(); 1085 while (enFD.HasMore() && !vboxGlobal_cleanup)1089 while (enFD.HasMore()) 1086 1090 { 1087 1091 CFloppyImage fd = enFD.GetNext(); 1088 1092 media_list += VBoxMedia (CUnknown (fd), VBoxDefs::FD, VBoxMedia::Unknown); 1089 1093 } 1090 if (!vboxGlobal_cleanup)1091 emit mediaEnumStarted();1092 1094 } 1093 1095 … … 1097 1099 public: 1098 1100 1099 Thread ( VBoxMediaList &aList) : mList (aList) {}1101 Thread (const VBoxMediaList &aList) : mList (aList) {} 1100 1102 1101 1103 virtual void run() … … 1109 1111 /* enumerating list */ 1110 1112 int index = 0; 1111 VBoxMediaList:: Iterator it;1113 VBoxMediaList::const_iterator it; 1112 1114 for (it = mList.begin(); 1113 1115 it != mList.end() && !vboxGlobal_cleanup; 1114 1116 ++ it, ++ index) 1115 1117 { 1116 VBoxMedia &media = *it;1118 VBoxMedia media = *it; 1117 1119 switch (media.type) 1118 1120 { … … 1134 1136 } 1135 1137 } 1136 VBoxMedia newMedia (CUnknown(hd), VBoxDefs::HD, media.status);1137 1138 QApplication::postEvent (target, 1138 new VBoxEnumerateMediaEvent ( newMedia, index));1139 new VBoxEnumerateMediaEvent (media, index)); 1139 1140 break; 1140 1141 } … … 1146 1147 cd.isOk() ? VBoxMedia::Inaccessible : 1147 1148 VBoxMedia::Error; 1148 VBoxMedia newMedia (CUnknown(cd), VBoxDefs::CD, media.status);1149 1149 QApplication::postEvent (target, 1150 new VBoxEnumerateMediaEvent ( newMedia, index));1150 new VBoxEnumerateMediaEvent (media, index)); 1151 1151 break; 1152 1152 } … … 1158 1158 fd.isOk() ? VBoxMedia::Inaccessible : 1159 1159 VBoxMedia::Error; 1160 VBoxMedia newMedia (CUnknown(fd), VBoxDefs::FD, media.status);1161 1160 QApplication::postEvent (target, 1162 new VBoxEnumerateMediaEvent ( newMedia, index));1161 new VBoxEnumerateMediaEvent (media, index)); 1163 1162 break; 1164 1163 } … … 1181 1180 private: 1182 1181 1183 VBoxMediaList &mList;1182 const VBoxMediaList &mList; 1184 1183 }; 1185 1184 1186 1185 media_enum_thread = new Thread (media_list); 1186 AssertReturnVoid (media_enum_thread); 1187 1188 /* emit mediaEnumStarted() after we set media_enum_thread to != NULL 1189 * to cause isMediaEnumerationStarted() to return TRUE from slots */ 1190 emit mediaEnumStarted(); 1191 1187 1192 media_enum_thread->start(); 1188 1193 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r548 r563 981 981 if (it != list.end() && vboxProblem().remindAboutInaccessibleMedia()) 982 982 { 983 /* pass the list we got in the argument to indicate that 984 * VBoxDiskImageManagerDlg should not start the enumeration at the 985 * beginning (i.e. if being shown for the first time) */ 986 VBoxDiskImageManagerDlg::showModeless (&list); 983 /* Show the VDM dialog but don't refresh once more after a 984 * just-finished refresh */ 985 VBoxDiskImageManagerDlg::showModeless (false /* aRefresh */); 987 986 } 988 987 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxDiskImageManagerDlg.ui
r548 r563 603 603 <function returnType="QUuid">getSelectedUuid()</function> 604 604 <function returnType="QString">getSelectedPath()</function> 605 <function>setup( int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, const VBoxMediaList *mediaList = NULL, CMachine machine = 0)</function>605 <function>setup( int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, bool aRefresh = true, CMachine machine = NULL )</function> 606 606 <function access="private" returnType="QListView*">getCurrentListView()</function> 607 607 <function access="private" returnType="QListView*">getListView( VBoxDefs::DiskType )</function> … … 624 624 <function access="protected" returnType="QPushButton*">searchDefaultButton()</function> 625 625 <function access="protected">setCurrentItem( QListView*, QListViewItem* )</function> 626 <function specifier="non virtual">static showModeless( const VBoxMediaList * = NULL)</function>626 <function specifier="non virtual">static showModeless( bool aRefresh = true )</function> 627 627 <function specifier="non virtual" returnType="QString">static composeHdToolTip( CHardDisk &, VBoxMedia::Status = VBoxMedia::Ok )</function> 628 628 <function specifier="non virtual" returnType="QString">static composeCdToolTip( CDVDImage &, VBoxMedia::Status = VBoxMedia::Ok )</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxDiskImageManagerDlg.ui.h
r548 r563 146 146 147 147 148 void VBoxDiskImageManagerDlg::showModeless ( const VBoxMediaList *list /* = NULL*/)148 void VBoxDiskImageManagerDlg::showModeless (bool aRefresh /* = true */) 149 149 { 150 150 if (!mModelessDialog) … … 155 155 WType_TopLevel | WDestructiveClose); 156 156 mModelessDialog->setup (VBoxDefs::HD | VBoxDefs::CD | VBoxDefs::FD, 157 false, NULL, list);157 false, NULL, aRefresh); 158 158 159 159 /* listen to events that may change the media status and refresh … … 1211 1211 1212 1212 void VBoxDiskImageManagerDlg::setup (int aType, bool aDoSelect, 1213 const QUuid *aTargetVMId ,1214 const VBoxMediaList *mediaList,1215 CMachine machine )1213 const QUuid *aTargetVMId /* = NULL */, 1214 bool aRefresh /* = true */, 1215 CMachine machine /* = NULL */) 1216 1216 { 1217 1217 cmachine = machine; … … 1251 1251 this, SLOT (mediaRemoved (VBoxDefs::DiskType, const QUuid &))); 1252 1252 1253 /* insert already enumerated media */ 1254 VBoxMediaList list = mediaList ? 1255 *mediaList : vboxGlobal().currentMediaList(); 1253 if (aRefresh && !vboxGlobal().isMediaEnumerationStarted()) 1254 { 1255 vboxGlobal().startEnumeratingMedia(); 1256 } 1257 else 1258 { 1259 /* insert already enumerated media */ 1260 const VBoxMediaList &list = vboxGlobal().currentMediaList(); 1261 prepareToRefresh (list.size()); 1262 VBoxMediaList::const_iterator it; 1263 int index = 0; 1264 for (it = list.begin(); it != list.end(); ++ it) 1265 { 1266 mediaAdded (*it); 1267 if ((*it).status != VBoxMedia::Unknown) 1268 mProgressBar->setProgress (++ index); 1269 } 1270 1271 /* select first child */ 1272 setCurrentItem (hdsView, hdsView->firstChild()); 1273 setCurrentItem (cdsView, cdsView->firstChild()); 1274 setCurrentItem (fdsView, fdsView->firstChild()); 1275 1276 /* emulate the finished signal to reuse the code */ 1277 if (!vboxGlobal().isMediaEnumerationStarted()) 1278 mediaEnumFinished (list); 1279 } 1280 } 1281 1282 1283 void VBoxDiskImageManagerDlg::mediaEnumStarted() 1284 { 1285 /* load current media list */ 1286 const VBoxMediaList &list = vboxGlobal().currentMediaList(); 1256 1287 prepareToRefresh (list.size()); 1257 VBoxMediaList::const_iterator it;1258 int index = 0;1259 for (it = list.begin(); it != list.end(); ++ it)1260 {1261 mediaAdded (*it);1262 if ((*it).status != VBoxMedia::Unknown)1263 mProgressBar->setProgress (index ++);1264 }1265 /* select first child */1266 setCurrentItem (hdsView, hdsView->firstChild());1267 setCurrentItem (cdsView, cdsView->firstChild());1268 setCurrentItem (fdsView, fdsView->firstChild());1269 1270 if (mediaList)1271 {1272 mediaEnumFinished (list);1273 }1274 else1275 {1276 /* only start enumerating media if we haven't been supplied a list1277 * (it's ok if the enumeration has been already started, nothing will1278 * happen) */1279 vboxGlobal().startEnumeratingMedia();1280 }1281 }1282 1283 1284 void VBoxDiskImageManagerDlg::mediaEnumStarted()1285 {1286 VBoxMediaList list = vboxGlobal().currentMediaList();1287 prepareToRefresh (list.size());1288 /* clearing lists */1289 hdsView->clear(), cdsView->clear(), fdsView->clear();1290 /* load current media list */1291 1288 VBoxMediaList::const_iterator it; 1292 1289 for (it = list.begin(); it != list.end(); ++ it) 1293 1290 mediaAdded (*it); 1294 1291 /* select first child */ 1295 if (!hdsView-> isSelected (hdsView->currentItem()))1292 if (!hdsView->currentItem()) 1296 1293 setCurrentItem (hdsView, hdsView->firstChild()); 1297 if (!cdsView-> isSelected (cdsView->currentItem()))1294 if (!cdsView->currentItem()) 1298 1295 setCurrentItem (cdsView, cdsView->firstChild()); 1299 if (!fdsView-> isSelected (fdsView->currentItem()))1296 if (!fdsView->currentItem()) 1300 1297 setCurrentItem (fdsView, fdsView->firstChild()); 1301 1298 … … 1307 1304 { 1308 1305 mediaUpdated (aMedia); 1306 Assert (aMedia.status != VBoxMedia::Unknown); 1309 1307 if (aMedia.status != VBoxMedia::Unknown) 1310 mProgressBar->setProgress (aIndex );1308 mProgressBar->setProgress (aIndex + 1); 1311 1309 } 1312 1310 … … 1318 1316 imRefreshAction->setEnabled (true); 1319 1317 unsetCursor(); 1318 1319 /* adjust columns (it is strange to repeat but it works) */ 1320 1321 hdsView->adjustColumn (1); 1322 hdsView->adjustColumn (2); 1323 hdsView->adjustColumn (1); 1324 1325 cdsView->adjustColumn (1); 1326 cdsView->adjustColumn (2); 1327 cdsView->adjustColumn (1); 1328 1329 fdsView->adjustColumn (1); 1330 fdsView->adjustColumn (2); 1331 fdsView->adjustColumn (1); 1320 1332 1321 1333 processCurrentChanged(); … … 1450 1462 imRefreshAction->setEnabled (false); 1451 1463 setCursor (QCursor (BusyCursor)); 1464 1465 /* store the current list selections */ 1466 1467 QListViewItem *item; 1468 DiskImageItem *di; 1469 1470 item = hdsView->currentItem(); 1471 di = (item && item->rtti() == 1001) ? static_cast <DiskImageItem *> (item) : 0; 1472 hdSelectedId = di ? di->getUuid() : QUuid(); 1473 1474 item = cdsView->currentItem(); 1475 di = (item && item->rtti() == 1001) ? static_cast <DiskImageItem *> (item) : 0; 1476 cdSelectedId = di ? di->getUuid() : QUuid(); 1477 1478 item = fdsView->currentItem(); 1479 di = (item && item->rtti() == 1001) ? static_cast <DiskImageItem *> (item) : 0; 1480 fdSelectedId = di ? di->getUuid() : QUuid(); 1481 1482 /* finally, clear all lists */ 1483 hdsView->clear(); 1484 cdsView->clear(); 1485 fdsView->clear(); 1452 1486 } 1453 1487 … … 1528 1562 aListView->setCurrentItem (aItem); 1529 1563 aListView->setSelected (aListView->currentItem(), true); 1530 /* it is strange repeat but it works */1531 aListView->adjustColumn (1);1532 aListView->adjustColumn (2);1533 aListView->adjustColumn (1);1534 1564 } 1535 1565 … … 1608 1638 hdsPane4->setText (item->getInformation (item->getUsage())); 1609 1639 hdsPane5->setText (item->getInformation (item->getSnapshotName())); 1610 hdSelectedId = item->getUuid();1611 1640 } 1612 1641 else if (item->listView() == cdsView) … … 1614 1643 cdsPane1->setText (item->getInformation (item->getPath(), true, "end")); 1615 1644 cdsPane2->setText (item->getInformation (item->getUsage())); 1616 cdSelectedId = item->getUuid();1617 1645 } 1618 1646 else if (item->listView() == fdsView) … … 1620 1648 fdsPane1->setText (item->getInformation (item->getPath(), true, "end")); 1621 1649 fdsPane2->setText (item->getInformation (item->getUsage())); 1622 fdSelectedId = item->getUuid();1623 1650 } 1624 1651 }
Note:
See TracChangeset
for help on using the changeset viewer.