3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #define DEBUG_KP_THUMBNAIL 0
32 #include <kpThumbnail.h>
41 #include <kpDocument.h>
42 #include <kpMainWindow.h>
43 #include <kpThumbnailView.h>
47 struct kpThumbnailPrivate
49 kpMainWindow
*mainWindow
;
50 kpThumbnailView
*view
;
54 kpThumbnail::kpThumbnail (kpMainWindow
*parent
)
55 : kpSubWindow (parent
),
56 d (new kpThumbnailPrivate ())
60 d
->mainWindow
= parent
;
62 d
->lay
= new QHBoxLayout (this);
65 setMinimumSize (64, 64);
71 kpThumbnail::~kpThumbnail ()
78 kpThumbnailView
*kpThumbnail::view () const
84 void kpThumbnail::setView (kpThumbnailView
*view
)
86 #if DEBUG_KP_THUMBNAIL
87 kDebug () << "kpThumbnail::setView(" << view
<< ")";
96 disconnect (d
->view
, SIGNAL (destroyed ()),
97 this, SLOT (slotViewDestroyed ()));
98 disconnect (d
->view
, SIGNAL (zoomLevelChanged (int, int)),
99 this, SLOT (updateCaption ()));
101 d
->lay
->removeWidget (d
->view
);
108 connect (d
->view
, SIGNAL (destroyed ()),
109 this, SLOT (slotViewDestroyed ()));
110 connect (d
->view
, SIGNAL (zoomLevelChanged (int, int)),
111 this, SLOT (updateCaption ()));
113 Q_ASSERT (d
->view
->parent () == this);
114 d
->lay
->addWidget (d
->view
, Qt::AlignCenter
);
124 void kpThumbnail::updateCaption ()
126 setWindowTitle (view () ? view ()->caption () : i18n ("Thumbnail"));
131 void kpThumbnail::slotViewDestroyed ()
133 #if DEBUG_KP_THUMBNAIL
134 kDebug () << "kpThumbnail::slotViewDestroyed()";
142 // protected virtual [base QWidget]
143 void kpThumbnail::resizeEvent (QResizeEvent
*e
)
145 #if DEBUG_KP_THUMBNAIL
146 kDebug () << "kpThumbnail::resizeEvent(" << width ()
147 << "," << height () << ")" << endl
;
150 QWidget::resizeEvent (e
);
152 // updateVariableZoom (); TODO: is below a good idea since this commented out?
156 d
->mainWindow
->notifyThumbnailGeometryChanged ();
158 if (d
->mainWindow
->tool ())
159 d
->mainWindow
->tool ()->somethingBelowTheCursorChanged ();
163 // protected virtual [base QWidget]
164 void kpThumbnail::moveEvent (QMoveEvent
* /*e*/)
167 d
->mainWindow
->notifyThumbnailGeometryChanged ();
170 // protected virtual [base QWidget]
171 void kpThumbnail::closeEvent (QCloseEvent
*e
)
173 QWidget::closeEvent (e
);
175 emit
windowClosed ();
179 #include <kpThumbnail.moc>