From: Marcus Eggenberger Date: Wed, 12 Mar 2008 00:22:12 +0000 (+0000) Subject: - Topics are now editable even when they were empty X-Git-Tag: 0.2.0-alpha3~11 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=1b2d3ea62867220d7bffc3b23dda1dc14d429007 - Topics are now editable even when they were empty - TopicWidget reverts to regular mode when inputline loses focus - TopicWidget behaves now as a view while introducing a new abstract item view --- diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 34266321..52d6d54c 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -28,13 +28,10 @@ BufferModel::BufferModel(NetworkModel *parent) : QSortFilterProxyModel(parent), _selectionModelSynchronizer(this), - _propertyMapper(this) + _standardSelectionModel(this) { setSourceModel(parent); - - // initialize the Property Mapper - _propertyMapper.setModel(this); - _selectionModelSynchronizer.addRegularSelectionModel(_propertyMapper.selectionModel()); + _selectionModelSynchronizer.addRegularSelectionModel(standardSelectionModel()); } BufferModel::~BufferModel() { @@ -63,15 +60,11 @@ void BufferModel::synchronizeView(QAbstractItemView *view) { view->setSelectionModel(mappedSelectionModel); } -void BufferModel::mapProperty(int column, int role, QObject *target, const QByteArray &property) { - _propertyMapper.addMapping(column, role, target, property); -} - QModelIndex BufferModel::currentIndex() { - return propertyMapper()->selectionModel()->currentIndex(); + return standardSelectionModel()->currentIndex(); } void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) { - standardSelectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - standardSelectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect); + _standardSelectionModel.setCurrentIndex(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + _standardSelectionModel.select(newCurrent, QItemSelectionModel::ClearAndSelect); } diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index db8049d3..0be559aa 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -26,7 +26,6 @@ #include "types.h" #include "selectionmodelsynchronizer.h" -#include "modelpropertymapper.h" class NetworkModel; class MappedSelectionModel; @@ -42,19 +41,17 @@ public: bool filterAcceptsRow(int sourceRow, const QModelIndex &parent) const; inline const SelectionModelSynchronizer *selectionModelSynchronizer() const { return &_selectionModelSynchronizer; } - inline const ModelPropertyMapper *propertyMapper() const { return &_propertyMapper; } - inline QItemSelectionModel *standardSelectionModel() const { return _propertyMapper.selectionModel(); } - + inline QItemSelectionModel *standardSelectionModel() const { return const_cast(&_standardSelectionModel); } + void synchronizeSelectionModel(MappedSelectionModel *selectionModel); void synchronizeView(QAbstractItemView *view); - void mapProperty(int column, int role, QObject *target, const QByteArray &property); QModelIndex currentIndex(); void setCurrentIndex(const QModelIndex &newCurrent); private: SelectionModelSynchronizer _selectionModelSynchronizer; - ModelPropertyMapper _propertyMapper; + QItemSelectionModel _standardSelectionModel; }; #endif // BUFFERMODEL_H diff --git a/src/client/client.pri b/src/client/client.pri index cf6586c8..46ddc54f 100644 --- a/src/client/client.pri +++ b/src/client/client.pri @@ -1,6 +1,6 @@ DEPMOD = common QT_MOD = core network gui SRCS += buffer.cpp buffersettings.cpp treemodel.cpp networkmodel.cpp buffermodel.cpp client.cpp clientsettings.cpp clientsyncer.cpp \ - mappedselectionmodel.cpp modelpropertymapper.cpp selectionmodelsynchronizer.cpp + mappedselectionmodel.cpp selectionmodelsynchronizer.cpp HDRS += buffer.h buffersettings.h treemodel.h networkmodel.h buffermodel.h client.h clientsettings.h clientsyncer.h quasselui.h \ - mappedselectionmodel.h modelpropertymapper.h selectionmodelsynchronizer.h + mappedselectionmodel.h selectionmodelsynchronizer.h diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 51c551c3..d46fdec5 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -32,9 +32,7 @@ #include "global.h" BufferWidget::BufferWidget(QWidget *parent) - : QWidget(parent), - _bufferModel(0), - _selectionModel(0), + : AbstractItemView(parent), _currentBuffer(0) { ui.setupUi(this); @@ -46,30 +44,6 @@ BufferWidget::~BufferWidget() { void BufferWidget::init() { } -void BufferWidget::setModel(BufferModel *bufferModel) { - if(_bufferModel) { - disconnect(_bufferModel, 0, this, 0); - } - _bufferModel = bufferModel; - - if(bufferModel) { - connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); - } -} - -void BufferWidget::setSelectionModel(QItemSelectionModel *selectionModel) { - if(_selectionModel) { - disconnect(_selectionModel, 0, this, 0); - } - _selectionModel = selectionModel; - - if(selectionModel) { - connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); - } -} - void BufferWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { Q_ASSERT(model()); if(!parent.isValid()) { diff --git a/src/qtui/bufferwidget.h b/src/qtui/bufferwidget.h index 40413b37..089d498a 100644 --- a/src/qtui/bufferwidget.h +++ b/src/qtui/bufferwidget.h @@ -23,6 +23,7 @@ #include "ui_bufferwidget.h" +#include "abstractitemview.h" #include "chatview.h" #include "types.h" @@ -31,12 +32,11 @@ class ChatView; class ChatWidget; #include "buffermodel.h" -#include //! Displays the contents of a Buffer. /** */ -class BufferWidget : public QWidget { +class BufferWidget : public AbstractItemView { Q_OBJECT public: @@ -44,23 +44,11 @@ public: virtual ~BufferWidget(); void init(); - inline BufferModel *model() { return _bufferModel; } - void setModel(BufferModel *bufferModel); - - inline QItemSelectionModel *selectionModel() const { return _selectionModel; } - void setSelectionModel(QItemSelectionModel *selectionModel); - inline BufferId currentBuffer() const { return _currentBuffer; } protected slots: -// virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); -// virtual void commitData(QWidget *editor); virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); -// virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); -// virtual void editorDestroyed(QObject *editor); virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); -// virtual void rowsInserted(const QModelIndex &parent, int start, int end); -// virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); private slots: void removeBuffer(BufferId bufferId); @@ -71,9 +59,6 @@ private: QHash _chatWidgets; QHash _chatViews; - QPointer _bufferModel; - QPointer _selectionModel; - BufferId _currentBuffer; }; diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index d6f0aad6..0c667678 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -27,10 +27,8 @@ InputWidget::InputWidget(QWidget *parent) - : QWidget(parent), - validBuffer(false), - _bufferModel(0), - _selectionModel(0) + : AbstractItemView(parent), + validBuffer(false) { ui.setupUi(this); connect(ui.inputEdit, SIGNAL(sendText(QString)), this, SLOT(sendText(QString))); @@ -45,24 +43,6 @@ InputWidget::InputWidget(QWidget *parent) InputWidget::~InputWidget() { } -void InputWidget::setModel(BufferModel *bufferModel) { - if(_bufferModel) { - disconnect(_bufferModel, 0, this, 0); - } - _bufferModel = bufferModel; - connect(bufferModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), - this, SLOT(dataChanged(QModelIndex, QModelIndex))); -} - -void InputWidget::setSelectionModel(QItemSelectionModel *selectionModel) { - if(_selectionModel) { - disconnect(_selectionModel, 0, this, 0); - } - _selectionModel = selectionModel; - connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); -} - void InputWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { Q_UNUSED(previous); @@ -84,7 +64,7 @@ void InputWidget::currentChanged(const QModelIndex ¤t, const QModelIndex & void InputWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { QItemSelectionRange changedArea(topLeft, bottomRight); - QModelIndex currentIndex = Client::bufferModel()->currentIndex(); + QModelIndex currentIndex = selectionModel()->currentIndex(); if(changedArea.contains(currentIndex)) { ui.inputEdit->setEnabled(currentIndex.data(NetworkModel::ItemActiveRole).value()); } diff --git a/src/qtui/inputwidget.h b/src/qtui/inputwidget.h index 141105fe..371d4292 100644 --- a/src/qtui/inputwidget.h +++ b/src/qtui/inputwidget.h @@ -22,38 +22,25 @@ #define INPUTWIDGET_H #include "ui_inputwidget.h" -#include -#include +#include "abstractitemview.h" #include "buffermodel.h" #include "bufferinfo.h" #include "identity.h" #include "network.h" -class InputWidget : public QWidget { +class InputWidget : public AbstractItemView { Q_OBJECT public: InputWidget(QWidget *parent = 0); virtual ~InputWidget(); - inline BufferModel *model() { return _bufferModel; } - void setModel(BufferModel *bufferModel); - - inline QItemSelectionModel *selectionModel() const { return _selectionModel; } - void setSelectionModel(QItemSelectionModel *selectionModel); - const Network *currentNetwork() const; protected slots: -// virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); -// virtual void commitData(QWidget *editor); virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); -// virtual void editorDestroyed(QObject *editor); -// virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); -// virtual void rowsInserted(const QModelIndex &parent, int start, int end); -// virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); private slots: void sendText(QString text); @@ -72,8 +59,6 @@ private: bool validBuffer; BufferInfo currentBufferInfo; - QPointer _bufferModel; - QPointer _selectionModel; NetworkId _networkId; IdentityId _identityId; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 5c3e73f1..4c89e8e2 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -114,7 +114,7 @@ void MainWin::init() { // attach the BufferWidget to the BufferModel and the default selection ui.bufferWidget->setModel(Client::bufferModel()); ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); - + if(Global::SPUTDEV) { //showSettingsDlg(); //showAboutDlg(); @@ -206,8 +206,6 @@ void MainWin::setupNickWidget() { // attach the NickListWidget to the BufferModel and the default selection nickListWidget->setModel(Client::bufferModel()); nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); - - Client::bufferModel()->mapProperty(0, NetworkModel::BufferIdRole, nickListWidget, "currentBuffer"); } void MainWin::setupChatMonitor() { @@ -262,7 +260,8 @@ void MainWin::setupTopicWidget() { dock->setWidget(topicwidget); - Client::bufferModel()->mapProperty(1, Qt::DisplayRole, topicwidget, "topic"); + topicwidget->setModel(Client::bufferModel()); + topicwidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); addDockWidget(Qt::TopDockWidgetArea, dock); diff --git a/src/qtui/nicklistwidget.cpp b/src/qtui/nicklistwidget.cpp index 4cfd5b68..714731a9 100644 --- a/src/qtui/nicklistwidget.cpp +++ b/src/qtui/nicklistwidget.cpp @@ -28,39 +28,11 @@ #include "nickviewfilter.h" NickListWidget::NickListWidget(QWidget *parent) - : QWidget(parent), - _bufferModel(0), - _selectionModel(0) + : AbstractItemView(parent) { ui.setupUi(this); } -void NickListWidget::setModel(BufferModel *bufferModel) { - if(_bufferModel) { - disconnect(_bufferModel, 0, this, 0); - } - - _bufferModel = bufferModel; - - if(bufferModel) { - connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); - } -} - -void NickListWidget::setSelectionModel(QItemSelectionModel *selectionModel) { - if(_selectionModel) { - disconnect(_selectionModel, 0, this, 0); - } - - _selectionModel = selectionModel; - - if(selectionModel) { - connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); - } -} - void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { BufferInfo::Type bufferType = (BufferInfo::Type)current.data(NetworkModel::BufferTypeRole).toInt(); BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value(); diff --git a/src/qtui/nicklistwidget.h b/src/qtui/nicklistwidget.h index 1fca5e0b..8c266052 100644 --- a/src/qtui/nicklistwidget.h +++ b/src/qtui/nicklistwidget.h @@ -22,42 +22,29 @@ #define _NICKLISTWIDGET_H_ #include "ui_nicklistwidget.h" +#include "abstractitemview.h" + #include "types.h" #include -#include -#include - #include "buffermodel.h" class Buffer; class NickView; -class NickListWidget : public QWidget { +class NickListWidget : public AbstractItemView { Q_OBJECT public: NickListWidget(QWidget *parent = 0); - inline BufferModel *model() { return _bufferModel; } - void setModel(BufferModel *bufferModel); - - inline QItemSelectionModel *selectionModel() const { return _selectionModel; } - void setSelectionModel(QItemSelectionModel *selectionModel); - protected: virtual QSize sizeHint() const; protected slots: -// virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); -// virtual void commitData(QWidget *editor); virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); -// virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); -// virtual void editorDestroyed(QObject *editor); virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); -// virtual void rowsInserted(const QModelIndex &parent, int start, int end); -// virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); private slots: void removeBuffer(BufferId bufferId); @@ -65,9 +52,6 @@ private slots: private: Ui::NickListWidget ui; QHash nickViews; - - QPointer _bufferModel; - QPointer _selectionModel; }; #endif diff --git a/src/qtui/topicbutton.cpp b/src/qtui/topicbutton.cpp index a83779ea..a31c69de 100644 --- a/src/qtui/topicbutton.cpp +++ b/src/qtui/topicbutton.cpp @@ -35,6 +35,7 @@ TopicButton::TopicButton(QWidget *parent) : QAbstractButton(parent) { + setFixedHeight(QFontMetrics(qApp->font()).height()); } void TopicButton::paintEvent(QPaintEvent *event) { @@ -59,6 +60,7 @@ void TopicButton::paintEvent(QPaintEvent *event) { void TopicButton::setAndStyleText(const QString &text) { if(QAbstractButton::text() == text) return; + setText(text); // this triggers a repaint event styledText = QtUi::style()->styleString(Message::mircToInternal(text)); @@ -66,5 +68,10 @@ void TopicButton::setAndStyleText(const QString &text) { foreach(QTextLayout::FormatRange fr, styledText.formats) { height = qMax(height, QFontMetrics(fr.format.font()).height()); } + + // ensure the button is editable (height != 1) if there is no text to show + if(text.isEmpty()) + height = QFontMetrics(qApp->font()).height(); + setFixedHeight(height); } diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 511d2752..f5e6c9e1 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -23,7 +23,7 @@ #include TopicWidget::TopicWidget(QWidget *parent) - : QWidget(parent) + : AbstractItemView(parent) { ui.setupUi(this); ui.topicLineEdit->hide(); @@ -31,6 +31,23 @@ TopicWidget::TopicWidget(QWidget *parent) ui.topicButton->show(); } +void TopicWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { + Q_UNUSED(previous); + setTopicForIndex(current); +} + +void TopicWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + QItemSelectionRange changedArea(topLeft, bottomRight); + QModelIndex currentIndex = selectionModel()->currentIndex(); + if(changedArea.contains(currentIndex)) + setTopicForIndex(currentIndex); +}; + +void TopicWidget::setTopicForIndex(const QModelIndex &index) { + QModelIndex topicIndex = index.sibling(index.row(), 1); + setTopic(topicIndex.data().toString()); +} + void TopicWidget::setTopic(const QString &newtopic) { if(_topic == newtopic) return; @@ -42,8 +59,8 @@ void TopicWidget::setTopic(const QString &newtopic) { } void TopicWidget::on_topicLineEdit_returnPressed() { + emit topicChanged(ui.topicLineEdit->text()); switchPlain(); - emit topicChanged(topic()); } void TopicWidget::on_topicButton_clicked() { @@ -59,9 +76,16 @@ void TopicWidget::switchEditable() { void TopicWidget::switchPlain() { ui.topicLineEdit->hide(); ui.topicButton->show(); + ui.topicLineEdit->setText(_topic); } +// filter for the input widget to switch back to normal mode bool TopicWidget::eventFilter(QObject *obj, QEvent *event) { + if(event->type() == QEvent::FocusOut) { + switchPlain(); + return true; + } + if(event->type() != QEvent::KeyPress) return QObject::eventFilter(obj, event); @@ -69,7 +93,6 @@ bool TopicWidget::eventFilter(QObject *obj, QEvent *event) { if(keyEvent->key() == Qt::Key_Escape) { switchPlain(); - ui.topicLineEdit->setText(_topic); return true; } diff --git a/src/qtui/topicwidget.h b/src/qtui/topicwidget.h index c1bae921..95ceadfc 100644 --- a/src/qtui/topicwidget.h +++ b/src/qtui/topicwidget.h @@ -21,25 +21,28 @@ #ifndef _TOPICWIDGET_H_ #define _TOPICWIDGET_H_ -#include +#include "abstractitemview.h" #include "ui_topicwidget.h" -class TopicWidget : public QWidget { +class TopicWidget : public AbstractItemView { Q_OBJECT - Q_PROPERTY(QString topic READ topic WRITE setTopic STORED false) public: TopicWidget(QWidget *parent = 0); - inline QString topic() const { return ui.topicLineEdit->text(); } void setTopic(const QString &newtopic); + void setTopicForIndex(const QModelIndex &index); virtual bool eventFilter(QObject *obj, QEvent *event); signals: void topicChanged(const QString &text); - + +protected slots: + virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + private slots: void on_topicLineEdit_returnPressed(); void on_topicButton_clicked(); diff --git a/src/uisupport/abstractitemview.cpp b/src/uisupport/abstractitemview.cpp new file mode 100644 index 00000000..dd6760e6 --- /dev/null +++ b/src/uisupport/abstractitemview.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "abstractitemview.h" + +AbstractItemView::AbstractItemView(QWidget *parent) + : QWidget(parent), + _model(0), + _selectionModel(0) +{ +} + +void AbstractItemView::setModel(QAbstractItemModel *model) { + if(_model) { + disconnect(_model, 0, this, 0); + } + _model = model; + connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), + this, SLOT(dataChanged(QModelIndex, QModelIndex))); + connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); + connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), + this, SLOT(rowsInserted(QModelIndex, int, int))); +} + + + +void AbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) { + if(_selectionModel) { + disconnect(_selectionModel, 0, this, 0); + } + _selectionModel = selectionModel; + connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + this, SLOT(currentChanged(QModelIndex, QModelIndex))); + connect(selectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + this, SLOT(selectionChanged(QItemSelection, QItemSelection))); +} + diff --git a/src/uisupport/abstractitemview.h b/src/uisupport/abstractitemview.h new file mode 100644 index 00000000..bffc35b0 --- /dev/null +++ b/src/uisupport/abstractitemview.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef ABSTRACTITEMVIEW_H +#define ABSTRACTITEMVIEW_H + +#include +#include +#include +#include +#include +#include +#include + +class AbstractItemView : public QWidget { + Q_OBJECT + +public: + AbstractItemView(QWidget *parent = 0); + + inline QAbstractItemModel *model() { return _model; } + void setModel(QAbstractItemModel *model); + + inline QItemSelectionModel *selectionModel() const { return _selectionModel; } + void setSelectionModel(QItemSelectionModel *selectionModel); + +protected slots: + virtual void closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint) {}; + virtual void commitData(QWidget *) {}; + virtual void currentChanged(const QModelIndex &, const QModelIndex &) {}; + virtual void dataChanged(const QModelIndex &, const QModelIndex &) {}; + virtual void editorDestroyed(QObject *) {}; + virtual void rowsAboutToBeRemoved(const QModelIndex &, int, int) {}; + virtual void rowsInserted(const QModelIndex &, int, int) {}; + virtual void selectionChanged(const QItemSelection &, const QItemSelection &) {}; + +protected: + QPointer _model; + QPointer _selectionModel; +}; + +#endif // ABSTRACTITEMVIEW_H diff --git a/src/uisupport/uisupport.pri b/src/uisupport/uisupport.pri index 6e68378b..496382ba 100644 --- a/src/uisupport/uisupport.pri +++ b/src/uisupport/uisupport.pri @@ -1,8 +1,8 @@ DEPMOD = common client QT_MOD = core gui network -SRCS += bufferview.cpp bufferviewfilter.cpp colorbutton.cpp nickviewfilter.cpp inputline.cpp nickview.cpp settingspage.cpp tabcompleter.cpp uisettings.cpp uistyle.cpp uistylesettings.cpp -HDRS += bufferview.h bufferviewfilter.h colorbutton.h nickviewfilter.h inputline.h nickview.h settingspage.h tabcompleter.h uisettings.h uistyle.h uistylesettings.h +SRCS += abstractitemview.cpp bufferview.cpp bufferviewfilter.cpp colorbutton.cpp nickviewfilter.cpp inputline.cpp nickview.cpp settingspage.cpp tabcompleter.cpp uisettings.cpp uistyle.cpp uistylesettings.cpp +HDRS += abstractitemview.h bufferview.h bufferviewfilter.h colorbutton.h nickviewfilter.h inputline.h nickview.h settingspage.h tabcompleter.h uisettings.h uistyle.h uistylesettings.h FORMNAMES = diff --git a/version.inc b/version.inc index a83d2538..dc19cb6a 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-alpha3-pre"; - quasselDate = "2008-03-11"; - quasselBuild = 628; + quasselDate = "2008-03-12"; + quasselBuild = 630; //! Minimum client build number the core needs clientBuildNeeded = 628;