📄 global.cpp
字号:
/* This file is part of the KDE project Copyright (C) 2000-2001 Simon Hausmann <hausmann@kde.org> Copyright (C) 2001 Dirk Mueller <mueller@kde.org> Copyright (C) 2002-2003 Luciano Montanaro <mikelima@cirulla.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/#include <kio/global.h>#include <klocale.h>#include <stdio.h>#include <qstring.h>//The original version converts to GB, MB etc. Maybe it is useful, we'll see.QString KIO::convertSize( KIO::filesize_t size ){ return number(size);}KIO::CacheControl KIO::parseCacheControl(const QString &cacheControl){ QString tmp = cacheControl.lower(); if (tmp == "cacheonly") return KIO::CC_CacheOnly; if (tmp == "cache") return KIO::CC_Cache; if (tmp == "verify") return KIO::CC_Verify; if (tmp == "reload") return KIO::CC_Reload; return KIO::CC_Verify;}QString KIO::getCacheControlString(KIO::CacheControl cacheControl){ if (cacheControl == KIO::CC_CacheOnly) return "CacheOnly"; if (cacheControl == KIO::CC_Cache) return "Cache"; if (cacheControl == KIO::CC_Verify) return "Verify"; if (cacheControl == KIO::CC_Reload) return "Reload"; return QString::null;}QString KIO::number( KIO::filesize_t size ){ char charbuf[256]; sprintf(charbuf, "%lld", size); return QString::fromLatin1(charbuf);}QString KIO::buildErrorString(int errorCode, const QString &errorText){ QString result; switch( errorCode ) { case KIO::ERR_CANNOT_OPEN_FOR_READING: result = i18n( "Could not read %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_OPEN_FOR_WRITING: result = i18n( "Could not write to %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_LAUNCH_PROCESS: result = i18n( "Could not start process %1" ).arg( errorText ); break; case KIO::ERR_INTERNAL: result = i18n( "Internal Error\nPlease send a full bug report at http://bugs.kde.org\n%1" ).arg( errorText ); break; case KIO::ERR_MALFORMED_URL: result = i18n( "Malformed URL %1" ).arg( errorText ); break; case KIO::ERR_UNSUPPORTED_PROTOCOL: result = i18n( "The protocol %1 is not supported." ).arg( errorText ); break; case KIO::ERR_NO_SOURCE_PROTOCOL: result = i18n( "The protocol %1 is only a filter protocol.").arg( errorText ); break; case KIO::ERR_UNSUPPORTED_ACTION: result = errorText;// result = i18n( "Unsupported action %1" ).arg( errorText ); break; case KIO::ERR_IS_DIRECTORY: result = i18n( "%1 is a directory, but a file was expected." ).arg( errorText ); break; case KIO::ERR_IS_FILE: result = i18n( "%1 is a file, but a directory was expected." ).arg( errorText ); break; case KIO::ERR_DOES_NOT_EXIST: result = i18n( "The file or directory %1 does not exist." ).arg( errorText ); break; case KIO::ERR_FILE_ALREADY_EXIST: result = i18n( "A file named %1 already exists." ).arg( errorText ); break; case KIO::ERR_DIR_ALREADY_EXIST: result = i18n( "A directory named %1 already exists." ).arg( errorText ); break; case KIO::ERR_UNKNOWN_HOST: result = i18n( "Unknown host %1" ).arg( errorText ); break; case KIO::ERR_ACCESS_DENIED: result = i18n( "Access denied to %1" ).arg( errorText ); break; case KIO::ERR_WRITE_ACCESS_DENIED: result = i18n( "Access denied\nCould not write to %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_ENTER_DIRECTORY: result = i18n( "Could not enter directory %1" ).arg( errorText ); break; case KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM: result = i18n( "The protocol %1 does not implement a directory service." ).arg( errorText ); break; case KIO::ERR_CYCLIC_LINK: result = i18n( "Found a cyclic link in %1" ).arg( errorText ); break; case KIO::ERR_USER_CANCELED: // Do nothing in this case. The user doesn't need to be told what he just did. break; case KIO::ERR_CYCLIC_COPY: result = i18n( "Found a cyclic link while copying %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_CREATE_SOCKET: result = i18n( "Could not create socket for accessing %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_CONNECT: result = i18n( "Could not connect to host %1" ).arg( errorText ); break; case KIO::ERR_CONNECTION_BROKEN: result = i18n( "Connection to host %1 is broken" ).arg( errorText ); break; case KIO::ERR_NOT_FILTER_PROTOCOL: result = i18n( "The protocol %1 is not a filter protocol" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_MOUNT: result = i18n( "Could not mount device.\nThe reported error was:\n%1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_UNMOUNT: result = i18n( "Could not unmount device.\nThe reported error was:\n%1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_READ: result = i18n( "Could not read file %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_WRITE: result = i18n( "Could not write to file %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_BIND: result = i18n( "Could not bind %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_LISTEN: result = i18n( "Could not listen %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_ACCEPT: result = i18n( "Could not accept %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_LOGIN: result = errorText; break; case KIO::ERR_COULD_NOT_STAT: result = i18n( "Could not access %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_CLOSEDIR: result = i18n( "Could not terminate listing %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_MKDIR: result = i18n( "Could not make directory %1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_RMDIR: result = i18n( "Could not remove directory %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_RESUME: result = i18n( "Could not resume file %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_RENAME: result = i18n( "Could not rename file %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_CHMOD: result = i18n( "Could not change permissions for %1" ).arg( errorText ); break; case KIO::ERR_CANNOT_DELETE: result = i18n( "Could not delete file %1" ).arg( errorText ); break; case KIO::ERR_SLAVE_DIED: result = i18n( "The process for the %1 protocol died unexpectedly." ).arg( errorText ); break; case KIO::ERR_OUT_OF_MEMORY: result = i18n( "Error. Out of Memory.\n%1" ).arg( errorText ); break; case KIO::ERR_UNKNOWN_PROXY_HOST: result = i18n( "Unknown proxy host\n%1" ).arg( errorText ); break; case KIO::ERR_COULD_NOT_AUTHENTICATE: result = i18n( "Authorization failed, %1 authentication not supported" ).arg( errorText ); break; case KIO::ERR_ABORTED: result = i18n( "User canceled action\n%1" ).arg( errorText ); break; case KIO::ERR_INTERNAL_SERVER: result = i18n( "Internal error in server\n%1" ).arg( errorText ); break; case KIO::ERR_SERVER_TIMEOUT: result = i18n( "Timeout on server\n%1" ).arg( errorText ); break; case KIO::ERR_UNKNOWN: result = i18n( "Unknown error\n%1" ).arg( errorText ); break; case KIO::ERR_UNKNOWN_INTERRUPT: result = i18n( "Unknown interrupt\n%1" ).arg( errorText ); break;/* case KIO::ERR_CHECKSUM_MISMATCH: if (errorText) result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg(errorText); else result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg("document"); break;*/ case KIO::ERR_CANNOT_DELETE_ORIGINAL: result = i18n( "Could not delete original file %1.\nPlease check permissions." ).arg( errorText ); break; case KIO::ERR_CANNOT_DELETE_PARTIAL: result = i18n( "Could not delete partial file %1.\nPlease check permissions." ).arg( errorText ); break; case KIO::ERR_CANNOT_RENAME_ORIGINAL: result = i18n( "Could not rename original file %1.\nPlease check permissions." ).arg( errorText ); break; case KIO::ERR_CANNOT_RENAME_PARTIAL: result = i18n( "Could not rename partial file %1.\nPlease check permissions." ).arg( errorText ); break; case KIO::ERR_CANNOT_SYMLINK: result = i18n( "Could not create symlink %1.\nPlease check permissions." ).arg( errorText ); break; case KIO::ERR_NO_CONTENT: result = errorText; break; case KIO::ERR_DISK_FULL: result = i18n( "Could not write file %1.\nDisk full." ).arg( errorText ); break; case KIO::ERR_IDENTICAL_FILES: result = i18n( "The source and destination are the same file.\n%1" ).arg( errorText ); break; case KIO::ERR_SLAVE_DEFINED: result = errorText; break; default: result = i18n( "Unknown error code %1\n%2\nPlease send a full bug report at http://bugs.kde.org." ).arg( errorCode ).arg( errorText ); break; } return result;}// ### Minimal function, to compile konq-embed - MLQByteArray KIO::rawErrorDetail(int errorCode, const QString &errorText, const KURL *reqUrl /*= 0L*/, int /*method = -1*/ ){ QString url, host, protocol; QByteArray ret; QDataStream stream(ret, IO_WriteOnly); if (reqUrl) { url = reqUrl->prettyURL(); host = reqUrl->host(); protocol = reqUrl->protocol(); } else { url = host = protocol = errorText; } stream << buildErrorString(errorCode, errorText); return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -