some improvement in 'recent file' and 'noname' tab handling.
This commit is contained in:
@ -850,7 +850,9 @@ void PTextEdit::fileOpen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// in case there is a 1st empty tab "noname", remove it
|
// in case there is a 1st empty tab "noname", remove it
|
||||||
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
|
QString tabStr = fTabWidget->tabText(0);
|
||||||
|
tabStr.remove('&'); // this is needed since the QTabWidget adds short-cut info as '&' to the tab name
|
||||||
|
if (tabStr == "noname") { // has to be the first, otherwise do nothing
|
||||||
fFileSystemWatcher->removePath("noname");
|
fFileSystemWatcher->removePath("noname");
|
||||||
|
|
||||||
delete fTabWidget->widget(0);
|
delete fTabWidget->widget(0);
|
||||||
@ -864,12 +866,15 @@ void PTextEdit::fileOpen()
|
|||||||
void PTextEdit::fileOpenRecent()
|
void PTextEdit::fileOpenRecent()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
|
||||||
if (action) {
|
if (action) {
|
||||||
// check if this file is already open and if so, switch the tab
|
// check if this file is already open and if so, switch the tab
|
||||||
QFileInfo finfo1, finfo2;
|
QFileInfo finfo1, finfo2;
|
||||||
QString tabFln;
|
QString tabFln;
|
||||||
bool alreadyOpen = false;
|
bool alreadyOpen = false;
|
||||||
finfo1.setFile(action->text());
|
QString fln = action->text();
|
||||||
|
fln.remove('&');
|
||||||
|
finfo1.setFile(fln);
|
||||||
|
|
||||||
for (int i=0; i<fTabWidget->count(); i++) {
|
for (int i=0; i<fTabWidget->count(); i++) {
|
||||||
tabFln = *fFilenames.find( dynamic_cast<PSubTextEdit*>(fTabWidget->widget(i)));
|
tabFln = *fFilenames.find( dynamic_cast<PSubTextEdit*>(fTabWidget->widget(i)));
|
||||||
@ -881,19 +886,27 @@ void PTextEdit::fileOpenRecent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyOpen)
|
if (!alreadyOpen) {
|
||||||
load(action->text());
|
// make sure the file exists
|
||||||
else
|
if (!finfo1.exists()) {
|
||||||
|
QMessageBox::critical(this, "ERROR", QString("File '%1' does not exist.\nWill not do anything.").arg(fln));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
load(fln);
|
||||||
|
} else {
|
||||||
fileReload();
|
fileReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// in case there is a 1st empty tab "noname", remove it
|
// in case there is a 1st empty tab "noname", remove it
|
||||||
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
|
fln = fTabWidget->tabText(0);
|
||||||
|
fln.remove("&");
|
||||||
|
if (fln == "noname") { // has to be the first, otherwise do nothing
|
||||||
fFileSystemWatcher->removePath("noname");
|
fFileSystemWatcher->removePath("noname");
|
||||||
|
|
||||||
delete fTabWidget->widget(0);
|
delete fTabWidget->widget(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user