make sure to attach to the document also when a resize event is received prior of...
[kdegraphics.git] / kolourpaint / views / kpThumbnailView.cpp
blob6713cd0b3b4cb5b15436c6dc7ee00e0f42b8f6c3
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
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_VIEW 0
32 #include <kpThumbnailView.h>
34 #include <kdebug.h>
37 kpThumbnailView::kpThumbnailView (kpDocument *document,
38 kpToolToolBar *toolToolBar,
39 kpViewManager *viewManager,
40 kpView *buddyView,
41 kpViewScrollableContainer *scrollableContainer,
42 QWidget *parent)
44 : kpView (document, toolToolBar, viewManager,
45 buddyView,
46 scrollableContainer,
47 parent)
51 kpThumbnailView::~kpThumbnailView ()
56 // protected
57 void kpThumbnailView::setMaskToCoverDocument ()
59 #if DEBUG_KP_THUMBNAIL_VIEW
60 kDebug () << "kpThumbnailView::setMaskToCoverDocument()"
61 << " origin=" << origin ()
62 << " zoomedDoc: width=" << zoomedDocWidth ()
63 << " height=" << zoomedDocHeight ()
64 << endl;
65 #endif
67 setMask (QRegion (QRect (origin ().x (), origin ().y (),
68 zoomedDocWidth (), zoomedDocHeight ())));
72 // protected virtual [base kpView]
73 void kpThumbnailView::resizeEvent (QResizeEvent *e)
75 #if DEBUG_KP_THUMBNAIL_VIEW
76 kDebug () << "kpThumbnailView(" << name () << ")::resizeEvent()"
77 << endl;
78 #endif
80 // For QResizeEvent's, Qt already throws an entire widget repaint into
81 // the event loop. So eat useless update() calls that can only slow
82 // things down.
83 // TODO: this doesn't seem to work.
84 // Later: In Qt4, setUpdatesEnabled(true) calls update().
85 const bool oldIsUpdatesEnabled = updatesEnabled ();
86 setUpdatesEnabled (false);
89 kpView::resizeEvent (e);
91 adjustToEnvironment ();
94 setUpdatesEnabled (oldIsUpdatesEnabled);
98 #include <kpThumbnailView.moc>