diff options
author | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2008-07-23 00:23:03 -0300 |
---|---|---|
committer | Daniel Nicoletti <dantti85-pk@yahoo.com.br> | 2008-07-23 00:23:03 -0300 |
commit | 9ac0ad7fa8e872426ffb2f5d6e59993567732728 (patch) | |
tree | 22c4c5fa0ada47495675ca89957ba49aab5ec0db | |
parent | 094f5d0a1ef33448dbec68cc121dbfb4872c53cc (diff) |
Add info enum, fixed the app to use it, fixed the compilation problem in the updates that only needs actions now.
-rwxr-xr-x | gui/AddRm/PkAddRm.cpp | 4 | ||||
-rw-r--r-- | gui/AddRm/PkAddRm_Model.cpp | 2 | ||||
-rwxr-xr-x | gui/AddRm/PkReviewChanges.cpp | 4 | ||||
-rwxr-xr-x | gui/Common/PkStrings.cpp | 70 | ||||
-rwxr-xr-x | gui/Common/PkStrings.h | 2 | ||||
-rw-r--r-- | gui/KPackageKit/CMakeLists.txt | 3 | ||||
-rwxr-xr-x | gui/KPackageKit/PkNotify.cpp | 76 | ||||
-rw-r--r-- | gui/Updater/PkAddRm_Model.cpp | 16 | ||||
-rw-r--r-- | gui/Updater/PkAddRm_Model.h | 2 | ||||
-rw-r--r-- | gui/Updater/pkg_item.cpp | 5 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 6 | ||||
-rw-r--r-- | lib/Exit.h | 4 | ||||
-rw-r--r-- | lib/Package.cpp | 4 | ||||
-rw-r--r-- | lib/Package.h | 9 | ||||
-rw-r--r-- | lib/Provides.h | 1 | ||||
-rw-r--r-- | lib/QPackageKit | 1 | ||||
-rw-r--r-- | lib/Role.h | 3 | ||||
-rw-r--r-- | lib/Status.h | 7 | ||||
-rw-r--r-- | lib/Transaction.cpp | 2 |
19 files changed, 120 insertions, 101 deletions
diff --git a/gui/AddRm/PkAddRm.cpp b/gui/AddRm/PkAddRm.cpp index eed3f6c..1cfde42 100755 --- a/gui/AddRm/PkAddRm.cpp +++ b/gui/AddRm/PkAddRm.cpp @@ -315,14 +315,14 @@ void PkAddRm::Finished(Exit::Value status, uint runtime) notifyL->setAutoFillBackground(true); m_notifyT.start(100); break; - case Exit::KeyRequired : + case Exit::Key_required : notifyL->setText("Search finished in " + KGlobal::locale()->formatDuration(runtime) ); teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150)); notifyL->setPalette(teste); notifyL->setAutoFillBackground(true); m_notifyT.start(100); break; - case Exit::EulaRequired : + case Exit::Eula_required : notifyL->setText("Search finished in " + KGlobal::locale()->formatDuration(runtime) ); teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150)); notifyL->setPalette(teste); diff --git a/gui/AddRm/PkAddRm_Model.cpp b/gui/AddRm/PkAddRm_Model.cpp index 43c03af..68077f7 100644 --- a/gui/AddRm/PkAddRm_Model.cpp +++ b/gui/AddRm/PkAddRm_Model.cpp @@ -51,7 +51,7 @@ QVariant PkAddRmModel::data(const QModelIndex &index, int role) const return p->summary(); case InstalledRole: - if ( p->info() == "available" ) + if ( p->info() == Info::Available ) return false; else return true; diff --git a/gui/AddRm/PkReviewChanges.cpp b/gui/AddRm/PkReviewChanges.cpp index 1f11443..5d1a13d 100755 --- a/gui/AddRm/PkReviewChanges.cpp +++ b/gui/AddRm/PkReviewChanges.cpp @@ -70,13 +70,13 @@ void PkReviewChanges::doAction() // check what packages are installed and marked to be removed for (int i = 0; i < m_pkgModelMain->packagesChanges().size(); ++i) { - if ( m_pkgModelMain->packagesChanges().at(i)->info() == "installed" ) + if ( m_pkgModelMain->packagesChanges().at(i)->info() == Info::Installed ) m_remPackages << m_pkgModelMain->packagesChanges().takeAt(i); } // check what packages are avaliable and marked to be installed for (int i = 0; i < m_pkgModelMain->packagesChanges().size(); ++i) { - if ( m_pkgModelMain->packagesChanges().at(i)->info() == "available" ) + if ( m_pkgModelMain->packagesChanges().at(i)->info() == Info::Available ) m_addPackages << m_pkgModelMain->packagesChanges().takeAt(i); } diff --git a/gui/Common/PkStrings.cpp b/gui/Common/PkStrings.cpp index 9d03a07..63bf9d9 100755 --- a/gui/Common/PkStrings.cpp +++ b/gui/Common/PkStrings.cpp @@ -20,7 +20,7 @@ #include <KLocale> -#include <KMessageBox> +#include <KDebug> #include "PkStrings.h" @@ -413,24 +413,54 @@ KIcon PkStrings::GroupsIcon(Groups::Value v) } } -// void PkTransaction::Finished(Exit::Value status, uint /*runtime*/) -// { -// qDebug() << "trans finished: " << status ; -// switch(status) { -// case Exit::Success : -// qDebug() << "trans succes: "; -// break; -// case Exit::Failed : -// qDebug() << "trans failed: "; -// m_notifyT.start(50); -// break; -// case Exit::Kill : -// qDebug() << "trans quit: "; -// break; -// case Exit::Unknown : -// qDebug() << "trans quit: "; -// break; -// } -// } +QString PkStrings::Info(Info::Value v) +{ + switch (v) { + case Info::Low : + return i18n("Trivial update"); + case Info::Normal : + return i18n("Update"); + case Info::Important : + return i18n("Important update"); + case Info::Security : + return i18n("Security update"); + case Info::Bugfix : + return i18n("Bug fix update"); + case Info::Enhancement : + return i18n("Enhancement update"); + case Info::Blocked : + return i18n("Blocked update"); + case Info::Installed : + return i18n("Installed"); + case Info::Available : + return i18n("Available"); + case Info::Unknown : + return i18n("Unknown update"); + default : + kDebug() << "info unrecognised: " << v; + return QString(); + } +} + +QString PkStrings::InfoUpdate(Info::Value v, int number) +{ + switch (v) { + case Info::Low : + return i18np("1 trivial update", "%1 trivial updates", number); + case Info::Normal : + return i18np("1 update", "%1 updates", number); + case Info::Important : + return i18np("1 important update", "%1 important updates", number); + case Info::Security : + return i18np("1 security update", "%1 security updates", number); + case Info::Bugfix : + return i18np("1 bug fix update", "%1 bug fix updates", number); + case Info::Enhancement : + return i18np("1 enhancement update", "%1 enhancement updates", number); + default : + kDebug() << "update info unrecognised: " << v; + return i18np("1 unknown update", "%1 unknown updates", number); + } +} #include "PkStrings.moc" diff --git a/gui/Common/PkStrings.h b/gui/Common/PkStrings.h index a3d568e..cead6ac 100755 --- a/gui/Common/PkStrings.h +++ b/gui/Common/PkStrings.h @@ -41,6 +41,8 @@ public: static QString StatusChanged(Status::Value v); static QString Groups(Groups::Value v); static KIcon GroupsIcon(Groups::Value v); + static QString Info(Info::Value v); + static QString InfoUpdate(Info::Value v, int number); }; #endif diff --git a/gui/KPackageKit/CMakeLists.txt b/gui/KPackageKit/CMakeLists.txt index 770b0f7..32ad4a3 100644 --- a/gui/KPackageKit/CMakeLists.txt +++ b/gui/KPackageKit/CMakeLists.txt @@ -4,6 +4,7 @@ set(kpackagekit_SRCS main.cpp kpk.cpp PkNotify.cpp + ../Common/PkStrings.cpp ) kde4_add_executable(kpackagekit ${kpackagekit_SRCS}) @@ -12,4 +13,4 @@ target_link_libraries(kpackagekit ${KDE4_KDEUI_LIBS} ${KDE4_KNOTIFY_LIBS} ${QPAC install(TARGETS kpackagekit ${INSTALL_TARGETS_DEFAULT_ARGS}) # keep the KPackageKit dir upper cased for notification -install(FILES KPackageKit.notifyrc DESTINATION ${DATA_INSTALL_DIR}/KPackageKit)
\ No newline at end of file +install(FILES KPackageKit.notifyrc DESTINATION ${DATA_INSTALL_DIR}/KPackageKit) diff --git a/gui/KPackageKit/PkNotify.cpp b/gui/KPackageKit/PkNotify.cpp index ffb3a9e..4b86034 100755 --- a/gui/KPackageKit/PkNotify.cpp +++ b/gui/KPackageKit/PkNotify.cpp @@ -19,6 +19,8 @@ ***************************************************************************/ #include "PkNotify.h" +#include "../Common/PkStrings.h" + #include <KMessageBox> #include <KLocale> #include <KIcon> @@ -83,69 +85,35 @@ void PkNotify::UpdatesFinished(Exit::Value status, uint /*runtime*/) updatesNotification = new KNotification( "ShowUpdates" ); // here we check if they are too many // i think 5 is the maximun number to show them detailed -// if ( packages.size() <= 5 ) { -// QString text; -// text.append( i18np("<b>You have one update:", "<br>You have %1 updates:</b>", packages.size() ) ); -// for ( int i = 0; i < packages.size(); i++) { -// text.append( "<br><b>" + packages.at(i)->name() + "</b> - " + packages.at(i)->summary() ); -// } -// updatesNotification->setText(text); -// } -// else { + if ( packages.size() <= 5 ) { + QString text; + text.append( i18np("<b>You have one update:", "<br>You have %1 updates:</b>", packages.size() ) ); + for ( int i = 0; i < packages.size(); i++) { + text.append( "<br><b>" + packages.at(i)->name() + "</b> - " + packages.at(i)->summary() ); + } + updatesNotification->setText(text); + } + else { QString text; text.append( i18n("<b>You have %1 updates:</b>", packages.size() ) ); - - QHash<QString, int> info; - -// - - /*for ( int i = 0; i < packages.size(); i++) { - if ( p->info() == "available" || p->info() == "installed" ) - if ( p->data() == "debian" ) - return m_iconDeb; - else if ( p->data() == "fedora" ) - return m_iconRpm; - else - return m_iconGeneric; - else if ( p->info() == "bugfix" ) - return m_iconBugFix; - else if ( p->info() == "security-important" ) - return m_iconImportant; - else if ( p->info() == "security-low" ) - return m_iconLow; - else if ( p->info() == "enhancement" ) - return m_iconEnhancement; - else if ( p->info() == "security" ) - return m_iconSecurity; - else if ( p->info() == "normal" ) - return m_iconNormal; - else - return m_iconGeneric; - - */ - - + + QHash<Info::Value, int> info; for ( int i = 0; i < packages.size(); i++) { info[ packages.at(i)->info() ] = ++info[ packages.at(i)->info() ]; } - // if we have only one kind of update don't show total of updates - if ( info ) { - text.append( i18n("<b>You have %1 %1 updates:</b>", packages.size() ) ); - } - else { - QHashIterator<QString, int> i(hash); - while (i.hasNext()) { - i.next(); - cout << i.key() << ": " << i.value() << endl; - } + + QHashIterator<Info::Value, int> i(info); + while (i.hasNext()) { + i.next(); + text.append( "<br>" + PkStrings::InfoUpdate( i.key(), i.value() ) ); } + updatesNotification->setText(text); - kDebug() << info; -// } + } KIcon icon("security-high"); updatesNotification->setPixmap( icon.pixmap( QSize(128,128) ) ); - QStringList actions( i18n("Update Now") ); - actions << i18n("Not Now"); + QStringList actions( i18n("Update") ); + actions << i18n("Not now"); actions << i18n("Don't ask anymore"); updatesNotification->setActions(actions); //TODO close the notifications !! memoryleak diff --git a/gui/Updater/PkAddRm_Model.cpp b/gui/Updater/PkAddRm_Model.cpp index 638542f..e93a0f1 100644 --- a/gui/Updater/PkAddRm_Model.cpp +++ b/gui/Updater/PkAddRm_Model.cpp @@ -50,24 +50,24 @@ QVariant PkAddRmModel::data(const QModelIndex &index, int role) const case Qt::DisplayRole: return item->name(); case Qt::DecorationRole: - if ( p->info() == "available" || p->info() == "installed" ) + if ( p->info() == Info::Available || p->info() == Info::Installed ) if ( p->data() == "debian" ) return m_iconDeb; else if ( p->data() == "fedora" ) return m_iconRpm; else return m_iconGeneric; - else if ( p->info() == "bugfix" ) + else if ( p->info() == Info::Bugfix ) return m_iconBugFix; - else if ( p->info() == "security-important" ) + else if ( p->info() == Info::Important ) return m_iconImportant; - else if ( p->info() == "security-low" ) + else if ( p->info() == Info::Low ) return m_iconLow; - else if ( p->info() == "enhancement" ) + else if ( p->info() == Info::Enhancement ) return m_iconEnhancement; - else if ( p->info() == "security" ) + else if ( p->info() == Info::Security ) return m_iconSecurity; - else if ( p->info() == "normal" ) + else if ( p->info() == Info::Normal ) return m_iconNormal; else return m_iconGeneric; @@ -76,7 +76,7 @@ QVariant PkAddRmModel::data(const QModelIndex &index, int role) const return p->summary(); case InstalledRole: - if ( p->info() == "available" ) + if ( p->info() == Info::Available ) return false; else return true; diff --git a/gui/Updater/PkAddRm_Model.h b/gui/Updater/PkAddRm_Model.h index 02d467f..a2144d3 100644 --- a/gui/Updater/PkAddRm_Model.h +++ b/gui/Updater/PkAddRm_Model.h @@ -35,7 +35,7 @@ public: }; private: - QHash<QString, PackageItem*> packages; + QHash<Info::Value, PackageItem*> packages; PackageItem *rootItem; KIcon m_iconDeb; KIcon m_iconRpm; diff --git a/gui/Updater/pkg_item.cpp b/gui/Updater/pkg_item.cpp index 95b6111..88a3852 100644 --- a/gui/Updater/pkg_item.cpp +++ b/gui/Updater/pkg_item.cpp @@ -18,11 +18,12 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pkg_item.h" +#include "../Common/PkStrings.h" #include <QStringList> PackageItem::PackageItem(Package *pkg, PackageItem *parent) - : parentItem(parent), m_pkg(pkg) + : m_pkg(pkg), parentItem(parent) { } @@ -35,7 +36,7 @@ QString PackageItem::name() { if (parentItem) if ( m_pkg->name().isEmpty() ) - return QString::number( childCount() ) + " " + m_pkg->info(); + return PkStrings::InfoUpdate( m_pkg->info(), m_pkg->info() ); else return m_pkg->name() + " - " + m_pkg->version() + " (" + m_pkg->arch() + ")"; else diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 318d6ab..fbc8607 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -30,11 +30,11 @@ set( PK_LIB_SRCS set( PK_SRCS CentralProxy.h + TransactionProxy.h Daemon.h + Transaction.h Package.h PolkitClient.h - Transaction.h - TransactionProxy.h Error.h Exit.h Actions.h @@ -44,6 +44,7 @@ set( PK_SRCS SignatureType.h Status.h Groups.h + Info.h ) QT4_WRAP_CPP( Pk_MOC_SRCS ${PK_SRCS} ) @@ -80,6 +81,7 @@ install(FILES SignatureType.h Status.h Groups.h + Info.h QPackageKit DESTINATION include/packagekit-qt) @@ -28,8 +28,8 @@ typedef enum { Success, Failed, Cancelled, - KeyRequired, - EulaRequired, + Key_required, + Eula_required, Kill, Unknown } Value; diff --git a/lib/Package.cpp b/lib/Package.cpp index d064e61..8004505 100644 --- a/lib/Package.cpp +++ b/lib/Package.cpp @@ -22,7 +22,7 @@ Package::Package(const QString& packageId, QObject *parent) : QObject(parent) { _data = tokens.at(3); } -Package::Package(const QString& packageId, const QString& info, const QString& summary, QObject *parent) +Package::Package(const QString& packageId, const Info::Value& info, const QString& summary, QObject *parent) : QObject(parent), _info(info), _summary(summary) { QStringList tokens = packageId.split(';'); if(tokens.size() != 4) qWarning("Package : bad package id"); @@ -52,7 +52,7 @@ const QString& Package::data() { return _data; } -const QString& Package::info() { +const Info::Value& Package::info() { return _info; } diff --git a/lib/Package.h b/lib/Package.h index 99aa3ff..d695ed0 100644 --- a/lib/Package.h +++ b/lib/Package.h @@ -14,6 +14,8 @@ #include <QtCore> +#include "Info.h" + namespace PackageKit { class Package : public QObject { @@ -22,19 +24,20 @@ class Package : public QObject { public: Package(const QString& packageId, QObject *parent = 0); - Package(const QString& packageId, const QString& info, const QString& summary, QObject *parent = 0); + Package(const QString& packageId, const Info::Value& info, const QString& summary, QObject *parent = 0); const QString id(); const QString& name(); const QString& version(); const QString& arch(); const QString& data(); - const QString& info(); + const Info::Value& info(); const QString& summary(); bool operator==(const Package &other) const; private: - QString _name, _version, _arch, _data, _info, _summary; + QString _name, _version, _arch, _data, _summary; + Info::Value _info; }; } diff --git a/lib/Provides.h b/lib/Provides.h index 9d945fb..47a0220 100644 --- a/lib/Provides.h +++ b/lib/Provides.h @@ -29,6 +29,7 @@ public: Modalias, Codec, Mimetype, + Font, Unknown }; }; diff --git a/lib/QPackageKit b/lib/QPackageKit index f125cbe..6c91a75 100644 --- a/lib/QPackageKit +++ b/lib/QPackageKit @@ -15,5 +15,6 @@ #include "SignatureType.h" #include "Status.h" #include "Groups.h" +#include "Info.h" #endif @@ -48,6 +48,9 @@ typedef enum { Repo_enable, Repo_set_data, Service_pack, + What_provides, + Accept_eula, + Download_packages, Unknown } Value; diff --git a/lib/Status.h b/lib/Status.h index 0beb090..2037713 100644 --- a/lib/Status.h +++ b/lib/Status.h @@ -42,6 +42,13 @@ public: Request, Finished, Cancel, + Download_repository, + Download_package, + Download_filelist, + Download_changelog, + Download_group, + Download_updateinfo, + Repackaging, Unknown }; }; diff --git a/lib/Transaction.cpp b/lib/Transaction.cpp index 75ee2ab..c2815b2 100644 --- a/lib/Transaction.cpp +++ b/lib/Transaction.cpp @@ -349,7 +349,7 @@ bool Transaction::acceptEula(const QString &id) { // Signal callbacks void Transaction::Package_cb(const QString &info, const QString &package_id, const QString &summary) { - emit GotPackage(new Package(package_id, info, summary, this)); + emit GotPackage(new Package(package_id, (Info::Value)EnumFromString<Info>(info), summary, this)); } void Transaction::Details_cb(const QString &package_id, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size) { |