Author: tgoettlicher
Date: Wed Oct 5 10:29:37 2011
New Revision: 66247
URL: http://svn.opensuse.org/viewcvs/yast?rev=66247&view=rev
Log:
- Applied Stano's patch to make installation history accessible
from Yast GUI
- 2.21.8
Added:
trunk/qt-pkg/src/YQPkgHistoryDialog.cc
trunk/qt-pkg/src/YQPkgHistoryDialog.h
Modified:
trunk/qt-pkg/VERSION.cmake
trunk/qt-pkg/package/yast2-qt-pkg.changes
trunk/qt-pkg/src/CMakeLists.txt
trunk/qt-pkg/src/YQPackageSelector.cc
trunk/qt-pkg/src/YQPackageSelector.h
Modified: trunk/qt-pkg/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/VERSION.cmake?rev=66247&r1=66246&r2=66247&view=diff
==============================================================================
--- trunk/qt-pkg/VERSION.cmake (original)
+++ trunk/qt-pkg/VERSION.cmake Wed Oct 5 10:29:37 2011
@@ -1,3 +1,3 @@
SET(VERSION_MAJOR "2")
SET(VERSION_MINOR "21")
-SET(VERSION_PATCH "7")
+SET(VERSION_PATCH "8")
Modified: trunk/qt-pkg/package/yast2-qt-pkg.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/package/yast2-qt-pkg.changes?rev=66247&r1=66246&r2=66247&view=diff
==============================================================================
--- trunk/qt-pkg/package/yast2-qt-pkg.changes (original)
+++ trunk/qt-pkg/package/yast2-qt-pkg.changes Wed Oct 5 10:29:37 2011
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Oct 5 08:34:23 CEST 2011 - tgoettlicher@suse.de
+
+- Applied Stano's patch to make installation history accessible
+ from Yast GUI
+- 2.21.8
+
+-------------------------------------------------------------------
Tue Sep 20 14:42:24 CEST 2011 - tgoettlicher@suse.de
- respect stylesheet in package selector
Modified: trunk/qt-pkg/src/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/CMakeLists.txt?rev=66247&r1=66246&r2=66247&view=diff
==============================================================================
--- trunk/qt-pkg/src/CMakeLists.txt (original)
+++ trunk/qt-pkg/src/CMakeLists.txt Wed Oct 5 10:29:37 2011
@@ -35,6 +35,7 @@
YQPkgFileListView.cc
YQPkgFilterTab.cc
YQPkgGenericDetailsView.cc
+ YQPkgHistoryDialog.cc
YQPkgLangList.cc
YQPkgList.cc
YQPkgObjList.cc
Modified: trunk/qt-pkg/src/YQPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPackageSelector.cc?rev=66247&r1=66246&r2=66247&view=diff
==============================================================================
--- trunk/qt-pkg/src/YQPackageSelector.cc (original)
+++ trunk/qt-pkg/src/YQPackageSelector.cc Wed Oct 5 10:29:37 2011
@@ -90,6 +90,7 @@
#include "YQPkgDiskUsageWarningDialog.h"
#include "YQPkgFileListView.h"
#include "YQPkgFilterTab.h"
+#include "YQPkgHistoryDialog.h"
#include "YQPkgLangList.h"
#include "YQPkgList.h"
#include "YQPkgPackageKitGroupsFilterView.h"
@@ -850,6 +851,7 @@
_extrasMenu->addAction( _( "Show &Products" ), this, SLOT( showProducts() ) );
_extrasMenu->addAction( _( "Show P&ackage Changes" ), this, SLOT( showAutoPkgList() ), Qt::CTRL + Qt::Key_A );
+ _extrasMenu->addAction( _( "Show &History" ), this, SLOT( showHistory() ) );
_extrasMenu->addSeparator();
@@ -1510,6 +1512,12 @@
void
+YQPackageSelector::showHistory()
+{
+ YQPkgHistoryDialog::showHistoryDialog();
+}
+
+void
YQPackageSelector::installDevelPkgs()
{
installSubPkgs( "-devel" );
Modified: trunk/qt-pkg/src/YQPackageSelector.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPackageSelector.h?rev=66247&r1=66246&r2=66247&view=diff
==============================================================================
--- trunk/qt-pkg/src/YQPackageSelector.h (original)
+++ trunk/qt-pkg/src/YQPackageSelector.h Wed Oct 5 10:29:37 2011
@@ -238,6 +238,11 @@
* Show all products in a popup dialog.
**/
void showProducts();
+
+ /**
+ * Show dialog for pkgmgr history
+ */
+ void showHistory();
/**
* a link in the repo upgrade label was clicked
Added: trunk/qt-pkg/src/YQPkgHistoryDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgHistoryDialog.cc?rev=66247&view=auto
==============================================================================
--- trunk/qt-pkg/src/YQPkgHistoryDialog.cc (added)
+++ trunk/qt-pkg/src/YQPkgHistoryDialog.cc Wed Oct 5 10:29:37 2011
@@ -0,0 +1,320 @@
+/**************************************************************************
+Copyright (C) 2000 - 2011 Novell, Inc.
+All Rights Reserved.
+
+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.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+**************************************************************************/
+
+
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQPkgHistoryDialog.cc
+
+ Author: Stanislav Visnovsky
+
+ Textdomain "qt-pkg"
+
+/-*/
+
+#define YUILogComponent "qt-pkg"
+#include "YUILog.h"
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QSplitter>
+#include <QStyle>
+#include <QList>
+#include <QBoxLayout>
+#include <QTreeWidget>
+#include <QMessageBox>
+
+#include
+#include
+#include
+
+#include
+
+#include "YQPkgHistoryDialog.h"
+#include "YQPkgList.h"
+#include "QY2LayoutUtils.h"
+#include "YQi18n.h"
+#include "YQUI.h"
+#include "YQIconPool.h"
+#include "utf8.h"
+
+
+#define SPACING 2 // between subwidgets
+#define MARGIN 4 // around the widget
+
+#define FILENAME "/var/log/zypp/history"
+
+YQPkgHistoryDialog::YQPkgHistoryDialog( QWidget * parent )
+ : QDialog( parent )
+{
+ // Dialog title
+ setWindowTitle( _( "Package History" ) );
+
+ // Enable dialog resizing even without window manager
+ setSizeGripEnabled( true );
+
+ // Layout for the dialog (can't simply insert a QVBox)
+
+ QVBoxLayout * layout = new QVBoxLayout();
+ Q_CHECK_PTR( layout );
+ setLayout(layout);
+ layout->setMargin(MARGIN);
+ layout->setSpacing(SPACING);
+
+ setMinimumSize (300,400);
+
+ QLabel * label = new QLabel ( _("Show History (/var/log/zypp/history)" ), this );
+ label->setFixedHeight (label->sizeHint ().height ());
+ layout->addWidget (label);
+
+ // VBox for splitter
+ QSplitter * splitter = new QSplitter( Qt::Horizontal, this );
+ Q_CHECK_PTR( splitter );
+ layout->addWidget( splitter );
+
+ // History view
+ _dates = new QTreeWidget (splitter);
+ _dates->setColumnCount (1);
+ _dates->setHeaderLabels ( QStringList( _("Date") ) );
+
+ _actions = new QTreeWidget (splitter);
+ _actions->setColumnCount (2);
+ _actions->setHeaderLabels ( QStringList( _("Action") ) << _("Version/URL") );
+ _actions->setColumnWidth (0, 200);
+
+ splitter->setStretchFactor (0, 1);
+ splitter->setStretchFactor (1, 2);
+
+ // Button box (to center the single button)
+
+ QHBoxLayout * hbox = new QHBoxLayout();
+ Q_CHECK_PTR( hbox );
+ hbox->setSpacing( SPACING );
+ hbox->setMargin ( MARGIN );
+ layout->addLayout( hbox );
+ hbox->addStretch();
+
+ // "OK" button
+
+ QPushButton * button = new QPushButton( _( "&Close" ), this );
+ Q_CHECK_PTR( button );
+ hbox->addWidget(button);
+ button->setDefault( true );
+
+ connect( button, SIGNAL( clicked() ),
+ this, SLOT ( accept() ) );
+
+ connect( _dates, SIGNAL( itemSelectionChanged () ),
+ this, SLOT ( moveToDate () ) );
+
+ connect( _actions, SIGNAL( itemSelectionChanged() ),
+ this, SLOT ( moveToAction () ) );
+
+ initialize ();
+}
+
+QSize
+YQPkgHistoryDialog::sizeHint() const
+{
+ QRect available = qApp->desktop()->availableGeometry( (QWidget *) this );
+ QSize size = QDialog::sizeHint();
+ size = size.boundedTo( QSize( available.width(), available.height() ) );
+
+ return size;
+}
+
+
+void
+YQPkgHistoryDialog::showHistoryDialog()
+{
+ YQPkgHistoryDialog dialog( 0 );
+ dialog.exec();
+}
+
+QPixmap actionIcon (zypp::HistoryActionID id)
+{
+ switch (id.toEnum ()) {
+ case zypp::HistoryActionID::INSTALL_e : return YQIconPool::pkgInstall ();
+ case zypp::HistoryActionID::REMOVE_e : return YQIconPool::pkgDel ();
+ case zypp::HistoryActionID::REPO_REMOVE_e : return YQIconPool::treeMinus ();
+ case zypp::HistoryActionID::REPO_ADD_e : return YQIconPool::treePlus ();
+ default: return QPixmap ();
+ }
+
+ return QPixmap ();
+}
+
+struct HistoryItemCollector
+{
+ QTreeWidget* actions, * dates;
+ std::string _last;
+ QTreeWidgetItem* date_start;
+
+ bool operator()( const zypp::HistoryItem::Ptr & item_ptr )
+ {
+ std::string d = item_ptr->date.form("%e %B %Y");
+ if (d != _last)
+ {
+ _last = d;
+ date_start = new QTreeWidgetItem (actions, QStringList(QString(d.c_str())));
+ date_start->setExpanded (true);
+ actions-> insertTopLevelItem ( 0, date_start );
+ dates-> insertTopLevelItem ( 0, new QTreeWidgetItem (dates, QStringList(QString(d.c_str()))));
+ }
+
+ QStringList columns;
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::INSTALL_e )
+ {
+ zypp::HistoryItemInstall* item = static_cast (item_ptr.get());
+
+ columns << QString(item->name.c_str());
+ columns << QString(item->edition.version().c_str());
+ } else
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::REMOVE_e )
+ {
+ zypp::HistoryItemRemove* item = static_cast (item_ptr.get());
+
+ columns << QString(item->name.c_str());
+ columns << QString(item->edition.version().c_str());
+ } else
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::REPO_ADD_e )
+ {
+ zypp::HistoryItemRepoAdd* item = static_cast (item_ptr.get());
+
+ columns << QString(item->alias.c_str());
+ columns << QString(item->url.asString().c_str());
+ } else
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::REPO_REMOVE_e )
+ {
+ zypp::HistoryItemRepoRemove* item = static_cast (item_ptr.get());
+
+ columns << QString(item->alias.c_str());
+ } else
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::REPO_CHANGE_ALIAS_e )
+ {
+ zypp::HistoryItemRepoAliasChange* item = static_cast (item_ptr.get());
+
+ columns << QString( (item->oldalias + " -> " + item->newalias).c_str());
+ } else
+ if ( item_ptr->action.toEnum () == zypp::HistoryActionID::REPO_CHANGE_URL_e )
+ {
+ zypp::HistoryItemRepoUrlChange* item = static_cast (item_ptr.get());
+
+ columns << QString(item->alias.c_str());
+ columns << QString(item->newurl.asString().c_str());
+ }
+
+ QTreeWidgetItem *action = new QTreeWidgetItem (date_start, columns);
+ action->setIcon (0,actionIcon (item_ptr->action) );
+ return true;
+ }
+};
+
+
+void
+YQPkgHistoryDialog::initialize()
+{
+ HistoryItemCollector ic;
+
+ ic.actions = _actions;
+ ic.dates = _dates;
+ zypp::parser::HistoryLogReader reader(FILENAME, boost::ref(ic));
+
+ try
+ {
+ reader.readAll();
+ }
+ catch (const zypp::Exception & exception)
+ {
+ yuiWarning() << "CAUGHT zypp exception: " << exception.asUserHistory() << endl;
+
+ QMessageBox msgBox;
+
+ // Translators: This is a (short) text indicating that something went
+ // wrong while trying to read history file.
+
+ QString heading = _( "Unable to read history" );
+
+ if ( heading.length() < 25 ) // Avoid very narrow message boxes
+ {
+ QString blanks;
+ blanks.fill( ' ', 50 - heading.length() );
+ heading += blanks;
+ }
+
+ msgBox.setText( heading );
+ msgBox.setIcon( QMessageBox::Warning );
+ msgBox.setInformativeText( fromUTF8( exception.asUserHistory() ) );
+ msgBox.exec();
+ }
+}
+
+
+void
+YQPkgHistoryDialog::moveToDate ()
+{
+ if (signalsBlocked() ) return;
+ QString item = _dates->selectedItems().first()->text(0);
+ QList items = _actions->findItems (item, Qt::MatchExactly, 0);
+
+ if( items.size () > 0 )
+ {
+ blockSignals(true);
+ _actions->expandItem (items.first());
+ _actions->setCurrentItem (items.first());
+ _actions->scrollToItem( items.first(), QAbstractItemView::PositionAtTop );
+ blockSignals(false);
+ }
+}
+
+void
+YQPkgHistoryDialog::moveToAction ()
+{
+ if (signalsBlocked() ) return;
+ QTreeWidgetItem* item = _actions->selectedItems().first();
+
+ // if this is not top-level item, better pick top-level one
+ if (item->parent ())
+ item = item->parent ();
+
+ QList items = _dates->findItems (item->text(0), Qt::MatchExactly | Qt::MatchRecursive, 0);
+
+ if( items.size () > 0 )
+ {
+ blockSignals(true);
+ _dates->setCurrentItem (items.first());
+ blockSignals(false);
+ }
+}
+
+#include "YQPkgHistoryDialog.moc"
Added: trunk/qt-pkg/src/YQPkgHistoryDialog.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt-pkg/src/YQPkgHistoryDialog.h?rev=66247&view=auto
==============================================================================
--- trunk/qt-pkg/src/YQPkgHistoryDialog.h (added)
+++ trunk/qt-pkg/src/YQPkgHistoryDialog.h Wed Oct 5 10:29:37 2011
@@ -0,0 +1,95 @@
+/**************************************************************************
+Copyright (C) 2000 - 2011 Novell, Inc.
+All Rights Reserved.
+
+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.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+**************************************************************************/
+
+
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YQPkgHistoryDialog.h
+
+ Author: Stanislav Visnovsky
+
+/-*/
+
+
+#ifndef YQPkgHistoryDialog_h
+#define YQPkgHistoryDialog_h
+
+#include
+
+
+class YQPkgList;
+class YQPkgHistoryView;
+class QTreeWidget;
+
+
+/**
+ * Pkg status and History as a standalone popup dialog.
+ **/
+class YQPkgHistoryDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ /**
+ * Static convenience method: Post a History dialog for pkg 'pkgName'.
+ **/
+ static void showHistoryDialog();
+
+ /**
+ * Returns the preferred size.
+ *
+ * Reimplemented from QWidget to limit the dialog to the screen dimensions.
+ **/
+ virtual QSize sizeHint () const;
+
+
+protected:
+
+ void initialize ();
+
+ /**
+ * Constructor: Creates a History dialog for all packages that match 'pkgName'.
+ **/
+ YQPkgHistoryDialog( QWidget * parent );
+
+ // Data members
+
+ QTreeWidget * _dates;
+ QTreeWidget * _actions;
+
+public slots:
+ void moveToDate ();
+ void moveToAction ();
+
+};
+
+
+#endif // ifndef YQPkgHistoryDialog_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org