分类?
This commit is contained in:
parent
a3c5b9fc87
commit
bd51419f52
@ -69,6 +69,14 @@ void AptPkgInfo::ReadAptData()
|
|||||||
status = pkgDataStatus::UnContain;
|
status = pkgDataStatus::UnContain;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PkgSearchOption::HeadInclude:
|
||||||
|
if(pkgName.mid(0, this->pkgName.length()) == this->pkgName) {
|
||||||
|
status = pkgDataStatus::IsContain;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
status = pkgDataStatus::UnContain;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// 解析为 QJsonObject
|
// 解析为 QJsonObject
|
||||||
pkgData.insert("Package", pkgName);
|
pkgData.insert("Package", pkgName);
|
||||||
@ -87,7 +95,7 @@ void AptPkgInfo::ReadAptData()
|
|||||||
void AptPkgInfo::SetPkgName(QString pkgName)
|
void AptPkgInfo::SetPkgName(QString pkgName)
|
||||||
{
|
{
|
||||||
this->pkgName = pkgName;
|
this->pkgName = pkgName;
|
||||||
pkgInfo = GetPkgInfo(pkgName);
|
//pkgInfo = GetPkgInfo(pkgName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AptPkgInfo::GetPkgInfo(QString pkgName) const
|
QString AptPkgInfo::GetPkgInfo(QString pkgName) const
|
||||||
|
@ -11,7 +11,8 @@ class AptPkgInfo: QObject
|
|||||||
public:
|
public:
|
||||||
enum PkgSearchOption {
|
enum PkgSearchOption {
|
||||||
Include = 0,
|
Include = 0,
|
||||||
Equal = 1
|
Equal = 1,
|
||||||
|
HeadInclude = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
AptPkgInfo(QString pkgName, PkgSearchOption option = PkgSearchOption::Equal);
|
AptPkgInfo(QString pkgName, PkgSearchOption option = PkgSearchOption::Equal);
|
||||||
|
@ -15,18 +15,53 @@ void KernelInformation::LoadInfo()
|
|||||||
/*for(QString i: data) {
|
/*for(QString i: data) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::Include);
|
AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::HeadInclude);
|
||||||
QStringList list = info.GetAptPackageList();
|
QStringList list = info.GetAptPackageList();
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
for(QString i: list) {
|
for(QString i: list) {
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
info.SetPkgName(i);
|
bool isContinue = false;
|
||||||
object.insert("Name", i);
|
for(QString j: unShowMap) {
|
||||||
|
if(i.contains(j)) {
|
||||||
|
isContinue = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 跳过此次循环
|
||||||
|
if(isContinue) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
isContinue = true;
|
||||||
|
for(QString j: showMap) {
|
||||||
|
if(i.contains(j)) {
|
||||||
|
isContinue = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 跳过此次循环
|
||||||
|
if(isContinue) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString strTemp = i;
|
||||||
|
strTemp.replace("-image", "");
|
||||||
|
strTemp.replace("-headers", "");
|
||||||
|
int alreadyIndex = -1;
|
||||||
|
if(indexMap.contains(strTemp)) {
|
||||||
|
// 如果已经存在
|
||||||
|
alreadyIndex = indexMap.value(strTemp);
|
||||||
|
QJsonArray pkgArray = array.at(alreadyIndex).toObject().value("PkgName").toArray();
|
||||||
|
pkgArray.append(i);
|
||||||
|
array.insert(alreadyIndex, array.at(alreadyIndex).toObject().insert("PkgName", pkgArray)->toObject());
|
||||||
|
//array.at(alreadyIndex).toObject().insert("PkgName", pkgArray);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
info.SetPkgName(strTemp);
|
||||||
|
object.insert("Name", strTemp);
|
||||||
object.insert("Author", info.get_maintainer(i));
|
object.insert("Author", info.get_maintainer(i));
|
||||||
object.insert("Des", info.get_maintainer(i));
|
object.insert("Des", info.get_maintainer(i));
|
||||||
object.insert("Arch", info.get_architecture(i));
|
object.insert("Arch", info.get_architecture(i));
|
||||||
|
object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i));
|
||||||
array.append(object);
|
array.append(object);
|
||||||
qDebug() << object;
|
|
||||||
}
|
}
|
||||||
this->listData = array;
|
this->listData = array;
|
||||||
emit loadFinished(NULL);
|
emit loadFinished(NULL);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
class KernelInformation : public QObject
|
class KernelInformation : public QObject
|
||||||
{
|
{
|
||||||
@ -47,6 +48,18 @@ private:
|
|||||||
QString url = "http://info.kernel.gxde.gfdgdxi.top/information.json";
|
QString url = "http://info.kernel.gxde.gfdgdxi.top/information.json";
|
||||||
QJsonArray listData;
|
QJsonArray listData;
|
||||||
|
|
||||||
|
QStringList unShowMap = {
|
||||||
|
"-dbg"
|
||||||
|
};
|
||||||
|
|
||||||
|
QStringList showMap = {
|
||||||
|
"linux-headers",
|
||||||
|
"linux-image",
|
||||||
|
"linux-kernel"
|
||||||
|
};
|
||||||
|
|
||||||
|
QMap<QString, int> indexMap;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ void MainWindow::RefreshKernelList()
|
|||||||
{
|
{
|
||||||
ui->m_nowKernel->setText(tr("Kernel: ") + kernelInformation->localKernelName() + " " + tr("Arch: ") + kernelInformation->arch());
|
ui->m_nowKernel->setText(tr("Kernel: ") + kernelInformation->localKernelName() + " " + tr("Arch: ") + kernelInformation->arch());
|
||||||
connect(kernelInformation, &KernelInformation::loadFinished, this, [this](){
|
connect(kernelInformation, &KernelInformation::loadFinished, this, [this](){
|
||||||
qDebug() << this->kernelInformation->get_listData();
|
|
||||||
RefreshKernelListView(kernelInformation, ui->m_showLocalArchOnly->isChecked());
|
RefreshKernelListView(kernelInformation, ui->m_showLocalArchOnly->isChecked());
|
||||||
});
|
});
|
||||||
kernelInformation->LoadInfo();
|
kernelInformation->LoadInfo();
|
||||||
@ -54,7 +53,7 @@ void MainWindow::RefreshKernelListView(KernelInformation *info, bool showLocalAr
|
|||||||
model->setItem(line, 1, new QStandardItem(info->get_name(i)));
|
model->setItem(line, 1, new QStandardItem(info->get_name(i)));
|
||||||
model->setItem(line, 2, new QStandardItem(info->get_author(i)));
|
model->setItem(line, 2, new QStandardItem(info->get_author(i)));
|
||||||
model->setItem(line, 3, new QStandardItem(kernelArch));
|
model->setItem(line, 3, new QStandardItem(kernelArch));
|
||||||
//model->setItem(line, 4, new QStandardItem((QStringList() << "" << "Y").at(info->get_installedAlready(i))));
|
model->setItem(line, 4, new QStandardItem((QStringList() << "" << "Y").at(info->get_installedAlready(i))));
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
ui->m_kernelShow->setModel(model);
|
ui->m_kernelShow->setModel(model);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user