libyui-qt-pkg  2.47.2
YQPkgUpdateProblemFilterView.cc
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgUpdateProblemFilterView.cc
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38  Textdomain "qt-pkg"
39 
40 /-*/
41 
42 
43 #define YUILogComponent "qt-pkg"
44 #include "YUILog.h"
45 
46 #include "YQPkgUpdateProblemFilterView.h"
47 #include "YQi18n.h"
48 #include "utf8.h"
49 
50 #include <zypp/ZYppFactory.h>
51 #include <zypp/Resolver.h>
52 
53 using std::list;
54 using std::endl;
55 
56 
58  : QTextBrowser( parent )
59 {
60  QString html = _( "\
61 <br>\n\
62 <h2>Update Problem</h2>\n\
63 <p>\n\
64 The packages in this list cannot be updated automatically.\n\
65 </p>\n\
66 <p>Possible reasons:</p>\n\
67 <ul>\n\
68 <li>They are obsoleted by other packages\n\
69 <li>There is no newer version to update to on any installation media\n\
70 <li>They are third-party packages\n\
71 </ul>\n\
72 </p>\n\
73 <p>\n\
74 Please choose manually what to do with them.\n\
75 The safest course of action is to delete them.\n\
76 </p>\
77 " );
78 
79  setHtml( html );
80 }
81 
82 
84 {
85  // NOP
86 }
87 
88 void
90 {
91  if ( isVisible() )
92  filter();
93 }
94 
95 
96 void
98 {
99  emit filterStart();
100 
101  list<zypp::PoolItem> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
102 
103  for ( list<zypp::PoolItem>::const_iterator it = problemList.begin();
104  it != problemList.end();
105  ++it )
106  {
107  ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
108 
109  if ( pkg )
110  {
111  ZyppSel sel = _selMapper.findZyppSel( pkg );
112 
113  if ( sel )
114  {
115  yuiMilestone() << "Problematic package: "
116  << pkg->name() << "-" << pkg->edition().asString()
117  << endl;
118 
119  emit filterMatch( sel, pkg );
120  }
121  }
122 
123  }
124 
125  emit filterFinished();
126 }
127 
128 
129 bool
131 {
132  return ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty();
133 }
134 
135 
YQPkgUpdateProblemFilterView::YQPkgUpdateProblemFilterView
YQPkgUpdateProblemFilterView(QWidget *parent)
Constructor.
Definition: YQPkgUpdateProblemFilterView.cc:56
YQPkgUpdateProblemFilterView::filterMatch
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
YQPkgUpdateProblemFilterView::~YQPkgUpdateProblemFilterView
virtual ~YQPkgUpdateProblemFilterView()
Destructor.
Definition: YQPkgUpdateProblemFilterView.cc:82
YQPkgSelMapper::findZyppSel
ZyppSel findZyppSel(ZyppPkg pkg)
Find the corresponding ZyppSel to a ZyppPkg.
Definition: YQPkgSelMapper.cc:108
YQPkgUpdateProblemFilterView::filterStart
void filterStart()
Emitted when the filtering starts.
YQPkgUpdateProblemFilterView::filterFinished
void filterFinished()
Emitted when filtering is finished.
YQPkgUpdateProblemFilterView::filterIfVisible
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
Definition: YQPkgUpdateProblemFilterView.cc:88
YQPkgUpdateProblemFilterView::haveProblematicPackages
static bool haveProblematicPackages()
Check if there are any problematic packages at all, i.e.
Definition: YQPkgUpdateProblemFilterView.cc:129
YQPkgUpdateProblemFilterView::filter
void filter()
Filter according to the view's rules and current selection.
Definition: YQPkgUpdateProblemFilterView.cc:96