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) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/showimg/ImageFileSelector.cpp | 46 |
1 files changed, 20 insertions, 26 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 | |||
@@ -21,10 +21,8 @@ | |||
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 ) |
@@ -38,7 +36,7 @@ ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent, | |||
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 | } |
@@ -53,15 +51,15 @@ void ThumbWidget::paintEvent( QPaintEvent *e ) | |||
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()); |
@@ -78,7 +76,8 @@ ImageFileSelectorItem::~ImageFileSelectorItem() | |||
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); |
@@ -165,8 +164,9 @@ void ImageFileSelector::updateSizes() | |||
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 ) |
@@ -177,21 +177,18 @@ void ImageFileSelector::reread(bool purgeCache) | |||
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 ); |
@@ -200,10 +197,10 @@ void ImageFileSelector::reread(bool purgeCache) | |||
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()); |
203 | if( !img.isNull()) { | ||
207 | img=img.smoothScale(64,64); | 204 | img=img.smoothScale(64,64); |
208 | QPixmap pix; | 205 | QPixmap pix; |
209 | pix.convertFromImage(img); | 206 | pix.convertFromImage(img); |
@@ -211,17 +208,14 @@ void ImageFileSelector::reread(bool purgeCache) | |||
211 | l->setBackgroundColor(colorGroup().base()); | 208 | l->setBackgroundColor(colorGroup().base()); |
212 | gl->addWidget(l,j,i); | 209 | gl->addWidget(l,j,i); |
213 | i++; | 210 | i++; |
214 | if ( i==2 ) | 211 | if ( i==2 ) { |
215 | { | ||
216 | i=0; | 212 | i=0; |
217 | j++; | 213 | j++; |
218 | } | 214 | } |
219 | tList.append(l); | 215 | tList.append(l); |
220 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); | 216 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); |
221 | |||
222 | } | 217 | } |
223 | 218 | } | |
224 | |||
225 | 219 | ||
226 | if ( !detailed->selectedItem() ) | 220 | if ( !detailed->selectedItem() ) |
227 | detailed->setCurrentItem( detailed->firstChild() ); | 221 | detailed->setCurrentItem( detailed->firstChild() ); |
@@ -230,7 +224,6 @@ void ImageFileSelector::reread(bool purgeCache) | |||
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() |
@@ -239,6 +232,7 @@ int ImageFileSelector::fileCount() | |||
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() ); |