| 1 |
/* |
| 2 |
This file is part of Icecream. |
| 3 |
|
| 4 |
Copyright (c) 2004-2006 Andre Wöbbeking <[email protected]> |
| 5 |
Copyright (c) 2012 Kevin Funk <[email protected]> |
| 6 |
|
| 7 |
This program is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
| 9 |
the Free Software Foundation; either version 2 of the License, or |
| 10 |
(at your option) any later version. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License along |
| 18 |
with this program; if not, write to the Free Software Foundation, Inc., |
| 19 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "hostlistview.h" |
| 23 |
|
| 24 |
#include "models/hostlistmodel.h" |
| 25 |
|
| 26 |
#include <QHeaderView> |
| 27 |
|
| 28 |
HostListView::HostListView(QWidget *parent) |
| 29 |
: QTreeView(parent) |
| 30 |
{ |
| 31 |
setAllColumnsShowFocus(true); |
| 32 |
setRootIsDecorated(false); |
| 33 |
setSortingEnabled(true); |
| 34 |
setWindowTitle(tr("Hosts")); |
| 35 |
} |
| 36 |
|
| 37 |
void HostListView::setModel(QAbstractItemModel *model) |
| 38 |
{ |
| 39 |
QTreeView::setModel(model); |
| 40 |
if (model) { |
| 41 |
sortByColumn(HostListModel::ColumnID, Qt::AscendingOrder); |
| 42 |
header()->setStretchLastSection(false); |
| 43 |
header()->setSectionResizeMode(HostListModel::ColumnName, QHeaderView::Stretch); |
| 44 |
header()->setSectionResizeMode(HostListModel::ColumnColor, QHeaderView::ResizeToContents); |
| 45 |
header()->setSectionResizeMode(HostListModel::ColumnIP, QHeaderView::ResizeToContents); |
| 46 |
header()->setSectionResizeMode(HostListModel::ColumnPlatform, QHeaderView::ResizeToContents); |
| 47 |
} |
| 48 |
} |