X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=f1316953b9b234bd24e496131ab0c356b02880d2;hp=5ac201b9ef9dc23f1dc8fd9bab7670553086fcf7;hb=e2188dc438be6f3eb0d9cdf47d28821aefe9835e;hpb=5c4459d5df51a99bc6ee2e7389e3a7aec3f81091 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 5ac201b9..f1316953 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -56,7 +56,7 @@ BufferView::BufferView(QWidget *parent) setSelectionMode(QAbstractItemView::ExtendedSelection); QAbstractItemDelegate *oldDelegate = itemDelegate(); - BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this); + auto *tristateDelegate = new BufferViewDelegate(this); setItemDelegate(tristateDelegate); delete oldDelegate; } @@ -75,9 +75,7 @@ void BufferView::init() setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - // breaks with Qt 4.8 - if (QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10! - setAnimated(true); + setAnimated(true); // FIXME This is to workaround bug #663 setUniformRowHeights(true); @@ -141,7 +139,7 @@ void BufferView::setModel(QAbstractItemModel *model) void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config) { - BufferViewFilter *filter = qobject_cast(model()); + auto *filter = qobject_cast(model()); if (filter) { filter->setConfig(config); setConfig(config); @@ -149,15 +147,15 @@ void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig * } if (model()) { - disconnect(this, 0, model(), 0); - disconnect(model(), 0, this, 0); + disconnect(this, nullptr, model(), nullptr); + disconnect(model(), nullptr, this, nullptr); } if (!model_) { setModel(model_); } else { - BufferViewFilter *filter = new BufferViewFilter(model_, config); + auto *filter = new BufferViewFilter(model_, config); setModel(filter); connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged())); } @@ -171,7 +169,7 @@ void BufferView::setConfig(BufferViewConfig *config) return; if (_config) { - disconnect(_config, 0, this, 0); + disconnect(_config, nullptr, this, nullptr); } _config = config; @@ -264,7 +262,7 @@ void BufferView::dropEvent(QDropEvent *event) return TreeViewTouch::dropEvent(event); // Confirm that the user really wants to merge the buffers before doing so - int res = QMessageBox::question(0, tr("Merge buffers permanently?"), + int res = QMessageBox::question(nullptr, tr("Merge buffers permanently?"), tr("Do you want to merge the buffer \"%1\" permanently into buffer \"%2\"?\n This cannot be reversed!").arg(Client::networkModel()->bufferName(bufferId2)).arg(Client::networkModel()->bufferName(bufferId1)), QMessageBox::Yes|QMessageBox::No, QMessageBox::No); if (res == QMessageBox::Yes) { @@ -394,15 +392,9 @@ void BufferView::setExpandedState(const QModelIndex &networkIdx) storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state } -#if QT_VERSION < 0x050000 -void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) -{ - TreeViewTouch::dataChanged(topLeft, bottomRight); -#else void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { TreeViewTouch::dataChanged(topLeft, bottomRight, roles); -#endif // determine how many items have been changed and if any of them is a networkitem // which just swichted from active to inactive or vice versa @@ -418,7 +410,7 @@ void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bott void BufferView::toggleHeader(bool checked) { - QAction *action = qobject_cast(sender()); + auto *action = qobject_cast(sender()); header()->setSectionHidden((action->property("column")).toInt(), !checked); } @@ -455,7 +447,7 @@ void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index) void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index) { - BufferViewFilter *filter = qobject_cast(model()); + auto *filter = qobject_cast(model()); if (filter) { QList filterActions = filter->actions(index); if (!filterActions.isEmpty()) { @@ -594,9 +586,9 @@ void BufferView::hideCurrentBuffer() config()->requestRemoveBuffer(bufferId); } -void BufferView::filterTextChanged(QString filterString) +void BufferView::filterTextChanged(const QString& filterString) { - BufferViewFilter *filter = qobject_cast(model()); + auto *filter = qobject_cast(model()); if (!filter) { return; } @@ -624,15 +616,15 @@ QSize BufferView::sizeHint() const } -void BufferView::changeHighlight(const BufferView::Direction direction) +void BufferView::changeHighlight(BufferView::Direction direction) { // If for some weird reason we get a new delegate - BufferViewDelegate *delegate = qobject_cast(itemDelegate(m_currentHighlight)); + auto delegate = qobject_cast(itemDelegate(_currentHighlight)); if (delegate) { delegate->currentHighlight = QModelIndex(); } - QModelIndex newIndex = m_currentHighlight; + QModelIndex newIndex = _currentHighlight; if (!newIndex.isValid()) { newIndex = model()->index(0, 0); } @@ -647,20 +639,20 @@ void BufferView::changeHighlight(const BufferView::Direction direction) return; } - m_currentHighlight = newIndex; + _currentHighlight = newIndex; - delegate = qobject_cast(itemDelegate(m_currentHighlight)); + delegate = qobject_cast(itemDelegate(_currentHighlight)); if (delegate) { - delegate->currentHighlight = m_currentHighlight; + delegate->currentHighlight = _currentHighlight; } viewport()->update(); } void BufferView::selectHighlighted() { - if (m_currentHighlight.isValid()) { - selectionModel()->setCurrentIndex(m_currentHighlight, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - selectionModel()->select(m_currentHighlight, QItemSelectionModel::ClearAndSelect); + if (_currentHighlight.isValid()) { + selectionModel()->setCurrentIndex(_currentHighlight, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + selectionModel()->select(_currentHighlight, QItemSelectionModel::ClearAndSelect); } else { selectFirstBuffer(); } @@ -671,16 +663,16 @@ void BufferView::selectHighlighted() void BufferView::clearHighlight() { // If for some weird reason we get a new delegate - BufferViewDelegate *delegate = qobject_cast(itemDelegate(m_currentHighlight)); + auto delegate = qobject_cast(itemDelegate(_currentHighlight)); if (delegate) { delegate->currentHighlight = QModelIndex(); } - m_currentHighlight = QModelIndex(); + _currentHighlight = QModelIndex(); viewport()->update(); } // **************************************** -// BufferViewDelgate +// BufferViewDelegate // **************************************** class ColorsChangedEvent : public QEvent { @@ -716,20 +708,16 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c if (!value.isValid()) return QStyledItemDelegate::editorEvent(event, model, option, index); -#if QT_VERSION < 0x050000 - QStyleOptionViewItemV4 viewOpt(option); -#else QStyleOptionViewItem viewOpt(option); -#endif initStyleOption(&viewOpt, index); QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget); - QMouseEvent *me = static_cast(event); + auto *me = static_cast(event); if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos())) return QStyledItemDelegate::editorEvent(event, model, option, index); - Qt::CheckState state = static_cast(value.toInt()); + auto state = static_cast(value.toInt()); if (state == Qt::Unchecked) state = Qt::PartiallyChecked; else if (state == Qt::PartiallyChecked) @@ -746,7 +734,7 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c // ============================== BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent) : QDockWidget(parent), - _childWidget(0), + _childWidget(nullptr), _widget(new QWidget(parent)), _filterEdit(new QLineEdit(parent)), _active(false), @@ -776,7 +764,7 @@ BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent) void BufferViewDock::setLocked(bool locked) { if (locked) { - setFeatures(0); + setFeatures(nullptr); } else { setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); @@ -803,7 +791,7 @@ void BufferViewDock::onFilterReturnPressed() { if (_oldFocusItem) { _oldFocusItem->setFocus(); - _oldFocusItem = 0; + _oldFocusItem = nullptr; } if (!config()->showSearch()) { @@ -846,7 +834,7 @@ bool BufferViewDock::eventFilter(QObject *object, QEvent *event) return true; } } else if (event->type() == QEvent::KeyRelease) { - QKeyEvent *keyEvent = static_cast(event); + auto keyEvent = static_cast(event); BufferView *view = bufferView(); if (!view) { @@ -906,7 +894,7 @@ BufferViewConfig *BufferViewDock::config() const { BufferView *view = bufferView(); if (!view) - return 0; + return nullptr; else return view->config(); }