summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f173ecc..5472ead 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -49,138 +49,141 @@ namespace {
49 QPixmap* pixmap()const; 49 QPixmap* pixmap()const;
50 QString path()const { return m_path; } 50 QString path()const { return m_path; }
51 bool isDir()const { return m_isDir; } 51 bool isDir()const { return m_isDir; }
52 void setText( const QString& ); 52 void setText( const QString& );
53 bool textOnly()const{return m_textOnly;} 53 bool textOnly()const{return m_textOnly;}
54 void setTextOnly(bool how){m_textOnly=how;} 54 void setTextOnly(bool how){m_textOnly=how;}
55 /* just for starting recalc of item rect! */ 55 /* just for starting recalc of item rect! */
56 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); 56 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
57 /* just for starting recalc of item rect! */ 57 /* just for starting recalc of item rect! */
58 virtual void setPixmap( const QPixmap & icon); 58 virtual void setPixmap( const QPixmap & icon);
59 59
60 protected: 60 protected:
61 mutable QPixmap* m_pix; 61 mutable QPixmap* m_pix;
62 int m_iconsize; 62 int m_iconsize;
63 void check_pix()const; 63 void check_pix()const;
64 64
65 private: 65 private:
66 QString m_path; 66 QString m_path;
67 bool m_isDir : 1; 67 bool m_isDir : 1;
68 bool m_noInfo :1; 68 bool m_noInfo :1;
69 bool m_textOnly:1; 69 bool m_textOnly:1;
70 bool m_NameOnly:1; 70 bool m_NameOnly:1;
71 bool m_Pixset:1; 71 bool m_Pixset:1;
72 }; 72 };
73 class TextViewItem : public IconViewItem { 73 class TextViewItem : public IconViewItem {
74 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); 74 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false);
75 QPixmap *pixmap()const; 75 QPixmap *pixmap()const;
76 void setText( const QString& ); 76 void setText( const QString& );
77 }; 77 };
78 class ThumbViewItem : public IconViewItem { 78 class ThumbViewItem : public IconViewItem {
79 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); 79 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false );
80 QPixmap *pixmap()const; 80 QPixmap *pixmap()const;
81 void setText( const QString& ); 81 void setText( const QString& );
82 }; 82 };
83 83
84 84
85/* 85/*
86 * If we request an Image or String 86 * If we request an Image or String
87 * we add it to the map 87 * we add it to the map
88 */ 88 */
89 static QMap<QString, IconViewItem*> g_stringInf; 89 static QMap<QString, IconViewItem*> g_stringInf;
90 static QMap<QString, IconViewItem*> g_stringPix; 90 static QMap<QString, IconViewItem*> g_stringPix;
91 91
92 IconViewItem::IconViewItem( QIconView* view,const QString& path, 92 IconViewItem::IconViewItem( QIconView* view,const QString& path,
93 const QString& name, int a_iconsize, bool isDir) 93 const QString& name, int a_iconsize, bool isDir)
94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
95 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 95 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
96 { 96 {
97 m_iconsize = a_iconsize; 97 m_iconsize = a_iconsize;
98 if ( isDir ) { 98 if ( isDir ) {
99 if (!_dirPix ) { 99 if (!_dirPix ) {
100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
101 } 101 }
102 } else { 102 } else {
103 if (!_unkPix ) { 103 if (!_unkPix ) {
104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
105 } 105 }
106 } 106 }
107 check_pix(); 107 check_pix();
108 } 108 }
109 109
110 inline void IconViewItem::check_pix()const 110 inline void IconViewItem::check_pix()const
111 { 111 {
112 if (_dirPix && _dirPix->width()>m_iconsize) { 112 if (_dirPix && _dirPix->width()>m_iconsize) {
113 QPixmap*Pix = new QPixmap(*_dirPix); 113 QImage Pix = _dirPix->convertToImage();
114 Pix->resize(m_iconsize,m_iconsize); 114 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize);
115 delete _dirPix;
116 _dirPix = Pix;
117 } 115 }
118 if (!_cpyPix && _unkPix) { 116 if (!_cpyPix && _unkPix) {
119 if (_unkPix->width()>=m_iconsize) { 117 if (_unkPix->width()>=m_iconsize) {
120 _cpyPix = new QPixmap(*_unkPix); 118 QImage Pix = _unkPix->convertToImage();
121 if (_unkPix->width()>m_iconsize) 119 _cpyPix = new QPixmap();
122 _cpyPix->resize(m_iconsize,m_iconsize); 120 if (_unkPix->width()>m_iconsize) {
121 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize);
122 } else {
123 _cpyPix->convertFromImage(Pix);
124 }
125
123 } else { 126 } else {
124 _cpyPix = new QPixmap(m_iconsize,m_iconsize); 127 _cpyPix = new QPixmap(m_iconsize,m_iconsize);
125 _cpyPix->fill(); 128 _cpyPix->fill();
126 QPainter pa(_cpyPix); 129 QPainter pa(_cpyPix);
127 int offset = (m_iconsize-_unkPix->width())/2; 130 int offset = (m_iconsize-_unkPix->width())/2;
128 int offy = (m_iconsize-_unkPix->height())/2; 131 int offy = (m_iconsize-_unkPix->height())/2;
129 if (offy<0) offy=0; 132 if (offy<0) offy=0;
130 pa.drawPixmap(offset,offy,*_unkPix); 133 pa.drawPixmap(offset,offy,*_unkPix);
131 pa.end(); 134 pa.end();
132 } 135 }
133 } 136 }
134 } 137 }
135 138
136 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 139 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
137 { 140 {
138 m_Pixset = true; 141 m_Pixset = true;
139 calcRect(text()); 142 calcRect(text());
140 } 143 }
141 inline void IconViewItem::setPixmap( const QPixmap & ) 144 inline void IconViewItem::setPixmap( const QPixmap & )
142 { 145 {
143 m_Pixset = true; 146 m_Pixset = true;
144 calcRect(text()); 147 calcRect(text());
145 } 148 }
146 149
147 inline QPixmap* IconViewItem::pixmap()const { 150 inline QPixmap* IconViewItem::pixmap()const {
148// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 151// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
149// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 152// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
150// << " " << iconView()->contentsY() << oendl; 153// << " " << iconView()->contentsY() << oendl;
151 154
152 if (textOnly()&&!m_isDir) { 155 if (textOnly()&&!m_isDir) {
153 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 156 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
154 return _emptyPix; 157 return _emptyPix;
155 } 158 }
156 if ( m_isDir ) 159 if ( m_isDir )
157 return _dirPix; 160 return _dirPix;
158 else{ 161 else{
159 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 162 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
160 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 163 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
161 currentView()->dirLister()->imageInfo( m_path ); 164 currentView()->dirLister()->imageInfo( m_path );
162 } 165 }
163 166
164 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); 167 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize );
165 if (!m_pix && !g_stringPix.contains( m_path )) { 168 if (!m_pix && !g_stringPix.contains( m_path )) {
166 check_pix(); 169 check_pix();
167 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 170 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
168 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); 171 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize);
169 } 172 }
170 return m_pix ? m_pix : _cpyPix; 173 return m_pix ? m_pix : _cpyPix;
171 } 174 }
172 } 175 }
173 inline void IconViewItem::setText( const QString& str ) { 176 inline void IconViewItem::setText( const QString& str ) {
174 QString text = QIconViewItem::text()+"\n"+str; 177 QString text = QIconViewItem::text()+"\n"+str;
175 m_noInfo = true; 178 m_noInfo = true;
176 QIconViewItem::setText( text ); 179 QIconViewItem::setText( text );
177 } 180 }
178} 181}
179 182
180 183
181/* 184/*
182 * Set up the GUI.. initialize the slave set up gui 185 * Set up the GUI.. initialize the slave set up gui
183 * and also load a dir 186 * and also load a dir
184 */ 187 */
185PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 188PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
186 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 189 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )