1
/***************************************************************************
2
* Copyright (C) 2009 by Rafael Fernández López <ereslibre@kde.org> *
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. *
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. *
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
***************************************************************************/
21
#include "CategorizedView.h"
23
#include "CategoryDrawer.h"
25
#include <KFileItemDelegate>
26
#include <QSortFilterProxyModel>
29
CategorizedView::CategorizedView(QWidget *parent)
30
: KCategorizedView(parent)
33
CategoryDrawer *drawer = new CategoryDrawer(this);
34
setCategoryDrawer(drawer);
37
void CategorizedView::setModel(QAbstractItemModel *model)
39
KCategorizedView::setModel(model);
40
// KFileItemDelegate *delegate = qobject_cast<KFileItemDelegate*>(itemDelegate());
41
// kDebug() << delegate->maximumSize();
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);
52
// kDebug() << maxWidth << maxHeight;
53
setGridSize(QSize(maxWidth, maxHeight ));
54
// delegate->setMaximumSize(QSize(maxWidth, maxHeight));