diff options
Diffstat (limited to 'src/Authoring/Studio/UI/RecentItems.cpp')
-rw-r--r-- | src/Authoring/Studio/UI/RecentItems.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/Authoring/Studio/UI/RecentItems.cpp b/src/Authoring/Studio/UI/RecentItems.cpp index e7497d40..e2e39c6f 100644 --- a/src/Authoring/Studio/UI/RecentItems.cpp +++ b/src/Authoring/Studio/UI/RecentItems.cpp @@ -32,10 +32,7 @@ #include "RecentItems.h" #include "Preferences.h" -#include <QMenu> - -// using namespace Q3DStudio; <-- Do not do this here because it will conflict with CList and make -// the template generator go blah +#include <QtWidgets/qmenu.h> const Q3DStudio::CString CRecentItems::RECENTITEM_KEY = "RecentItem"; const Q3DStudio::CString CRecentItems::RECENTIMPORT_KEY = "RecentImport"; @@ -49,6 +46,8 @@ CRecentItems::CRecentItems(QMenu *inMenuID, long inCommandID, Q3DStudio::CString m_ValidItems = 10; m_PreferenceKey = inPreferenceKey; + connect(m_Menu, &QMenu::aboutToShow, this, &CRecentItems::handleAboutToShow); + ReconstructList(); } @@ -97,11 +96,8 @@ void CRecentItems::ReconstructList() Q3DStudio::CString theFilename = thePrefs.GetStringValue(theKey, ""); if (theFilename != "") { Qt3DSFile theFile(theFilename); - - QAction *act = m_Menu->addAction(theFile.GetName().toQString(), - this, &CRecentItems::onTriggerRecent); - act->setData(static_cast<int>(m_RecentItems.size())); - m_RecentItems.push_back(theFile); + if (theFile.Exists()) + m_RecentItems.push_back(theFile); } } } @@ -114,19 +110,25 @@ void CRecentItems::RebuildList() thePrefs.SetLongValue(RECENTITEM_VALID, GetItemCount()); TFileList::iterator thePos = m_RecentItems.begin(); for (long theIndex = 0; thePos != m_RecentItems.end(); ++thePos, ++theIndex) { - Q3DStudio::CString theFilename = (*thePos).GetName(); + Qt3DSFile theFile = *thePos; + if (theFile.Exists()) { + QAction *act = m_Menu->addAction(theFile.GetName().toQString(), + this, &CRecentItems::onTriggerRecent); + act->setData(static_cast<int>(theIndex)); - QAction *act = m_Menu->addAction(theFilename.toQString(), - this, &CRecentItems::onTriggerRecent); - act->setData(static_cast<int>(theIndex)); + Q3DStudio::CString theKey; + theKey.Format(_LSTR("%ls%d"), static_cast<const wchar_t *>(m_PreferenceKey), theIndex); - Q3DStudio::CString theKey; - theKey.Format(_LSTR("%ls%d"), static_cast<const wchar_t *>(m_PreferenceKey), theIndex); - - thePrefs.SetStringValue(theKey, (*thePos).GetAbsolutePath()); + thePrefs.SetStringValue(theKey, (*thePos).GetAbsolutePath()); + } } } +void CRecentItems::handleAboutToShow() +{ + RebuildList(); +} + void CRecentItems::ClearMenu() { m_Menu->clear(); |