Column handles (but not yet the columns themselves) are now movable
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 24 Jul 2008 23:05:10 +0000 (01:05 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 2 Aug 2008 13:17:10 +0000 (15:17 +0200)
src/qtui/chatscene.cpp
src/qtui/chatscene.h
src/qtui/chatview.cpp
src/qtui/columnhandleitem.cpp
src/qtui/columnhandleitem.h

index d7ad76a..bcf3c93 100644 (file)
@@ -98,15 +98,3 @@ void ChatScene::rectChanged(const QRectF &rect) {
   firstColHandle->sceneRectChanged(rect);
   secondColHandle->sceneRectChanged(rect);
 }
   firstColHandle->sceneRectChanged(rect);
   secondColHandle->sceneRectChanged(rect);
 }
-
-void ChatScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
-  /*
-  qDebug() << "recv" << mouseEvent->scenePos();
-  ChatLine *line = static_cast<ChatLine*>(itemAt(mouseEvent->scenePos()));
-  ChatItem *item = static_cast<ChatItem*>(itemAt(mouseEvent->scenePos()));
-  qDebug() << (void*)line << (void*)item;
-  if(line) {
-    line->myMousePressEvent(mouseEvent);
-  } else  QGraphicsScene::mousePressEvent(mouseEvent);
-  */
-}
index daabba7..9d8a565 100644 (file)
@@ -53,7 +53,6 @@ class ChatScene : public QGraphicsScene {
 
   protected slots:
     void rowsInserted(const QModelIndex &, int, int);
 
   protected slots:
     void rowsInserted(const QModelIndex &, int, int);
-    void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
 
   private:
     qreal _width, _height;
 
   private:
     qreal _width, _height;
index eeaaf56..cc06e6a 100644 (file)
@@ -31,9 +31,6 @@
 
 ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), AbstractChatView() {
   setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
 ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), AbstractChatView() {
   setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  setOptimizationFlags(QGraphicsView::DontClipPainter
-      |QGraphicsView::DontSavePainterState
-      |QGraphicsView::DontAdjustForAntialiasing);
   setAlignment(Qt::AlignBottom);
   setInteractive(true);
 
   setAlignment(Qt::AlignBottom);
   setInteractive(true);
 
index 16cec89..3b84f57 100644 (file)
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
 
+#include <QCursor>
 #include <QGraphicsScene>
 #include <QPainter>
 
 #include <QGraphicsScene>
 #include <QPainter>
 
+#include <QDebug>
+
 #include "columnhandleitem.h"
 
 ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) : QGraphicsItem(parent) {
   _width = w;
 #include "columnhandleitem.h"
 
 ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) : QGraphicsItem(parent) {
   _width = w;
-
+  setZValue(10);
+  setCursor(QCursor(Qt::OpenHandCursor));
+  setFlag(ItemIsMovable);
 }
 
 void ColumnHandleItem::setXPos(qreal xpos) {
 }
 
 void ColumnHandleItem::setXPos(qreal xpos) {
@@ -37,6 +42,21 @@ void ColumnHandleItem::sceneRectChanged(const QRectF &rect) {
     prepareGeometryChange();
 }
 
     prepareGeometryChange();
 }
 
+void ColumnHandleItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+
+  QGraphicsItem::mouseMoveEvent(event);
+}
+
+void ColumnHandleItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { qDebug() << "pressed!";
+  setCursor(QCursor(Qt::ClosedHandCursor));
+  QGraphicsItem::mousePressEvent(event);
+}
+
+void ColumnHandleItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
+  setCursor(QCursor(Qt::OpenHandCursor));
+  QGraphicsItem::mouseReleaseEvent(event);
+}
+
 void ColumnHandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
   Q_UNUSED(option);
   Q_UNUSED(widget);
 void ColumnHandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
   Q_UNUSED(option);
   Q_UNUSED(widget);
index 81c411e..3bfe5ba 100644 (file)
@@ -32,7 +32,10 @@ class ColumnHandleItem : public QGraphicsItem {
     inline QRectF boundingRect() const;
     void setXPos(qreal xpos);
 
     inline QRectF boundingRect() const;
     void setXPos(qreal xpos);
 
-    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+    void mousePressEvent(QGraphicsSceneMouseEvent *event);
+    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
 
     void sceneRectChanged(const QRectF &);
 
 
     void sceneRectChanged(const QRectF &);