diff options
author | Daniel Nicoletti <mirttex85-pk@yahoo.com.br> | 2008-06-15 18:43:25 -0300 |
---|---|---|
committer | Daniel Nicoletti <mirttex85-pk@yahoo.com.br> | 2008-06-15 18:43:25 -0300 |
commit | e6a64e9a59699bff58155e8371246828cdf84fd2 (patch) | |
tree | 03730a810f792e4ed716cc7dba1181d203f03db0 | |
parent | 9ada17d9708d0e4b01b8d971a2103c41e5883b88 (diff) |
Groups mapped
-rwxr-xr-x | gui/ui/AddRm/PkAddRm.cpp | 180 | ||||
-rwxr-xr-x | gui/ui/AddRm/PkAddRm.h | 11 | ||||
-rw-r--r-- | gui/ui/AddRm/PkAddRm.ui | 62 | ||||
-rw-r--r-- | gui/ui/AddRm/PkAddRm_Model.cpp | 16 | ||||
-rw-r--r-- | gui/ui/AddRm/PkDelegate.cpp | 5 | ||||
-rw-r--r-- | gui/ui/AddRm/PkRequirements.ui | 34 | ||||
-rwxr-xr-x | gui/ui/AddRm/PkTransaction.cpp | 4 | ||||
-rwxr-xr-x | gui/ui/AddRm/PkTransaction.h | 2 | ||||
-rwxr-xr-x | gui/ui/Common/PkStrings.cpp | 269 | ||||
-rwxr-xr-x | gui/ui/Common/PkStrings.h | 4 | ||||
-rw-r--r-- | lib/Daemon.cpp | 11 | ||||
-rw-r--r-- | lib/Daemon.h | 2 | ||||
-rw-r--r-- | lib/Groups.h | 63 | ||||
-rw-r--r-- | lib/QPackageKit.h | 1 | ||||
-rw-r--r-- | lib/Transaction.cpp | 6 | ||||
-rw-r--r-- | lib/Transaction.h | 5 | ||||
-rw-r--r-- | lib/lib.pro | 2 |
17 files changed, 509 insertions, 168 deletions
diff --git a/gui/ui/AddRm/PkAddRm.cpp b/gui/ui/AddRm/PkAddRm.cpp index 6d89364..5a154ef 100755 --- a/gui/ui/AddRm/PkAddRm.cpp +++ b/gui/ui/AddRm/PkAddRm.cpp @@ -32,7 +32,8 @@ #define UNIVERSAL_PADDING 6 PkAddRm::PkAddRm( QWidget *parent ) - : QWidget( parent ), m_viewWidth(0) + : QWidget( parent ),m_mTransRuning(false), m_findIcon("edit-find"), + m_cancelIcon("dialog-cancel"), m_viewWidth(0) { setupUi( this ); @@ -45,25 +46,27 @@ PkAddRm::PkAddRm( QWidget *parent ) packageView->viewport()->setAttribute(Qt::WA_Hover); // check to see if the backend support these actions - if ( m_daemon->getActions() & Actions::Install_packages || m_daemon->getActions() & Actions::Remove_packages) + uint actions = m_daemon->getActions(); + if ( actions & Actions::Install_packages || actions & Actions::Remove_packages) connect( m_pkg_model_main, SIGNAL( changed(bool) ), this, SIGNAL( changed(bool) ) ); - if ( !(m_daemon->getActions() & Actions::Get_details) ) + + if ( !(actions & Actions::Get_details) ) tabWidget->setTabEnabled(0, false); - if ( !(m_daemon->getActions() & Actions::Get_requires) ) + if ( !(actions & Actions::Get_requires) ) tabWidget->setTabEnabled(1, false); - if ( !(m_daemon->getActions() & Actions::Get_depends) ) + if ( !(actions & Actions::Get_depends) ) tabWidget->setTabEnabled(2, false); - if ( !(m_daemon->getActions() & Actions::Get_files) ) + if ( !(actions & Actions::Get_files) ) tabWidget->setTabEnabled(3, false); - if ( !(m_daemon->getActions() & Actions::Search_name) ) - searchPB->setEnabled(false); + if ( !(actions & Actions::Search_name) ) + findPB->setEnabled(false); - if ( !(m_daemon->getActions() & Actions::Search_group) ) + if ( !(actions & Actions::Search_group) ) groupsCB->setEnabled(false); // create the main transaction @@ -73,29 +76,38 @@ PkAddRm::PkAddRm( QWidget *parent ) connect( m_pkClient_main, SIGNAL( ErrorCode(Error::Value, const QString&) ), this, SLOT( ErrorCode(Error::Value, const QString&) ) ); connect( m_pkClient_main, SIGNAL( Message(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) ); connect( m_pkClient_main, SIGNAL( StatusChanged(Status::Value) ), this, SLOT( StatusChanged(Status::Value) ) ); + connect( m_pkClient_main, SIGNAL( AllowCancel(bool) ), findPB, SLOT( setEnabled(bool) ) ); + connect( m_pkClient_main, SIGNAL( ProgressChanged(uint, uint, uint, uint) ), this, SLOT( ProgressChanged(uint, uint, uint, uint) ) ); //initialize the groups //TODO map everything and fix search group. - for (int i = 0; i < m_daemon->getGroups().size(); ++i) { - if ( m_daemon->getGroups().at(i) == "accessories" ) - groupsCB->addItem(KIcon("applications-accessories"), i18n("Accessories")); - else if ( m_daemon->getGroups().at(i) == "games" ) - groupsCB->addItem(KIcon("applications-games"), i18n("Games")); - else if ( m_daemon->getGroups().at(i) == "graphics" ) - groupsCB->addItem(KIcon("applications-graphics"), i18n("Graphics")); - else if ( m_daemon->getGroups().at(i) == "internet" ) - groupsCB->addItem(KIcon("applications-internet"), i18n("Internet")); - else if ( m_daemon->getGroups().at(i) == "office" ) - groupsCB->addItem(KIcon("applications-office"), i18n("Office")); - else if ( m_daemon->getGroups().at(i) == "other" ) - groupsCB->addItem(KIcon("applications-other"), i18n("Other")); - else if ( m_daemon->getGroups().at(i) == "programming" ) - groupsCB->addItem(KIcon("applications-development"), i18n("Development")); - else if ( m_daemon->getGroups().at(i) == "multimedia" ) - groupsCB->addItem(KIcon("applications-multimedia"), i18n("Multimedia")); - else if ( m_daemon->getGroups().at(i) == "system" ) - groupsCB->addItem(KIcon("applications-system"), i18n("System")); - } + qDebug() << m_daemon->getGroups(); + +// QMetaObject const* mo = m_daemon->getGroups()->metaObject(); +// QMetaEnum me = mo->enumerator(mo->indexOfEnumerator("Groups::Value")); +// for (int i = 0; i < me.keyCount(); ++i) { +// qDebug() << "Next MyEnum value is" << me.key(i) << me.value(i); +// } +// for (int i = 0; i < m_daemon->getGroups().size(); ++i) { +// if ( m_daemon->getGroups().at(i) == "accessories" ) +// groupsCB->addItem(KIcon("applications-accessories"), i18n("Accessories")); +// else if ( m_daemon->getGroups().at(i) == "games" ) +// groupsCB->addItem(KIcon("applications-games"), i18n("Games")); +// else if ( m_daemon->getGroups().at(i) == "graphics" ) +// groupsCB->addItem(KIcon("applications-graphics"), i18n("Graphics")); +// else if ( m_daemon->getGroups().at(i) == "internet" ) +// groupsCB->addItem(KIcon("applications-internet"), i18n("Internet")); +// else if ( m_daemon->getGroups().at(i) == "office" ) +// groupsCB->addItem(KIcon("applications-office"), i18n("Office")); +// else if ( m_daemon->getGroups().at(i) == "other" ) +// groupsCB->addItem(KIcon("applications-other"), i18n("Other")); +// else if ( m_daemon->getGroups().at(i) == "programming" ) +// groupsCB->addItem(KIcon("applications-development"), i18n("Development")); +// else if ( m_daemon->getGroups().at(i) == "multimedia" ) +// groupsCB->addItem(KIcon("applications-multimedia"), i18n("Multimedia")); +// else if ( m_daemon->getGroups().at(i) == "system" ) +// groupsCB->addItem(KIcon("applications-system"), i18n("System")); +// } // install the backend filters FilterMenu( m_daemon->getFilters() ); @@ -120,12 +132,13 @@ PkAddRm::PkAddRm( QWidget *parent ) requiredByLV->setModel(m_pkg_model_req = new PkAddRmModel(this)); connect( m_pkClient_req, SIGNAL(GotPackage(Package *)), m_pkg_model_req, SLOT(addPackage(Package *)) ); - // connect the timer... - connect(&m_notifyT, SIGNAL(timeout()), this, SLOT(notifyUpdate())); + // connect the notify and busy timer... + connect( &m_busyT, SIGNAL( timeout() ), this, SLOT( updateProgress() ) ); + connect( &m_notifyT, SIGNAL( timeout() ), this, SLOT( notifyUpdate() ) ); // set fucus on the search lineEdit lineEdit->setFocus(Qt::OtherFocusReason); - + findPB->setIcon(m_findIcon); infoHide(); } @@ -133,11 +146,26 @@ void PkAddRm::StatusChanged(Status::Value v) { notifyF->show(); notifyL->setText( PkStrings::StatusChanged(v) ); + m_busyT.start(10); +} + +void PkAddRm::ProgressChanged(uint percentage, uint /*subpercentage*/, uint /*elapsed*/, uint /*remaining*/) +{ + busyPB->setMaximum(100); + busyPB->setValue(percentage); +} + +void PkAddRm::updateProgress() +{ + if ( busyPB->maximum() == 0 ) + busyPB->setValue(busyPB->value() + 1); + else + m_busyT.stop(); } void PkAddRm::ErrorCode(Error::Value v, const QString &details) { - KMessageBox::detailedSorry( this, PkStrings::ErrorCode(v), details, i18n("Erro PackageKit"), KMessageBox::Notify ); + KMessageBox::detailedSorry( this, PkStrings::ErrorMessage(v), details, PkStrings::Error(v), KMessageBox::Notify ); } void PkAddRm::resizeEvent ( QResizeEvent * event ) @@ -200,26 +228,41 @@ void PkAddRm::infoShow() descriptionDW->setVisible(true); } -void PkAddRm::on_searchPB_clicked() -{ - infoHide(); - updateColumnsWidth(); -// qDebug() << "Search Name " << filters() ; - m_pkClient_main->searchName( filters(), lineEdit->text() ); -} - -void PkAddRm::Message(const QString &one, const QString &two) +void PkAddRm::on_findPB_clicked() { - qDebug() << "Error code: " << one << " two: " << two; + if ( m_mTransRuning ) { + m_pkClient_main->cancel(); + } + else { + m_pkClient_main->searchName( filters(), lineEdit->text() ); + StatusChanged( m_pkClient_main->getStatus() ); + search(); + } } void PkAddRm::on_groupsCB_currentIndexChanged( const QString & text ) { //TODO fix this mapping qDebug() << "Search Group " << text.toLower(); + m_pkClient_main->searchGroup( filters(), Groups::Office ); + search(); +} + +void PkAddRm::search() +{ infoHide(); updateColumnsWidth(); - m_pkClient_main->searchGroup( filters(), text.toLower() ); + busyPB->setMaximum(0); + busyPB->setValue(0); + m_mTransRuning = true; + findPB->setText( i18n("&Cancel") ); + findPB->setIcon(m_cancelIcon); + findPB->setEnabled(false); +} + +void PkAddRm::Message(const QString &one, const QString &two) +{ + qDebug() << "Error code: " << one << " two: " << two; } void PkAddRm::on_packageView_pressed( const QModelIndex & index ) @@ -242,6 +285,7 @@ void PkAddRm::on_packageView_pressed( const QModelIndex & index ) //ask files in packages if ( m_daemon->getActions() & Actions::Get_files ) m_pkClient_files->getFiles(p); + } } @@ -261,6 +305,12 @@ void PkAddRm::Finished(Exit::Value status, uint runtime) { notifyF->show(); QPalette teste; + m_busyT.stop(); + busyPB->setValue(100); + m_mTransRuning = false; + findPB->setEnabled(true); + findPB->setText( i18n("&Find") ); + findPB->setIcon(m_findIcon); switch(status) { case Exit::Success : notifyL->setText("Search finished in " + KGlobal::locale()->formatDuration(runtime) ); @@ -270,17 +320,47 @@ void PkAddRm::Finished(Exit::Value status, uint runtime) m_notifyT.start(100); break; case Exit::Failed : - notifyL->setText("Search Failed " + KGlobal::locale()->formatDuration(runtime) ); + notifyL->setText("Search failed"); teste.setColor(QPalette::Normal, QPalette::Window, QColor(255,0,0,150)); notifyL->setPalette(teste); notifyL->setAutoFillBackground(true); m_notifyT.start(50); break; - case Exit::Cancelled : break; - case Exit::KeyRequired : break; - case Exit::EulaRequired : break; - case Exit::Kill : break; - case Exit::Unknown : break; + case Exit::Cancelled : + notifyL->setText("Search canceled"); + teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150)); + notifyL->setPalette(teste); + notifyL->setAutoFillBackground(true); + m_notifyT.start(100); + break; + case Exit::KeyRequired : + 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 : + 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::Kill : + notifyL->setText("Search killed"); + teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150)); + notifyL->setPalette(teste); + notifyL->setAutoFillBackground(true); + m_notifyT.start(100); + break; + case Exit::Unknown : + notifyL->setText("Search finished with unknown status"); + teste.setColor( QPalette::Normal, QPalette::Window, QColor(0,255,0,150)); + notifyL->setPalette(teste); + notifyL->setAutoFillBackground(true); + m_notifyT.start(100); + break; } } diff --git a/gui/ui/AddRm/PkAddRm.h b/gui/ui/AddRm/PkAddRm.h index dd75c68..1fc1e57 100755 --- a/gui/ui/AddRm/PkAddRm.h +++ b/gui/ui/AddRm/PkAddRm.h @@ -24,6 +24,8 @@ #include <QtGui/QtGui> #include <QtCore/QtCore> +#include <KIcon> + #include "PkAddRm_Model.h" #include "PkDelegate.h" @@ -40,7 +42,7 @@ public: ~PkAddRm(); public slots: - void on_searchPB_clicked(); + void on_findPB_clicked(); void on_groupsCB_currentIndexChanged( const QString &text ); void on_packageView_pressed( const QModelIndex &index ); void Description(Package *p, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size); @@ -56,6 +58,7 @@ private: void infoHide(); void infoShow(); + bool m_mTransRuning;//main trans PkAddRmModel *m_pkg_model_main; PkAddRmModel *m_pkg_model_dep; PkAddRmModel *m_pkg_model_req; @@ -69,7 +72,10 @@ private: Transaction *m_pkClient_req; QTimer m_notifyT; + QTimer m_busyT; QMenu *m_toolQM; + KIcon m_findIcon; + KIcon m_cancelIcon; // We need to keep a list to build the filters string QList<QAction*> actions; @@ -78,9 +84,12 @@ private: void updateColumnsWidth(bool force = false); int m_viewWidth; + void search(); private slots: void notifyUpdate(); + void updateProgress(); + void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining); signals: void changed(bool state); diff --git a/gui/ui/AddRm/PkAddRm.ui b/gui/ui/AddRm/PkAddRm.ui index 1d36b4d..2d69642 100644 --- a/gui/ui/AddRm/PkAddRm.ui +++ b/gui/ui/AddRm/PkAddRm.ui @@ -18,6 +18,9 @@ <property name="windowTitle" > <string>Add and Remove Software</string> </property> + <property name="locale" > + <locale country="UnitedStates" language="English" /> + </property> <layout class="QGridLayout" name="gridLayout" > <property name="margin" > <number>0</number> @@ -32,23 +35,13 @@ </property> </widget> </item> - <item row="0" column="1" > - <widget class="QPushButton" name="searchPB" > - <property name="text" > - <string>Search in:</string> - </property> - <property name="default" > - <bool>true</bool> - </property> - </widget> - </item> <item row="0" column="2" > <widget class="QToolButton" name="filtersTB" > <property name="locale" > <locale country="UnitedStates" language="English" /> </property> <property name="text" > - <string/> + <string>Filters</string> </property> <property name="popupMode" > <enum>QToolButton::InstantPopup</enum> @@ -132,10 +125,10 @@ <widget class="QWidget" name="dockWidgetContents" > <property name="geometry" > <rect> - <x>4</x> + <x>2</x> <y>22</y> - <width>533</width> - <height>191</height> + <width>537</width> + <height>189</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_2" > @@ -167,8 +160,8 @@ <rect> <x>0</x> <y>0</y> - <width>513</width> - <height>146</height> + <width>517</width> + <height>141</height> </rect> </property> <attribute name="title" > @@ -189,8 +182,8 @@ <rect> <x>0</x> <y>0</y> - <width>513</width> - <height>146</height> + <width>517</width> + <height>141</height> </rect> </property> <attribute name="title" > @@ -214,8 +207,8 @@ <rect> <x>0</x> <y>0</y> - <width>272</width> - <height>140</height> + <width>517</width> + <height>141</height> </rect> </property> <attribute name="title" > @@ -242,8 +235,8 @@ <rect> <x>0</x> <y>0</y> - <width>272</width> - <height>140</height> + <width>517</width> + <height>141</height> </rect> </property> <attribute name="title" > @@ -284,7 +277,7 @@ <property name="spacing" > <number>0</number> </property> - <item row="0" column="0" > + <item row="0" column="1" > <widget class="QLabel" name="notifyL" > <property name="sizePolicy" > <sizepolicy vsizetype="Preferred" hsizetype="Expanding" > @@ -306,9 +299,32 @@ </property> </widget> </item> + <item row="0" column="0" > + <widget class="QProgressBar" name="busyPB" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximum" > + <number>0</number> + </property> + </widget> + </item> </layout> </widget> </item> + <item row="0" column="1" > + <widget class="QPushButton" name="findPB" > + <property name="text" > + <string>&Find</string> + </property> + <property name="default" > + <bool>true</bool> + </property> + </widget> + </item> </layout> </widget> <customwidgets> diff --git a/gui/ui/AddRm/PkAddRm_Model.cpp b/gui/ui/AddRm/PkAddRm_Model.cpp index 0b0b0a6..dd70646 100644 --- a/gui/ui/AddRm/PkAddRm_Model.cpp +++ b/gui/ui/AddRm/PkAddRm_Model.cpp @@ -26,7 +26,7 @@ int PkAddRmModel::rowCount(const QModelIndex &) const int PkAddRmModel::columnCount(const QModelIndex &) const { - return 2;//for now we have only the name collumn + return 2; } QVariant PkAddRmModel::data(const QModelIndex &index, int role) const @@ -60,11 +60,15 @@ QVariant PkAddRmModel::data(const QModelIndex &index, int role) const return p->id(); case Qt::CheckStateRole : - for (int i = 0; i < m_packagesChanges.size(); ++i) { - if ( m_packagesChanges.at(i)->id() == package(index)->id() ) - return Qt::Checked; - } - return Qt::Unchecked; + if ( index.column() == 1 ) { + for (int i = 0; i < m_packagesChanges.size(); ++i) { + if ( m_packagesChanges.at(i)->id() == package(index)->id() ) + return Qt::Checked; + } + return Qt::Unchecked; + } + else + return QVariant(); default: return QVariant(); diff --git a/gui/ui/AddRm/PkDelegate.cpp b/gui/ui/AddRm/PkDelegate.cpp index 666af55..e429af7 100644 --- a/gui/ui/AddRm/PkDelegate.cpp +++ b/gui/ui/AddRm/PkDelegate.cpp @@ -45,8 +45,6 @@ PkDelegate::PkDelegate(QObject * parent) void PkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { -// KCategorizedItemsViewModels::AbstractItem * item = -// getItemByProxyIndex(index); if (!index.isValid()) return; QStyleOptionViewItemV4 opt(option); @@ -279,6 +277,9 @@ bool PkDelegate::editorEvent(QEvent *event, { if ( event->type() == QEvent::MouseButtonPress && index.column() == 1 ) return model->setData(index, !model->data(index, Qt::CheckStateRole).toBool(), Qt::CheckStateRole ); +// else if ( event->type() == QEvent::KeyPress ) { +// +// } else return QItemDelegate::editorEvent(event, model, option, index); } diff --git a/gui/ui/AddRm/PkRequirements.ui b/gui/ui/AddRm/PkRequirements.ui index d91baad..5d169ff 100644 --- a/gui/ui/AddRm/PkRequirements.ui +++ b/gui/ui/AddRm/PkRequirements.ui @@ -10,7 +10,7 @@ </rect> </property> <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > + <item row="1" column="0" > <widget class="QLabel" name="label" > <property name="font" > <font> @@ -35,34 +35,16 @@ </property> </widget> </item> - <item row="1" column="0" > - <widget class="QTreeView" name="packageView" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > - <horstretch>2</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="sizeIncrement" > - <size> - <width>0</width> - <height>2</height> - </size> + <item row="2" column="0" > + <widget class="QListView" name="packageView" > + <property name="editTriggers" > + <set>QAbstractItemView::NoEditTriggers</set> </property> - <property name="locale" > - <locale country="UnitedStates" language="English" /> - </property> - <property name="rootIsDecorated" > - <bool>false</bool> - </property> - <property name="itemsExpandable" > - <bool>false</bool> - </property> - <property name="headerHidden" > + <property name="alternatingRowColors" > <bool>true</bool> </property> - <property name="expandsOnDoubleClick" > - <bool>false</bool> + <property name="selectionMode" > + <enum>QAbstractItemView::NoSelection</enum> </property> </widget> </item> diff --git a/gui/ui/AddRm/PkTransaction.cpp b/gui/ui/AddRm/PkTransaction.cpp index 9de2ded..5d0f2f6 100755 --- a/gui/ui/AddRm/PkTransaction.cpp +++ b/gui/ui/AddRm/PkTransaction.cpp @@ -96,9 +96,9 @@ void PkTransaction::StatusChanged(Status::Value v) currentL->setText( PkStrings::StatusChanged(v) ); } -void PkTransaction::ErrorCode(const QString &one, const QString &two) +void PkTransaction::ErrorCode(Error::Value v, const QString &details) { - KMessageBox::detailedSorry( this, one, two, i18n("Erro PackageKit"), KMessageBox::Notify ); + KMessageBox::detailedSorry( this, PkStrings::ErrorMessage(v), details, PkStrings::Error(v), KMessageBox::Notify ); } // void PkTransaction::reqFinished(Exit::Value status, uint runtime) diff --git a/gui/ui/AddRm/PkTransaction.h b/gui/ui/AddRm/PkTransaction.h index 898b5cd..7e3446f 100755 --- a/gui/ui/AddRm/PkTransaction.h +++ b/gui/ui/AddRm/PkTransaction.h @@ -38,7 +38,7 @@ public: public slots: // void reqFinished(Exit::Value status, uint runtime); void Finished(Exit::Value status, uint runtime); - void ErrorCode(const QString &one, const QString &two); + void ErrorCode(Error::Value v, const QString &details); void StatusChanged(Status::Value v); void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining); private: diff --git a/gui/ui/Common/PkStrings.cpp b/gui/ui/Common/PkStrings.cpp index 99834e3..137327f 100755 --- a/gui/ui/Common/PkStrings.cpp +++ b/gui/ui/Common/PkStrings.cpp @@ -77,98 +77,275 @@ QString PkStrings::StatusChanged(Status::Value v) } } -QString PkStrings::ErrorCode(Error::Value v) +QString PkStrings::Error(Error::Value v) { switch (v) { case Error::Oom : - return i18n("Waiting for service to start"); + return i18n("Out of memory"); case Error::No_network : - return i18n("Waiting for service to start"); + return i18n("No network connection available"); case Error::Not_supported : - return i18n("Waiting for service to start"); + return i18n("Not supported by this backend"); case Error::Internal_error : - return i18n("Waiting for service to start"); + return i18n("An internal system error has occurred"); case Error::Gpg_failure : - return i18n("Waiting for service to start"); + return i18n("A security trust relationship is not present"); case Error::Package_id_invalid : - return i18n("Waiting for service to start"); + return i18n("The package identifier was not well formed"); case Error::Package_not_installed : - return i18n("Waiting for service to start"); + return i18n("The package is not installed"); case Error::Package_not_found : - return i18n("Waiting for service to start"); + return i18n("The package was not found"); case Error::Package_already_installed : - return i18n("Waiting for service to start"); + return i18n("The package is already installed"); case Error::Package_download_failed : - return i18n("Waiting for service to start"); + return i18n("The package download failed"); case Error::Group_not_found : - return i18n("Waiting for service to start"); + return i18n("The group was not found"); case Error::Group_list_invalid : - return i18n("Waiting for service to start"); + return i18n("The group list was invalid"); case Error::Dep_resolution_failed : - return i18n("Waiting for service to start"); + return i18n("Dependency resolution failed"); case Error::Filter_invalid : - return i18n("Waiting for service to start"); + return i18n("Search filter was invalid"); case Error::Create_thread_failed : - return i18n("Waiting for service to start"); + return i18n("Failed to create a thread"); case Error::Transaction_error : - return i18n("Waiting for service to start"); + return i18n("Transaction error"); case Error::Transaction_cancelled : - return i18n("Waiting for service to start"); + return i18n("The task was canceled"); case Error::No_cache : - return i18n("Waiting for service to start"); + return i18n("No package cache is available"); case Error::Repo_not_found : - return i18n("Waiting for service to start"); + return i18n("Repository name was not found"); case Error::Cannot_remove_system_package : - return i18n("Waiting for service to start"); + return i18n("Could not remove a protected system package"); case Error::Process_kill : - return i18n("Waiting for service to start"); + return i18n("The task was forcibly canceled"); case Error::Failed_initialization : - return i18n("Waiting for service to start"); + return i18n("Failed to initialize"); case Error::Failed_finalise : - return i18n("Waiting for service to start"); + return i18n("Failed to finalise"); case Error::Failed_config_parsing : - return i18n("Waiting for service to start"); + return i18n("Reading the config file failed"); case Error::Cannot_cancel : - return i18n("Waiting for service to start"); + return i18n("The task cannot be cancelled"); case Error::Cannot_getLock : - return i18n("Waiting for service to start"); + return i18n("Cannot get lock"); case Error::No_packages_to_update : - return i18n("Waiting for service to start"); + return i18n("No packages to update"); case Error::Cannot_write_repo_config : - return i18n("Waiting for service to start"); + return i18n("Cannot write repository configuration"); case Error::Local_install_failed : - return i18n("Waiting for service to start"); + return i18n("Local install failed"); case Error::Bad_gpg_signature : - return i18n("Waiting for service to start"); + return i18n("Bad GPG signature"); case Error::Missing_gpg_signature : - return i18n("Waiting for service to start"); + return i18n("Missing GPG signature"); case Error::Cannot_install_source_package : - return i18n("Waiting for service to start"); + return i18n("Source packages cannot be installed"); case Error::Repo_configuration_error : - return i18n("Waiting for service to start"); + return i18n("Repository configuration invalid"); case Error::No_license_agreement : - return i18n("Waiting for service to start"); + return i18n("The license agreement failed"); case Error::File_conflicts : - return i18n("Waiting for service to start"); + return i18n("Local file conflict between packages"); case Error::Repo_not_available : - return i18n("Waiting for service to start"); + return i18n("Problem connecting to a software source"); case Error::Invalid_package_file : - return i18n("Waiting for service to start"); + return i18n("Invalid package file"); case Error::Package_install_blocked : - return i18n("Waiting for service to start"); + return i18n("Package install blocked"); case Error::Package_corrupt : - return i18n("Waiting for service to start"); + return i18n("Package is corrupt"); case Error::Unknown : - return i18n("Waiting for service to start"); + return i18n("Unknown error"); default : - return i18n("Unknown Error"); + return i18n("Unknown error"); } } -// void PkTransaction::ErrorCode(const QString &one, const QString &two) -// { -// KMessageBox::detailedSorry( this, one, two, i18n("Erro PackageKit"), KMessageBox::Notify ); -// } +QString PkStrings::ErrorMessage(Error::Value v) +{ + switch (v) { + case Error::Oom : + return i18n("The service that is responsible for handling user requests is out of memory.\n" + "Please restart your computer."); + case Error::No_network : + return i18n("There is no network connection available.\n" + "Please check your connection settings and try again"); + case Error::Not_supported : + return i18n("The action is not supported by this backend.\n" + "Please report a bug as this shouldn't have happened."); + case Error::Internal_error : + return i18n("A problem that we were not expecting has occurred.\n" + "Please report this bug with the error description."); + case Error::Gpg_failure : + return i18n("A security trust relationship could not be made with software source.\n" + "Please check your security settings."); + case Error::Package_id_invalid : + return i18n("The package identifier was not well formed when sent to the server.\n" + "This normally indicates an internal error and should be reported."); + case Error::Package_not_installed : + return i18n("The package that is trying to be removed or updated is not already installed."); + case Error::Package_not_found : + return i18n("The package that is being modified was not found on your system or in any software source."); + case Error::Package_already_installed : + return i18n("The package that is trying to be installed is already installed."); + case Error::Package_download_failed : + return i18n("The package download failed.\n" + "Please check your network connectivity."); + case Error::Group_not_found : + return i18n("The group type was not found.\n" + "Please check your group list and try again."); + case Error::Group_list_invalid : + return i18n("The group list could not be loaded.\n" + "Refreshing your cache may help, although this is normally a software " + "source error."); + case Error::Dep_resolution_failed : + return i18n("A package could not be found that allows the task to complete.\n" + "More information is available in the detailed report."); + case Error::Filter_invalid : + return i18n("The search filter was not correctly formed."); + case Error::Create_thread_failed : + return i18n("A thread could not be created to service the user request."); + case Error::Transaction_error : + return i18n("An unspecified task error has occurred.\n" + "More information is available in the detailed report."); + case Error::Transaction_cancelled : + return i18n("The task was canceled successfully and no packages were changed."); + case Error::No_cache : + return i18n("The package list needs to be rebuilt.\n" + "This should have been done by the backend automatically."); + case Error::Repo_not_found : + return i18n("The remote software source name was not found.\n" + "You may need to enable an item in Software Sources."); + case Error::Cannot_remove_system_package : + return i18n("Removing a protected system package is not alloed."); + case Error::Process_kill : + return i18n("The task was canceled successfully and no packages were changed.\n" + "The backend did not exit cleanly."); + case Error::Failed_initialization : + return i18n("Failed to initialize packaging backend.\n" + "This may occur if other packaging tools are being used simultaneously."); + case Error::Failed_finalise : + return i18n("Failed to close down the backend instance.\n" + "This error can normally be ignored."); + case Error::Failed_config_parsing : + return i18n("The native package configuration file could not be opened.\n" + "Please make sure configuration is valid."); + case Error::Cannot_cancel : + return i18n("The task is not safe to be cancelled at this time."); + case Error::Cannot_getLock : + return i18n("Cannot get the exclusive lock on the packaging backend.\n" + "Please close any other legacy packaging tools that may be open."); + case Error::No_packages_to_update : + return i18n("None of the selected packages could be updated."); + case Error::Cannot_write_repo_config : + return i18n("The repository configuration could not be modified."); + case Error::Local_install_failed : + return i18n("Installing the local file failed.\n" + "More information is available in the detailed report."); + case Error::Bad_gpg_signature : + return i18n("The package signature could not be verified."); + case Error::Missing_gpg_signature : + return i18n("The package signature was missing and this package is untrusted.\n" + "This package was not signed with a GPG key when created."); + case Error::Cannot_install_source_package : + return i18n("Source packages are not normally installed this way.\n" + "Check the extension of the file you are trying to install."); + case Error::Repo_configuration_error : + return i18n("Repository configuration was invalid and could not be read."); + case Error::No_license_agreement : + return i18n("The license agreement was not agreed to.\n" + "To use this software you have to accept the license."); + case Error::File_conflicts : + return i18n("Two packages provide the same file.\n" + "This is usually due to mixing packages for different software sources."); + case Error::Repo_not_available : + return i18n("There was a (possibly temporary) problem connecting to a software source\n" + "Please check the detailed error for further details."); + case Error::Invalid_package_file : + return i18n("The package you are attempting to install is not valid.\n" + "The package file could be corrupt, or not a proper package."); + case Error::Package_install_blocked : + return i18n("Installation of this package prevented by your packaging system's configuration."); + case Error::Package_corrupt : + return i18n("The package that was downloaded is corrupt and needs to be downloaded again."); + case Error::Unknown : + return i18n("Unknown error, please report a bug.\n" + "More information is available in the detailed report."); + default : + return i18n("Unknown error, please report a bug.\n" + "More information is available in the detailed report."); + } +} + +QString PkStrings::Groups(Groups::Value v) +{ + switch (v) { + case Groups::Accessibility : + return i18n("Accessibility"); + case Groups::Accessories : + return i18n("Accessories"); + case Groups::Admin_tools : + return i18n("Admin tools"); + case Groups::Communication : + return i18n("Communication"); + case Groups::Desktop_gnome : + return i18n("GNOME desktop"); + case Groups::Desktop_kde : + return i18n("KDE desktop"); + case Groups::Desktop_other : + return i18n("Other desktops"); + case Groups::Desktop_xfce : + return i18n("XFCE desktop"); + case Groups::Education : + return i18n("Education"); + case Groups::Fonts : + return i18n("Fonts"); + case Groups::Games : + return i18n("Games"); + case Groups::Graphics : + return i18n("Graphics"); + case Groups::Internet : + return i18n("Internet"); + case Groups::Legacy : + return i18n("Legacy"); + case Groups::Localization : + return i18n("Localization"); + case Groups::Maps : + return i18n("Maps"); + case Groups::Multimedia : + return i18n("Multimedia"); + case Groups::Network : + return i18n("Network"); + case Groups::Office : + return i18n("Office"); + case Groups::Other : + return i18n("Other"); + case Groups::Power_management : + return i18n("Power management"); + case Groups::Programming : + return i18n("Development"); + case Groups::Publishing : + return i18n("Publishing"); + case Groups::Repos : + return i18n("Software sources"); + case Groups::Security : + return i18n("Security"); + case Groups::Servers : + return i18n("Servers"); + case Groups::System : + return i18n("System"); + case Groups::Virtualization : + return i18n("Virtualization"); + case Groups::Unknown : + return i18n("Unknown group"); + default : + return i18n( "group unrecognised" ); + } +} // void PkTransaction::Finished(Exit::Value status, uint /*runtime*/) // { diff --git a/gui/ui/Common/PkStrings.h b/gui/ui/Common/PkStrings.h index 21a8a95..db6878d 100755 --- a/gui/ui/Common/PkStrings.h +++ b/gui/ui/Common/PkStrings.h @@ -35,8 +35,10 @@ public: ~PkStrings(); static QString Finished(Exit::Value status); - static QString ErrorCode(Error::Value v); + static QString Error(Error::Value v); + static QString ErrorMessage(Error::Value v); static QString StatusChanged(Status::Value v); + static QString Groups(Groups::Value v); }; #endif diff --git a/lib/Daemon.cpp b/lib/Daemon.cpp index 822b519..22dcd9a 100644 --- a/lib/Daemon.cpp +++ b/lib/Daemon.cpp @@ -13,6 +13,7 @@ #include "constants.h" #include "PolkitClient.h" #include "Actions.h" +#include "Groups.h" using namespace PackageKit; @@ -48,9 +49,13 @@ QStringList Daemon::getFilters() { return filters.split(";"); } -QStringList Daemon::getGroups() { - QString groups = proxy->GetGroups(); - return groups.split(";"); +Groups::Value Daemon::getGroups() { + QStringList groups = QString(proxy->GetGroups()).split(";"); + unsigned int ret = 0; + for(int i = 0 ; i < groups.size() ; ++i) { + ret |= EnumFromString<Groups>(groups.at(i)); + } + return (Groups::Value) ret; } QStringList Daemon::getTransactionList() { diff --git a/lib/Daemon.h b/lib/Daemon.h index 6a1ad49..a76df94 100644 --- a/lib/Daemon.h +++ b/lib/Daemon.h @@ -37,7 +37,7 @@ public: unsigned int getActions(); void getBackendDetails(QString &name, QString &author); QStringList getFilters(); - QStringList getGroups(); + Groups::Value getGroups(); QStringList getTransactionList(); uint getTimeSinceAction(Role::Value role); diff --git a/lib/Groups.h b/lib/Groups.h new file mode 100644 index 0000000..8f63d17 --- /dev/null +++ b/lib/Groups.h @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2007 Adrien Bustany <madcat@mymadcat.com> +* +* Licensed under the GNU General Public License Version 2 +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 See MA 02111-1307, USA. +* +*/ + +#ifndef GROUPS_H +#define GROUPS_H + +#include <QtCore> + +#include "Enum.h" + +namespace PackageKit { + +class Groups : public QObject { + + Q_OBJECT + Q_ENUMS(Value) + +public: +typedef enum { + Accessibility = 1 << 0, + Accessories = 1 << 1, + Admin_tools = 1 << 2, + Communication = 1 << 3, + Desktop_gnome = 1 << 4, + Desktop_kde = 1 << 5, + Desktop_other = 1 << 6, + Desktop_xfce = 1 << 7, + Education = 1 << 8, + Fonts = 1 << 9, + Games = 1 << 10, + Graphics = 1 << 11, + Internet = 1 << 12, + Legacy = 1 << 13, + Localization = 1 << 14, + Maps = 1 << 15, + Multimedia = 1 << 16, + Network = 1 << 17, + Office = 1 << 18, + Other = 1 << 19, + Power_management = 1 << 20, + Programming = 1 << 21, + Publishing = 1 << 22, + Repos = 1 << 23, + Security = 1 << 24, + Servers = 1 << 25, + System = 1 << 26, + Virtualization = 1 << 27, + Unknown = 1 << 28 +} Value; + +}; + +} // End namespace PackageKit + +#endif diff --git a/lib/QPackageKit.h b/lib/QPackageKit.h index ddbd2e6..f125cbe 100644 --- a/lib/QPackageKit.h +++ b/lib/QPackageKit.h @@ -14,5 +14,6 @@ #include "Role.h" #include "SignatureType.h" #include "Status.h" +#include "Groups.h" #endif diff --git a/lib/Transaction.cpp b/lib/Transaction.cpp index a832973..9e34c22 100644 --- a/lib/Transaction.cpp +++ b/lib/Transaction.cpp @@ -84,9 +84,9 @@ void Transaction::searchDetails(const QString &filter, const QString& search) { proxy->SearchDetails(filter, search); } -void Transaction::searchGroup(const QString &filter, const QString& search) { +void Transaction::searchGroup(const QString &filter, const Groups::Value &group) { renewTid(); - proxy->SearchGroup(filter, search); + proxy->SearchGroup(filter, EnumToString<Groups>(group)); } void Transaction::searchFile(const QString &filter, const QString& file) { @@ -278,7 +278,7 @@ void Transaction::Package_cb(const QString &info, const QString &package_id, con } void Transaction::Details_cb(const QString &package_id, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size) { - emit Details(new Package(package_id), license, group, detail, url, size); + emit Details(new Package(package_id), license, (Groups::Value)EnumFromString<Groups>(group), detail, url, size); } void Transaction::Files_cb(const QString &pid, const QString &file_list) { diff --git a/lib/Transaction.h b/lib/Transaction.h index 48218e8..f331726 100644 --- a/lib/Transaction.h +++ b/lib/Transaction.h @@ -24,6 +24,7 @@ #include "Role.h" #include "Status.h" #include "Error.h" +#include "Groups.h" namespace PackageKit { @@ -46,7 +47,7 @@ public: void searchName(const QString& filter, const QString& name); void searchDetails(const QString &filter, const QString& search); - void searchGroup(const QString &filter, const QString& search); + void searchGroup(const QString &filter, const Groups::Value &group); void searchFile(const QString &filter, const QString& file); void getPackages(const QString& filter); void getDetails(Package *p); @@ -82,7 +83,7 @@ public: signals: void GotPackage(Package *p); - void Details(Package *p, const QString& license, const QString& group, const QString& detail, const QString& url, qulonglong size); + void Details(Package *p, const QString& license, Groups::Value group, const QString& detail, const QString& url, qulonglong size); void Files(Package *p, QStringList files); void Finished(Exit::Value status, uint runtime); void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining); diff --git a/lib/lib.pro b/lib/lib.pro index a9f8f61..7e883f1 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -12,5 +12,5 @@ LIBS += -lpolkit -lpolkit-dbus QT += dbus # Input -HEADERS += CentralProxy.h constants.h Status.h Exit.h Role.h Package.h Restart.h Daemon.h Transaction.h TransactionProxy.h Provides.h SignatureType.h PolkitClient.h Error.h Actions.h +HEADERS += CentralProxy.h constants.h Status.h Exit.h Role.h Package.h Restart.h Daemon.h Transaction.h TransactionProxy.h Provides.h SignatureType.h PolkitClient.h Error.h Actions.h Groups.h SOURCES += CentralProxy.cpp Package.cpp Daemon.cpp TransactionProxy.cpp Transaction.cpp PolkitClient.cpp |