1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 ***************************************************************************/
20 #include "viewextensionsfactory.h"
22 #include "dolphincontroller.h"
23 #include "dolphinsortfilterproxymodel.h"
24 #include "dolphinview.h"
25 #include "settings/dolphinsettings.h"
26 #include "tooltips/tooltipmanager.h"
28 #include "dolphin_generalsettings.h"
30 #include <kfilepreviewgenerator.h>
31 #include <QAbstractItemView>
33 ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView
* view
,
34 DolphinController
* controller
) :
36 m_controller(controller
),
40 if (DolphinSettings::instance().generalSettings()->showToolTips()) {
41 DolphinSortFilterProxyModel
* proxyModel
= static_cast<DolphinSortFilterProxyModel
*>(view
->model());
42 m_toolTipManager
= new ToolTipManager(view
, proxyModel
);
44 connect(controller
, SIGNAL(hideToolTip()),
45 m_toolTipManager
, SLOT(hideTip()));
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()));
58 ViewExtensionsFactory::~ViewExtensionsFactory()
62 void ViewExtensionsFactory::updateIcons()
64 m_previewGenerator
->updateIcons();
67 void ViewExtensionsFactory::cancelPreviews()
69 m_previewGenerator
->cancelPreviews();
72 void ViewExtensionsFactory::slotShowPreviewChanged()
74 const bool show
= m_controller
->dolphinView()->showPreview();
75 m_previewGenerator
->setPreviewShown(show
);
78 #include "viewextensionsfactory.moc"