move ipath computations from reslist to internfile
This commit is contained in:
parent
d6636e2597
commit
353ddb9a96
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.38 2008-05-27 05:40:58 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.39 2008-08-26 07:33:05 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -47,6 +47,24 @@ using namespace std;
|
||||
// file to ipath separator : "|"
|
||||
static const string isep(":");
|
||||
|
||||
bool FileInterner::getEnclosing(const string &url, const string &ipath,
|
||||
string &eurl, string &eipath)
|
||||
{
|
||||
eurl = url;
|
||||
eipath = ipath;
|
||||
string::size_type colon;
|
||||
LOGDEB(("FileInterner::getEnclosing(): [%s]\n", eipath.c_str()));
|
||||
if (eipath.empty())
|
||||
return false;
|
||||
if ((colon = eipath.find_last_of(isep)) != string::npos) {
|
||||
eipath.erase(colon);
|
||||
} else {
|
||||
eipath.erase();
|
||||
}
|
||||
LOGDEB(("FileInterner::getEnclosing() after: [%s]\n", eipath.c_str()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Execute the command to uncompress a file into a temporary one.
|
||||
static bool uncompressfile(RclConfig *conf, const string& ifn,
|
||||
const list<string>& cmdv, const string& tdir,
|
||||
@ -610,6 +628,11 @@ Usage(void)
|
||||
static int op_flags;
|
||||
#define OPT_q 0x1
|
||||
|
||||
RclConfig *config;
|
||||
RclConfig *RclConfig::getMainConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
thisprog = argv[0];
|
||||
@ -639,7 +662,7 @@ int main(int argc, char **argv)
|
||||
argc--;
|
||||
}
|
||||
string reason;
|
||||
RclConfig *config = recollinit(0, 0, reason);
|
||||
config = recollinit(0, 0, reason);
|
||||
|
||||
if (config == 0 || !config->ok()) {
|
||||
string str = "Configuration problem: ";
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _INTERNFILE_H_INCLUDED_
|
||||
#define _INTERNFILE_H_INCLUDED_
|
||||
/* @(#$Id: internfile.h,v 1.16 2007-06-26 16:09:19 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: internfile.h,v 1.17 2008-08-26 07:33:05 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -39,7 +39,14 @@ struct stat;
|
||||
*/
|
||||
class FileInterner {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Get immediate parent for document.
|
||||
*
|
||||
* This is not in general the same as the "parent" document used
|
||||
* with Rcl::Db::addOrUpdate(). The latter is generally the enclosing file.
|
||||
*/
|
||||
static bool getEnclosing(const string &url, const string &ipath,
|
||||
string &eurl, string &eipath);
|
||||
/**
|
||||
* Identify and possibly decompress file, create adequate
|
||||
* handler. The mtype parameter is only set when the object is
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.40 2008-07-01 08:27:58 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.41 2008-08-26 07:33:05 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
@ -41,6 +41,7 @@ static char rcsid[] = "@(#$Id: reslist.cpp,v 1.40 2008-07-01 08:27:58 dockes Exp
|
||||
#include "mimehandler.h"
|
||||
#include "plaintorich.h"
|
||||
#include "refcntr.h"
|
||||
#include "internfile.h"
|
||||
|
||||
#include "reslist.h"
|
||||
#include "moc_reslist.cpp"
|
||||
@ -679,29 +680,15 @@ void ResList::menuSeeParent()
|
||||
Rcl::Doc doc;
|
||||
if (getDoc(m_popDoc, doc)) {
|
||||
Rcl::Doc doc1;
|
||||
if (doc.ipath.empty()) {
|
||||
if (FileInterner::getEnclosing(doc.url, doc.ipath,
|
||||
doc1.url, doc1.ipath)) {
|
||||
emit previewRequested(doc1);
|
||||
} else {
|
||||
// No parent doc: show enclosing folder with app configured for
|
||||
// directories
|
||||
doc1.url = path_getfather(doc.url);
|
||||
doc1.mimetype = "application/x-fsdirectory";
|
||||
emit editRequested(doc1);
|
||||
} else {
|
||||
doc1.url = doc.url;
|
||||
doc1.ipath = doc.ipath;
|
||||
string::size_type colon;
|
||||
LOGDEB(("Ipath: [%s]\n", doc1.ipath.c_str()));
|
||||
if ((colon=doc1.ipath.find_last_of(":")) != string::npos) {
|
||||
doc1.ipath.erase(colon);
|
||||
} else {
|
||||
doc1.ipath.erase();
|
||||
}
|
||||
LOGDEB(("Ipath after: [%s]\n", doc1.ipath.c_str()));
|
||||
|
||||
list<string> lipath;
|
||||
stringToTokens(doc.ipath, lipath, ":");
|
||||
if (lipath.size() >= 1)
|
||||
lipath.pop_back();
|
||||
emit previewRequested(doc1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user