Changeset 43005 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 27, 2012 5:35:33 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r42945 r43005 1451 1451 connect(m_pChooser, SIGNAL(sigToggleStarted()), m_pDetails, SIGNAL(sigToggleStarted())); 1452 1452 connect(m_pChooser, SIGNAL(sigToggleFinished()), m_pDetails, SIGNAL(sigToggleFinished())); 1453 connect(m_pChooser, SIGNAL(sigGroupSavingStarted()), this, SLOT(sltGroupSavingUpdate())); 1454 connect(m_pChooser, SIGNAL(sigGroupSavingFinished()), this, SLOT(sltGroupSavingUpdate())); 1453 connect(m_pChooser, SIGNAL(sigGroupSavingStateChanged()), this, SLOT(sltGroupSavingUpdate())); 1455 1454 1456 1455 /* Tool-bar connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.cpp
r42882 r43005 126 126 connect(m_pChooserModel, SIGNAL(sigToggleStarted()), this, SIGNAL(sigToggleStarted())); 127 127 connect(m_pChooserModel, SIGNAL(sigToggleFinished()), this, SIGNAL(sigToggleFinished())); 128 connect(m_pChooserModel, SIGNAL(sigGroupSavingStarted()), this, SIGNAL(sigGroupSavingStarted())); 129 connect(m_pChooserModel, SIGNAL(sigGroupSavingFinished()), this, SIGNAL(sigGroupSavingFinished())); 128 connect(m_pChooserModel, SIGNAL(sigGroupSavingStateChanged()), this, SIGNAL(sigGroupSavingStateChanged())); 130 129 connect(m_pChooserModel, SIGNAL(sigFocusChanged(UIGChooserItem*)), m_pChooserView, SLOT(sltFocusChanged(UIGChooserItem*))); 131 130 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.h
r42734 r43005 50 50 void sigToggleFinished(); 51 51 52 /* Notifiers: Group saving stuff: */ 53 void sigGroupSavingStarted(); 54 void sigGroupSavingFinished(); 52 /* Notifier: Group saving stuff: */ 53 void sigGroupSavingStateChanged(); 55 54 56 55 public: -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r42998 r43005 553 553 bool UIGChooserModel::isGroupSavingInProgress() const 554 554 { 555 return UIGroupsSavingThread::instance(); 555 return UIGroupDefinitionSaveThread::instance() || 556 UIGroupOrderSaveThread::instance(); 556 557 } 557 558 … … 977 978 void UIGChooserModel::sltGroupSavingStart() 978 979 { 979 saveGroupTree(); 980 } 981 982 void UIGChooserModel::sltGroupSavingComplete() 983 { 984 makeSureGroupSavingIsFinished(); 985 emit sigGroupSavingFinished(); 980 saveGroupDefinitions(); 981 saveGroupOrders(); 982 } 983 984 void UIGChooserModel::sltGroupDefinitionsSaveComplete() 985 { 986 makeSureGroupDefinitionsSaveIsFinished(); 987 emit sigGroupSavingStateChanged(); 988 } 989 990 void UIGChooserModel::sltGroupOrdersSaveComplete() 991 { 992 makeSureGroupOrdersSaveIsFinished(); 993 emit sigGroupSavingStateChanged(); 986 994 } 987 995 … … 1110 1118 void UIGChooserModel::cleanupGroupTree() 1111 1119 { 1112 makeSureGroup SavingIsFinished();1113 saveGroupsOrder();1120 makeSureGroupDefinitionsSaveIsFinished(); 1121 makeSureGroupOrdersSaveIsFinished(); 1114 1122 } 1115 1123 … … 1471 1479 } 1472 1480 1473 void UIGChooserModel::saveGroup Tree()1474 { 1475 /* Make sure there is no group sav ingactivity: */1476 if (UIGroup sSavingThread::instance())1481 void UIGChooserModel::saveGroupDefinitions() 1482 { 1483 /* Make sure there is no group save activity: */ 1484 if (UIGroupDefinitionSaveThread::instance()) 1477 1485 return; 1478 1486 1479 1487 /* Prepare full group map: */ 1480 1488 QMap<QString, QStringList> groups; 1481 gatherGroup Tree(groups, mainRoot());1489 gatherGroupDefinitions(groups, mainRoot()); 1482 1490 1483 1491 /* Save information in other thread: */ 1484 UIGroup sSavingThread::prepare();1485 emit sigGroupSavingSta rted();1486 UIGroup sSavingThread::instance()->configure(this, m_groups, groups);1487 UIGroup sSavingThread::instance()->start();1492 UIGroupDefinitionSaveThread::prepare(); 1493 emit sigGroupSavingStateChanged(); 1494 UIGroupDefinitionSaveThread::instance()->configure(this, m_groups, groups); 1495 UIGroupDefinitionSaveThread::instance()->start(); 1488 1496 m_groups = groups; 1489 1497 } 1490 1498 1491 void UIGChooserModel::saveGroupsOrder() 1492 { 1493 /* Clear all the extra-data records related to group-definitions: */ 1494 const QVector<QString> extraDataKeys = vboxGlobal().virtualBox().GetExtraDataKeys(); 1495 foreach (const QString &strKey, extraDataKeys) 1496 if (strKey.startsWith(UIDefs::GUI_GroupDefinitions)) 1497 vboxGlobal().virtualBox().SetExtraData(strKey, QString()); 1498 /* Save order starting from the root-item: */ 1499 saveGroupsOrder(mainRoot()); 1500 } 1501 1502 void UIGChooserModel::saveGroupsOrder(UIGChooserItem *pParentItem) 1503 { 1504 /* Prepare extra-data key for current group: */ 1505 QString strExtraDataKey = UIDefs::GUI_GroupDefinitions + fullName(pParentItem); 1506 /* Gather item order: */ 1507 QStringList order; 1508 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Group)) 1509 { 1510 saveGroupsOrder(pItem); 1511 QString strGroupDescriptor(pItem->toGroupItem()->opened() ? "go" : "gc"); 1512 order << QString("%1=%2").arg(strGroupDescriptor, pItem->name()); 1513 } 1514 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Machine)) 1515 order << QString("m=%1").arg(pItem->toMachineItem()->id()); 1516 vboxGlobal().virtualBox().SetExtraDataStringList(strExtraDataKey, order); 1517 } 1518 1519 void UIGChooserModel::gatherGroupTree(QMap<QString, QStringList> &groups, 1520 UIGChooserItem *pParentGroup) 1499 void UIGChooserModel::saveGroupOrders() 1500 { 1501 /* Make sure there is no group save activity: */ 1502 if (UIGroupOrderSaveThread::instance()) 1503 return; 1504 1505 /* Prepare full group map: */ 1506 QMap<QString, QStringList> groups; 1507 gatherGroupOrders(groups, mainRoot()); 1508 1509 /* Save information in other thread: */ 1510 UIGroupOrderSaveThread::prepare(); 1511 emit sigGroupSavingStateChanged(); 1512 UIGroupOrderSaveThread::instance()->configure(this, groups); 1513 UIGroupOrderSaveThread::instance()->start(); 1514 } 1515 1516 void UIGChooserModel::gatherGroupDefinitions(QMap<QString, QStringList> &groups, 1517 UIGChooserItem *pParentGroup) 1521 1518 { 1522 1519 /* Iterate over all the machine items: */ … … 1527 1524 /* Iterate over all the group items: */ 1528 1525 foreach (UIGChooserItem *pItem, pParentGroup->items(UIGChooserItemType_Group)) 1529 gatherGroupTree(groups, pItem); 1526 gatherGroupDefinitions(groups, pItem); 1527 } 1528 1529 void UIGChooserModel::gatherGroupOrders(QMap<QString, QStringList> &groups, 1530 UIGChooserItem *pParentItem) 1531 { 1532 /* Prepare extra-data key for current group: */ 1533 QString strExtraDataKey = UIDefs::GUI_GroupDefinitions + fullName(pParentItem); 1534 /* Iterate over all the group items: */ 1535 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Group)) 1536 { 1537 QString strGroupDescriptor(pItem->toGroupItem()->opened() ? "go" : "gc"); 1538 groups[strExtraDataKey] << QString("%1=%2").arg(strGroupDescriptor, pItem->name()); 1539 gatherGroupOrders(groups, pItem); 1540 } 1541 /* Iterate over all the machine items: */ 1542 foreach (UIGChooserItem *pItem, pParentItem->items(UIGChooserItemType_Machine)) 1543 groups[strExtraDataKey] << QString("m=%1").arg(pItem->toMachineItem()->id()); 1530 1544 } 1531 1545 … … 1901 1915 } 1902 1916 1903 void UIGChooserModel::makeSureGroupSavingIsFinished() 1904 { 1905 /* Nothing to do if thread is null: */ 1906 if (!UIGroupsSavingThread::instance()) 1907 return; 1908 1909 /* Cleanup thread otherwise: */ 1910 UIGroupsSavingThread::cleanup(); 1917 void UIGChooserModel::makeSureGroupDefinitionsSaveIsFinished() 1918 { 1919 /* Cleanup if necessary: */ 1920 if (UIGroupDefinitionSaveThread::instance()) 1921 UIGroupDefinitionSaveThread::cleanup(); 1922 } 1923 1924 void UIGChooserModel::makeSureGroupOrdersSaveIsFinished() 1925 { 1926 /* Cleanup if necessary: */ 1927 if (UIGroupOrderSaveThread::instance()) 1928 UIGroupOrderSaveThread::cleanup(); 1911 1929 } 1912 1930 … … 1930 1948 1931 1949 /* static */ 1932 UIGroup sSavingThread* UIGroupsSavingThread::m_spInstance = 0;1950 UIGroupDefinitionSaveThread* UIGroupDefinitionSaveThread::m_spInstance = 0; 1933 1951 1934 1952 /* static */ 1935 UIGroup sSavingThread* UIGroupsSavingThread::instance()1953 UIGroupDefinitionSaveThread* UIGroupDefinitionSaveThread::instance() 1936 1954 { 1937 1955 return m_spInstance; … … 1939 1957 1940 1958 /* static */ 1941 void UIGroup sSavingThread::prepare()1959 void UIGroupDefinitionSaveThread::prepare() 1942 1960 { 1943 1961 /* Make sure instance not prepared: */ … … 1946 1964 1947 1965 /* Crate instance: */ 1948 new UIGroup sSavingThread;1966 new UIGroupDefinitionSaveThread; 1949 1967 } 1950 1968 1951 1969 /* static */ 1952 void UIGroup sSavingThread::cleanup()1970 void UIGroupDefinitionSaveThread::cleanup() 1953 1971 { 1954 1972 /* Make sure instance prepared: */ … … 1960 1978 } 1961 1979 1962 void UIGroup sSavingThread::configure(QObject *pParent,1963 const QMap<QString, QStringList> &oldLists,1964 const QMap<QString, QStringList> &newLists)1980 void UIGroupDefinitionSaveThread::configure(QObject *pParent, 1981 const QMap<QString, QStringList> &oldLists, 1982 const QMap<QString, QStringList> &newLists) 1965 1983 { 1966 1984 m_oldLists = oldLists; 1967 1985 m_newLists = newLists; 1968 connect(this, SIGNAL(sigComplete()), pParent, SLOT(sltGroup SavingComplete()));1969 } 1970 1971 void UIGroup sSavingThread::sltHandleError(UIGroupsSavingError errorType, const CMachine &machine)1986 connect(this, SIGNAL(sigComplete()), pParent, SLOT(sltGroupDefinitionsSaveComplete())); 1987 } 1988 1989 void UIGroupDefinitionSaveThread::sltHandleError(UIGroupsSavingError errorType, const CMachine &machine) 1972 1990 { 1973 1991 switch (errorType) … … 1988 2006 } 1989 2007 1990 UIGroup sSavingThread::UIGroupsSavingThread()2008 UIGroupDefinitionSaveThread::UIGroupDefinitionSaveThread() 1991 2009 { 1992 2010 /* Assign instance: */ … … 1999 2017 } 2000 2018 2001 UIGroup sSavingThread::~UIGroupsSavingThread()2019 UIGroupDefinitionSaveThread::~UIGroupDefinitionSaveThread() 2002 2020 { 2003 2021 /* Wait: */ … … 2008 2026 } 2009 2027 2010 void UIGroup sSavingThread::run()2028 void UIGroupDefinitionSaveThread::run() 2011 2029 { 2012 2030 /* Lock other thread mutex: */ … … 2085 2103 } 2086 2104 2105 /* static */ 2106 UIGroupOrderSaveThread* UIGroupOrderSaveThread::m_spInstance = 0; 2107 2108 /* static */ 2109 UIGroupOrderSaveThread* UIGroupOrderSaveThread::instance() 2110 { 2111 return m_spInstance; 2112 } 2113 2114 /* static */ 2115 void UIGroupOrderSaveThread::prepare() 2116 { 2117 /* Make sure instance not prepared: */ 2118 if (m_spInstance) 2119 return; 2120 2121 /* Crate instance: */ 2122 new UIGroupOrderSaveThread; 2123 } 2124 2125 /* static */ 2126 void UIGroupOrderSaveThread::cleanup() 2127 { 2128 /* Make sure instance prepared: */ 2129 if (!m_spInstance) 2130 return; 2131 2132 /* Crate instance: */ 2133 delete m_spInstance; 2134 } 2135 2136 void UIGroupOrderSaveThread::configure(QObject *pParent, 2137 const QMap<QString, QStringList> &groups) 2138 { 2139 m_groups = groups; 2140 connect(this, SIGNAL(sigComplete()), pParent, SLOT(sltGroupOrdersSaveComplete())); 2141 } 2142 2143 UIGroupOrderSaveThread::UIGroupOrderSaveThread() 2144 { 2145 /* Assign instance: */ 2146 m_spInstance = this; 2147 } 2148 2149 UIGroupOrderSaveThread::~UIGroupOrderSaveThread() 2150 { 2151 /* Wait: */ 2152 wait(); 2153 2154 /* Erase instance: */ 2155 m_spInstance = 0; 2156 } 2157 2158 void UIGroupOrderSaveThread::run() 2159 { 2160 /* COM prepare: */ 2161 COMBase::InitializeCOM(false); 2162 2163 /* Clear all the extra-data records related to group-definitions: */ 2164 const QVector<QString> extraDataKeys = vboxGlobal().virtualBox().GetExtraDataKeys(); 2165 foreach (const QString &strKey, extraDataKeys) 2166 if (strKey.startsWith(UIDefs::GUI_GroupDefinitions)) 2167 vboxGlobal().virtualBox().SetExtraData(strKey, QString()); 2168 2169 /* For every particular group definition: */ 2170 foreach (const QString &strId, m_groups.keys()) 2171 vboxGlobal().virtualBox().SetExtraDataStringList(strId, m_groups[strId]); 2172 2173 /* Notify listeners about completeness: */ 2174 emit sigComplete(); 2175 2176 /* COM cleanup: */ 2177 COMBase::CleanupCOM(); 2178 } 2179 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r42998 r43005 85 85 /* Notifiers: Group saving stuff: */ 86 86 void sigStartGroupSaving(); 87 void sigGroupSavingStarted(); 88 void sigGroupSavingFinished(); 87 void sigGroupSavingStateChanged(); 89 88 90 89 public: … … 213 212 /* Handlers: Group saving stuff: */ 214 213 void sltGroupSavingStart(); 215 void sltGroupSavingComplete(); 214 void sltGroupDefinitionsSaveComplete(); 215 void sltGroupOrdersSaveComplete(); 216 216 217 217 /* Handler: Lookup stuff: */ … … 266 266 void createMachineItem(const CMachine &machine, UIGChooserItem *pParentItem); 267 267 268 /* Helpers: Saving: */269 void saveGroup Tree();270 void saveGroup sOrder();271 void saveGroupsOrder(UIGChooserItem *pParentItem);272 void gatherGroup Tree(QMap<QString, QStringList> &groups, UIGChooserItem *pParentGroup);268 /* Helpers: Group saving stuff: */ 269 void saveGroupDefinitions(); 270 void saveGroupOrders(); 271 void gatherGroupDefinitions(QMap<QString, QStringList> &groups, UIGChooserItem *pParentGroup); 272 void gatherGroupOrders(QMap<QString, QStringList> &groups, UIGChooserItem *pParentItem); 273 273 QString fullName(UIGChooserItem *pItem); 274 274 … … 307 307 void sortItems(UIGChooserItem *pParent, bool fRecursively = false); 308 308 309 /* Helper: Group saving stuff: */ 310 void makeSureGroupSavingIsFinished(); 309 /* Helpers: Group saving stuff: */ 310 void makeSureGroupDefinitionsSaveIsFinished(); 311 void makeSureGroupOrdersSaveIsFinished(); 311 312 312 313 /* Helper: Lookup stuff: */ … … 339 340 }; 340 341 341 /* Represents group -savingerror types: */342 /* Represents group definitions save error types: */ 342 343 enum UIGroupsSavingError 343 344 { … … 348 349 Q_DECLARE_METATYPE(UIGroupsSavingError); 349 350 350 /* Allows to save group settings asynchronously: */351 class UIGroup sSavingThread : public QThread351 /* Allows to save group definitions asynchronously: */ 352 class UIGroupDefinitionSaveThread : public QThread 352 353 { 353 354 Q_OBJECT; … … 364 365 365 366 /* Singleton stuff: */ 366 static UIGroup sSavingThread* instance();367 static UIGroupDefinitionSaveThread* instance(); 367 368 static void prepare(); 368 369 static void cleanup(); … … 381 382 382 383 /* Constructor/destructor: */ 383 UIGroup sSavingThread();384 ~UIGroup sSavingThread();384 UIGroupDefinitionSaveThread(); 385 ~UIGroupDefinitionSaveThread(); 385 386 386 387 /* Worker thread stuff: */ … … 388 389 389 390 /* Variables: */ 390 static UIGroup sSavingThread *m_spInstance;391 static UIGroupDefinitionSaveThread *m_spInstance; 391 392 QMap<QString, QStringList> m_oldLists; 392 393 QMap<QString, QStringList> m_newLists; … … 395 396 }; 396 397 398 /* Allows to save group order asynchronously: */ 399 class UIGroupOrderSaveThread : public QThread 400 { 401 Q_OBJECT; 402 403 signals: 404 405 /* Notifier: Complete stuff: */ 406 void sigComplete(); 407 408 public: 409 410 /* Singleton stuff: */ 411 static UIGroupOrderSaveThread* instance(); 412 static void prepare(); 413 static void cleanup(); 414 415 /* API: Configuring stuff: */ 416 void configure(QObject *pParent, const QMap<QString, QStringList> &groups); 417 418 private: 419 420 /* Constructor/destructor: */ 421 UIGroupOrderSaveThread(); 422 ~UIGroupOrderSaveThread(); 423 424 /* Worker thread stuff: */ 425 void run(); 426 427 /* Variables: */ 428 static UIGroupOrderSaveThread *m_spInstance; 429 QMap<QString, QStringList> m_groups; 430 }; 431 397 432 #endif /* __UIGChooserModel_h__ */ 398 433
Note:
See TracChangeset
for help on using the changeset viewer.