Diffstat (limited to 'noncore/multimedia/showimg/ImageFileSelector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/showimg/ImageFileSelector.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp index 79ee925..53cc883 100644 --- a/noncore/multimedia/showimg/ImageFileSelector.cpp +++ b/noncore/multimedia/showimg/ImageFileSelector.cpp | |||
@@ -1,35 +1,37 @@ | |||
1 | #include "ImageFileSelector.h" | ||
1 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | #include <qpe/qpeapplication.h> | ||
6 | using namespace Opie::Core; | ||
2 | 7 | ||
3 | #include "qpe/qpeapplication.h" | 8 | /* QT */ |
4 | 9 | #include <qlabel.h> | |
5 | #include <stdlib.h> | ||
6 | |||
7 | #include <qlabel.h> | ||
8 | #include <qfileinfo.h> | 10 | #include <qfileinfo.h> |
9 | 11 | ||
10 | #include "ImageFileSelector.h" | 12 | /* STD */ |
11 | 13 | #include <stdlib.h> | |
12 | 14 | ||
13 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) | 15 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) |
14 | : QWidget( parent ),fl(f) | 16 | : QWidget( parent ),fl(f) |
15 | { | 17 | { |
16 | setBackgroundMode(NoBackground); | 18 | setBackgroundMode(NoBackground); |
17 | if ( w!=-1 ) | 19 | if ( w!=-1 ) |
18 | setMinimumSize(w,p.height()+24); | 20 | setMinimumSize(w,p.height()+24); |
19 | else | 21 | else |
20 | setMinimumSize(p.width(),p.height()+24); | 22 | setMinimumSize(p.width(),p.height()+24); |
21 | description=new QLabel(text,this); | 23 | description=new QLabel(text,this); |
22 | description->setBackgroundColor(colorGroup().base()); | 24 | description->setBackgroundColor(colorGroup().base()); |
23 | description->setAlignment(AlignCenter); | 25 | description->setAlignment(AlignCenter); |
24 | description->setGeometry(0,height()-24,width(),24); | 26 | description->setGeometry(0,height()-24,width(),24); |
25 | pixmap=p; | 27 | pixmap=p; |
26 | } | 28 | } |
27 | 29 | ||
28 | void ThumbWidget::resizeEvent(QResizeEvent *) | 30 | void ThumbWidget::resizeEvent(QResizeEvent *) |
29 | { | 31 | { |
30 | description->setGeometry(0,height()-24,width(),24); | 32 | description->setGeometry(0,height()-24,width(),24); |
31 | } | 33 | } |
32 | 34 | ||
33 | void ThumbWidget::paintEvent( QPaintEvent *e ) | 35 | void ThumbWidget::paintEvent( QPaintEvent *e ) |
34 | { | 36 | { |
35 | QPainter painter(this); | 37 | QPainter painter(this); |
@@ -134,49 +136,49 @@ void ImageFileSelector::setView(CURRENT_VIEW v) | |||
134 | raiseWidget(detailed); | 136 | raiseWidget(detailed); |
135 | updateSizes(); | 137 | updateSizes(); |
136 | } | 138 | } |
137 | 139 | ||
138 | 140 | ||
139 | } | 141 | } |
140 | 142 | ||
141 | void ImageFileSelector::resizeEvent(QResizeEvent *) | 143 | void ImageFileSelector::resizeEvent(QResizeEvent *) |
142 | { | 144 | { |
143 | updateSizes(); | 145 | updateSizes(); |
144 | } | 146 | } |
145 | 147 | ||
146 | void ImageFileSelector::updateSizes() | 148 | void ImageFileSelector::updateSizes() |
147 | { | 149 | { |
148 | int ww=(detailed->width()-detailed->frameWidth()*2); | 150 | int ww=(detailed->width()-detailed->frameWidth()*2); |
149 | double w=(double)ww*0.70; | 151 | double w=(double)ww*0.70; |
150 | detailed->setColumnWidth(0,(int)w); | 152 | detailed->setColumnWidth(0,(int)w); |
151 | detailed->setColumnWidth(1,ww-(int)w); | 153 | detailed->setColumnWidth(1,ww-(int)w); |
152 | background->setMinimumWidth(thumb->visibleWidth()); | 154 | background->setMinimumWidth(thumb->visibleWidth()); |
153 | thumb->updateScrollBars(); | 155 | thumb->updateScrollBars(); |
154 | } | 156 | } |
155 | 157 | ||
156 | void ImageFileSelector::reread(bool) | 158 | void ImageFileSelector::reread(bool) |
157 | { | 159 | { |
158 | // qDebug("reread"); | 160 | // odebug << "reread" << oendl; |
159 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); | 161 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); |
160 | QString oldFile; | 162 | QString oldFile; |
161 | if ( item ) | 163 | if ( item ) |
162 | oldFile = item->file().file(); | 164 | oldFile = item->file().file(); |
163 | detailed->clear(); | 165 | detailed->clear(); |
164 | tList.clear(); | 166 | tList.clear(); |
165 | DocLnkSet files; | 167 | DocLnkSet files; |
166 | Global::findDocuments(&files, "image/*"); | 168 | Global::findDocuments(&files, "image/*"); |
167 | count = files.children().count(); | 169 | count = files.children().count(); |
168 | QListIterator<DocLnk> dit( files.children() ); | 170 | QListIterator<DocLnk> dit( files.children() ); |
169 | // int y=0; | 171 | // int y=0; |
170 | // int x=4; | 172 | // int x=4; |
171 | // int totalHeight=4; | 173 | // int totalHeight=4; |
172 | ThumbWidget *l=0; | 174 | ThumbWidget *l=0; |
173 | int width=80; | 175 | int width=80; |
174 | gl->expand(dit.count()/2,2); | 176 | gl->expand(dit.count()/2,2); |
175 | int i,j; | 177 | int i,j; |
176 | i=j=0; | 178 | i=j=0; |
177 | detailed->setUpdatesEnabled(false); | 179 | detailed->setUpdatesEnabled(false); |
178 | thumb->setUpdatesEnabled(false); | 180 | thumb->setUpdatesEnabled(false); |
179 | 181 | ||
180 | for ( ; dit.current(); ++dit ) { | 182 | for ( ; dit.current(); ++dit ) { |
181 | item = new ImageFileSelectorItem( detailed, **dit ); | 183 | item = new ImageFileSelectorItem( detailed, **dit ); |
182 | if ( item->file().file() == oldFile ) | 184 | if ( item->file().file() == oldFile ) |
@@ -200,49 +202,49 @@ void ImageFileSelector::reread(bool) | |||
200 | if ( i==2 ) { | 202 | if ( i==2 ) { |
201 | i=0; | 203 | i=0; |
202 | j++; | 204 | j++; |
203 | } | 205 | } |
204 | tList.append(l); | 206 | tList.append(l); |
205 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); | 207 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); |
206 | } | 208 | } |
207 | } | 209 | } |
208 | 210 | ||
209 | if ( !detailed->selectedItem() ) | 211 | if ( !detailed->selectedItem() ) |
210 | detailed->setCurrentItem( detailed->firstChild() ); | 212 | detailed->setCurrentItem( detailed->firstChild() ); |
211 | 213 | ||
212 | detailed->setUpdatesEnabled(true); | 214 | detailed->setUpdatesEnabled(true); |
213 | thumb->setUpdatesEnabled(true); | 215 | thumb->setUpdatesEnabled(true); |
214 | detailed->update(); | 216 | detailed->update(); |
215 | thumb->update(); | 217 | thumb->update(); |
216 | } | 218 | } |
217 | 219 | ||
218 | int ImageFileSelector::fileCount() | 220 | int ImageFileSelector::fileCount() |
219 | { | 221 | { |
220 | return count; | 222 | return count; |
221 | } | 223 | } |
222 | const DocLnk * ImageFileSelector::selected() | 224 | const DocLnk * ImageFileSelector::selected() |
223 | { | 225 | { |
224 | qDebug("image selected"); | 226 | odebug << "image selected" << oendl; |
225 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); | 227 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); |
226 | if ( item ) | 228 | if ( item ) |
227 | return new DocLnk( item->file() ); | 229 | return new DocLnk( item->file() ); |
228 | return 0; | 230 | return 0; |
229 | } | 231 | } |
230 | 232 | ||
231 | 233 | ||
232 | 234 | ||
233 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) | 235 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) |
234 | { | 236 | { |
235 | if ( !i ) | 237 | if ( !i ) |
236 | return; | 238 | return; |
237 | if ( button == Qt::LeftButton ) | 239 | if ( button == Qt::LeftButton ) |
238 | { | 240 | { |
239 | fileClicked( i ); | 241 | fileClicked( i ); |
240 | } | 242 | } |
241 | } | 243 | } |
242 | // pressed to get 'right down' | 244 | // pressed to get 'right down' |
243 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) | 245 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) |
244 | { | 246 | { |
245 | 247 | ||
246 | } | 248 | } |
247 | void ImageFileSelector::fileClicked( QListViewItem *i) | 249 | void ImageFileSelector::fileClicked( QListViewItem *i) |
248 | { | 250 | { |