初步实现版本号切割
This commit is contained in:
parent
ee34925def
commit
ebe3473d15
@ -11,6 +11,63 @@ AptPkgInfo::AptPkgInfo(QString pkgName, PkgSearchOption option)
|
||||
ReadAptData();
|
||||
}
|
||||
|
||||
QStringList AptPkgInfo::SplitVersion(QString version) const
|
||||
{
|
||||
SplitVersionStatus status = SplitVersionStatus::Checking;
|
||||
QStringList versionList;
|
||||
QString versionNumberTemp = "";
|
||||
QString versionLetterTemp = "";
|
||||
for(QString i: version) {
|
||||
if(symbolList.contains(i)) {
|
||||
// 如果是特殊字符
|
||||
|
||||
switch(status) {
|
||||
case SplitVersionStatus::Checking:
|
||||
versionList.append(versionNumberTemp);
|
||||
break;
|
||||
case SplitVersionStatus::MeetedEnglishLetter:
|
||||
versionList.append(versionLetterTemp);
|
||||
break;
|
||||
}
|
||||
versionList.append(i);
|
||||
versionNumberTemp = "";
|
||||
versionLetterTemp = "";
|
||||
status = SplitVersionStatus::MeetSymbol;
|
||||
continue;
|
||||
}
|
||||
if(i[0].isLetter()) {
|
||||
switch(status) {
|
||||
case SplitVersionStatus::Checking:
|
||||
versionList.append(versionNumberTemp);
|
||||
break;
|
||||
}
|
||||
versionLetterTemp += i;
|
||||
versionNumberTemp = "";
|
||||
status = SplitVersionStatus::MeetedEnglishLetter;
|
||||
continue;
|
||||
}
|
||||
switch(status) {
|
||||
case SplitVersionStatus::MeetedEnglishLetter:
|
||||
versionList.append(versionLetterTemp);
|
||||
break;
|
||||
}
|
||||
versionNumberTemp += i;
|
||||
status = SplitVersionStatus::Checking;
|
||||
versionLetterTemp = "";
|
||||
}
|
||||
if(status == SplitVersionStatus::Checking) {
|
||||
versionList.append(versionNumberTemp);
|
||||
}
|
||||
|
||||
|
||||
return versionList;
|
||||
}
|
||||
|
||||
bool AptPkgInfo::CompareVersion(QString version1, QString version2) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AptPkgInfo::ReadAptData()
|
||||
{
|
||||
this->aptData = QJsonObject();
|
||||
@ -36,7 +93,19 @@ void AptPkgInfo::ReadAptData()
|
||||
if(strTemp.replace(" ", "").replace("\n", "") == "") {
|
||||
// 空行
|
||||
if(status == pkgDataStatus::IsContain) {
|
||||
aptData.insert(pkgData.value("Package").toString(), pkgData);
|
||||
QString addPkgName = pkgData.value("Package").toString();
|
||||
// 如果已经存在表中
|
||||
if(pkgData.contains(addPkgName)) {
|
||||
// 新增数据
|
||||
QJsonObject allDataObject = aptData.value(addPkgName).toObject();
|
||||
// 判断版本大小,如果新于表内版本则更新
|
||||
QString dataVersion = allDataObject.value("Version").toString();
|
||||
|
||||
}
|
||||
else {
|
||||
aptData.insert(addPkgName, pkgData);
|
||||
}
|
||||
|
||||
}
|
||||
status = pkgDataStatus::EmptyLine;
|
||||
pkgData = QJsonObject(); // 清空
|
||||
@ -149,3 +218,8 @@ QByteArray AptPkgInfo::GetCommandResult(QString command, QStringList argv, QProc
|
||||
process.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
QJsonObject AptPkgInfo::get_data() const
|
||||
{
|
||||
return aptData;
|
||||
}
|
||||
|
17
aptpkginfo.h
17
aptpkginfo.h
@ -28,6 +28,9 @@ public:
|
||||
QString get_description(QString pkgName) const;
|
||||
QString get_architecture(QString pkgName) const;
|
||||
|
||||
QJsonObject get_data() const;
|
||||
|
||||
bool CompareVersion(QString version1, QString version2) const;
|
||||
|
||||
|
||||
private:
|
||||
@ -35,6 +38,15 @@ private:
|
||||
QString pkgInfo;
|
||||
QJsonObject aptData;
|
||||
PkgSearchOption pkgSearchOption = PkgSearchOption::Equal;
|
||||
QStringList symbolList = {"-", "~", "+"};
|
||||
enum SplitVersionStatus {
|
||||
Checking,
|
||||
MeetedEnglishLetter,
|
||||
MeetSymbol,
|
||||
Other
|
||||
};
|
||||
|
||||
QStringList SplitVersion(QString version) const;
|
||||
|
||||
enum pkgDataStatus {
|
||||
EmptyLine = 0,
|
||||
@ -43,7 +55,10 @@ private:
|
||||
Readed = 3,
|
||||
None = 4,
|
||||
UnContain = 5,
|
||||
IsContain = 6
|
||||
IsContain = 6,
|
||||
IsContainOldVersion = 7,
|
||||
IsContainNewVersion = 8,
|
||||
IsContainSameVersion = 9
|
||||
};
|
||||
|
||||
void ReadAptData();
|
||||
|
@ -14,6 +14,7 @@ void KernelInformation::LoadInfo()
|
||||
QJsonArray array;
|
||||
AptPkgInfo kernelManagerinfo = AptPkgInfo("gxde-kernel-manager", AptPkgInfo::PkgSearchOption::Equal);
|
||||
QStringList list = kernelManagerinfo.GetAptPackageList();
|
||||
qDebug() << kernelManagerinfo.get_data();
|
||||
for(QString i: list) {
|
||||
QJsonObject object;
|
||||
kernelManagerinfo.SetPkgName(i);
|
||||
|
@ -47,6 +47,8 @@ private slots:
|
||||
|
||||
void on_m_kernelShow_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_actionSourceforge_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
KernelInformation *kernelInformation;
|
||||
|
@ -126,6 +126,7 @@
|
||||
</property>
|
||||
<addaction name="actionGitee"/>
|
||||
<addaction name="actionGithub"/>
|
||||
<addaction name="actionSourceforge"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDonate"/>
|
||||
<addaction name="separator"/>
|
||||
@ -140,8 +141,15 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionUpgrade"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuGrub">
|
||||
<property name="title">
|
||||
<string>Grub</string>
|
||||
</property>
|
||||
<addaction name="actionUpdate_Grub"/>
|
||||
</widget>
|
||||
<addaction name="menuProgram"/>
|
||||
<addaction name="menuApt"/>
|
||||
<addaction name="menuGrub"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
@ -185,6 +193,16 @@
|
||||
<string>Donate</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSourceforge">
|
||||
<property name="text">
|
||||
<string>Sourceforge</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUpdate_Grub">
|
||||
<property name="text">
|
||||
<string>Update Grub</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="Resource.qrc"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user