~ubuntu-branches/ubuntu/karmic/kid3/karmic

« back to all changes in this revision

Viewing changes to kid3/framelist.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2009-05-20 16:12:30 UTC
  • mfrom: (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: james.westby@ubuntu.com-20090520161230-qetp532r8ydujkz2
Tags: upstream-1.2
Import upstream version 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <qapplication.h>
38
38
#include <qclipboard.h>
39
39
#include <qbuffer.h>
 
40
#include <qdesktopwidget.h>
40
41
#if QT_VERSION >= 0x040000
41
42
#include <QListWidget>
42
43
#include <QVBoxLayout>
225
226
};
226
227
 
227
228
 
228
 
/** Image widget. */
229
 
class ImageWidget : public QWidget {
230
 
public:
231
 
        /**
232
 
         * Constructor.
233
 
         *
234
 
         * @param parent parent widget
235
 
         * @param img    image to display in window
236
 
         */
237
 
        ImageWidget(QWidget* parent, QImage* img);
238
 
 
239
 
protected:
240
 
        /**
241
 
         * Paint image, called when window has to be drawn.
242
 
         */
243
 
        void paintEvent(QPaintEvent*);
244
 
 
245
 
private:
246
 
        /** Image to view */
247
 
        QImage* m_image; 
248
 
};
249
 
 
250
229
/** Window to view image */
251
230
class ImageViewer : public QDialog {
252
231
public:
256
235
         * @param parent parent widget
257
236
         * @param img    image to display in window
258
237
         */
259
 
        ImageViewer(QWidget* parent, QImage* img);
 
238
        ImageViewer(QWidget* parent, const QImage& img);
260
239
 
261
240
        /**
262
241
         * Destructor.
265
244
 
266
245
private:
267
246
        /** image to view */
268
 
        ImageWidget* m_image; 
 
247
        QLabel* m_image; 
269
248
};
270
249
 
271
250
 
345
324
        m_label = new QLabel(this);
346
325
        m_spinbox = new QSpinBox(this);
347
326
        if (layout && m_label && m_spinbox) {
 
327
                m_spinbox->setRange(0, INT_MAX);
348
328
                layout->setMargin(0);
349
329
                layout->setSpacing(2);
350
330
                layout->addWidget(m_label);
352
332
        }
353
333
}
354
334
 
355
 
/**
356
 
 * Constructor.
357
 
 *
358
 
 * @param parent parent widget
359
 
 * @param img    image to display in window
360
 
 */
361
 
ImageWidget::ImageWidget(QWidget* parent, QImage* img) :
362
 
        QWidget(parent), m_image(img)
363
 
{
364
 
        setFixedSize(m_image->width(), m_image->height());
365
 
}
366
 
 
367
 
/**
368
 
 * Paint image, called when window has to be drawn.
369
 
 */
370
 
void ImageWidget::paintEvent(QPaintEvent*)
371
 
{
372
 
        QPainter paint(this);
373
 
        paint.drawImage(0, 0, *m_image, 0, 0, m_image->width(), m_image->height());
374
 
}
375
 
 
376
 
 
377
 
/**
378
 
 * Constructor.
379
 
 *
380
 
 * @param parent parent widget
381
 
 * @param img    image to display in window
382
 
 */
383
 
ImageViewer::ImageViewer(QWidget* parent, QImage* img) :
 
335
 
 
336
/**
 
337
 * Constructor.
 
338
 *
 
339
 * @param parent parent widget
 
340
 * @param img    image to display in window
 
341
 */
 
342
ImageViewer::ImageViewer(QWidget* parent, const QImage& img) :
384
343
        QDialog(parent)
385
344
{
386
345
        setModal(true);
394
353
        QHBoxLayout* hlayout = new QHBoxLayout;
395
354
        QSpacerItem* hspacer = new QSpacerItem(16, 0, QSizePolicy::Expanding,
396
355
                                               QSizePolicy::Minimum);
397
 
        m_image = new ImageWidget(this, img);
 
356
        m_image = new QLabel(this);
398
357
        QPushButton* closeButton = new QPushButton(i18n("&Close"), this);
399
358
        if (vlayout && hlayout && m_image && closeButton) {
 
359
                m_image->setScaledContents(true);
 
360
                QSize imageSize(img.size());
 
361
                QSize desktopSize(QApplication::desktop()->availableGeometry().size());
 
362
                desktopSize -= QSize(12, 12);
 
363
                if (imageSize.width() > desktopSize.width() ||
 
364
                                imageSize.height() > desktopSize.height()) {
 
365
#if QT_VERSION >= 0x040000
 
366
                        m_image->setPixmap(QPixmap::fromImage(img.scaled(desktopSize, Qt::KeepAspectRatio)));
 
367
#else
 
368
                        m_image->setPixmap(QPixmap(img.scale(desktopSize, QImage::ScaleMin)));
 
369
#endif
 
370
                } else {
 
371
#if QT_VERSION >= 0x040000
 
372
                        m_image->setPixmap(QPixmap::fromImage(img));
 
373
#else
 
374
                        m_image->setPixmap(QPixmap(img));
 
375
#endif
 
376
                }
400
377
                vlayout->addWidget(m_image);
401
378
                hlayout->addItem(hspacer);
402
379
                hlayout->addWidget(closeButton);
875
852
{
876
853
        QImage image;
877
854
        if (image.loadFromData(m_byteArray)) {
878
 
                ImageViewer iv(this, &image);
 
855
                ImageViewer iv(this, image);
879
856
                iv.exec();
880
857
        }
881
858
}
1475
1452
        }
1476
1453
        if (result && m_file) {
1477
1454
                if (m_file->setFrameV2(frame)) {
1478
 
                        m_file->markTag2Changed();
 
1455
                        m_file->markTag2Changed(frame.getType());
1479
1456
                }
1480
1457
        }
1481
1458
        return result;
1529
1506
                if (edit) {
1530
1507
                        if (!editFrame(m_frame)) {
1531
1508
                                m_file->deleteFrameV2(m_frame);
1532
 
                                m_file->markTag2Changed(false);
 
1509
                                m_file->markTag2Unchanged();
1533
1510
                                return false;
1534
1511
                        }
1535
1512
                }