[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kpovmodeler
From: Andreas Zehender <az () azweb ! de>
Date: 2007-03-04 13:27:35
Message-ID: 1173014855.135615.2155.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 639127 by azehende:
fixed crash when top level widget changes
fixed dragging (TODO: drag rectangle)
M +73 -50 pmdockwidget.cpp
M +29 -6 pmdockwidget.h
M +1 -0 pmdockwidget_private.cpp
M +2 -0 pmdockwidget_private.h
--- trunk/KDE/kdegraphics/kpovmodeler/pmdockwidget.cpp #639126:639127
@@ -114,6 +114,27 @@
"#...#",
"#####"};
+PMDockMain::PMDockMain(QWidget* parent)
+ : QWidget(parent)
+{
+ m_pTop = 0;
+}
+
+void PMDockMain::setTopWidget(QWidget* top)
+{
+ m_pTop = top;
+ if(m_pTop){
+ if(m_pTop->parent() != this) m_pTop->setParent(this);
+ m_pTop->setGeometry(QRect(QPoint(0,0),size()));
+ }
+}
+
+void PMDockMain::resizeEvent(QResizeEvent *rsize)
+{
+ QWidget::resizeEvent(rsize);
+ if(m_pTop) m_pTop->setGeometry(QRect(QPoint(0,0),size()));
+}
+
class PMDockMainWindowPrivate
{
public:
@@ -150,6 +171,9 @@
d = new PMDockMainWindowPrivate( );
PartBase::setPartObject( this );
+
+ m_pMain = new PMDockMain(this);
+ KMainWindow::setCentralWidget(m_pMain);
}
PMDockMainWindow::~PMDockMainWindow()
@@ -266,12 +290,7 @@
//if ( view->isA("PMDockWidget") ){
// if ( view->parent() != this ) ((PMDockWidget*)view)->applyToWidget( this );
//}
-
- QWidget* central = KMainWindow::centralWidget();
- if(central != view){
- if(central) central->setParent(0);
- KMainWindow::setCentralWidget(view);
- }
+ m_pMain->setTopWidget(view);
}
PMDockWidget* PMDockMainWindow::createDockWidget( const QPixmap &pixmap, QWidget* \
parent, const QString& strCaption, const QString& strTabPageLabel) @@ -575,8 +594,8 \
@@ setParent( s );
}
- if ( s && s->inherits("PMDockMainWindow") ){
- ((PMDockMainWindow*)s)->setView( this );
+ if ( s && s->inherits("PMDockMain") ){
+ ((PMDockMain*)s)->setTopWidget( this );
}
if ( s == manager->main ){
@@ -1218,6 +1237,31 @@
if(manager == obj) manager = 0;
}
+void PMDockWidget::drawDragRectangle(const QRect& r){
+ // TODO use transparent overlay widget
+ d->drawRectangle = true;
+ d->rect = r;
+ bool clipped = testAttribute(Qt::WA_PaintUnclipped);
+ setAttribute( Qt::WA_PaintUnclipped );
+ repaint();
+ setAttribute( Qt::WA_PaintUnclipped, clipped );
+}
+
+void PMDockWidget::paintEvent( QPaintEvent* ev){
+ if(d->drawRectangle){
+ QPainter paint;
+ if(paint.begin( this )){
+ paint.setCompositionMode(QPainter::CompositionMode_Xor);
+ // draw the rectangle
+ paint.drawRect(d->rect.x(), d->rect.y(), d->rect.width(), d->rect.height());
+ paint.end();
+ }
+ d->drawRectangle = false;
+ } else {
+ QWidget::paintEvent( ev );
+ }
+}
+
/**************************************************************************************/
class PMDockManager::PMDockManagerPrivate
@@ -1249,6 +1293,7 @@
bool splitterOpaqueResize;
bool splitterKeepSize;
bool splitterHighResolution;
+ MouseButton button;
};
PMDockManager::PMDockManager( QWidget* mainWindow )
@@ -1268,6 +1313,7 @@
d->splitterOpaqueResize = false;
d->splitterKeepSize = false;
d->splitterHighResolution = false;
+ d->readyToDrag = false;
main->installEventFilter( this );
@@ -1358,6 +1404,7 @@
d->dragRect.moveTopLeft(p);
drawDragRectangle();
d->readyToDrag = true;
+ d->button = ((QMouseEvent*)event)->button();
d->dragOffset = QCursor::pos()-currentDragWidget->mapToGlobal(QPoint(0,0));
}
@@ -1422,11 +1469,10 @@
} else {
if (d->readyToDrag) {
d->readyToDrag = false;
+ if ( curdw->eDocking != (int)PMDockWidget::DockNone) {
+ startDrag( curdw);
+ }
}
- if ( (((QMouseEvent*)event)->button() == Qt::LeftButton) &&
- (curdw->eDocking != (int)PMDockWidget::DockNone) ) {
- startDrag( curdw);
- }
}
break;
default:
@@ -1445,22 +1491,14 @@
if (currentDragWidget->eDocking == (int)PMDockWidget::DockNone ) return 0L;
- QWidget* p = QApplication::widgetAt( pos );
- if ( !p ) {
+ QWidget* w = QApplication::widgetAt( pos );
+ while(w && !w->inherits("PMDockWidget")) w = w->parentWidget();
+
+ if ( !w ) {
dropCancel = false;
return 0L;
}
-#if defined(_OS_WIN32_) || defined(Q_OS_WIN32)
- p = p->topLevelWidget();
-#endif
- QWidget* w = 0L;
- findChildDockWidget( w, p, p->mapFromGlobal(pos) );
- if ( !w ){
- if ( !p->inherits("PMDockWidget") ) {
- return 0L;
- }
- w = p;
- }
+
if ( findChild<PMDockSplitter*>("_dock_split_")) return 0L;
if ( findChild<PMDockTabGroup*>( "_dock_tab" )) return 0L;
@@ -1774,6 +1812,8 @@
if (d->oldDragRect == d->dragRect)
return;
+ // TODO fixme
+ /*
int i;
QRect oldAndNewDragRect[2];
oldAndNewDragRect[0] = d->oldDragRect;
@@ -1784,32 +1824,15 @@
if (oldAndNewDragRect[i].isEmpty())
continue;
- PMDockWidget* pDockWdgAtRect = (PMDockWidget*) QApplication::widgetAt( \
oldAndNewDragRect[i].topLeft() );
- if (!pDockWdgAtRect)
- continue;
-
- bool isOverMainWdg = false;
- PMDockMainWindow* pMain = 0L;
- PMDockWidget* pTLDockWdg = 0L;
- QWidget* topWdg;
- if (pDockWdgAtRect->topLevelWidget() == main) {
- isOverMainWdg = true;
- topWdg = pMain = (PMDockMainWindow*) main;
- }
- else {
- topWdg = pTLDockWdg = (PMDockWidget*) pDockWdgAtRect->topLevelWidget();
- }
-
- // draw the rectangle unclipped over the main dock window
- QPainter p;
- if(p.begin( topWdg )){;
- // draw the rectangle
- QRect r = oldAndNewDragRect[i];
- r.moveTopLeft( r.topLeft() - topWdg->mapToGlobal(QPoint(0,0)) );
- p.drawRect(r.x(), r.y(), r.width(), r.height());
- p.end();
- }
+ QWidget* w = (PMDockWidget*) QApplication::widgetAt( \
oldAndNewDragRect[i].topLeft() ); + while(w && !w->inherits("PMDockWidget")) w = \
w->parentWidget(); + if(!w) continue;
+
+ QRect r = oldAndNewDragRect[i];
+ r.moveTopLeft( r.topLeft() - w->mapToGlobal(QPoint(0,0)) );
+ ((PMDockWidget*)w)->drawDragRectangle(r);
}
+ */
// memorize the current rectangle for later removing
d->oldDragRect = d->dragRect;
--- trunk/KDE/kdegraphics/kpovmodeler/pmdockwidget.h #639126:639127
@@ -91,6 +91,18 @@
class KToolBar;
class KConfig;
+class PMDockMain : public QWidget
+{
+ Q_OBJECT
+public:
+ PMDockMain(QWidget* parent);
+ void setTopWidget(QWidget* top);
+public:
+ virtual void resizeEvent(QResizeEvent *);
+private:
+ QWidget* m_pTop;
+};
+
/**
* An abstract base clase for all dockwidget headers (and member of the dockwidget \
class set).
* See the class description of @ref PMDockWidgetHeader!
@@ -587,12 +599,22 @@
* Return the current dock position of the widget
*/
DockPosition getDockPosition( ) const { return currentDockPos; }
- public slots:
- /**
- * Docks a dockwidget back to the dockwidget that was the neighbor
- widget before the current dock position.
- */
- void dockBack();
+ /**
+ * Paints the drag rectangle
+ */
+ void drawDragRectangle(const QRect& r);
+protected:
+ /**
+ * Draws the drag panel (a double line)
+ */
+ virtual void paintEvent( QPaintEvent* );
+
+public slots:
+ /**
+ * Docks a dockwidget back to the dockwidget that was the neighbor
+ * widget before the current dock position.
+ */
+ void dockBack();
/**
* Toggles the visibility state of the dockwidget if it is able to be shown or to \
be hidden. @@ -1290,6 +1312,7 @@
private:
PMDockMainWindowPrivate *d;
+ PMDockMain* m_pMain;
};
--- trunk/KDE/kdegraphics/kpovmodeler/pmdockwidget_private.cpp #639126:639127
@@ -359,6 +359,7 @@
_parent = 0L;
transient = false;
+ drawRectangle = false;
}
PMDockWidgetPrivate::~PMDockWidgetPrivate()
--- trunk/KDE/kdegraphics/kpovmodeler/pmdockwidget_private.h #639126:639127
@@ -141,6 +141,8 @@
QWidget *_parent;
bool transient;
+ bool drawRectangle;
+ QRect rect;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic