From 1f943a9241d4bb7c5753eef51dd8f33159f4db21 Mon Sep 17 00:00:00 2001 From: dockes Date: Sat, 23 Sep 2006 07:39:55 +0000 Subject: [PATCH] fix file name display in tooltips --- src/qtgui/guiutils.cpp | 14 +++++++++++++- src/qtgui/guiutils.h | 5 ++++- src/qtgui/preview_w.cpp | 8 ++++++-- src/qtgui/reslist.cpp | 17 +++++++---------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 297c80b9..79be8a98 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -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 #include @@ -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; diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index 1efbd801..5eb3b51d 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -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: diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index 24902526..d2b2f9b8 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -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"; diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index ff160705..b75e6326 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -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 @@ -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