Arrange things so that "open parent" selects the file child when the parent is a directory

This commit is contained in:
Jean-Francois Dockes 2013-02-27 14:36:45 +01:00
parent 05db0dcd05
commit ccaac8cf0e
5 changed files with 33 additions and 5 deletions

View file

@ -930,13 +930,19 @@ void ResList::createPopupMenu(const QPoint& pos)
} }
popup->addAction(tr("Find &similar documents"), this, SLOT(menuExpand())); popup->addAction(tr("Find &similar documents"), this, SLOT(menuExpand()));
popup->addAction(tr("Preview P&arent document/folder"),
this, SLOT(menuPreviewParent())); Rcl::Doc pdoc;
if (m_source.isNotNull() && m_source->getEnclosing(doc, pdoc))
popup->addAction(tr("Preview P&arent document/folder"),
this, SLOT(menuPreviewParent()));
popup->addAction(tr("&Open Parent document/folder"), popup->addAction(tr("&Open Parent document/folder"),
this, SLOT(menuOpenParent())); this, SLOT(menuOpenParent()));
if (havedoc && doc.haspages && m_source->snippetsCapable()) if (havedoc && doc.haspages && m_source->snippetsCapable())
popup->addAction(tr("Open &Snippets window"), popup->addAction(tr("Open &Snippets window"),
this, SLOT(menuOpenSnippets())); this, SLOT(menuOpenSnippets()));
popup->popup(mapToGlobal(pos)); popup->popup(mapToGlobal(pos));
} }
@ -983,6 +989,8 @@ void ResList::menuOpenParent()
// No parent doc: show enclosing folder with app configured for // No parent doc: show enclosing folder with app configured for
// directories // directories
pdoc.url = path_getfather(doc.url); pdoc.url = path_getfather(doc.url);
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
pdoc.mimetype = "application/x-fsdirectory"; pdoc.mimetype = "application/x-fsdirectory";
emit editRequested(pdoc); emit editRequested(pdoc);
} }

View file

@ -745,11 +745,18 @@ void ResTable::createPopupMenu(const QPoint& pos)
popup->addAction(tr("&Open"), this, SLOT(menuEdit())); popup->addAction(tr("&Open"), this, SLOT(menuEdit()));
popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN())); popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN()));
popup->addAction(tr("Copy &URL"), this, SLOT(menuCopyURL())); popup->addAction(tr("Copy &URL"), this, SLOT(menuCopyURL()));
if (m_detaildoc.ipath.empty()) if (m_detaildoc.ipath.empty())
popup->addAction(tr("&Write to File"), this, SLOT(menuSaveToFile())); popup->addAction(tr("&Write to File"), this, SLOT(menuSaveToFile()));
popup->addAction(tr("Find &similar documents"), this, SLOT(menuExpand())); popup->addAction(tr("Find &similar documents"), this, SLOT(menuExpand()));
popup->addAction(tr("Preview P&arent document/folder"),
this, SLOT(menuPreviewParent())); RefCntr<DocSequence> source = m_model->getDocSource();
Rcl::Doc pdoc;
if (source.isNotNull() && source->getEnclosing(m_detaildoc, pdoc))
popup->addAction(tr("Preview P&arent document/folder"),
this, SLOT(menuPreviewParent()));
popup->addAction(tr("&Open Parent document/folder"), popup->addAction(tr("&Open Parent document/folder"),
this, SLOT(menuOpenParent())); this, SLOT(menuOpenParent()));
popup->popup(mapToGlobal(pos)); popup->popup(mapToGlobal(pos));
@ -784,6 +791,8 @@ void ResTable::menuPreviewParent()
// No parent doc: show enclosing folder with app configured for // No parent doc: show enclosing folder with app configured for
// directories // directories
pdoc.url = path_getfather(doc.url); pdoc.url = path_getfather(doc.url);
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
pdoc.mimetype = "application/x-fsdirectory"; pdoc.mimetype = "application/x-fsdirectory";
emit editRequested(pdoc); emit editRequested(pdoc);
} }
@ -804,6 +813,8 @@ void ResTable::menuOpenParent()
// No parent doc: show enclosing folder with app configured for // No parent doc: show enclosing folder with app configured for
// directories // directories
pdoc.url = path_getfather(doc.url); pdoc.url = path_getfather(doc.url);
pdoc.meta[Rcl::Doc::keychildurl] = doc.url;
pdoc.meta[Rcl::Doc::keyapptg] = "parentopen";
pdoc.mimetype = "application/x-fsdirectory"; pdoc.mimetype = "application/x-fsdirectory";
emit editRequested(pdoc); emit editRequested(pdoc);
} }

View file

@ -20,6 +20,7 @@
namespace Rcl { namespace Rcl {
const string Doc::keyurl("url"); const string Doc::keyurl("url");
const string Doc::keychildurl("childurl");
const string Doc::keyfn("filename"); const string Doc::keyfn("filename");
const string Doc::keyipt("ipath"); const string Doc::keyipt("ipath");
const string Doc::keytp("mtype"); const string Doc::keytp("mtype");

View file

@ -194,6 +194,9 @@ class Doc {
// enforced in internfile.cpp and misc other bits of metadata-gathering // enforced in internfile.cpp and misc other bits of metadata-gathering
// code // code
static const string keyurl; // url static const string keyurl; // url
// childurl. This is set when working with the parent of the result, to hold
// the child of interest url, typically to highlight a directory entry
static const string keychildurl;
static const string keyfn; // file name static const string keyfn; // file name
static const string keyipt; // ipath static const string keyipt; // ipath
static const string keytp; // mime type static const string keytp; // mime type

View file

@ -17,7 +17,8 @@
# - For pages of CHM and EPUB documents where we can choose to open the # - For pages of CHM and EPUB documents where we can choose to open the
# parent document instead of a temporary html file. # parent document instead of a temporary html file.
xallexcepts = application/pdf application/postscript application/x-dvi \ xallexcepts = application/pdf application/postscript application/x-dvi \
text/html|gnuinfo text/html|chm text/html|epub text/html|gnuinfo text/html|chm text/html|epub \
application/x-fsdirectory|parentopen
[view] [view]
# Pseudo entry used if the 'use desktop' preference is set in the GUI # Pseudo entry used if the 'use desktop' preference is set in the GUI
@ -77,7 +78,11 @@ text/rtf = libreoffice %f
application/x-chm = kchmviewer %f application/x-chm = kchmviewer %f
application/x-dia-diagram = dia %f application/x-dia-diagram = dia %f
application/x-fsdirectory = dolphin %f application/x-fsdirectory = dolphin %f
#application/x-fsdirectory|parentopen = nautilus %(childurl)
application/x-fsdirectory|parentopen = dolphin --select %(childurl) %f
application/x-gnuinfo = xterm -e "info -f %f" application/x-gnuinfo = xterm -e "info -f %f"
application/x-gnumeric = gnumeric %f application/x-gnumeric = gnumeric %f