fix file name display in tooltips

This commit is contained in:
dockes 2006-09-23 07:39:55 +00:00
parent 417586fb2b
commit 1f943a9241
4 changed files with 30 additions and 14 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.20 2006-09-21 09:37:28 dockes Exp $ (C) 2005 Jean-Francois Dockes";
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.21 2006-09-23 07:39:55 dockes Exp $ (C) 2005 Jean-Francois Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -28,6 +28,7 @@ static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.20 2006-09-21 09:37:28 dockes Ex
#include "pathut.h"
#include "base64.h"
#include "rcldb.h"
#include "transcode.h"
#include <qsettings.h>
#include <qstringlist.h>
@ -100,6 +101,17 @@ bool startHelpBrowser(const string &iurl)
return false;
}
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
bool printableUrl(const string &in, string &out)
{
string fcharset = rclconfig->getDefCharset(true);
int ecnt = 0;
if (!transcode(in, out, fcharset, "UTF-8", &ecnt) || ecnt) {
out = url_encode(in, 7);
}
return true;
}
// The global preferences structure
PrefsPack prefs;

View File

@ -17,7 +17,7 @@
#ifndef _GUIUTILS_H_INCLUDED_
#define _GUIUTILS_H_INCLUDED_
/*
* @(#$Id: guiutils.h,v 1.12 2006-09-21 09:37:28 dockes Exp $ (C) 2005 Jean-Francois Dockes
* @(#$Id: guiutils.h,v 1.13 2006-09-23 07:39:55 dockes Exp $ (C) 2005 Jean-Francois Dockes
* jean-francois.dockes@wanadoo.fr
*
* This program is free software; you can redistribute it and/or modify
@ -49,6 +49,9 @@ using std::list;
/** Start a browser on the help document */
extern bool startHelpBrowser(const string& url = "");
/** Try to make an utf8 printable url */
extern bool printableUrl(const string &in, string &out);
/** Holder for preferences (gets saved to user Qt prefs) */
class PrefsPack {
public:

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.3 2006-09-21 12:56:57 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.4 2006-09-23 07:39:55 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -50,6 +50,7 @@ using std::pair;
#include "wipedir.h"
#include "cancelcheck.h"
#include "preview_w.h"
#include "guiutils.h"
#if (QT_VERSION < 0x030300)
#define wasCanceled wasCancelled
@ -325,7 +326,10 @@ void Preview::setCurTabProps(const string &fn, const Rcl::Doc &doc,
struct tm *tm = localtime(&mtime);
strftime(datebuf, 99, "%Y-%m-%d %H:%M:%S", tm);
}
string tiptxt = doc.url + string("\n");
LOGDEB(("Doc.url: [%s]\n", doc.url.c_str()));
string url;
printableUrl(doc.url, url);
string tiptxt = url + string("\n");
tiptxt += doc.mimetype + " " + string(datebuf) + "\n";
if (!doc.title.empty())
tiptxt += doc.title + "\n";

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.1 2006-09-22 07:29:34 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: reslist.cpp,v 1.2 2006-09-23 07:39:55 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@ -333,16 +333,13 @@ void ResList::resultPageNext()
char perbuf[10];
sprintf(perbuf, "%3d%% ", percent);
// Make title out of file name if none yet
string fcharset = rclconfig->getDefCharset(true);
if (doc.title.empty()) {
transcode(path_getsimple(doc.url), doc.title, fcharset, "UTF-8");
}
// Printable url: either utf-8 if transcoding succeeds, or url-encoded
string url; int ecnt = 0;
if (!transcode(doc.url, url, fcharset, "UTF-8", &ecnt) || ecnt) {
url = url_encode(doc.url, 7);
string url;
printableUrl(doc.url, url);
// Make title out of file name if none yet
if (doc.title.empty()) {
doc.title = path_getsimple(url);
}
// Document date: either doc or file modification time