-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::setCustomFont(const QVariant &v) {
+ QFont font = v.value<QFont>();
+ if(font.family().isEmpty())
+ font = QApplication::font();
+ setFont(font);
+}
+
+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)) {
+ QCoreApplication::postEvent(this, new ExpandAllEvent);
+ }
+}
+
+void NickView::setRootIndex(const QModelIndex &index) {
+ QAbstractItemView::setRootIndex(index);
+ if(index.isValid())
+ QCoreApplication::postEvent(this, new ExpandAllEvent);
+}
+
+QModelIndexList NickView::selectedIndexes() const {
+ QModelIndexList indexList = QTreeView::selectedIndexes();
+
+ // make sure the item we clicked on is first
+ if(indexList.contains(currentIndex())) {
+ indexList.removeAll(currentIndex());
+ indexList.prepend(currentIndex());
+ }
+
+ return indexList;