author | llornkcor <llornkcor> | 2002-11-03 17:59:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-03 17:59:00 (UTC) |
commit | 16e8fad81f7ee6045990f48edc84542638bf07d7 (patch) (unidiff) | |
tree | 96d836f914e0d1104d7c84830acac08a43ee4ac2 /noncore/multimedia/showimg/ImageFileSelector.cpp | |
parent | 2981b8f55f4a33860452f4571ef9f04781267489 (diff) | |
download | opie-16e8fad81f7ee6045990f48edc84542638bf07d7.zip opie-16e8fad81f7ee6045990f48edc84542638bf07d7.tar.gz opie-16e8fad81f7ee6045990f48edc84542638bf07d7.tar.bz2 |
added preferences dialog, and added slidshow
Diffstat (limited to 'noncore/multimedia/showimg/ImageFileSelector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/showimg/ImageFileSelector.cpp | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp index 347300f..7872c09 100644 --- a/noncore/multimedia/showimg/ImageFileSelector.cpp +++ b/noncore/multimedia/showimg/ImageFileSelector.cpp | |||
@@ -20,12 +20,10 @@ | |||
20 | 20 | ||
21 | #include "ImageFileSelector.h" | 21 | #include "ImageFileSelector.h" |
22 | 22 | ||
23 | 23 | ||
24 | 24 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) | |
25 | 25 | : QWidget( parent ),fl(f) | |
26 | |||
27 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) : QWidget( parent ),fl(f) | ||
28 | { | 26 | { |
29 | setBackgroundMode(NoBackground); | 27 | setBackgroundMode(NoBackground); |
30 | if ( w!=-1 ) | 28 | if ( w!=-1 ) |
31 | setMinimumSize(w,p.height()+24); | 29 | setMinimumSize(w,p.height()+24); |
@@ -37,9 +35,9 @@ ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent, | |||
37 | description->setGeometry(0,height()-24,width(),24); | 35 | description->setGeometry(0,height()-24,width(),24); |
38 | pixmap=p; | 36 | pixmap=p; |
39 | } | 37 | } |
40 | 38 | ||
41 | void ThumbWidget::resizeEvent(QResizeEvent *e) | 39 | void ThumbWidget::resizeEvent(QResizeEvent *) |
42 | { | 40 | { |
43 | description->setGeometry(0,height()-24,width(),24); | 41 | description->setGeometry(0,height()-24,width(),24); |
44 | } | 42 | } |
45 | 43 | ||
@@ -52,17 +50,17 @@ void ThumbWidget::paintEvent( QPaintEvent *e ) | |||
52 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); | 50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); |
53 | 51 | ||
54 | } | 52 | } |
55 | 53 | ||
56 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* event) | 54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) |
57 | { | 55 | { |
58 | emit clicked(fl); | 56 | emit clicked(fl); |
59 | } | 57 | } |
60 | 58 | ||
61 | 59 | ||
62 | 60 | ||
63 | 61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) | |
64 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f): QListViewItem( parent ), fl( f ) | 62 | : QListViewItem( parent ), fl( f ) |
65 | { | 63 | { |
66 | setText( 0, f.name() ); | 64 | setText( 0, f.name() ); |
67 | QFileInfo fi(f.file()); | 65 | QFileInfo fi(f.file()); |
68 | setText( 1, (fi.extension()).upper() ); | 66 | setText( 1, (fi.extension()).upper() ); |
@@ -77,9 +75,10 @@ ImageFileSelectorItem::~ImageFileSelectorItem() | |||
77 | 75 | ||
78 | } | 76 | } |
79 | 77 | ||
80 | 78 | ||
81 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char *name ):QWidgetStack(parent) | 79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) |
80 | : QWidgetStack(parent) | ||
82 | { | 81 | { |
83 | 82 | ||
84 | detailed=new QListView(this); | 83 | detailed=new QListView(this); |
85 | 84 | ||
@@ -164,10 +163,11 @@ void ImageFileSelector::updateSizes() | |||
164 | background->setMinimumWidth(thumb->visibleWidth()); | 163 | background->setMinimumWidth(thumb->visibleWidth()); |
165 | thumb->updateScrollBars(); | 164 | thumb->updateScrollBars(); |
166 | } | 165 | } |
167 | 166 | ||
168 | void ImageFileSelector::reread(bool purgeCache) | 167 | void ImageFileSelector::reread(bool) |
169 | { | 168 | { |
169 | // qDebug("reread"); | ||
170 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); | 170 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); |
171 | QString oldFile; | 171 | QString oldFile; |
172 | if ( item ) | 172 | if ( item ) |
173 | oldFile = item->file().file(); | 173 | oldFile = item->file().file(); |
@@ -176,70 +176,64 @@ void ImageFileSelector::reread(bool purgeCache) | |||
176 | DocLnkSet files; | 176 | DocLnkSet files; |
177 | Global::findDocuments(&files, "image/*"); | 177 | Global::findDocuments(&files, "image/*"); |
178 | count = files.children().count(); | 178 | count = files.children().count(); |
179 | QListIterator<DocLnk> dit( files.children() ); | 179 | QListIterator<DocLnk> dit( files.children() ); |
180 | int y=0; | 180 | // int y=0; |
181 | int x=4; | 181 | // int x=4; |
182 | int totalHeight=4; | 182 | // int totalHeight=4; |
183 | ThumbWidget *l=0; | 183 | ThumbWidget *l=0; |
184 | int width=80; | 184 | int width=80; |
185 | gl->expand(dit.count()/2,2); | 185 | gl->expand(dit.count()/2,2); |
186 | |||
187 | int i,j; | 186 | int i,j; |
188 | |||
189 | i=j=0; | 187 | i=j=0; |
190 | |||
191 | detailed->setUpdatesEnabled(false); | 188 | detailed->setUpdatesEnabled(false); |
192 | thumb->setUpdatesEnabled(false); | 189 | thumb->setUpdatesEnabled(false); |
193 | for ( ; dit.current(); ++dit ) | 190 | |
194 | { | 191 | for ( ; dit.current(); ++dit ) { |
195 | item = new ImageFileSelectorItem( detailed, **dit ); | 192 | item = new ImageFileSelectorItem( detailed, **dit ); |
196 | if ( item->file().file() == oldFile ) | 193 | if ( item->file().file() == oldFile ) |
197 | detailed->setCurrentItem( item ); | 194 | detailed->setCurrentItem( item ); |
198 | } | 195 | } |
199 | 196 | ||
200 | QListViewItemIterator it( detailed ); | 197 | QListViewItemIterator it( detailed ); |
201 | ImageFileSelectorItem *ii; | 198 | ImageFileSelectorItem *ii; |
202 | // iterate through all items of the listview | 199 | // iterate through all items of the listview |
203 | for ( ; it.current(); ++it ) | 200 | for ( ; it.current(); ++it ) { |
204 | { | ||
205 | ii=(ImageFileSelectorItem *)it.current(); | 201 | ii=(ImageFileSelectorItem *)it.current(); |
206 | QImage img(ii->file().file()); | 202 | QImage img( ii->file().file() ); |
207 | img=img.smoothScale(64,64); | 203 | if( !img.isNull()) { |
208 | QPixmap pix; | 204 | img=img.smoothScale(64,64); |
209 | pix.convertFromImage(img); | 205 | QPixmap pix; |
210 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); | 206 | pix.convertFromImage(img); |
211 | l->setBackgroundColor(colorGroup().base()); | 207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); |
212 | gl->addWidget(l,j,i); | 208 | l->setBackgroundColor(colorGroup().base()); |
213 | i++; | 209 | gl->addWidget(l,j,i); |
214 | if ( i==2 ) | 210 | i++; |
215 | { | 211 | if ( i==2 ) { |
216 | i=0; | 212 | i=0; |
217 | j++; | 213 | j++; |
214 | } | ||
215 | tList.append(l); | ||
216 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); | ||
218 | } | 217 | } |
219 | tList.append(l); | ||
220 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); | ||
221 | |||
222 | } | 218 | } |
223 | 219 | ||
224 | |||
225 | |||
226 | if ( !detailed->selectedItem() ) | 220 | if ( !detailed->selectedItem() ) |
227 | detailed->setCurrentItem( detailed->firstChild() ); | 221 | detailed->setCurrentItem( detailed->firstChild() ); |
228 | 222 | ||
229 | detailed->setUpdatesEnabled(true); | 223 | detailed->setUpdatesEnabled(true); |
230 | thumb->setUpdatesEnabled(true); | 224 | thumb->setUpdatesEnabled(true); |
231 | detailed->update(); | 225 | detailed->update(); |
232 | thumb->update(); | 226 | thumb->update(); |
233 | |||
234 | } | 227 | } |
235 | 228 | ||
236 | int ImageFileSelector::fileCount() | 229 | int ImageFileSelector::fileCount() |
237 | { | 230 | { |
238 | return count; | 231 | return count; |
239 | } | 232 | } |
240 | const DocLnk * ImageFileSelector::selected() | 233 | const DocLnk * ImageFileSelector::selected() |
241 | { | 234 | { |
235 | qDebug("image selected"); | ||
242 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); | 236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); |
243 | if ( item ) | 237 | if ( item ) |
244 | return new DocLnk( item->file() ); | 238 | return new DocLnk( item->file() ); |
245 | return 0; | 239 | return 0; |