]> cloud.milkyroute.net Git - dolphin.git/blob - src/viewextensionsfactory.cpp
Move code for initializing and handling view extensions to the new class ViewExtensio...
[dolphin.git] / src / viewextensionsfactory.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "viewextensionsfactory.h"
21
22 #include "dolphincontroller.h"
23 #include "dolphinsortfilterproxymodel.h"
24 #include "dolphinview.h"
25 #include "settings/dolphinsettings.h"
26 #include "tooltips/tooltipmanager.h"
27
28 #include "dolphin_generalsettings.h"
29
30 #include <kfilepreviewgenerator.h>
31 #include <QAbstractItemView>
32
33 ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
34 DolphinController* controller) :
35 QObject(view),
36 m_controller(controller),
37 m_toolTipManager(0),
38 m_previewGenerator(0)
39 {
40 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
41 DolphinSortFilterProxyModel* proxyModel = static_cast<DolphinSortFilterProxyModel*>(view->model());
42 m_toolTipManager = new ToolTipManager(view, proxyModel);
43
44 connect(controller, SIGNAL(hideToolTip()),
45 m_toolTipManager, SLOT(hideTip()));
46 }
47
48 m_previewGenerator = new KFilePreviewGenerator(view);
49 m_previewGenerator->setPreviewShown(controller->dolphinView()->showPreview());
50 connect(controller, SIGNAL(zoomLevelChanged(int)),
51 this, SLOT(updateIcons()));
52 connect(controller, SIGNAL(cancelPreviews()),
53 this, SLOT(cancelPreviews()));
54 connect(controller->dolphinView(), SIGNAL(showPreviewChanged()),
55 this, SLOT(slotShowPreviewChanged()));
56 }
57
58 ViewExtensionsFactory::~ViewExtensionsFactory()
59 {
60 }
61
62 void ViewExtensionsFactory::updateIcons()
63 {
64 m_previewGenerator->updateIcons();
65 }
66
67 void ViewExtensionsFactory::cancelPreviews()
68 {
69 m_previewGenerator->cancelPreviews();
70 }
71
72 void ViewExtensionsFactory::slotShowPreviewChanged()
73 {
74 const bool show = m_controller->dolphinView()->showPreview();
75 m_previewGenerator->setPreviewShown(show);
76 }
77
78 #include "viewextensionsfactory.moc"
79