~ubuntu-branches/debian/stretch/apper/stretch

« back to all changes in this revision

Viewing changes to libapper/CategorizedView.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klumpp
  • Date: 2011-10-06 17:54:49 UTC
  • Revision ID: package-import@ubuntu.com-20111006175449-mirjm0uszjmbj4tj
Tags: upstream-0.7.0
Import upstream version 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2009 by Rafael Fernández López <ereslibre@kde.org>    *
 
3
 *   dantti12@gmail.com                                                    *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "CategorizedView.h"
 
22
 
 
23
#include "CategoryDrawer.h"
 
24
 
 
25
#include <KFileItemDelegate>
 
26
#include <QSortFilterProxyModel>
 
27
#include <KDebug>
 
28
 
 
29
CategorizedView::CategorizedView(QWidget *parent)
 
30
    : KCategorizedView(parent)
 
31
{
 
32
    setWordWrap(true);
 
33
    CategoryDrawer *drawer = new CategoryDrawer(this);
 
34
    setCategoryDrawer(drawer);
 
35
}
 
36
 
 
37
void CategorizedView::setModel(QAbstractItemModel *model)
 
38
{
 
39
    KCategorizedView::setModel(model);
 
40
    //     KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate*>(itemDelegate());
 
41
//     kDebug() << delegate->maximumSize();
 
42
//     if (delegate) {
 
43
        int maxWidth = -1;
 
44
        int maxHeight = -1;
 
45
        for (int i = 0; i < model->rowCount(); ++i) {
 
46
            const QModelIndex index = model->index(i, modelColumn(), rootIndex());
 
47
            const QSize size = sizeHintForIndex(index);
 
48
            maxWidth = qMax(maxWidth, size.width());
 
49
            maxHeight = qMax(maxHeight, size.height());
 
50
//             kDebug() << size << index.data(Qt::DisplayRole);
 
51
        }
 
52
//          kDebug() << maxWidth << maxHeight;
 
53
        setGridSize(QSize(maxWidth, maxHeight ));
 
54
//         delegate->setMaximumSize(QSize(maxWidth, maxHeight));
 
55
// //     }
 
56
}