File indexing completed on 2024-05-12 05:46:54

0001 /*
0002  * This file is part of the proxy model test suite.
0003  *
0004  * Copyright 2009  Stephen Kelly <steveire@gmail.com>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0019  * 02110-1301  USA
0020  */
0021 
0022 #include "proxymodeltestwidget.h"
0023 
0024 #include <QSplitter>
0025 #include <QTreeView>
0026 #include <QPushButton>
0027 #include <QVBoxLayout>
0028 
0029 #include "modelcommander.h"
0030 #include "dynamictreemodel.h"
0031 #include "kselectionproxymodel.h"
0032 #if 0
0033 #include "kdescendantsproxymodel.h"
0034 #endif
0035 #include "modelcommanderwidget.h"
0036 
0037 ProxyModelTestWidget::ProxyModelTestWidget(QWidget *parent, Qt::WindowFlags f)
0038     : QWidget(parent, f)
0039 {
0040     QVBoxLayout *layout = new QVBoxLayout(this);
0041     QSplitter *splitter = new QSplitter(this);
0042 
0043     m_rootModel = new DynamicTreeModel(this);
0044 
0045     (void) new ModelCommanderWidget(m_rootModel, splitter);
0046 
0047     QTreeView *rootModelView = new QTreeView(splitter);
0048     rootModelView->setModel(m_rootModel);
0049     rootModelView->setSelectionMode(QTreeView::ExtendedSelection);
0050 
0051     KSelectionProxyModel *selProxyModel = new KSelectionProxyModel(rootModelView->selectionModel(), this);
0052     selProxyModel->setSourceModel(m_rootModel);
0053     selProxyModel->setFilterBehavior(KSelectionProxyModel::ChildrenOfExactSelection);
0054 
0055     QTreeView *selModelView = new QTreeView(splitter);
0056     selModelView->setModel(selProxyModel);
0057 
0058 #if 0
0059     KDescendantsProxyModel *descProxyModel = new KDescendantsProxyModel(this);
0060     descProxyModel->setSourceModel(m_rootModel);
0061     QTreeView *descProxyModelView = new QTreeView(splitter);
0062     descProxyModelView ->setModel(descProxyModel);
0063 #endif
0064 
0065     // Your Proxy Here?
0066 
0067     layout->addWidget(splitter);
0068 
0069 }