2 Star 0 Fork 0

mirrors_anthonyfok/scantailor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Utils.h 2.68 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Scan Tailor - Interactive post-processing tool for scanned pages.
Copyright (C) Joseph Artsimovich <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <QString>
#include "ThumbnailPixmapCache.h"
class Utils
{
public:
template<typename M, typename K, typename V>
static typename M::iterator mapSetValue(
M& map, K const& key, V const& val);
/**
* \brief If \p output_dir exists, creates a "cache" subdirectory under it.
*
* The idea is to prevent creating a bogus directory structure when loading
* a project created on another machine.
*/
static void maybeCreateCacheDir(QString const& output_dir);
static QString outputDirToThumbDir(QString const& output_dir);
static IntrusivePtr<ThumbnailPixmapCache> createThumbnailCache(QString const& output_dir);
/**
* Unlike QFile::rename(), this one overwrites existing files.
*/
static bool overwritingRename(QString const& from, QString const& to);
/**
* \brief A high precision, locale independent number to string conversion.
*
* This function is intended to be used instead of
* QDomElement::setAttribute(double), which is locale dependent.
*/
static QString doubleToString(double val) {
return QString::number(val, 'g', 16);
}
/**
* \brief Generate rich text, complete with headers and stuff,
* for a clickable link.
*
* \param label The text to show as a link.
* \param target A URL or something else. If the link will
* be used in a QLable, this string will be passed
* to QLabel::linkActivated(QString const&).
* \return The resulting reach text.
*/
static QString richTextForLink(
QString const& label,
QString const& target = QString(QChar('#')));
};
template<typename M, typename K, typename V>
typename M::iterator
Utils::mapSetValue(M& map, K const& key, V const& val)
{
typename M::iterator const it(map.lower_bound(key));
if (it == map.end() || map.key_comp()(key, it->first)) {
return map.insert(it, typename M::value_type(key, val));
} else {
it->second = val;
return it;
}
}
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_anthonyfok/scantailor.git
[email protected]:mirrors_anthonyfok/scantailor.git
mirrors_anthonyfok
scantailor
scantailor
master

搜索帮助