]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgUpdateProblemFilterView.cc
- Don't create layouts with parent. Qt 4.x automatically reparents
[duncan/yast2-qt4.git] / src / pkg / YQPkgUpdateProblemFilterView.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgUpdateProblemFilterView.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17   Textdomain "packages-qt"
18
19 /-*/
20
21
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
24
25 #include "YQPkgUpdateProblemFilterView.h"
26 #include "YQi18n.h"
27 #include "utf8.h"
28
29 #include <zypp/ZYppFactory.h>
30 #include <zypp/Resolver.h>
31
32 using std::list;
33
34
35 YQPkgUpdateProblemFilterView::YQPkgUpdateProblemFilterView( QWidget * parent )
36     : QTextBrowser( parent )
37 {
38     QString html = _( "\
39 <br>\n\
40 <h2>Update Problem</h2>\n\
41 <p>\n\
42 <font color='blue'>\n\
43 The packages in this list cannot be updated automatically.\n\
44 </font>\n\
45 </p>\n\
46 <p>Possible reasons:</p>\n\
47 <ul>\n\
48 <li>They are obsoleted by other packages\n\
49 <li>There is no newer version to update to on any installation media\n\
50 <li>They are third-party packages\n\
51 </ul>\n\
52 </p>\n\
53 <p>\n\
54 Please choose manually what to do with them.\n\
55 The safest course of action is to delete them.\n\
56 </p>\
57 " );
58
59     setHtml( html );
60 }
61
62
63 YQPkgUpdateProblemFilterView::~YQPkgUpdateProblemFilterView()
64 {
65     // NOP
66 }
67
68 void
69 YQPkgUpdateProblemFilterView::filterIfVisible()
70 {
71     if ( isVisible() )
72         filter();
73 }
74
75
76 void
77 YQPkgUpdateProblemFilterView::filter()
78 {
79     emit filterStart();
80
81     list<zypp::PoolItem_Ref> problemList = zypp::getZYpp()->resolver()->problematicUpdateItems();
82     
83     for ( list<zypp::PoolItem_Ref>::const_iterator it = problemList.begin();
84           it != problemList.end();
85           ++it )
86     {
87         ZyppPkg pkg = tryCastToZyppPkg( (*it).resolvable() );
88
89         if ( pkg )
90         {
91             ZyppSel sel = _selMapper.findZyppSel( pkg );
92
93             if ( sel )
94             {
95                 y2milestone( "Problematic package: %s-%s",
96                              pkg->name().c_str(), pkg->edition().asString().c_str() );
97                 
98                 emit filterMatch( sel, pkg );
99             }
100         }
101         
102     }
103
104     emit filterFinished();
105 }
106
107
108 bool
109 YQPkgUpdateProblemFilterView::haveProblematicPackages()
110 {
111     return ! zypp::getZYpp()->resolver()->problematicUpdateItems().empty();
112 }
113
114
115 #include "YQPkgUpdateProblemFilterView.moc"