summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien BUSTANY <madcat@mymadcat.com>2008-06-13 14:53:42 +0200
committerAdrien BUSTANY <madcat@mymadcat.com>2008-06-13 14:53:42 +0200
commita35ad8eaf8cc9597e95b26e97960774208d5414d (patch)
tree2fa64d636d225d4a47db909f98fbf05a66cb21fd
parent535a952f752af788a2838fb65bb05d89ca6b8f59 (diff)
parent15b09740501aa2cd52156093cd0d23595f5b68b3 (diff)
Merge branch 'master' of git+ssh://madcat@git.packagekit.org/srv/git/QPackageKit
-rw-r--r--gui/ui/AddRm/CMakeLists.txt6
-rwxr-xr-xgui/ui/AddRm/PkAddRm.cpp63
-rwxr-xr-xgui/ui/AddRm/PkAddRm.h11
-rw-r--r--gui/ui/AddRm/PkAddRm.ui12
-rw-r--r--gui/ui/AddRm/PkAddRm_Model.cpp2
-rw-r--r--gui/ui/AddRm/PkDelegate.cpp (renamed from gui/ui/AddRm/PkAddRm_Delegate.cpp)235
-rw-r--r--gui/ui/AddRm/PkDelegate.h (renamed from gui/ui/AddRm/PkAddRm_Delegate.h)34
-rwxr-xr-xgui/ui/AddRm/PkTransaction.cpp (renamed from gui/ui/AddRm/PkAddRm_Transaction.cpp)185
-rwxr-xr-xgui/ui/AddRm/PkTransaction.h (renamed from gui/ui/AddRm/PkAddRm_Transaction.h)33
-rw-r--r--gui/ui/AddRm/PkTransaction.ui (renamed from gui/ui/AddRm/PkAddRm_Transaction.ui)25
10 files changed, 344 insertions, 262 deletions
diff --git a/gui/ui/AddRm/CMakeLists.txt b/gui/ui/AddRm/CMakeLists.txt
index e15223b..5e81b91 100644
--- a/gui/ui/AddRm/CMakeLists.txt
+++ b/gui/ui/AddRm/CMakeLists.txt
@@ -2,14 +2,14 @@ set(kpk_addrm_SRCS
kpk-addrm.cpp
PkAddRm.cpp
PkAddRm_Model.cpp
- PkAddRm_Delegate.cpp
- PkAddRm_Transaction.cpp
+ PkDelegate.cpp
+ PkTransaction.cpp
PkRequirements.cpp
)
kde4_add_ui_files(kpk_addrm_SRCS
PkAddRm.ui
- PkAddRm_Transaction.ui
+ PkTransaction.ui
PkRequirements.ui
)
diff --git a/gui/ui/AddRm/PkAddRm.cpp b/gui/ui/AddRm/PkAddRm.cpp
index 24e4b95..15b415a 100755
--- a/gui/ui/AddRm/PkAddRm.cpp
+++ b/gui/ui/AddRm/PkAddRm.cpp
@@ -23,20 +23,24 @@
#include <QPalette>
#include <QColor>
-#include "PkAddRm_Transaction.h"
+#include "PkTransaction.h"
#include "PkAddRm.h"
-PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
+#define UNIVERSAL_PADDING 6
+
+PkAddRm::PkAddRm( QWidget *parent )
+ : QWidget( parent ), m_viewWidth(0)
{
setupUi( this );
//initialize the model, delegate, client and connect it's signals
+ packageView->setItemDelegate(pkg_delegate = new PkDelegate(this));
packageView->setModel(m_pkg_model_main = new PkAddRmModel(this));
- packageView->setItemDelegate(pkg_delegate = new PkAddRmDelegate(this));
+ updateColumnsWidth(true);
// Create a new daemon
m_daemon = new Daemon(this);
-
+qDebug() << m_daemon->getActions();
// create the install transaction
m_pkClient_install = m_daemon->newTransaction();
connect( m_pkClient_install, SIGNAL(GotPackage(Package *)), m_pkg_model_main, SLOT(addPackage(Package *)) );
@@ -103,6 +107,39 @@ PkAddRm::PkAddRm( QWidget *parent ) : QWidget( parent )
infoHide();
}
+void PkAddRm::resizeEvent ( QResizeEvent * event )
+{
+ updateColumnsWidth();
+
+ QWidget::resizeEvent(event);
+}
+
+bool PkAddRm::event ( QEvent * event )
+{
+ switch (event->type()) {
+ case QEvent::PolishRequest:
+ case QEvent::Polish:
+ updateColumnsWidth(true);
+ break;
+ default:
+ break;
+ }
+
+ return QWidget::event(event);
+}
+
+void PkAddRm::updateColumnsWidth(bool force)
+{
+ m_viewWidth = packageView->viewport()->width();
+
+ if (force) {
+ m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
+ }
+
+ packageView->setColumnWidth(0, pkg_delegate->columnWidth(0, m_viewWidth));
+ packageView->setColumnWidth(1, pkg_delegate->columnWidth(1, m_viewWidth));
+}
+
PkAddRm::~PkAddRm()
{
delete m_pkg_model_main;
@@ -161,19 +198,27 @@ void PkAddRm::on_packageView_pressed( const QModelIndex & index )
m_currPkg = m_pkg_model_main->package(index);
if (m_currPkg) {
if (m_currPkg->info() == "installed")
- actionPB->setText(i18n("Remove"));
+ actionPB->setText( i18n("Remove") );
else
- actionPB->setText(i18n("Install"));
+ actionPB->setText( i18n("Install") );
}
qDebug() << index.model()->data(index, PkAddRmModel::IdRole).toString();
}
void PkAddRm::on_actionPB_clicked()
{
- PkAddRmTransaction *frm = new PkAddRmTransaction(m_currPkg, this);
- frm->exec();
+packageView->resizeColumnToContents(1);
+// Transaction *trans = m_daemon->newTransaction();
+// if (m_daemon->getActions().contains("get-depends") ) {
+// trans->getDepends("~installed", m_currPkg, true);
+// // 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) ) );
+// }
+//
+// PkAddRmTransaction *frm = new PkAddRmTransaction(, this);
+// frm->exec();
// delete frm;
- qDebug() << "mainEXEC()";
+// qDebug() << "mainEXEC()";
}
void PkAddRm::Finished(Exit::Value status, uint runtime)
diff --git a/gui/ui/AddRm/PkAddRm.h b/gui/ui/AddRm/PkAddRm.h
index 9eba928..505ca7a 100755
--- a/gui/ui/AddRm/PkAddRm.h
+++ b/gui/ui/AddRm/PkAddRm.h
@@ -25,7 +25,7 @@
#include <QtCore/QtCore>
#include "PkAddRm_Model.h"
-#include "PkAddRm_Delegate.h"
+#include "PkDelegate.h"
#include "ui_PkAddRm.h"
@@ -54,7 +54,7 @@ private:
PkAddRmModel *m_pkg_model_main;
PkAddRmModel *m_pkg_model_dep;
PkAddRmModel *m_pkg_model_req;
- PkAddRmDelegate *pkg_delegate;
+ PkDelegate *pkg_delegate;
Transaction *m_pkClient_main;
Transaction *m_pkClient_desc;
Transaction *m_pkClient_files;
@@ -69,9 +69,16 @@ private:
void FilterMenu(const QStringList &filters);
QString filters();
Package *m_currPkg;
+ void updateColumnsWidth(bool force = false);
+ int m_viewWidth;
private slots:
void notifyUpdate();
+
+protected:
+ virtual void resizeEvent ( QResizeEvent * event );
+ virtual bool event ( QEvent * event );
+
};
#endif
diff --git a/gui/ui/AddRm/PkAddRm.ui b/gui/ui/AddRm/PkAddRm.ui
index cea9e17..f350b96 100644
--- a/gui/ui/AddRm/PkAddRm.ui
+++ b/gui/ui/AddRm/PkAddRm.ui
@@ -127,9 +127,9 @@
<property name="geometry" >
<rect>
<x>2</x>
- <y>24</y>
+ <y>22</y>
<width>690</width>
- <height>182</height>
+ <height>183</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
@@ -208,8 +208,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>670</width>
- <height>135</height>
+ <width>662</width>
+ <height>68</height>
</rect>
</property>
<attribute name="title" >
@@ -236,8 +236,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>670</width>
- <height>135</height>
+ <width>662</width>
+ <height>68</height>
</rect>
</property>
<attribute name="title" >
diff --git a/gui/ui/AddRm/PkAddRm_Model.cpp b/gui/ui/AddRm/PkAddRm_Model.cpp
index bfcaedc..9bc99fa 100644
--- a/gui/ui/AddRm/PkAddRm_Model.cpp
+++ b/gui/ui/AddRm/PkAddRm_Model.cpp
@@ -16,7 +16,7 @@ int PkAddRmModel::rowCount(const QModelIndex &) const
int PkAddRmModel::columnCount(const QModelIndex &) const
{
- return 1;//for now we have only the name collumn
+ return 2;//for now we have only the name collumn
}
QVariant PkAddRmModel::data(const QModelIndex &index, int role) const
diff --git a/gui/ui/AddRm/PkAddRm_Delegate.cpp b/gui/ui/AddRm/PkDelegate.cpp
index f0b2cff..02c7c3c 100644
--- a/gui/ui/AddRm/PkAddRm_Delegate.cpp
+++ b/gui/ui/AddRm/PkDelegate.cpp
@@ -1,6 +1,5 @@
/*
* 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
@@ -18,14 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "PkAddRm_Delegate.h"
+#include "PkDelegate.h"
#include <cmath>
#include <QtCore/QtCore>
#include <KDebug>
-
#include <KIconLoader>
#include "PkAddRm.h"
@@ -38,24 +36,22 @@
#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)*/
+PkDelegate::PkDelegate(QObject * parent)
+ : QItemDelegate(parent), m_addIcon("list-add"), m_removeIcon("list-remove")
{
-// m_parent = (PkAddRm *) parent;
+
}
-void PkAddRmDelegate::paint(QPainter *painter,
+void PkDelegate::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;
+if ( option.state & QStyle::State_MouseOver )
+ kDebug() << "oi";
+
QStyleOptionViewItemV4 opt(option);
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
@@ -67,35 +63,39 @@ void PkAddRmDelegate::paint(QPainter *painter,
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 PkDelegate::calcItemHeight(const QStyleOptionViewItem &option) const
{
+ // 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);
+
+ int textHeight = QFontInfo(local_option_title.font).pixelSize() + QFontInfo(local_option_normal.font).pixelSize();
+ return qMax(textHeight, MAIN_ICON_SIZE) + 2 * UNIVERSAL_PADDING;
+}
+
+void PkDelegate::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
+ // Painting main column
QStyleOptionViewItem local_option_title(option);
QStyleOptionViewItem local_option_normal(option);
@@ -109,37 +109,37 @@ void PkAddRmDelegate::paintColMain(QPainter *painter,
QLinearGradient gradient;
- // Easier to ask the model for the data
- QString title = index.model()->data(index, Qt::DisplayRole).toString();
+ 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;
+ const int itemHeight = calcItemHeight(option);
p.setPen(foregroundColor);
p.setFont(local_option_title.font);
p.drawText(
left + (leftToRight ? textInner : 0),
- top + UNIVERSAL_PADDING,
- width - textInner, MAIN_ICON_SIZE / 2,
+ top,
+ width - textInner, itemHeight / 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,
+ top + itemHeight / 2,
+ width - textInner, itemHeight / 2,
Qt::AlignTop | Qt::AlignLeft, description);
// Main icon
- index.model()->data(index, Qt::DecorationRole).value<QIcon>().paint(&p,
+ index.model()->data(index, Qt::DecorationRole).value<QIcon>().paint(&p,
leftToRight ? left + UNIVERSAL_PADDING : left + width - UNIVERSAL_PADDING - MAIN_ICON_SIZE,
- top + UNIVERSAL_PADDING,
+ top + UNIVERSAL_PADDING,
MAIN_ICON_SIZE, MAIN_ICON_SIZE, Qt::AlignCenter, iconMode);
// Counting the number of emblems for this item
- int emblemCount = 0;
+ int emblemCount = 1;
// QPair < Filter, QIcon * > emblem;
// foreach (emblem, m_parent->m_emblems) {
// if (item->passesFiltering(emblem.first)) ++emblemCount;
@@ -147,12 +147,12 @@ void PkAddRmDelegate::paintColMain(QPainter *painter,
// Gradient part of the background - fading of the text at the end
if (leftToRight) {
- gradient = QLinearGradient(left + width - UNIVERSAL_PADDING - FADE_LENGTH, 0,
+ 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,
+ gradient = QLinearGradient(left + UNIVERSAL_PADDING, 0,
left + UNIVERSAL_PADDING + FADE_LENGTH, 0);
gradient.setColorAt(0, Qt::transparent);
gradient.setColorAt(1, Qt::white);
@@ -178,17 +178,17 @@ void PkAddRmDelegate::paintColMain(QPainter *painter,
// Emblems icons
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
-// int emblemLeft = leftToRight ? (left + width - EMBLEM_ICON_SIZE) : left; // - FAV_ICON_SIZE - 2 * UNIVERSAL_PADDING
+ 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.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;
-// }
+ if (leftToRight) {
+ emblemLeft -= UNIVERSAL_PADDING + EMBLEM_ICON_SIZE;
+ } else {
+ emblemLeft += UNIVERSAL_PADDING + EMBLEM_ICON_SIZE;
+ }
// }
// }
p.end();
@@ -196,79 +196,89 @@ void PkAddRmDelegate::paintColMain(QPainter *painter,
painter->drawPixmap(option.rect.topLeft(), pixmap);
}
-void PkAddRmDelegate::paintColFav(QPainter *painter,
+void PkDelegate::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
-//
+ 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;
+
+ QIcon::Mode iconMode = QIcon::Normal;
+// if (!index.model()->data(index, PkAddRmModel::InstalledRole).toBool()) {
+ 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);
+// }
+
+ if ( index.model()->data(index, PkAddRmModel::InstalledRole).toBool() )
+ m_removeIcon.paint(painter,
+ left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
+ FAV_ICON_SIZE, FAV_ICON_SIZE, Qt::AlignCenter, iconMode);
+ else
+ m_addIcon.paint(painter,
+ left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
+ FAV_ICON_SIZE, FAV_ICON_SIZE, Qt::AlignCenter, iconMode);
+
+ iconMode = QIcon::Active;
+
+ const KIcon * icon = (index.model()->data(index, PkAddRmModel::InstalledRole).toBool())? & m_removeIcon : & m_addIcon;
+
+ if ( option.state & QStyle::State_MouseOver )
+{
+kDebug() << "oi";
+ 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
+// void PkDelegate::paintColRemove(QPainter *painter,
+// const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) 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));
+// // // 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)
-// {
+bool PkDelegate::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) {
@@ -281,25 +291,22 @@ void PkAddRmDelegate::paintColFav(QPainter *painter,
// return true;
// }
// }
-//
+//
// return QItemDelegate::editorEvent(event, model, option, index);
-// }
+}
-QSize PkAddRmDelegate::sizeHint(const QStyleOptionViewItem &option,
+QSize PkDelegate::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);
+ return QSize(width, calcItemHeight(option));
}
-int PkAddRmDelegate::columnWidth (int column, int viewWidth) const {
+int PkDelegate::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"
-
+#include "PkDelegate.moc"
diff --git a/gui/ui/AddRm/PkAddRm_Delegate.h b/gui/ui/AddRm/PkDelegate.h
index 4d2b84a..9c6317b 100644
--- a/gui/ui/AddRm/PkAddRm_Delegate.h
+++ b/gui/ui/AddRm/PkDelegate.h
@@ -1,6 +1,5 @@
/*
* 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
@@ -18,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef PKADDRMDELEGATE_H
-#define PKADDRMDELEGATE_H
+#ifndef PKDELEGATE_H
+#define PKDELEGATE_H
#include <QtCore/QtCore>
#include <QtGui/QtGui>
@@ -29,39 +28,34 @@
/**
* Delegate for displaying the items
*/
-class PkAddRmDelegate: public QItemDelegate
+class PkDelegate: public QItemDelegate
{
Q_OBJECT
-
+
public:
- PkAddRmDelegate(QObject *parent = 0);
-
+ PkDelegate(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);
+
+ 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_addIcon;
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;
+
+ int calcItemHeight(const QStyleOptionViewItem &option) const;
};
#endif /*KCATEGORIZEDITEMSVIEWDELEGATE_H_*/
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.cpp b/gui/ui/AddRm/PkTransaction.cpp
index 86091b9..9b73f74 100755
--- a/gui/ui/AddRm/PkAddRm_Transaction.cpp
+++ b/gui/ui/AddRm/PkTransaction.cpp
@@ -19,67 +19,91 @@
***************************************************************************/
#include <KLocale>
-#include <KStandardDirs>
+// #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)
+
+// #include <QPalette>
+// #include <QColor>
+// #include "PkRequirements.h"
+#include "PkTransaction.h"
+
+PkTransaction::PkTransaction( Transaction *trans, QString &caption, QWidget *parent )
+ : KDialog(parent), m_trans(trans)
{
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) ) );
+ setCaption( caption );
+// // 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_trans, SIGNAL( GotPackage(Package *) ), this, SLOT( currPackage(Package *) ) );
+ connect( m_trans, SIGNAL( Finished(Exit::Value, uint) ), this, SLOT( Finished(Exit::Value, uint) ) );
+ connect( m_trans, SIGNAL( AllowCancel(bool) ), this, SLOT( enableButtonCancel(bool) ) );
+ connect( m_trans, SIGNAL( ErrorCode(const QString&, const QString&) ), this, SLOT( ErrorCode(const QString&, const QString&) ) );
+
+ connect( m_trans, SIGNAL( ProgressChanged(uint, uint, uint, uint) ), this, SLOT( ProgressChanged(uint, uint, uint, uint) ) );
+ connect( m_trans, SIGNAL( StatusChanged(Status::Value) ), this, SLOT( StatusChanged(Status::Value) ) );
- setButtons( KDialog::Cancel | KDialog::Close );
+ // Set Cancel and custom bt hide
+ setButtons( KDialog::Cancel | KDialog::User1 );
+ setButtonText( KDialog::User1, i18n("Hide") );
+ setButtonToolTip( KDialog::User1, i18n("Allows you to hide the window but keeps running transaction task") );
enableButtonCancel(false);
-// setInitialSize( QSize(400,140) );
- incrementInitialSize( QSize(400,140) );
- m_pkClient_req->getDepends("~installed", pkg, true);
- progressBar->setMaximum(0);
- progressBar->setMinimum(0);
+
+
+// m_pkClient_req->getDepends("~installed", pkg, true);
+ m_pbTimer = new QTimer(this);
+ connect(m_pbTimer, SIGNAL(timeout()), this, SLOT(updateProgress() ));
+ m_pbTimer->start(5);
+
+ // set wait msg
+ currentL->setText( i18n("Please Wait..." ) );
+}
+
+void PkTransaction::updateProgress()
+{
+ progressBar->setValue(progressBar->value() + 1);
}
-void PkAddRmTransaction::currPackage(Package *p)
+void PkTransaction::ProgressChanged(uint percentage, uint /*subpercentage*/, uint /*elapsed*/, uint /*remaining*/)
+{
+ m_pbTimer->stop();
+ progressBar->setMaximum(100);
+ progressBar->setValue(percentage);
+}
+
+void PkTransaction::currPackage(Package *p)
{
packageL->setText( p->name() + " - " + p->version() + " (" + p->arch() + ")" );
descriptionL->setText( p->summary() );
}
-void PkAddRmTransaction::slotButtonClicked(int button)
+void PkTransaction::slotButtonClicked(int button)
{
-qDebug() << "slotbt";
- if (button == KDialog::Cancel)
- m_pkClient_action->cancel();/*accept();*/
- else
- KDialog::slotButtonClicked(button);
+ switch(button) {
+ case KDialog::Cancel :
+ m_trans->cancel();
+ break;/*accept();*/
+ case KDialog::User1 :
+ close();
+ break;
+ default :
+ KDialog::slotButtonClicked(button);
+ }
}
-PkAddRmTransaction::~PkAddRmTransaction()
+PkTransaction::~PkTransaction()
{
}
-void PkAddRmTransaction::StatusChanged(Status::Value v)
+void PkTransaction::StatusChanged(Status::Value v)
{
switch (v) {
case Status::Setup :
@@ -142,51 +166,46 @@ void PkAddRmTransaction::StatusChanged(Status::Value v)
}
}
-void PkAddRmTransaction::ProgressChanged(uint percentage, uint subpercentage, uint elapsed, uint remaining)
+void PkTransaction::ErrorCode(const QString &one, const QString &two)
{
- progressBar->setValue(percentage);
+ KMessageBox::detailedSorry( this, one, two, i18n("Error PackageKit"), KMessageBox::Notify );
}
-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 PkTransaction::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 PkTransaction::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( i18n("The following packages must also be installed"), 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)
+void PkTransaction::Finished(Exit::Value status, uint /*runtime*/)
{
switch(status) {
default :
@@ -216,4 +235,4 @@ qDebug() << "trans finished: " << status ;
// }
}
-#include "PkAddRm_Transaction.moc"
+#include "PkTransaction.moc"
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.h b/gui/ui/AddRm/PkTransaction.h
index 9208fdf..46e9876 100755
--- a/gui/ui/AddRm/PkAddRm_Transaction.h
+++ b/gui/ui/AddRm/PkTransaction.h
@@ -18,45 +18,40 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef PKADDRM_TRANSACTION_H
-#define PKADDRM_TRANSACTION_H
+#ifndef PKTRANSACTION_H
+#define PKTRANSACTION_H
#include <KDialog>
-// #include <QtCore/QtCore>
-#include "PkAddRm_Model.h"
-#include "ui_PkAddRm_Transaction.h"
+// #include "PkAddRm_Model.h"
+#include "ui_PkTransaction.h"
#include "../../../lib/QPackageKit.h"
using namespace PackageKit;
-class PkAddRmTransaction : public KDialog, Ui::PkAddRmTransaction
+class PkTransaction : public KDialog, Ui::PkTransaction
{
Q_OBJECT
public:
- PkAddRmTransaction( Package *pkg, QWidget *parent=0);
- ~PkAddRmTransaction();
+ PkTransaction( Transaction *trans, QString &caption, QWidget *parent=0);
+ ~PkTransaction();
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 reqFinished(Exit::Value status, uint runtime);
void Finished(Exit::Value status, uint runtime);
- void Message(const QString &one, const QString &two);
+ void ErrorCode(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;
+// PkAddRmModel *m_pkg_model_req;
+ Transaction *m_trans;
QTimer m_notifyT;
- Package *m_targetPackage;
+ QTimer *m_pbTimer;
private slots:
- void doAction();
+// void doAction();
void currPackage(Package *);
-
-private:
- Daemon *m_daemon;
+ void updateProgress();
protected slots:
virtual void slotButtonClicked(int button);
diff --git a/gui/ui/AddRm/PkAddRm_Transaction.ui b/gui/ui/AddRm/PkTransaction.ui
index cf4b5b7..5982683 100644
--- a/gui/ui/AddRm/PkAddRm_Transaction.ui
+++ b/gui/ui/AddRm/PkTransaction.ui
@@ -1,6 +1,6 @@
<ui version="4.0" >
- <class>PkAddRmTransaction</class>
- <widget class="QWidget" name="PkAddRmTransaction" >
+ <class>PkTransaction</class>
+ <widget class="QWidget" name="PkTransaction" >
<property name="windowModality" >
<enum>Qt::ApplicationModal</enum>
</property>
@@ -8,10 +8,22 @@
<rect>
<x>0</x>
<y>0</y>
- <width>500</width>
- <height>122</height>
+ <width>400</width>
+ <height>106</height>
</rect>
</property>
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>360</width>
+ <height>0</height>
+ </size>
+ </property>
<property name="windowTitle" >
<string>KPackageKit - Transaction</string>
</property>
@@ -44,6 +56,9 @@
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
+ <property name="maximum" >
+ <number>0</number>
+ </property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
@@ -81,7 +96,7 @@
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
- <height>40</height>
+ <height>0</height>
</size>
</property>
</spacer>