分类?
This commit is contained in:
parent
a3c5b9fc87
commit
bd51419f52
@ -69,6 +69,14 @@ void AptPkgInfo::ReadAptData()
|
||||
status = pkgDataStatus::UnContain;
|
||||
}
|
||||
break;
|
||||
case PkgSearchOption::HeadInclude:
|
||||
if(pkgName.mid(0, this->pkgName.length()) == this->pkgName) {
|
||||
status = pkgDataStatus::IsContain;
|
||||
}
|
||||
else {
|
||||
status = pkgDataStatus::UnContain;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 解析为 QJsonObject
|
||||
pkgData.insert("Package", pkgName);
|
||||
@ -87,7 +95,7 @@ void AptPkgInfo::ReadAptData()
|
||||
void AptPkgInfo::SetPkgName(QString pkgName)
|
||||
{
|
||||
this->pkgName = pkgName;
|
||||
pkgInfo = GetPkgInfo(pkgName);
|
||||
//pkgInfo = GetPkgInfo(pkgName);
|
||||
}
|
||||
|
||||
QString AptPkgInfo::GetPkgInfo(QString pkgName) const
|
||||
|
@ -11,7 +11,8 @@ class AptPkgInfo: QObject
|
||||
public:
|
||||
enum PkgSearchOption {
|
||||
Include = 0,
|
||||
Equal = 1
|
||||
Equal = 1,
|
||||
HeadInclude = 2
|
||||
};
|
||||
|
||||
AptPkgInfo(QString pkgName, PkgSearchOption option = PkgSearchOption::Equal);
|
||||
|
@ -15,18 +15,53 @@ void KernelInformation::LoadInfo()
|
||||
/*for(QString i: data) {
|
||||
|
||||
}*/
|
||||
AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::Include);
|
||||
AptPkgInfo info = AptPkgInfo("linux-", AptPkgInfo::PkgSearchOption::HeadInclude);
|
||||
QStringList list = info.GetAptPackageList();
|
||||
QJsonArray array;
|
||||
for(QString i: list) {
|
||||
QJsonObject object;
|
||||
info.SetPkgName(i);
|
||||
object.insert("Name", i);
|
||||
bool isContinue = false;
|
||||
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("Des", info.get_maintainer(i));
|
||||
object.insert("Arch", info.get_architecture(i));
|
||||
object.insert("PkgName", QJsonArray::fromStringList(QStringList() << i));
|
||||
array.append(object);
|
||||
qDebug() << object;
|
||||
}
|
||||
this->listData = array;
|
||||
emit loadFinished(NULL);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QProcess>
|
||||
|
||||
#include <QFile>
|
||||
#include <QMap>
|
||||
|
||||
class KernelInformation : public QObject
|
||||
{
|
||||
@ -47,6 +48,18 @@ private:
|
||||
QString url = "http://info.kernel.gxde.gfdgdxi.top/information.json";
|
||||
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());
|
||||
connect(kernelInformation, &KernelInformation::loadFinished, this, [this](){
|
||||
qDebug() << this->kernelInformation->get_listData();
|
||||
RefreshKernelListView(kernelInformation, ui->m_showLocalArchOnly->isChecked());
|
||||
});
|
||||
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, 2, new QStandardItem(info->get_author(i)));
|
||||
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++;
|
||||
}
|
||||
ui->m_kernelShow->setModel(model);
|
||||
|
Loading…
x
Reference in New Issue
Block a user