Ai
1 Star 1 Fork 1

HuanZeng/texstudio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
latexrepository.cpp 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
Jan Sundermeyer 提交于 2018-08-07 03:56 +08:00 . fix compiler warnings
#include "latexrepository.h"
#include <QMutex>
LatexRepository *LatexRepository::m_Instance = nullptr;
LatexRepository::LatexRepository() :
QObject(nullptr), m_dataSource(None)
{
loadStaticPackageList(":/utilities/packageList");
}
LatexRepository *LatexRepository::instance()
{
static QMutex mutex;
mutex.lock();
if (!m_Instance)
m_Instance = new LatexRepository();
mutex.unlock();
return m_Instance;
}
LatexRepository::DataSource LatexRepository::dataSource()
{
return m_dataSource;
}
bool LatexRepository::loadStaticPackageList(const QString &file)
{
if (file.isEmpty()) return false;
packages.reserve(3000);
QFile f(file);
if (! f.open(QFile::ReadOnly)) return false;
while (!f.atEnd()) {
QString line = f.readLine().trimmed();
if (line.startsWith('#')) continue;
int sep = line.indexOf(':');
if (sep < 0) {
packages.insert(line, LatexPackageInfo(line));
} else {
QString name = line.left(sep);
packages.insert(name, LatexPackageInfo(name, line.mid(sep + 1)));
}
}
m_dataSource = Static;
return true;
}
bool LatexRepository::packageExists(const QString &name)
{
return packages.keys().contains(name);
}
QString LatexRepository::shortDescription(const QString &name)
{
return packages[name].shortDescription;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xmrzh/texstudio.git
git@gitee.com:xmrzh/texstudio.git
xmrzh
texstudio
texstudio
master

搜索帮助