Recent files : Set last opened file first, remove file if load fails

This commit is contained in:
Magne Sjaastad 2014-07-31 11:54:07 +02:00
parent cdbc5829ab
commit fe712222ce
2 changed files with 27 additions and 2 deletions

View File

@ -957,14 +957,24 @@ void RiuMainWindow::slotOpenRecentFile()
if (action)
{
QString filename = action->data().toString();
bool loadingSucceded = false;
if (filename.contains(".rsp", Qt::CaseInsensitive) || filename.contains(".rip", Qt::CaseInsensitive) )
{
RiaApplication::instance()->loadProject(action->data().toString());
loadingSucceded = RiaApplication::instance()->loadProject(action->data().toString());
}
else if ( filename.contains(".egrid", Qt::CaseInsensitive) || filename.contains(".grid", Qt::CaseInsensitive) )
{
RiaApplication::instance()->openEclipseCaseFromFile(filename);
loadingSucceded = RiaApplication::instance()->openEclipseCaseFromFile(filename);
}
if (loadingSucceded)
{
addRecentFiles(filename);
}
else
{
removeRecentFiles(filename);
}
}
}
@ -1009,6 +1019,20 @@ void RiuMainWindow::addRecentFiles(const QString& file)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::removeRecentFiles(const QString& file)
{
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(file);
settings.setValue("recentFileList", files);
updateRecentFileActions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -113,6 +113,7 @@ private:
void updateRecentFileActions();
void addRecentFiles(const QString& file);
void removeRecentFiles(const QString& file);
QMdiSubWindow* findMdiSubWindow(RiuViewer* viewer);