Import of original sources
[qcomicbook-oblomov] / src / thumbnailswin.cpp
1 /*
2  * This file is a part of QComicBook.
3  *
4  * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
5  *
6  * QComicBook is free software; you can redestribute it and/or modify it
7  * under terms of GNU General Public License by Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY. See GPL for more details.
11  */
12
13 #include "thumbnailswin.h"
14 #include "thumbnailsview.h"
15 #include "thumbnailloader.h"
16 #include "thumbnail.h"
17 #include "thumbnailevent.h"
18
19 using namespace QComicBook;
20
21 ThumbnailsWindow::ThumbnailsWindow(Place p, QWidget *parent): QDockWindow(p, parent)
22 {
23         setCaption(tr("Thumbnails"));
24         setResizeEnabled(true);
25         setCloseMode(QDockWindow::Always);
26
27         tview = new ThumbnailsView(this);
28         setWidget(tview);
29         connect(tview, SIGNAL(requestedPage(int, bool)), this, SIGNAL(requestedPage(int, bool)));
30         connect(this, SIGNAL(orientationChanged(Orientation)), this, SLOT(onOrientationChanged(Orientation)));
31 }
32
33 ThumbnailsWindow::~ThumbnailsWindow()
34 {
35 }
36
37 void ThumbnailsWindow::customEvent(QCustomEvent *e)
38 {
39         if (e->type() == ThumbnailReady)
40         {
41                 ThumbnailEvent *evt = dynamic_cast<ThumbnailEvent *>(e);
42                 tview->setPage(*evt->getThumbnail());
43         }
44         else
45                 QDockWindow::customEvent(e);
46 }
47
48 void ThumbnailsWindow::onOrientationChanged(Orientation o)
49 {
50         tview->setArrangement(o == Qt::Horizontal ? QIconView::TopToBottom : QIconView::LeftToRight);
51 }
52
53 ThumbnailsView* ThumbnailsWindow::view() const
54 {
55         return tview;
56 }
57