mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 18:32:51 +00:00
knetpkg: display the contents information instead of the description
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c73a5eef40
commit
8d192bc45b
3 changed files with 53 additions and 21 deletions
|
@ -39,11 +39,11 @@ KNetPkg::KNetPkg(QWidget *parent)
|
||||||
foreach (const QFileInfo &netpkginfo, netpkgdir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)) {
|
foreach (const QFileInfo &netpkginfo, netpkgdir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs)) {
|
||||||
KNetPkgInfo knetpkginfo;
|
KNetPkgInfo knetpkginfo;
|
||||||
knetpkginfo.name = netpkginfo.fileName().toLocal8Bit();
|
knetpkginfo.name = netpkginfo.fileName().toLocal8Bit();
|
||||||
QFile netpkgdesc(netpkginfo.filePath() + QLatin1String("/+DESC"));
|
QFile netpkgcomment(netpkginfo.filePath() + QLatin1String("/+COMMENT"));
|
||||||
if (netpkgdesc.open(QFile::ReadOnly)) {
|
if (netpkgcomment.open(QFile::ReadOnly)) {
|
||||||
knetpkginfo.description = netpkgdesc.readAll();
|
knetpkginfo.comment = netpkgcomment.readAll().trimmed();
|
||||||
} else {
|
} else {
|
||||||
kWarning() << "No description for" << netpkginfo.filePath();
|
kWarning() << "No comment for" << netpkginfo.filePath();
|
||||||
}
|
}
|
||||||
QFile netpkgrequiredby(netpkginfo.filePath() + QLatin1String("/+REQUIRED_BY"));
|
QFile netpkgrequiredby(netpkginfo.filePath() + QLatin1String("/+REQUIRED_BY"));
|
||||||
if (netpkgrequiredby.open(QFile::ReadOnly)) {
|
if (netpkgrequiredby.open(QFile::ReadOnly)) {
|
||||||
|
@ -66,6 +66,22 @@ KNetPkg::KNetPkg(QWidget *parent)
|
||||||
} else {
|
} else {
|
||||||
kWarning() << "No size for" << netpkginfo.filePath();
|
kWarning() << "No size for" << netpkginfo.filePath();
|
||||||
}
|
}
|
||||||
|
QFile netpkgcontents(netpkginfo.filePath() + QLatin1String("/+CONTENTS"));
|
||||||
|
if (netpkgcontents.open(QFile::ReadOnly)) {
|
||||||
|
knetpkginfo.contents = netpkgcontents.readAll().trimmed();
|
||||||
|
const QList<QByteArray> contentslist = knetpkginfo.contents.split('\n');
|
||||||
|
knetpkginfo.contents.clear();
|
||||||
|
for (int i = 0; i < contentslist.size(); i++) {
|
||||||
|
const QByteArray contentsline = contentslist.at(i);
|
||||||
|
if (contentsline.isEmpty() || contentsline.startsWith('@') || contentsline.startsWith('+')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
knetpkginfo.contents.append(contentsline);
|
||||||
|
knetpkginfo.contents.append('\n');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
kWarning() << "No comment for" << netpkginfo.filePath();
|
||||||
|
}
|
||||||
m_packages.append(knetpkginfo);
|
m_packages.append(knetpkginfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +109,10 @@ void KNetPkg::slotCurrentTextChanged(const QString &netpkg)
|
||||||
// qDebug() << Q_FUNC_INFO << netpkg;
|
// qDebug() << Q_FUNC_INFO << netpkg;
|
||||||
foreach (const KNetPkgInfo &knetpkginfo, m_packages) {
|
foreach (const KNetPkgInfo &knetpkginfo, m_packages) {
|
||||||
if (knetpkginfo.name == netpkg) {
|
if (knetpkginfo.name == netpkg) {
|
||||||
|
m_ui.commentlabel->setText(knetpkginfo.comment);
|
||||||
m_ui.requiredbylabel->setText(knetpkginfo.requiredby);
|
m_ui.requiredbylabel->setText(knetpkginfo.requiredby);
|
||||||
m_ui.sizelabel->setText(KGlobal::locale()->formatByteSize(knetpkginfo.size.toDouble(), 1));
|
m_ui.sizelabel->setText(KGlobal::locale()->formatByteSize(knetpkginfo.size.toDouble(), 1));
|
||||||
m_ui.descriptionwidget->setText(knetpkginfo.description);
|
m_ui.contentswidget->setText(knetpkginfo.contents);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,10 @@
|
||||||
|
|
||||||
struct KNetPkgInfo {
|
struct KNetPkgInfo {
|
||||||
QByteArray name;
|
QByteArray name;
|
||||||
QByteArray description;
|
QByteArray comment;
|
||||||
QByteArray requiredby;
|
QByteArray requiredby;
|
||||||
QByteArray size;
|
QByteArray size;
|
||||||
|
QByteArray contents;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KNetPkg : public KMainWindow
|
class KNetPkg : public KMainWindow
|
||||||
|
|
|
@ -42,17 +42,7 @@
|
||||||
<string>Information</string>
|
<string>Information</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="1" column="1">
|
||||||
<widget class="KRichTextWidget" name="descriptionwidget">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="acceptRichText">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="requiredbylabel">
|
<widget class="QLabel" name="requiredbylabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
|
@ -62,7 +52,21 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="KRichTextWidget" name="contentswidget">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="sizelabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
@ -78,7 +82,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
@ -94,8 +98,18 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="sizelabel">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Comment:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="commentlabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue