00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file logheaderview.cpp 00024 * \version $Id: messagelog.cpp 797 2006-05-09 04:42:35Z edmanm $ 00025 * \brief Header for the message log QTreeView 00026 */ 00027 00028 #include "logheaderview.h" 00029 #include "logtreewidget.h" 00030 00031 00032 /* Column indices */ 00033 #define COL_TIME LogTreeWidget::TimeColumn 00034 #define COL_TYPE LogTreeWidget::TypeColumn 00035 #define COL_MESG LogTreeWidget::MessageColumn 00036 00037 /* Default column widths */ 00038 #define COL_TIME_WIDTH 135 00039 #define COL_TYPE_WIDTH 70 00040 00041 00042 /** Default constructor. */ 00043 LogHeaderView::LogHeaderView(QWidget *parent) 00044 : QHeaderView(Qt::Horizontal, parent) 00045 { 00046 } 00047 00048 /** Resets all column widths back to their defaults. */ 00049 void 00050 LogHeaderView::resetColumnWidths() 00051 { 00052 resizeSection(COL_TIME, COL_TIME_WIDTH); 00053 resizeSection(COL_TYPE, COL_TYPE_WIDTH); 00054 setStretchLastSection(true); 00055 } 00056 00057 00058 /** Resizes the column headers based on the longest message item. */ 00059 void 00060 LogHeaderView::resize(int hint) 00061 { 00062 int size = sectionSize(COL_MESG); 00063 if (hint > size) { 00064 /* The message is wider than the window, so expand the column */ 00065 setStretchLastSection(false); 00066 resizeSection(COL_MESG, hint); 00067 } else if (hint < size) { 00068 /* The message is short, so just stretch the last column to the end */ 00069 setStretchLastSection(true); 00070 } 00071 } 00072