• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

util

focusedtreeview.cpp

00001 /*
00002    This library is free software; you can redistribute it and/or
00003    modify it under the terms of the GNU Library General Public
00004    License version 2 as published by the Free Software Foundation.
00005 
00006    This library is distributed in the hope that it will be useful,
00007    but WITHOUT ANY WARRANTY; without even the implied warranty of
00008    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00009    Library General Public License for more details.
00010 
00011    You should have received a copy of the GNU Library General Public License
00012    along with this library; see the file COPYING.LIB.  If not, write to
00013    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00014    Boston, MA 02110-1301, USA.
00015 */
00016 
00017 #include "focusedtreeview.h"
00018 #include <QScrollBar>
00019 
00020 namespace KDevelop {
00021     
00022 FocusedTreeView::FocusedTreeView(QWidget* parent) : QTreeView(parent) {
00023     setVerticalScrollMode(ScrollPerItem);
00024     connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(resizeColumnsToContents()));
00025 }
00026 
00027 int FocusedTreeView::sizeHintForColumn(int column) const {
00028     QModelIndex i = indexAt(QPoint(0, 0));
00029     if(i.isValid()) {
00030         QSize hint = sizeHintForIndex(i);
00031         int maxWidth = hint.width();
00032         if(hint.height()) {
00033             //Also consider one item above, because else we can get problems with
00034             //the vertical scroll-bar
00035             for(int a = -1; a < (height() / hint.height())+1; ++a) {
00036                 QModelIndex current = i.sibling(i.row()+a, column);
00037                 QSize tempHint = sizeHintForIndex(current);
00038                 if(tempHint.width() > maxWidth)
00039                     maxWidth = tempHint.width();
00040             }
00041         }
00042         return maxWidth;
00043     }
00044     return columnWidth(column);
00045 }
00046 
00047 void FocusedTreeView::resizeColumnsToContents() {
00048     for(int a = 0; a < model()->columnCount(); ++a)
00049         resizeColumnToContents(a);
00050 }
00051 
00052 void FocusedTreeView::rowsInserted(const QModelIndex& parent, int start, int end) {
00053     QTreeView::rowsInserted(parent, start, end);
00054     resizeColumnsToContents();
00055 }
00056 
00057 }
00058 
00059 #include "focusedtreeview.moc"

util

Skip menu "util"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal