- Don't create layouts with parent. Qt 4.x automatically reparents
[duncan/yast2-qt4.git] / src / YQIconPool.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQIconPool.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #define y2log_component "qt-ui"
20 #include <ycp/y2log.h>
21
22 #include "YQIconPool.h"
23
24
25 #include "pkg/icons/autodel.xpm"
26 #include "pkg/icons/autodel_disabled.xpm"
27 #include "pkg/icons/autoinstall.xpm"
28 #include "pkg/icons/autoinstall_disabled.xpm"
29 #include "pkg/icons/autoupdate.xpm"
30 #include "pkg/icons/autoupdate_disabled.xpm"
31 #include "pkg/icons/del.xpm"
32 #include "pkg/icons/del_disabled.xpm"
33 #include "pkg/icons/install.xpm"
34 #include "pkg/icons/install_disabled.xpm"
35 #include "pkg/icons/keepinstalled.xpm"
36 #include "pkg/icons/keepinstalled_disabled.xpm"
37 #include "pkg/icons/noinst.xpm"
38 #include "pkg/icons/noinst_disabled.xpm"
39 #include "pkg/icons/protected.xpm"
40 #include "pkg/icons/protected_disabled.xpm"
41 #include "pkg/icons/sel_autodel.xpm"
42 #include "pkg/icons/sel_autodel_disabled.xpm"
43 #include "pkg/icons/sel_autoinstall.xpm"
44 #include "pkg/icons/sel_autoinstall_disabled.xpm"
45 #include "pkg/icons/sel_autoupdate.xpm"
46 #include "pkg/icons/sel_autoupdate_disabled.xpm"
47 #include "pkg/icons/taboo.xpm"
48 #include "pkg/icons/taboo_disabled.xpm"
49 #include "pkg/icons/update.xpm"
50 #include "pkg/icons/update_disabled.xpm"
51 #include "pkg/icons/tree_plus.xpm"
52 #include "pkg/icons/tree_minus.xpm"
53 #include "pkg/icons/warning_sign.xpm"
54 #include "pkg/icons/satisfied.xpm"
55
56 #include "pkg/icons/normal_conflict.xpm"
57 #include "pkg/icons/select_conflict.xpm"
58 #include "pkg/icons/delete_conflict.xpm"
59 #include "pkg/icons/unresolvable_conflict.xpm"
60
61 #include "pkg/icons/checklist_off.xpm"
62 #include "pkg/icons/checklist_on.xpm"
63
64 #include "pkg/icons/step_current.xpm"
65 #include "pkg/icons/step_todo.xpm"
66 #include "pkg/icons/step_done.xpm"
67 //Added by qt3to4:
68 #include <qpixmap.h>
69
70
71 YQIconPool * YQIconPool::_iconPool = 0;
72
73 QPixmap YQIconPool::pkgTaboo()                  { return iconPool()->cachedIcon( taboo_xpm );                   }
74 QPixmap YQIconPool::pkgDel()                    { return iconPool()->cachedIcon( del_xpm );                     }
75 QPixmap YQIconPool::pkgUpdate()                 { return iconPool()->cachedIcon( update_xpm );                  }
76 QPixmap YQIconPool::pkgInstall()                { return iconPool()->cachedIcon( install_xpm );                 }
77 QPixmap YQIconPool::pkgAutoInstall()            { return iconPool()->cachedIcon( autoinstall_xpm );             }
78 QPixmap YQIconPool::pkgAutoUpdate()             { return iconPool()->cachedIcon( autoupdate_xpm );              }
79 QPixmap YQIconPool::pkgAutoDel()                { return iconPool()->cachedIcon( autodel_xpm );                 }
80 QPixmap YQIconPool::pkgSelAutoInstall()         { return iconPool()->cachedIcon( sel_autoinstall_xpm );         }
81 QPixmap YQIconPool::pkgSelAutoUpdate()          { return iconPool()->cachedIcon( sel_autoupdate_xpm );          }
82 QPixmap YQIconPool::pkgSelAutoDel()             { return iconPool()->cachedIcon( sel_autodel_xpm );             }
83 QPixmap YQIconPool::pkgKeepInstalled()          { return iconPool()->cachedIcon( keepinstalled_xpm );           }
84 QPixmap YQIconPool::pkgNoInst()                 { return iconPool()->cachedIcon( noinst_xpm );                  }
85 QPixmap YQIconPool::pkgProtected()              { return iconPool()->cachedIcon( protected_xpm );               }
86
87 QPixmap YQIconPool::disabledPkgTaboo()          { return iconPool()->cachedIcon( taboo_disabled_xpm );          }
88 QPixmap YQIconPool::disabledPkgDel()            { return iconPool()->cachedIcon( del_disabled_xpm );            }
89 QPixmap YQIconPool::disabledPkgUpdate()         { return iconPool()->cachedIcon( update_disabled_xpm );         }
90 QPixmap YQIconPool::disabledPkgInstall()        { return iconPool()->cachedIcon( install_disabled_xpm );        }
91 QPixmap YQIconPool::disabledPkgAutoInstall()    { return iconPool()->cachedIcon( autoinstall_disabled_xpm );    }
92 QPixmap YQIconPool::disabledPkgAutoUpdate()     { return iconPool()->cachedIcon( autoupdate_disabled_xpm );     }
93 QPixmap YQIconPool::disabledPkgAutoDel()        { return iconPool()->cachedIcon( autodel_disabled_xpm );        }
94 QPixmap YQIconPool::disabledPkgSelAutoInstall() { return iconPool()->cachedIcon( sel_autoinstall_disabled_xpm );}
95 QPixmap YQIconPool::disabledPkgSelAutoUpdate()  { return iconPool()->cachedIcon( sel_autoupdate_disabled_xpm ); }
96 QPixmap YQIconPool::disabledPkgSelAutoDel()     { return iconPool()->cachedIcon( sel_autodel_disabled_xpm );    }
97 QPixmap YQIconPool::disabledPkgKeepInstalled()  { return iconPool()->cachedIcon( keepinstalled_disabled_xpm );  }
98 QPixmap YQIconPool::disabledPkgNoInst()         { return iconPool()->cachedIcon( noinst_disabled_xpm );         }
99 QPixmap YQIconPool::disabledPkgProtected()      { return iconPool()->cachedIcon( protected_disabled_xpm );      }
100
101 QPixmap YQIconPool::checkMarkOn()               { return iconPool()->cachedIcon( checklist_on_xpm );            }
102 QPixmap YQIconPool::checkMarkOff()              { return iconPool()->cachedIcon( checklist_off_xpm );           }
103
104 QPixmap YQIconPool::normalPkgConflict()         { return iconPool()->cachedIcon( normal_conflict_xpm );         }
105 QPixmap YQIconPool::severePkgConflict()         { return iconPool()->cachedIcon( normal_conflict_xpm );         }
106 QPixmap YQIconPool::unresolvablePkgConflict()   { return iconPool()->cachedIcon( unresolvable_conflict_xpm );   }
107 QPixmap YQIconPool::deletePkgConflict()         { return iconPool()->cachedIcon( delete_conflict_xpm );         }
108 QPixmap YQIconPool::tabooPkgConflict()          { return iconPool()->cachedIcon( normal_conflict_xpm );         }
109 QPixmap YQIconPool::selectPkgConflict()         { return iconPool()->cachedIcon( select_conflict_xpm );         }
110
111 QPixmap YQIconPool::treePlus()                  { return iconPool()->cachedIcon( tree_plus_xpm  );              }
112 QPixmap YQIconPool::treeMinus()                 { return iconPool()->cachedIcon( tree_minus_xpm );              }
113
114 QPixmap YQIconPool::warningSign()               { return iconPool()->cachedIcon( warning_sign_xpm );            }
115 QPixmap YQIconPool::pkgSatisfied()              { return iconPool()->cachedIcon( satisfied_xpm );               }
116
117 QPixmap YQIconPool::stepCurrent()               { return iconPool()->cachedIcon( step_current_xpm );            }
118 QPixmap YQIconPool::stepToDo()                  { return iconPool()->cachedIcon( step_todo_xpm );               }
119 QPixmap YQIconPool::stepDone()                  { return iconPool()->cachedIcon( step_done_xpm );               }
120
121
122 YQIconPool * YQIconPool::iconPool()
123 {
124     if ( ! _iconPool )
125         _iconPool = new YQIconPool();
126
127     return _iconPool;
128 }
129
130
131 YQIconPool::YQIconPool()
132 {
133 }
134
135
136 YQIconPool::~YQIconPool()
137 {
138     // NOP
139 }
140
141
142
143 QPixmap
144 YQIconPool::cachedIcon( const char ** xpm_data )
145 {
146     QPixmap iconPtr = _iconCache[ xpm_data ];
147
148     if ( iconPtr.isNull() )
149     {
150         iconPtr = QPixmap( xpm_data );
151         _iconCache.insert( xpm_data, iconPtr );
152     }
153
154     return iconPtr;
155 }
156