]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/zoomlevelinfo.cpp
d64974d2944404f5335b2e99e8e76ac180ad657a
[dolphin.git] / src / views / zoomlevelinfo.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
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 "zoomlevelinfo.h"
21
22 #include <KIconLoader>
23
24 #include <QSize>
25
26 int ZoomLevelInfo::minimumLevel()
27 {
28 return 0;
29 }
30
31 int ZoomLevelInfo::maximumLevel()
32 {
33 return 16;
34 }
35
36 int ZoomLevelInfo::iconSizeForZoomLevel(int level)
37 {
38 int size = KIconLoader::SizeMedium;
39 switch (level) {
40 case 0: size = KIconLoader::SizeSmall; break;
41 case 1: size = KIconLoader::SizeSmallMedium; break;
42 case 2: size = KIconLoader::SizeMedium; break;
43 case 3: size = KIconLoader::SizeLarge; break;
44 case 4: size = KIconLoader::SizeHuge; break;
45 default: size = KIconLoader::SizeHuge + ((level - 4) << 4);
46 }
47 return size;
48 }
49
50 int ZoomLevelInfo::zoomLevelForIconSize(const QSize& size)
51 {
52 int level = 0;
53 switch (size.height()) {
54 case KIconLoader::SizeSmall: level = 0; break;
55 case KIconLoader::SizeSmallMedium: level = 1; break;
56 case KIconLoader::SizeMedium: level = 2; break;
57 case KIconLoader::SizeLarge: level = 3; break;
58 case KIconLoader::SizeHuge: level = 4; break;
59 default: level = 4 + ((size.height() - KIconLoader::SizeHuge) >> 4);
60 }
61 return level;
62 }