summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien BUSTANY <madcat@mymadcat.com>2008-06-13 01:16:03 +0200
committerAdrien BUSTANY <madcat@mymadcat.com>2008-06-13 01:16:03 +0200
commita77da4d2bebfe0beb166ad622333621b7406b8aa (patch)
treeed9b356bad8751c9ab921e59f45c7b561183bcb3
parent2bb004c03ab1b1b65273db4594de4b0c0587e569 (diff)
parentab3401ba9b953d148a9eefa9542c4c55f20a857b (diff)
Merge branch 'master' of git+ssh://madcat@git.packagekit.org/srv/git/QPackageKit
-rw-r--r--gui/ui/AddRm/CMakeLists.txt4
-rwxr-xr-xgui/ui/AddRm/PkAddRm.cpp70
-rwxr-xr-xgui/ui/AddRm/PkAddRm.h17
-rw-r--r--gui/ui/AddRm/PkAddRm_Model.h1
-rwxr-xr-xgui/ui/AddRm/PkAddRm_Transaction.cpp219
-rwxr-xr-xgui/ui/AddRm/PkAddRm_Transaction.h65
-rw-r--r--gui/ui/AddRm/PkAddRm_Transaction.ui93
-rwxr-xr-xgui/ui/AddRm/PkRequirements.cpp36
-rwxr-xr-xgui/ui/AddRm/PkRequirements.h40
-rw-r--r--gui/ui/AddRm/PkRequirements.ui73
-rw-r--r--gui/ui/AddRm/kpk-addrm.cpp8
-rw-r--r--gui/ui/AddRm/kpk-addrm.h5
-rw-r--r--gui/ui/Updater/CMakeLists.txt5
-rw-r--r--gui/ui/Updater/PkAddRm_Delegate.cpp302
-rw-r--r--gui/ui/Updater/PkAddRm_Delegate.h67
-rw-r--r--gui/ui/Updater/PkAddRm_Model.cpp168
-rw-r--r--gui/ui/Updater/PkAddRm_Model.h52
-rwxr-xr-xgui/ui/Updater/PkUpdate.cpp32
-rwxr-xr-xgui/ui/Updater/PkUpdate.h24
-rw-r--r--gui/ui/Updater/PkUpdate.ui142
-rw-r--r--gui/ui/Updater/kpk-update.cpp6
-rw-r--r--gui/ui/Updater/kpk-update.h12
-rw-r--r--gui/ui/Updater/pkg_item.cpp86
-rw-r--r--gui/ui/Updater/pkg_item.h56
24 files changed, 1440 insertions, 143 deletions
diff --git a/gui/ui/AddRm/CMakeLists.txt b/gui/ui/AddRm/CMakeLists.txt
index 3f56a58..e15223b 100644
--- a/gui/ui/AddRm/CMakeLists.txt
+++ b/gui/ui/AddRm/CMakeLists.txt
@@ -3,10 +3,14 @@ set(kpk_addrm_SRCS
PkAddRm.cpp
PkAddRm_Model.cpp
PkAddRm_Delegate.cpp
+ PkAddRm_Transaction.cpp
+ PkRequirements.cpp
)
kde4_add_ui_files(kpk_addrm_SRCS
PkAddRm.ui
+ PkAddRm_Transaction.ui
+ PkRequirements.ui
)
kde4_add_plugin(kcm_kpk_addrm ${kpk_addrm_SRCS})
diff --git a/gui/ui/AddRm/PkAddRm.cpp b/gui/ui/AddRm/PkAddRm.cpp
index 0e1334b..24e4b95 100755
--- a/gui/ui/AddRm/PkAddRm.cpp
+++ b/gui/ui/AddRm/PkAddRm.cpp
@@ -18,10 +18,12 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#include <klocale.h>
-#include <kstandarddirs.h>
+#include <KLocale>
+#include <KStandardDirs>
#include <QPalette>
#include <QColor>
+
+#include "PkAddRm_Transaction.h"
#include "PkAddRm.h"
PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
@@ -35,11 +37,18 @@ PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
// Create a new daemon
m_daemon = new Daemon(this);
+ // create the install transaction
+ m_pkClient_install = m_daemon->newTransaction();
+ connect( m_pkClient_install, SIGNAL(GotPackage(Package *)), m_pkg_model_main, SLOT(addPackage(Package *)) );
+ connect( m_pkClient_install, SIGNAL(Finished(Exit::Value, uint)), this, SLOT(Finished(Exit::Value, uint)) );
+ connect( m_pkClient_install, SIGNAL(Files(Package *, QStringList)), this, SLOT(Files(Package *, QStringList)) );
+ connect( m_pkClient_install, SIGNAL( Message(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
+ connect( m_pkClient_install, SIGNAL( ErrorCode(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
+
// create the main transaction
m_pkClient_main = m_daemon->newTransaction();
connect( m_pkClient_main, SIGNAL(GotPackage(Package *)), m_pkg_model_main, SLOT(addPackage(Package *)) );
connect( m_pkClient_main, SIGNAL(Finished(Exit::Value, uint)), this, SLOT(Finished(Exit::Value, uint)) );
- connect( m_pkClient_main, SIGNAL(Files(Package *, QStringList)), this, SLOT(Files(Package *, QStringList)) );
connect( m_pkClient_main, SIGNAL( Message(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
//initialize the groups
@@ -82,7 +91,7 @@ PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
m_pkClient_dep = m_daemon->newTransaction();
dependsOnLV->setModel(m_pkg_model_dep = new PkAddRmModel(this));
connect( m_pkClient_dep, SIGNAL(GotPackage(Package *)), m_pkg_model_dep, SLOT(addPackage(Package *)) );
-
+
// create a transaction for the requirements, and its model.
m_pkClient_req = m_daemon->newTransaction();
requiredByLV->setModel(m_pkg_model_req = new PkAddRmModel(this));
@@ -91,10 +100,7 @@ PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
// connect the timer...
connect(&m_notifyT, SIGNAL(timeout()), this, SLOT(notifyUpdate()));
- // hides the description to have more space.
- descriptionDW->hide();
- actionPB->hide();
- notifyF->hide();
+ infoHide();
}
PkAddRm::~PkAddRm()
@@ -109,12 +115,31 @@ PkAddRm::~PkAddRm()
delete m_pkClient_req;
}
-void PkAddRm::on_searchPB_clicked()
+void PkAddRm::infoHide()
{
+ // hides the description to have more space.
+ descriptionDW->setVisible(false);
+ actionPB->hide();
+ notifyF->hide();
+ // cleans the models
+ m_currPkg = 0;
m_pkg_model_main->clear();
+ m_pkg_model_req->clear();
+ m_pkg_model_dep->clear();
+}
+
+void PkAddRm::infoShow()
+{
+ descriptionDW->setVisible(true);
+ notifyF->show();
+ actionPB->show();
+}
+
+void PkAddRm::on_searchPB_clicked()
+{
+ infoHide();
// qDebug() << "Search Name " << filters() ;
m_pkClient_main->searchName( filters(), lineEdit->text() );
- descriptionDW->setVisible(false);
}
void PkAddRm::Message(const QString &one, const QString &two)
@@ -124,25 +149,31 @@ void PkAddRm::Message(const QString &one, const QString &two)
void PkAddRm::on_groupsCB_currentIndexChanged( const QString & text )
{
+ //TODO fix this mapping
qDebug() << "Search Group " << text.toLower();
- m_pkg_model_main->clear();
+ infoHide();
m_pkClient_main->searchGroup( filters(), text.toLower() );
- descriptionDW->setVisible(false);
}
void PkAddRm::on_packageView_pressed( const QModelIndex & index )
{
m_pkClient_desc->getDetails(m_pkg_model_main->package(index));
-
- notifyF->show();
- actionPB->show();
+ m_currPkg = m_pkg_model_main->package(index);
+ if (m_currPkg) {
+ if (m_currPkg->info() == "installed")
+ actionPB->setText(i18n("Remove"));
+ else
+ actionPB->setText(i18n("Install"));
+ }
qDebug() << index.model()->data(index, PkAddRmModel::IdRole).toString();
}
void PkAddRm::on_actionPB_clicked()
{
- qDebug() << "install pkg";
- m_pkClient_main->installPackage(new Package("vim-vimoutliner;0.3.4-9.fc7;noarch;fedora") );
+ PkAddRmTransaction *frm = new PkAddRmTransaction(m_currPkg, this);
+ frm->exec();
+// delete frm;
+ qDebug() << "mainEXEC()";
}
void PkAddRm::Finished(Exit::Value status, uint runtime)
@@ -190,7 +221,6 @@ void PkAddRm::notifyUpdate()
void PkAddRm::Description(Package *p, const QString& license, const QString& group, const QString& detail, const QString& url, qulonglong size)
{
qDebug() << p->id();
-
//ask required by packages
m_pkClient_req->getRequires("none", p, false);
@@ -214,7 +244,7 @@ void PkAddRm::Description(Package *p, const QString& license, const QString& gro
if ( size > 0 )
description += "<b>" + i18n("Size") + ":</b> " + KGlobal::locale()->formatByteSize(size);
descriptionKTB->setHtml(description);
- descriptionDW->setVisible(true);
+ infoShow();
}
void PkAddRm::Files(Package *, QStringList files)
@@ -222,7 +252,7 @@ void PkAddRm::Files(Package *, QStringList files)
filesPTE->clear();
for (int i = 0; i < files.size(); ++i)
filesPTE->appendPlainText(files.at(i));
- descriptionDW->setVisible(true);
+ infoShow();
}
void PkAddRm::FilterMenu(const QStringList &filters)
diff --git a/gui/ui/AddRm/PkAddRm.h b/gui/ui/AddRm/PkAddRm.h
index f901c2e..9eba928 100755
--- a/gui/ui/AddRm/PkAddRm.h
+++ b/gui/ui/AddRm/PkAddRm.h
@@ -37,6 +37,7 @@ class PkAddRm : public QWidget, public Ui::PkAddRm
public:
PkAddRm( QWidget *parent=0 );
~PkAddRm();
+
public slots:
void on_searchPB_clicked();
void on_actionPB_clicked();
@@ -48,6 +49,8 @@ public slots:
void Message(const QString &one, const QString &two);
private:
+ void infoHide();
+ void infoShow();
PkAddRmModel *m_pkg_model_main;
PkAddRmModel *m_pkg_model_dep;
PkAddRmModel *m_pkg_model_req;
@@ -57,20 +60,18 @@ private:
Transaction *m_pkClient_files;
Transaction *m_pkClient_dep;
Transaction *m_pkClient_req;
+ Transaction *m_pkClient_install;
QTimer m_notifyT;
-private slots:
- void notifyUpdate();
-//Filter Menu
-public:
- void FilterMenu(const QStringList &filters);
- QString filters();
-
-private:
QMenu *m_toolQM;
Daemon *m_daemon;
// We need to keep a list to build the filters string
QList<QAction*> actions;
+ void FilterMenu(const QStringList &filters);
+ QString filters();
+ Package *m_currPkg;
+private slots:
+ void notifyUpdate();
};
#endif
diff --git a/gui/ui/AddRm/PkAddRm_Model.h b/gui/ui/AddRm/PkAddRm_Model.h
index 06ab4b2..7753cf5 100644
--- a/gui/ui/AddRm/PkAddRm_Model.h
+++ b/gui/ui/AddRm/PkAddRm_Model.h
@@ -5,7 +5,6 @@
#include <KIcon>
#include "../../../lib/QPackageKit.h"
-// #include "../../../lib/Package.h"
using namespace PackageKit;
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.cpp b/gui/ui/AddRm/PkAddRm_Transaction.cpp
new file mode 100755
index 0000000..86091b9
--- /dev/null
+++ b/gui/ui/AddRm/PkAddRm_Transaction.cpp
@@ -0,0 +1,219 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * mirttex85-pk@yahoo.com.br *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <KLocale>
+#include <KStandardDirs>
+#include <KMessageBox>
+// #include <KDialog>
+#include <QPalette>
+#include <QColor>
+#include "PkRequirements.h"
+#include "PkAddRm_Transaction.h"
+
+PkAddRmTransaction::PkAddRmTransaction( Package *pkg, QWidget *parent )
+ : m_targetPackage(pkg)
+{
+ setupUi( mainWidget() );
+// setMainWidget(this);
+ // Create a new daemon
+ m_daemon = new Daemon(this);
+ // Create the requirements transaction and it's model
+ m_pkClient_req = m_daemon->newTransaction();
+ m_pkg_model_req = new PkAddRmModel(this);
+ connect( m_pkClient_req, SIGNAL(GotPackage(Package *)), m_pkg_model_req, SLOT(addPackage(Package *)) );
+ connect( m_pkClient_req, SIGNAL(Finished(Exit::Value, uint)), this, SLOT(reqFinished(Exit::Value, uint)) );
+
+ // create the install transaction
+ m_pkClient_action = m_daemon->newTransaction();
+ connect( m_pkClient_action, SIGNAL( GotPackage(Package *) ), this, SLOT( currPackage(Package *) ) );
+ connect( m_pkClient_action, SIGNAL( Finished(Exit::Value, uint) ), this, SLOT( Finished(Exit::Value, uint) ) );
+ connect( m_pkClient_action, SIGNAL( AllowCancel(bool) ), this, SLOT( enableButtonCancel(bool) ) );
+ connect( m_pkClient_action, SIGNAL( ErrorCode(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
+
+ connect( m_pkClient_action, SIGNAL( ProgressChanged(uint, uint, uint, uint) ), this, SLOT( ProgressChanged(uint, uint, uint, uint) ) );
+ connect( m_pkClient_action, SIGNAL( StatusChanged(Status::Value) ), this, SLOT( StatusChanged(Status::Value) ) );
+
+ setButtons( KDialog::Cancel | KDialog::Close );
+ enableButtonCancel(false);
+// setInitialSize( QSize(400,140) );
+ incrementInitialSize( QSize(400,140) );
+ m_pkClient_req->getDepends("~installed", pkg, true);
+ progressBar->setMaximum(0);
+ progressBar->setMinimum(0);
+}
+
+void PkAddRmTransaction::currPackage(Package *p)
+{
+ packageL->setText( p->name() + " - " + p->version() + " (" + p->arch() + ")" );
+ descriptionL->setText( p->summary() );
+}
+
+void PkAddRmTransaction::slotButtonClicked(int button)
+{
+qDebug() << "slotbt";
+ if (button == KDialog::Cancel)
+ m_pkClient_action->cancel();/*accept();*/
+ else
+ KDialog::slotButtonClicked(button);
+}
+
+PkAddRmTransaction::~PkAddRmTransaction()
+{
+
+}
+
+void PkAddRmTransaction::StatusChanged(Status::Value v)
+{
+ switch (v) {
+ case Status::Setup :
+ currentL->setText( i18n("Waiting for service to start") );
+ break;
+ case Status::Wait :
+ currentL->setText( i18n("Waiting for other tasks") );
+ break;
+ case Status::Query :
+ currentL->setText( i18n("Querying") );
+ break;
+ case Status::Info :
+ currentL->setText( i18n("Getting information") );
+ break;
+ case Status::Remove :
+ currentL->setText( i18n("Removing") );
+ break;
+ case Status::Refresh_cache :
+ currentL->setText( i18n("Refreshing software list") );
+ break;
+ case Status::Download :
+ currentL->setText( i18n("Downloading") );
+ break;
+ case Status::Install :
+ currentL->setText( i18n("Installing") );
+ break;
+ case Status::Update :
+ currentL->setText( i18n("Updating") );
+ break;
+ case Status::Cleanup :
+ currentL->setText( i18n("Cleaning Up") );
+ break;
+ case Status::Obsolete :
+ currentL->setText( i18n("Obsoletiong") );
+ break;
+ case Status::Dep_resolve :
+ currentL->setText( i18n("Resolving dependencies") );
+ break;
+ case Status::Rollback :
+ currentL->setText( i18n("Rolling back") );
+ break;
+ case Status::Commit :
+ currentL->setText( i18n("Committing changes") );
+ break;
+ case Status::Request :
+ currentL->setText( i18n("Requesting data") );
+ break;
+ case Status::Finished :
+ currentL->setText( i18n("Finished") );
+ break;
+ case Status::Cancel :
+ currentL->setText( i18n("Cancelling") );
+ break;
+ case Status::Unknown :
+ currentL->setText( i18n("Unknown state") );
+ break;
+ default :
+ currentL->setText( i18n("Running task") );
+ break;
+ }
+}
+
+void PkAddRmTransaction::ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining)
+{
+ progressBar->setValue(percentage);
+}
+
+void PkAddRmTransaction::Message(const QString &one, const QString &two)
+{
+ qDebug() << "Error code: " << one << " two: " << two;
+}
+
+void PkAddRmTransaction::doAction()
+{
+ m_pkClient_action->installPackage(m_targetPackage);
+}
+
+void PkAddRmTransaction::reqFinished(Exit::Value status, uint runtime)
+{
+ switch(status) {
+ case Exit::Success :
+ if (m_pkg_model_req->rowCount( QModelIndex() ) > 0 ) {
+ KDialog *dialog = new KDialog( this );
+ dialog->setCaption( "Confirm" );
+ dialog->setButtons( KDialog::Ok | KDialog::Cancel );
+
+ PkRequirements *widget = new PkRequirements( "The Folow...", m_pkg_model_req, this );
+ dialog->setMainWidget( widget );
+ connect( dialog, SIGNAL( okClicked() ), this, SLOT( doAction() ) );
+ connect( dialog, SIGNAL( cancelClicked() ), this, SLOT( close() ) );
+ dialog->exec();qDebug() << "exec())) ...";
+ }
+ else
+ doAction();
+ // case Status::Failed :
+// currentL->setText( i18n("Failed") );
+// break;
+// case Status::Quit :
+// currentL->setText( i18n("Quiting") );
+// break;
+// case Status::Kill :
+// currentL->setText( i18n("Killing") );
+// break;
+ }
+}
+
+void PkAddRmTransaction::Finished(Exit::Value status, uint runtime)
+{
+ switch(status) {
+ default :
+ close();
+ }
+qDebug() << "trans finished: " << status ;
+// notifyF->show();
+// QPalette teste;
+// switch(status) {
+// case Exit::Success :
+// 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::Failed :
+// notifyL->setText("Search Failed " + KGlobal::locale()->formatDuration(runtime) );
+// teste.setColor(QPalette::Normal, QPalette::Window, QColor(255,0,0,150));
+// notifyL->setPalette(teste);
+// notifyL->setAutoFillBackground(true);
+// m_notifyT.start(50);
+// break;
+// case Exit::Quit : break;
+// case Exit::Kill : break;
+// case Exit::Unknown : break;
+// }
+}
+
+#include "PkAddRm_Transaction.moc"
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.h b/gui/ui/AddRm/PkAddRm_Transaction.h
new file mode 100755
index 0000000..9208fdf
--- /dev/null
+++ b/gui/ui/AddRm/PkAddRm_Transaction.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * mirttex85-pk@yahoo.com.br *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef PKADDRM_TRANSACTION_H
+#define PKADDRM_TRANSACTION_H
+
+#include <KDialog>
+// #include <QtCore/QtCore>
+
+#include "PkAddRm_Model.h"
+#include "ui_PkAddRm_Transaction.h"
+#include "../../../lib/QPackageKit.h"
+
+using namespace PackageKit;
+
+class PkAddRmTransaction : public KDialog, Ui::PkAddRmTransaction
+{
+ Q_OBJECT
+public:
+ PkAddRmTransaction( Package *pkg, QWidget *parent=0);
+ ~PkAddRmTransaction();
+
+public slots:
+// void Description(Package *p, const QString &license, const QString &group, const QString &detail, const QString &url, qulonglong size);
+// void Files(Package *p, QStringList files);
+ void reqFinished(Exit::Value status, uint runtime);
+ void Finished(Exit::Value status, uint runtime);
+ void Message(const QString &one, const QString &two);
+ void StatusChanged(Status::Value v);
+ void ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining);
+private:
+ PkAddRmModel *m_pkg_model_req;
+ Transaction *m_pkClient_req, *m_pkClient_action;
+ QTimer m_notifyT;
+ Package *m_targetPackage;
+
+private slots:
+ void doAction();
+ void currPackage(Package *);
+
+private:
+ Daemon *m_daemon;
+
+protected slots:
+ virtual void slotButtonClicked(int button);
+};
+
+#endif
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.ui b/gui/ui/AddRm/PkAddRm_Transaction.ui
new file mode 100644
index 0000000..cf4b5b7
--- /dev/null
+++ b/gui/ui/AddRm/PkAddRm_Transaction.ui
@@ -0,0 +1,93 @@
+<ui version="4.0" >
+ <class>PkAddRmTransaction</class>
+ <widget class="QWidget" name="PkAddRmTransaction" >
+ <property name="windowModality" >
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>122</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>KPackageKit - Transaction</string>
+ </property>
+ <property name="locale" >
+ <locale country="UnitedStates" language="English" />
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" colspan="2" >
+ <widget class="QLabel" name="currentL" >
+ <property name="font" >
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="locale" >
+ <locale country="UnitedStates" language="English" />
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="QProgressBar" name="progressBar" >
+ <property name="locale" >
+ <locale country="UnitedStates" language="English" />
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2" >
+ <widget class="QLabel" name="descriptionL" >
+ <property name="font" >
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="packageL" >
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLabel" name="timeL" >
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2" >
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/ui/AddRm/PkRequirements.cpp b/gui/ui/AddRm/PkRequirements.cpp
new file mode 100755
index 0000000..94b8786
--- /dev/null
+++ b/gui/ui/AddRm/PkRequirements.cpp
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * mirttex85-pk@yahoo.com.br *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "PkRequirements.h"
+
+PkRequirements::PkRequirements( QString msg, PkAddRmModel* model, QWidget *parent )
+ : QWidget( parent )
+{
+ setupUi( this );
+
+ label->setText(msg);
+ packageView->setModel(model);
+}
+
+PkRequirements::~PkRequirements()
+{
+}
+
+#include "PkRequirements.moc"
diff --git a/gui/ui/AddRm/PkRequirements.h b/gui/ui/AddRm/PkRequirements.h
new file mode 100755
index 0000000..dfb7c93
--- /dev/null
+++ b/gui/ui/AddRm/PkRequirements.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * mirttex85-pk@yahoo.com.br *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef PKREQUIREMENTS_H
+#define PKREQUIREMENTS_H
+
+#include <QWidget>
+
+#include "PkAddRm_Model.h"
+#include "ui_PkRequirements.h"
+// #include "../../../lib/QPackageKit.h"
+
+using namespace PackageKit;
+
+class PkRequirements : public QWidget, public Ui::PkRequirements
+{
+ Q_OBJECT
+public:
+ PkRequirements( QString msg, PkAddRmModel *model, QWidget *parent=0);
+ ~PkRequirements();
+};
+
+#endif
diff --git a/gui/ui/AddRm/PkRequirements.ui b/gui/ui/AddRm/PkRequirements.ui
new file mode 100644
index 0000000..d91baad
--- /dev/null
+++ b/gui/ui/AddRm/PkRequirements.ui
@@ -0,0 +1,73 @@
+<ui version="4.0" >
+ <class>PkRequirements</class>
+ <widget class="QWidget" name="PkRequirements" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="font" >
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text" >
+ <string>The Following packages have also to be removed/installed:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::AutoText</enum>
+ </property>
+ <property name="scaledContents" >
+ <bool>false</bool>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </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>
+ </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" >
+ <bool>true</bool>
+ </property>
+ <property name="expandsOnDoubleClick" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/ui/AddRm/kpk-addrm.cpp b/gui/ui/AddRm/kpk-addrm.cpp
index ea3ec3c..2ca4053 100644
--- a/gui/ui/AddRm/kpk-addrm.cpp
+++ b/gui/ui/AddRm/kpk-addrm.cpp
@@ -17,7 +17,7 @@
*
*/
-#include <kgenericfactory.h>
+#include <KGenericFactory>
#include <KAboutData>
#include "kpk-addrm.h"
@@ -35,9 +35,3 @@ KPackageKit::KPackageKit(QWidget *parent, const QVariantList &args)
view = new PkAddRm(this);
m_grid->addWidget(view);
}
-
-KPackageKit::~KPackageKit()
-{
- delete view;
- delete m_grid;
-}
diff --git a/gui/ui/AddRm/kpk-addrm.h b/gui/ui/AddRm/kpk-addrm.h
index cb68f9d..c7a5d84 100644
--- a/gui/ui/AddRm/kpk-addrm.h
+++ b/gui/ui/AddRm/kpk-addrm.h
@@ -25,11 +25,10 @@
class KPackageKit : public KCModule
{
- Q_OBJECT
-
+Q_OBJECT
public:
KPackageKit(QWidget *parent, const QVariantList &args);
- ~KPackageKit();
+
private:
PkAddRm *view;
QGridLayout *m_grid;
diff --git a/gui/ui/Updater/CMakeLists.txt b/gui/ui/Updater/CMakeLists.txt
index 0dd36ec..47a05c4 100644
--- a/gui/ui/Updater/CMakeLists.txt
+++ b/gui/ui/Updater/CMakeLists.txt
@@ -1,12 +1,15 @@
set(kpk_update_SRCS
kpk-update.cpp
PkUpdate.cpp
+ PkAddRm_Model.cpp
+ PkAddRm_Delegate.cpp
+ pkg_item.cpp
)
kde4_add_ui_files(kpk_update_SRCS
PkUpdate.ui
)
kde4_add_plugin(kcm_kpk_update ${kpk_update_SRCS})
-target_link_libraries(kcm_kpk_update ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KNEWSTUFF2_LIBS})
+target_link_libraries(kcm_kpk_update ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KNEWSTUFF2_LIBS} packagekit-qt)
install(TARGETS kcm_kpk_update DESTINATION ${PLUGIN_INSTALL_DIR} ) \ No newline at end of file
diff --git a/gui/ui/Updater/PkAddRm_Delegate.cpp b/gui/ui/Updater/PkAddRm_Delegate.cpp
new file mode 100644
index 0000000..b6ec7f9
--- /dev/null
+++ b/gui/ui/Updater/PkAddRm_Delegate.cpp
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
+ * Copyright (C) 2008 Daniel Nicoletti <mirttex85-pk@yahoo.com.br>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library/Lesser General Public License
+ * version 2, or (at your option) any later version, as published by the
+ * Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details
+ *
+ * You should have received a copy of the GNU Library/Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "PkAddRm_Delegate.h"
+
+#include <cmath>
+#include <QtCore/QtCore>
+#include <KDebug>
+#include <KIconLoader>
+
+#include "PkAddRm_Model.h"
+
+#define FAV_ICON_SIZE 24
+#define EMBLEM_ICON_SIZE 16
+#define UNIVERSAL_PADDING 6
+#define FADE_LENGTH 32
+#define MAIN_ICON_SIZE 48
+#define DROPDOWN_PADDING 2
+#define DROPDOWN_SEPARATOR_HEIGHT 32
+
+PkAddRmDelegate::PkAddRmDelegate(QObject * parent)
+ : QItemDelegate(parent), m_favoriteIcon("bookmarks"),
+ m_favoriteAddIcon("list-add"), m_removeIcon("list-remove")/*,
+ m_onFavoriteIconItem(NULL)*/
+{
+// m_parent = (PkAddRm *) parent;
+}
+
+void PkAddRmDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+
+// index.model()->data(index, Qt::EditRole).toInt();
+
+// KCategorizedItemsViewModels::AbstractItem * item =
+// getItemByProxyIndex(index);
+// if (!item) return;
+
+ QStyleOptionViewItemV4 opt(option);
+ QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
+ style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
+
+ switch (index.column()) {
+ case 0:
+ paintColMain(painter, option, index);
+ break;
+ case 1:
+ paintColFav(painter, option, index);
+ break;
+// case 2:
+// paintColRemove(painter, option, index);
+// break;
+ default:
+ kDebug() << "unexpected column";
+ }
+}
+
+void PkAddRmDelegate::paintColMain(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+
+ int left = option.rect.left();
+ int top = option.rect.top();
+ int width = option.rect.width();
+
+ bool leftToRight = (painter->layoutDirection() == Qt::LeftToRight);
+
+ // selects the mode to paint the icon based on the info field
+ QIcon::Mode iconMode = ( index.model()->data(index, PkAddRmModel::InstalledRole).toBool() ? QIcon::Normal : QIcon::Disabled);
+// if ( index.model()->data(index, PkAddRmModel::InstalledRole).toBool() )
+// QIcon::Mode iconMode = QIcon::Normal;
+// else
+// QIcon::Mode iconMode = QIcon::Disabled;
+
+ QColor foregroundColor = (option.state.testFlag(QStyle::State_Selected))?
+ option.palette.color(QPalette::HighlightedText):option.palette.color(QPalette::Text);
+
+ // Painting main column
+ QStyleOptionViewItem local_option_title(option);
+ QStyleOptionViewItem local_option_normal(option);
+
+ local_option_title.font.setBold(true);
+ local_option_title.font.setPointSize(local_option_title.font.pointSize() + 2);
+
+ QPixmap pixmap(option.rect.size());
+ pixmap.fill(Qt::transparent);
+ QPainter p(&pixmap);
+ p.translate(-option.rect.topLeft());
+
+ QLinearGradient gradient;
+
+ // Easier to ask the model for the data
+ QString title = index.model()->data(index, Qt::DisplayRole).toString();
+ QString description = index.model()->data(index, PkAddRmModel::SummaryRole).toString();
+
+ // Painting
+
+ // Text
+ int textInner = 2 * UNIVERSAL_PADDING + MAIN_ICON_SIZE;
+
+ p.setPen(foregroundColor);
+ p.setFont(local_option_title.font);
+ p.drawText(
+ left + (leftToRight ? textInner : 0),
+ top + UNIVERSAL_PADDING,
+ width - textInner, MAIN_ICON_SIZE / 2,
+ Qt::AlignBottom | Qt::AlignLeft, title);
+ p.setFont(local_option_normal.font);
+ p.drawText(
+ left + (leftToRight ? textInner : 0),
+ top + UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2,
+ width - textInner, MAIN_ICON_SIZE / 2,
+ Qt::AlignTop | Qt::AlignLeft, description);
+
+ // Main icon
+ index.model()->data(index, Qt::DecorationRole).value<QIcon>().paint(&p,
+ leftToRight ? left + UNIVERSAL_PADDING : left + width - UNIVERSAL_PADDING - MAIN_ICON_SIZE,
+ top + UNIVERSAL_PADDING,
+ MAIN_ICON_SIZE, MAIN_ICON_SIZE, Qt::AlignCenter, iconMode);
+
+ // Counting the number of emblems for this item
+ int emblemCount = 0;
+// QPair < Filter, QIcon * > emblem;
+// foreach (emblem, m_parent->m_emblems) {
+// if (item->passesFiltering(emblem.first)) ++emblemCount;
+// }
+
+ // Gradient part of the background - fading of the text at the end
+ if (leftToRight) {
+ gradient = QLinearGradient(left + width - UNIVERSAL_PADDING - FADE_LENGTH, 0,
+ left + width - UNIVERSAL_PADDING, 0);
+ gradient.setColorAt(0, Qt::white);
+ gradient.setColorAt(1, Qt::transparent);
+ } else {
+ gradient = QLinearGradient(left + UNIVERSAL_PADDING, 0,
+ left + UNIVERSAL_PADDING + FADE_LENGTH, 0);
+ gradient.setColorAt(0, Qt::transparent);
+ gradient.setColorAt(1, Qt::white);
+ }
+
+ QRect paintRect = option.rect;
+ p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ p.fillRect(paintRect, gradient);
+
+ if (leftToRight) {
+ gradient.setStart(left + width
+ - emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) - FADE_LENGTH, 0);
+ gradient.setFinalStop(left + width
+ - emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
+ } else {
+ gradient.setStart(left + UNIVERSAL_PADDING
+ + emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
+ gradient.setFinalStop(left + UNIVERSAL_PADDING
+ + emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) + FADE_LENGTH, 0);
+ }
+ paintRect.setHeight(UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2);
+ p.fillRect(paintRect, gradient);
+
+ // Emblems icons
+ p.setCompositionMode(QPainter::CompositionMode_SourceOver);
+// int emblemLeft = leftToRight ? (left + width - EMBLEM_ICON_SIZE) : left; // - FAV_ICON_SIZE - 2 * UNIVERSAL_PADDING
+// foreach (emblem, m_parent->m_emblems) {
+// if (item->passesFiltering(emblem.first)) {
+// emblem.second->paint(&p,
+// emblemLeft, top + UNIVERSAL_PADDING,
+// EMBLEM_ICON_SIZE, EMBLEM_ICON_SIZE, Qt::AlignCenter, iconMode);
+// if (leftToRight) {
+// emblemLeft -= UNIVERSAL_PADDING + EMBLEM_ICON_SIZE;
+// } else {
+// emblemLeft += UNIVERSAL_PADDING + EMBLEM_ICON_SIZE;
+// }
+// }
+// }
+ p.end();
+
+ painter->drawPixmap(option.rect.topLeft(), pixmap);
+}
+
+void PkAddRmDelegate::paintColFav(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+// int left = option.rect.left();
+// int top = option.rect.top();
+// int width = option.rect.width();
+//
+// // Painting favorite icon column
+//
+// if (! (option.state & QStyle::State_MouseOver) && m_onFavoriteIconItem == item)
+// m_onFavoriteIconItem = NULL;
+//
+// QIcon::Mode iconMode = QIcon::Normal;
+// if (!item->isFavorite()) {
+// iconMode = QIcon::Disabled;
+// } else if (option.state & QStyle::State_MouseOver) {
+// iconMode = QIcon::Active;
+// }
+//
+// m_favoriteIcon.paint(painter,
+// left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
+// FAV_ICON_SIZE, FAV_ICON_SIZE, Qt::AlignCenter, iconMode);
+//
+// const KIcon * icon = (item->isFavorite())? & m_removeIcon : & m_favoriteAddIcon;
+//
+// if ((option.state & QStyle::State_MouseOver) && (m_onFavoriteIconItem != item))
+// icon->paint(painter,
+// left + width - EMBLEM_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
+// EMBLEM_ICON_SIZE, EMBLEM_ICON_SIZE, Qt::AlignCenter, iconMode);
+}
+
+// void PkAddRmDelegate::paintColRemove(QPainter *painter,
+// const QStyleOptionViewItem &option, const QModelIndex &index) const
+// {
+// // Painting remove icon column
+// int running = item->running();
+// if (!running) {
+// return;
+// }
+//
+// int left = option.rect.left();
+// int top = option.rect.top();
+// int width = option.rect.width();
+//
+// QIcon::Mode iconMode = QIcon::Normal;
+// if (option.state & QStyle::State_MouseOver) {
+// iconMode = QIcon::Active;
+// }
+//
+// m_removeIcon.paint(painter,
+// left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
+// FAV_ICON_SIZE, FAV_ICON_SIZE, Qt::AlignCenter, iconMode);
+//
+// if (running == 1) {
+// return;
+// }
+// //paint number
+// QColor foregroundColor = (option.state.testFlag(QStyle::State_Selected))?
+// option.palette.color(QPalette::HighlightedText):option.palette.color(QPalette::Text);
+// painter->setPen(foregroundColor);
+// painter->setFont(option.font);
+// painter->drawText(
+// left + UNIVERSAL_PADDING, //FIXME might be wrong
+// top + UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2,
+// width - 2 * UNIVERSAL_PADDING, MAIN_ICON_SIZE / 2,
+// Qt::AlignCenter, QString::number(running));
+// }
+
+// bool PkAddRmDelegate::editorEvent(QEvent *event,
+// QAbstractItemModel *model,
+// const QStyleOptionViewItem &option,
+// const QModelIndex &index)
+// {
+// if (event->type() == QEvent::MouseButtonPress) {
+// KCategorizedItemsViewModels::AbstractItem * item = getItemByProxyIndex(index);
+// if (index.column() == 1) {
+// m_onFavoriteIconItem = item;
+// item->setFavorite(!item->isFavorite());
+// return true;
+// } else if (index.column() == 2 && item->running()) {
+// item->setRunning(0);
+// emit destroyApplets(item->name());
+// return true;
+// }
+// }
+//
+// return QItemDelegate::editorEvent(event, model, option, index);
+// }
+
+QSize PkAddRmDelegate::sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index ) const
+{
+ Q_UNUSED(option);
+
+ //Q_UNUSED(index);
+ int width = (index.column() == 0) ? 0 : FAV_ICON_SIZE;
+ return QSize(width, MAIN_ICON_SIZE + 2 * UNIVERSAL_PADDING);
+}
+
+int PkAddRmDelegate::columnWidth (int column, int viewWidth) const {
+ if (column != 0) {
+ return FAV_ICON_SIZE + 2 * UNIVERSAL_PADDING;
+ } else return viewWidth - 2 * columnWidth(1, viewWidth);
+}
+
+#include "PkAddRm_Delegate.moc"
+
diff --git a/gui/ui/Updater/PkAddRm_Delegate.h b/gui/ui/Updater/PkAddRm_Delegate.h
new file mode 100644
index 0000000..4d2b84a
--- /dev/null
+++ b/gui/ui/Updater/PkAddRm_Delegate.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>
+ * Copyright (C) 2008 Daniel Nicoletti <mirttex85-pk@yahoo.com.br>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library/Lesser General Public License
+ * version 2, or (at your option) any later version, as published by the
+ * Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details
+ *
+ * You should have received a copy of the GNU Library/Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PKADDRMDELEGATE_H
+#define PKADDRMDELEGATE_H
+
+#include <QtCore/QtCore>
+#include <QtGui/QtGui>
+
+#include <KIcon>
+
+/**
+ * Delegate for displaying the items
+ */
+class PkAddRmDelegate: public QItemDelegate
+{
+ Q_OBJECT
+
+public:
+ PkAddRmDelegate(QObject *parent = 0);
+
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
+ int columnWidth (int column, int viewWidth) const;
+
+// bool editorEvent(QEvent *event,
+// QAbstractItemModel *model,
+// const QStyleOptionViewItem &option,
+// const QModelIndex &index);
+
+Q_SIGNALS:
+ void destroyApplets(const QString name);
+private:
+
+// KCategorizedItemsView * m_parent;
+ KIcon m_favoriteIcon;
+ KIcon m_favoriteAddIcon;
+ KIcon m_removeIcon;
+
+// mutable KCategorizedItemsViewModels::AbstractItem * m_onFavoriteIconItem;
+
+ void paintColMain(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ void paintColFav(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const;
+// void paintColRemove(QPainter *painter,
+// const QStyleOptionViewItem &option, const QModelIndex &index) const;
+};
+
+#endif /*KCATEGORIZEDITEMSVIEWDELEGATE_H_*/
diff --git a/gui/ui/Updater/PkAddRm_Model.cpp b/gui/ui/Updater/PkAddRm_Model.cpp
new file mode 100644
index 0000000..638542f
--- /dev/null
+++ b/gui/ui/Updater/PkAddRm_Model.cpp
@@ -0,0 +1,168 @@
+#include "PkAddRm_Model.h"
+
+PkAddRmModel::PkAddRmModel(QObject *parent)
+: QAbstractTableModel(parent),
+ m_iconDeb("application-x-deb"),
+ m_iconRpm("application-x-rpm"),
+ m_iconTgz("application-x-compressed-tar"),
+ m_iconGeneric("utilities-file-archiver"),
+ m_iconBugFix("script-error"),
+ m_iconLow("security-high"),
+ m_iconImportant("security-low"),
+ m_iconEnhancement("ktip"),
+ m_iconSecurity("emblem-important"),
+ m_iconNormal("security-medium")
+{
+ rootItem = new PackageItem();
+}
+
+int PkAddRmModel::rowCount(const QModelIndex &parent) const
+{
+ PackageItem *parentItem;
+ if (parent.column() > 0)
+ return 0;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<PackageItem*>(parent.internalPointer());
+
+ return parentItem->childCount();
+}
+
+int PkAddRmModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return static_cast<PackageItem*>(parent.internalPointer())->columnCount();
+ else
+ return rootItem->columnCount();
+}
+
+QVariant PkAddRmModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ PackageItem *item = static_cast<PackageItem*>(index.internalPointer());
+ Package *p = item->data();
+
+ switch(role) {
+ case Qt::DisplayRole:
+ return item->name();
+ case Qt::DecorationRole:
+ 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;
+
+ case SummaryRole:
+ return p->summary();
+
+ case InstalledRole:
+ if ( p->info() == "available" )
+ return false;
+ else
+ return true;
+
+ case IdRole:
+ return p->id();
+
+ default:
+ return QVariant();
+ }
+}
+
+QModelIndex PkAddRmModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ PackageItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<PackageItem*>(parent.internalPointer());
+
+ PackageItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+QModelIndex PkAddRmModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ PackageItem *childItem = static_cast<PackageItem*>(index.internalPointer());
+ PackageItem *parentItem = childItem->parent();
+
+ if (parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+Package * PkAddRmModel::package(const QModelIndex &index)
+{
+ return static_cast<PackageItem*>(index.internalPointer())->data();
+}
+
+void PkAddRmModel::addPackage(Package *package)
+{
+// qDebug() << package->name() << package->version() << package->arch() << package->data() << package->info() << package->summary() ;
+
+
+ // check to see if the list of info has any package
+ if ( packages.contains( package->info() ) ) {
+ int row = packages.value( package->info() )->childCount();
+ beginInsertRows(createIndex(row, 1, packages.value( package->info() ) ), packages.size(), packages.size());
+ packages.value( package->info() )->appendChild( new PackageItem(package, packages.value( package->info() ) ) );
+ }
+ else {
+ beginInsertRows(QModelIndex(), packages.size(), packages.size());
+ // create the section root
+ packages.insert( package->info(), new PackageItem( new Package( ";;;", package->info(), QString() ), rootItem ) );
+ // add the child package
+ rootItem->appendChild( packages.value( package->info() ) );
+ endInsertRows();
+ int row = packages.value( package->info() )->childCount();
+ beginInsertRows(createIndex(row, 1, packages.value( package->info() ) ), packages.size(), packages.size());
+ packages.value( package->info() )->appendChild( new PackageItem(package, packages.value( package->info() )) );
+ }
+ endInsertRows();
+}
+
+void PkAddRmModel::removePackage(Package *package)
+{
+ beginRemoveRows(QModelIndex(), 1, 1);
+// packages.removeAt(packages.indexOf(package));
+ endRemoveRows();
+}
+
+void PkAddRmModel::clear()
+{
+ layoutChanged();
+// beginRemoveRows(QModelIndex(), 0, packages.size());
+// packages.clear();
+// endRemoveRows();
+}
diff --git a/gui/ui/Updater/PkAddRm_Model.h b/gui/ui/Updater/PkAddRm_Model.h
new file mode 100644
index 0000000..478648a
--- /dev/null
+++ b/gui/ui/Updater/PkAddRm_Model.h
@@ -0,0 +1,52 @@
+#ifndef KPK_PACKAGEMODEL_H
+#define KPK_PACKAGEMODEL_H
+
+#include <QAbstractTableModel>
+#include <KIcon>
+
+#include "pkg_item.h"
+#include "../../../lib/QPackageKit.h"
+
+using namespace PackageKit;
+
+class PkAddRmModel : public QAbstractTableModel
+{
+Q_OBJECT
+
+public:
+ PkAddRmModel(QObject *parent = 0);
+ int rowCount(const QModelIndex &/*parent = QModelIndex()*/) const;
+ int columnCount(const QModelIndex &) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+public slots:
+ void addPackage(Package *package);
+public:
+ void removePackage(Package *package);
+ Package * package(const QModelIndex &index);
+ void clear();
+
+ enum {
+ SummaryRole = 32,
+ InstalledRole,
+ IdRole
+ };
+
+private:
+ QHash<QString, PackageItem*> packages;
+ PackageItem *rootItem;
+ KIcon m_iconDeb;
+ KIcon m_iconRpm;
+ KIcon m_iconTgz;
+ KIcon m_iconGeneric;
+ KIcon m_iconBugFix;
+ KIcon m_iconLow;
+ KIcon m_iconImportant;
+ KIcon m_iconEnhancement;
+ KIcon m_iconSecurity;
+ KIcon m_iconNormal;
+};
+
+#endif
diff --git a/gui/ui/Updater/PkUpdate.cpp b/gui/ui/Updater/PkUpdate.cpp
index 5cdb3b5..274b8ce 100755
--- a/gui/ui/Updater/PkUpdate.cpp
+++ b/gui/ui/Updater/PkUpdate.cpp
@@ -23,11 +23,39 @@
PkUpdate::PkUpdate( QWidget *parent ) : QWidget( parent )
{
setupUi( this );
+ descriptionKTB->hide();
+
+ //initialize the model, delegate, client and connect it's signals
+ treeView->setModel(m_pkg_model_updates = new PkAddRmModel(this));
+ treeView->setItemDelegate(pkg_delegate = new PkAddRmDelegate(this));
+
+ // Create a new daemon
+ m_daemon = new Daemon(this);
+
+ m_pkClient_updates = m_daemon->newTransaction();
+ connect( m_pkClient_updates, SIGNAL(GotPackage(Package *)), m_pkg_model_updates, SLOT(addPackage(Package *)) );
+ connect( m_pkClient_updates, SIGNAL(Finished(Exit::Value, uint)), this, SLOT(Finished(Exit::Value, uint)) );
+ connect( m_pkClient_updates, SIGNAL(Files(Package *, QStringList)), this, SLOT(Files(Package *, QStringList)) );
+ connect( m_pkClient_updates, SIGNAL( Message(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
+ connect( m_pkClient_updates, SIGNAL( ErrorCode(const QString&, const QString&) ), this, SLOT( Message(const QString&, const QString&) ) );
+ m_pkClient_updates->getUpdates("none");
+}
+
+void PkUpdate::on_updatePB_clicked()
+{
+ qDebug() << "update";
+}
+
+void PkUpdate::on_refreshPB_clicked()
+{
+ qDebug() << "refresh";
}
-void PkUpdate::on_pBDefDir_clicked()
+void PkUpdate::on_historyPB_clicked()
{
-
+ qDebug() << "history";
+ m_pkg_model_updates->clear();
+// qDebug() << m_pkg_model_updates->rowCount();
}
#include "PkUpdate.moc"
diff --git a/gui/ui/Updater/PkUpdate.h b/gui/ui/Updater/PkUpdate.h
index 6022e55..cbdb25b 100755
--- a/gui/ui/Updater/PkUpdate.h
+++ b/gui/ui/Updater/PkUpdate.h
@@ -20,16 +20,28 @@
#ifndef PKUPDATE_H
#define PKUPDATE_H
-
+
+#include "PkAddRm_Model.h"
+#include "PkAddRm_Delegate.h"
#include "ui_PkUpdate.h"
+#include "../../../lib/QPackageKit.h"
+
+using namespace PackageKit;
class PkUpdate : public QWidget, public Ui::PkUpdate
{
- Q_OBJECT
- public:
- PkUpdate( QWidget *parent=0 );
- private slots:
- void on_pBDefDir_clicked();
+Q_OBJECT
+public:
+ PkUpdate( QWidget *parent=0 );
+private slots:
+ void on_updatePB_clicked();
+ void on_refreshPB_clicked();
+ void on_historyPB_clicked();
+private:
+ PkAddRmModel *m_pkg_model_updates;
+ PkAddRmDelegate *pkg_delegate;
+ Daemon *m_daemon;
+ Transaction *m_pkClient_updates;
};
#endif
diff --git a/gui/ui/Updater/PkUpdate.ui b/gui/ui/Updater/PkUpdate.ui
index 958979e..a006228 100644
--- a/gui/ui/Updater/PkUpdate.ui
+++ b/gui/ui/Updater/PkUpdate.ui
@@ -5,99 +5,63 @@
<rect>
<x>0</x>
<y>0</y>
- <width>668</width>
- <height>371</height>
+ <width>452</width>
+ <height>360</height>
</rect>
</property>
- <property name="windowTitle" >
- <string>Form</string>
+ <property name="locale" >
+ <locale country="UnitedStates" language="English" />
</property>
- <widget class="QPushButton" name="pushButton" >
- <property name="geometry" >
- <rect>
- <x>20</x>
- <y>10</y>
- <width>145</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text" >
- <string>Check for Updates</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton_2" >
- <property name="geometry" >
- <rect>
- <x>180</x>
- <y>10</y>
- <width>105</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text" >
- <string>Force Refresh</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton_3" >
- <property name="geometry" >
- <rect>
- <x>300</x>
- <y>10</y>
- <width>141</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text" >
- <string>Update System</string>
- </property>
- </widget>
- <widget class="QListView" name="listView" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>50</y>
- <width>241</width>
- <height>311</height>
- </rect>
- </property>
- </widget>
- <widget class="QListView" name="listView_2" >
- <property name="geometry" >
- <rect>
- <x>260</x>
- <y>50</y>
- <width>401</width>
- <height>191</height>
- </rect>
- </property>
- </widget>
- <widget class="QListView" name="listView_3" >
- <property name="geometry" >
- <rect>
- <x>260</x>
- <y>240</y>
- <width>401</width>
- <height>121</height>
- </rect>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton_4" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="geometry" >
- <rect>
- <x>470</x>
- <y>10</y>
- <width>161</width>
- <height>27</height>
- </rect>
- </property>
- <property name="text" >
- <string>Update Package</string>
- </property>
- </widget>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" colspan="3" >
+ <widget class="QSplitter" name="splitter" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QTreeView" name="treeView" >
+ <property name="alternatingRowColors" >
+ <bool>false</bool>
+ </property>
+ <property name="animated" >
+ <bool>true</bool>
+ </property>
+ <property name="headerHidden" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="KTextBrowser" name="descriptionKTB" />
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QPushButton" name="updatePB" >
+ <property name="text" >
+ <string>Update System</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QPushButton" name="refreshPB" >
+ <property name="text" >
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="historyPB" >
+ <property name="text" >
+ <string>History</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>KTextBrowser</class>
+ <extends>QTextBrowser</extends>
+ <header>ktextbrowser.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
diff --git a/gui/ui/Updater/kpk-update.cpp b/gui/ui/Updater/kpk-update.cpp
index 61646c7..2fc3726 100644
--- a/gui/ui/Updater/kpk-update.cpp
+++ b/gui/ui/Updater/kpk-update.cpp
@@ -17,7 +17,7 @@
*
*/
-#include <kgenericfactory.h>
+#include <KGenericFactory>
#include <KAboutData>
#include "kpk-update.h"
@@ -30,5 +30,7 @@ KPackageKit::KPackageKit(QWidget *&parent, const QVariantList &args)
{
KAboutData *about = new KAboutData("kcm_kpk_update", 0, ki18n("KPackageKit Update"),"0.1");
setAboutData(about);
- setupUi(this);
+ m_grid = new QGridLayout(this);
+ view = new PkUpdate(this);
+ m_grid->addWidget(view);
}
diff --git a/gui/ui/Updater/kpk-update.h b/gui/ui/Updater/kpk-update.h
index 975744c..b1ab064 100644
--- a/gui/ui/Updater/kpk-update.h
+++ b/gui/ui/Updater/kpk-update.h
@@ -20,14 +20,18 @@
#define KPACKAGEKIT_H
#include <KCModule>
+#include <QGridLayout>
#include "PkUpdate.h"
-class KPackageKit : public KCModule, Ui::PkUpdate
+class KPackageKit : public KCModule
{
- Q_OBJECT
+Q_OBJECT
+public:
+ KPackageKit(QWidget *&parent, const QVariantList &args);
- public:
- KPackageKit(QWidget *&parent, const QVariantList &args);
+private:
+ PkUpdate *view;
+ QGridLayout *m_grid;
};
#endif
diff --git a/gui/ui/Updater/pkg_item.cpp b/gui/ui/Updater/pkg_item.cpp
new file mode 100644
index 0000000..95b6111
--- /dev/null
+++ b/gui/ui/Updater/pkg_item.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * daniel@whitemoon *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "pkg_item.h"
+
+#include <QStringList>
+
+PackageItem::PackageItem(Package *pkg, PackageItem *parent)
+ : parentItem(parent), m_pkg(pkg)
+{
+}
+
+PackageItem::PackageItem()
+ : parentItem(0)
+{
+}
+
+QString PackageItem::name()
+{
+ if (parentItem)
+ if ( m_pkg->name().isEmpty() )
+ return QString::number( childCount() ) + " " + m_pkg->info();
+ else
+ return m_pkg->name() + " - " + m_pkg->version() + " (" + m_pkg->arch() + ")";
+ else
+ return QString();
+}
+
+PackageItem::~PackageItem()
+{
+ qDeleteAll(childItems);
+}
+
+void PackageItem::appendChild(PackageItem *item)
+{
+ childItems.append(item);
+}
+
+PackageItem *PackageItem::child(int row)
+{
+ return childItems.value(row);
+}
+
+int PackageItem::childCount() const
+{
+ return childItems.count();
+}
+
+int PackageItem::columnCount() const
+{
+ return 1;
+}
+
+Package *PackageItem::data() const
+{
+ return m_pkg;
+}
+
+PackageItem *PackageItem::parent()
+{
+ return parentItem;
+}
+
+int PackageItem::row() const
+{
+ if (parentItem)
+ return parentItem->childItems.indexOf(const_cast<PackageItem*>(this));
+
+ return 0;
+}
diff --git a/gui/ui/Updater/pkg_item.h b/gui/ui/Updater/pkg_item.h
new file mode 100644
index 0000000..187d59f
--- /dev/null
+++ b/gui/ui/Updater/pkg_item.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Daniel Nicoletti *
+ * daniel@whitemoon *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef PACKAGE_ITEM_H
+#define PACKAGE_ITEM_H
+
+#include "../../../lib/QPackageKit.h"
+
+#include <QList>
+#include <QVariant>
+
+using namespace PackageKit;
+
+/**
+ @author Daniel Nicoletti <daniel@whitemoon>
+*/
+class PackageItem{
+public:
+ PackageItem(Package *pkg, PackageItem *parent = 0);
+ PackageItem();
+
+ ~PackageItem();
+
+ void appendChild(PackageItem *child);
+
+ PackageItem *child(int row);
+ int childCount() const;
+ int columnCount() const;
+ Package *data() const;
+ int row() const;
+ PackageItem *parent();
+ QString name();
+
+private:
+ QList<PackageItem*> childItems;
+ Package *m_pkg;
+ PackageItem *parentItem;
+};
+
+#endif