- Topics are now editable even when they were empty
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 12 Mar 2008 00:22:12 +0000 (00:22 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 12 Mar 2008 00:22:12 +0000 (00:22 +0000)
- TopicWidget reverts to regular mode when inputline loses focus
- TopicWidget behaves now as a view while introducing a new abstract item view

17 files changed:
src/client/buffermodel.cpp
src/client/buffermodel.h
src/client/client.pri
src/qtui/bufferwidget.cpp
src/qtui/bufferwidget.h
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
src/qtui/mainwin.cpp
src/qtui/nicklistwidget.cpp
src/qtui/nicklistwidget.h
src/qtui/topicbutton.cpp
src/qtui/topicwidget.cpp
src/qtui/topicwidget.h
src/uisupport/abstractitemview.cpp [new file with mode: 0644]
src/uisupport/abstractitemview.h [new file with mode: 0644]
src/uisupport/uisupport.pri
version.inc

index 3426632..52d6d54 100644 (file)
 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);
 }
index db8049d..0be559a 100644 (file)
@@ -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<QItemSelectionModel *>(&_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
index cf6586c..46ddc54 100644 (file)
@@ -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
index 51c551c..d46fdec 100644 (file)
@@ -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()) {
index 40413b3..089d498 100644 (file)
@@ -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 <QItemSelectionModel>
 
 //! 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 &current, 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<BufferId, ChatWidget *> _chatWidgets;
   QHash<BufferId, ChatView *> _chatViews;
 
-  QPointer<BufferModel> _bufferModel;
-  QPointer<QItemSelectionModel> _selectionModel;
-
   BufferId _currentBuffer;
 };
 
index d6f0aad..0c66767 100644 (file)
 
 
 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 &current, const QModelIndex &previous) {
   Q_UNUSED(previous);
 
@@ -84,7 +64,7 @@ void InputWidget::currentChanged(const QModelIndex &current, 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<bool>());
   }
index 141105f..371d429 100644 (file)
 #define INPUTWIDGET_H
 
 #include "ui_inputwidget.h"
-#include <QPointer>
-#include <QItemSelectionModel>
 
+#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 &current, 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> _bufferModel;
-  QPointer<QItemSelectionModel> _selectionModel;
   NetworkId _networkId;
   IdentityId _identityId;
 
index 5c3e73f..4c89e8e 100644 (file)
@@ -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);
 
index 4cfd5b6..714731a 100644 (file)
 #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 &current, const QModelIndex &previous) {
   BufferInfo::Type bufferType = (BufferInfo::Type)current.data(NetworkModel::BufferTypeRole).toInt();
   BufferId newBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
index 1fca5e0..8c26605 100644 (file)
 #define _NICKLISTWIDGET_H_
 
 #include "ui_nicklistwidget.h"
+#include "abstractitemview.h"
+
 #include "types.h"
 
 #include <QHash>
 
-#include <QPointer>
-#include <QItemSelectionModel>
-
 #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 &current, 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<BufferId, NickView *> nickViews;
-
-  QPointer<BufferModel> _bufferModel;
-  QPointer<QItemSelectionModel> _selectionModel;
 };
 
 #endif
index a83779e..a31c69d 100644 (file)
@@ -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);
 }
index 511d275..f5e6c9e 100644 (file)
@@ -23,7 +23,7 @@
 #include <QDebug>
 
 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 &current, 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;
   }
   
index c1bae92..95ceadf 100644 (file)
 #ifndef _TOPICWIDGET_H_
 #define _TOPICWIDGET_H_
 
-#include <QWidget>
+#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 &current, 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 (file)
index 0000000..dd6760e
--- /dev/null
@@ -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 (file)
index 0000000..bffc35b
--- /dev/null
@@ -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 <QWidget>
+#include <QAbstractItemModel>
+#include <QItemSelectionModel>
+#include <QModelIndex>
+#include <QItemSelection>
+#include <QAbstractItemDelegate>
+#include <QPointer>
+
+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<QAbstractItemModel> _model;
+  QPointer<QItemSelectionModel> _selectionModel;
+};
+
+#endif // ABSTRACTITEMVIEW_H
index 6e68378..496382b 100644 (file)
@@ -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 = 
 
index a83d253..dc19cb6 100644 (file)
@@ -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;