[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdebase/kcontrol/kfontinst/kio
From: Craig Drummond <craig () kde ! org>
Date: 2005-04-13 17:57:13
Message-ID: 20050413175713.348D9496 () office ! kde ! org
[Download RAW message or body]
CVS commit by craig:
When installing a font, remove any spaces or dashes, and convert the extension to \
lowercase.
M +41 -8 KioFonts.cpp 1.56
--- kdebase/kcontrol/kfontinst/kio/KioFonts.cpp #1.55:1.56
@@ -115,4 +115,25 @@ int kdemain(int argc, char **argv)
inline QString getSect(const QString &f) { return f.section('/', 1, 1); }
+static QString modifyName(const QString &fname)
+{
+ static const char * constSymbols[]={ "-", " ", NULL };
+
+ QString rv(fname);
+ int dotPos=rv.findRev('.');
+
+ if(-1!=dotPos)
+ {
+ unsigned int rvLen=rv.length();
+
+ for(unsigned int i=dotPos+1; i<rvLen; ++i)
+ rv[i]=rv[i].lower();
+ }
+
+ for(int s=0; constSymbols[s]; ++s)
+ rv=rv.replace(QString::fromLatin1(constSymbols[s]), \
QString::fromLatin1("_")); +
+ return rv;
+}
+
static QString getFcString(FcPattern *pat, const char *val)
{
@@ -781,5 +802,12 @@ bool CKioFonts::createStatEntry(KIO::UDS
else
{
- FcPattern *pat=getEntry(folder, url.fileName());
+ QString name(url.fileName());
+ FcPattern *pat=getEntry(folder, name);
+
+ if(!pat) // OK, try the modified version of the name...
+ {
+ name=modifyName(name);
+ pat=getEntry(folder, name);
+ }
if(pat)
@@ -900,5 +928,5 @@ void CKioFonts::put(const KURL &u, int m
nrs=nonRootSys(url);
EFolder destFolder=itsRoot || \
i18n(KFI_KIO_FONTS_SYS)==getSect(url.path()) ? FOLDER_SYS : \
FOLDER_USER;
- QString dest=itsFolders[destFolder].location+url.fileName(),
+ QString dest=itsFolders[destFolder].location+modifyName(url.fileName()),
passwd;
QCString destC=QFile::encodeName(dest);
@@ -1165,5 +1193,5 @@ void CKioFonts::copy(const KURL &src, co
for(it=srcFiles.begin(); it!=end; ++it)
{
- cmd+=QFile::encodeName(KProcess::quote(*it));
+ cmd+=QFile::encodeName(KProcess::quote(modifyName(*it)));
cmd+=" ";
int s=getSize(QFile::encodeName(*it));
@@ -1201,6 +1229,5 @@ void CKioFonts::copy(const KURL &src, co
{
QCString realSrc(QFile::encodeName(*it)),
- \
realDest(QFile::encodeName(itsFolders[destFolder].location+Misc::getFile(*it)));
-
+ \
realDest(QFile::encodeName(itsFolders[destFolder].location+modifyName(Misc::getFile(*it))));
KDE_struct_stat buffSrc;
@@ -1893,5 +1920,10 @@ bool CKioFonts::checkDestFiles(const KUR
for(it=srcFiles.begin(); it!=end; ++it)
- if(NULL!=getEntry(destFolder, Misc::getFile(*it)))
+ {
+ QString file(Misc::getFile(*it));
+
+ //
+ // Check both original, and modified version of filename
+ if(NULL!=getEntry(destFolder, file) || NULL!=getEntry(destFolder, \
modifyName(file))) {
error(KIO::ERR_FILE_ALREADY_EXIST, dest.prettyURL());
@@ -1900,4 +1932,5 @@ bool CKioFonts::checkDestFiles(const KUR
}
}
+ }
return true;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic