2012-02-16 13:26 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp
  * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.h
    * Changed: dragging operation starting off mouse move event
       instead of mouse press event.
This commit is contained in:
Pritpal Bedi
2012-02-16 21:28:27 +00:00
parent 01678880fb
commit d0c8b8a3fc
3 changed files with 36 additions and 19 deletions

View File

@@ -16,6 +16,12 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-02-16 13:26 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp
* contrib/hbqt/qtgui/hbqt_hbqplaintextedit.h
* Changed: dragging operation starting off mouse move event
instead of mouse press event.
2012-02-16 19:27 UTC+0100 Viktor Szakats (harbour syenar.net)
* INSTALL
* minor to prev

View File

@@ -129,6 +129,7 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent
isCodeCompletionActive = true;
isCompletionTipsActive = true;
isInDrag = false;
dragStartPosition = QPoint();
#if 0
QTextFrameFormat format( this->document()->rootFrame()->frameFormat() );
@@ -979,27 +980,9 @@ void HBQPlainTextEdit::mousePressEvent( QMouseEvent *event )
QTextCursor c( cursorForPosition( event->pos() ) );
int row = c.blockNumber();
if( row >= rowBegins && row <= rowEnds )
{
event->ignore();
QDrag * qDrag = new QDrag( this );
QMimeData * qMimeData = new QMimeData();
hbCopy();
qMimeData->setText( QApplication::clipboard()->text() );
qDrag->setMimeData( qMimeData );
QPixmap pmap = QPixmap::grabWidget( this->viewport(), hbGetSelectionRect() );
pmap.setMask( pmap.createMaskFromColor( m_selectionColor, Qt::MaskInColor ) );
pmap.setMask( pmap.createMaskFromColor( palette().color( QPalette::Base ), Qt::MaskInColor ) );
pmap.setMask( pmap.createMaskFromColor( m_currentLineColor, Qt::MaskInColor ) );
qDrag->setPixmap( pmap );
qDrag->setHotSpot( QPoint( 5,5 ) );
qDrag->exec( Qt::MoveAction | Qt::CopyAction );
delete qDrag;
return;
dragStartPosition = event->pos();
}
else
{
@@ -1065,6 +1048,33 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event )
if( event->buttons() & Qt::LeftButton )
{
if( ( event->pos() - dragStartPosition ).manhattanLength() < QApplication::startDragDistance() )
{
QTextCursor c( cursorForPosition( event->pos() ) );
int row = c.blockNumber();
if( row >= rowBegins && row <= rowEnds )
{
event->ignore();
QDrag * qDrag = new QDrag( this );
QMimeData * qMimeData = new QMimeData();
hbCopy();
qMimeData->setText( QApplication::clipboard()->text() );
qDrag->setMimeData( qMimeData );
QPixmap pmap = QPixmap::grabWidget( this->viewport(), hbGetSelectionRect() );
pmap.setMask( pmap.createMaskFromColor( m_selectionColor, Qt::MaskInColor ) );
pmap.setMask( pmap.createMaskFromColor( palette().color( QPalette::Base ), Qt::MaskInColor ) );
pmap.setMask( pmap.createMaskFromColor( m_currentLineColor, Qt::MaskInColor ) );
qDrag->setPixmap( pmap );
qDrag->setHotSpot( QPoint( 5,5 ) );
qDrag->exec( Qt::MoveAction | Qt::CopyAction );
delete qDrag;
return;
}
}
if( selectionState == 1 )
{
selectionState = 2;

View File

@@ -175,6 +175,7 @@ private:
bool isCodeCompletionActive;
bool isCompletionTipsActive;
bool isInDrag;
QPoint dragStartPosition;
protected:
bool event( QEvent * event );