X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fnickview.cpp;h=78cb709be6c17099d5922cfdd3f5e350c219e192;hb=b68ffc844fc7504ecceeaa9348107ca5c249bd51;hp=7e30cb7c3d9d54e6a215624b369f65414923048a;hpb=923ab935b9e2936d2512ef9344811e9bb2f436f3;p=quassel.git diff --git a/src/uisupport/nickview.cpp b/src/uisupport/nickview.cpp index 7e30cb7c..78cb709b 100644 --- a/src/uisupport/nickview.cpp +++ b/src/uisupport/nickview.cpp @@ -30,7 +30,8 @@ NickView::NickView(QWidget *parent) - : QTreeView(parent) + : QTreeView(parent), + _sizeHint(QTreeView::sizeHint()) { setIndentation(10); setAnimated(true); @@ -41,7 +42,7 @@ NickView::NickView(QWidget *parent) setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(showContextMenu(const QPoint&))); + this, SLOT(showContextMenu(const QPoint&))); connect(this, SIGNAL(activated( const QModelIndex& )), this, SLOT(startQuery( const QModelIndex& ))); } @@ -57,6 +58,7 @@ void NickView::init() { setColumnHidden(i, true); expandAll(); + updateSizeHint(); } void NickView::setModel(QAbstractItemModel *model) { @@ -64,9 +66,21 @@ void NickView::setModel(QAbstractItemModel *model) { init(); } -void NickView::rowsInserted(const QModelIndex &index, int start, int end) { - QTreeView::rowsInserted(index, start, end); - expandAll(); // FIXME We need to do this more intelligently. Maybe a pimped TreeView? +void NickView::rowsInserted(const QModelIndex &parent, int start, int end) { + QTreeView::rowsInserted(parent, start, end); + if(model()->data(parent, NetworkModel::ItemTypeRole) == NetworkModel::UserCategoryItemType && !isExpanded(parent)) + expand(parent); + updateSizeHint(); +} + +void NickView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { + QTreeView::rowsAboutToBeRemoved(parent, start, end); + updateSizeHint(); +} + +void NickView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + QTreeView::dataChanged(topLeft, bottomRight); + updateSizeHint(); } QString NickView::nickFromModelIndex(const QModelIndex & index) { @@ -143,9 +157,9 @@ void NickView::executeCommand(const BufferInfo & bufferInfo, const QString & com Client::instance()->userInput(bufferInfo, command); } -QSize NickView::sizeHint() const { +void NickView::updateSizeHint() { if(!model()) - return QTreeView::sizeHint(); + return; int columnSize = 0; for(int i = 0; i < model()->columnCount(); i++) { @@ -153,5 +167,9 @@ QSize NickView::sizeHint() const { columnSize += sizeHintForColumn(i); } - return QSize(columnSize, 50); + _sizeHint = QSize(columnSize, 50); +} + +QSize NickView::sizeHint() const { + return _sizeHint; }