added text to drag object pixmaps

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@12 b624d157-de02-0410-bad0-e51aec6abb33
master
tariq 19 years ago
parent b2ae2d1d17
commit c646a94f3c
  1. 18
      src/lib/GroupView.cpp
  2. 1
      src/lib/GroupView.h

@ -25,6 +25,12 @@
#include <QMouseEvent>
#include <QApplication>
#include <QFont>
#include <QFontMetrics>
#include <QSize>
#include <QPixmap>
#include <QPainter>
#include <QPen>
#include <QBrush>
#include "main.h"
#include "GroupView.h"
@ -94,10 +100,20 @@ void KeepassGroupView::mouseMoveEvent(QMouseEvent *event){
GroupViewItem* item=(GroupViewItem*)itemAt(DragStartPos);
if(!item)return;
QDrag *drag = new QDrag(this);
QFontMetrics fontmet(item->font(0));
int DragPixmHeight=16;
if(fontmet.height()>16)DragPixmHeight=fontmet.height();
DragPixmap = QPixmap(fontmet.width(item->text(0))+19,DragPixmHeight);
DragPixmap.fill(QColor(255,255,255));
QPainter painter(&DragPixmap);
painter.setPen(QColor(0,0,0));
painter.setFont(item->font(0));
painter.drawPixmap(0,0,item->icon(0).pixmap());
painter.drawText(19,DragPixmHeight-fontmet.strikeOutPos(),item->text(0));
QMimeData *mimeData = new QMimeData;
mimeData->setData("keepass/group",QByteArray((char*)&(item->pGroup),sizeof(void*)));
drag->setMimeData(mimeData);
drag->setPixmap(item->icon(0).pixmap());
drag->setPixmap(DragPixmap);
drag->start();

@ -42,6 +42,7 @@ protected:
private:
QPoint DragStartPos;
QPixmap DragPixmap;
GroupViewItem* LastHoverItem;
GroupViewItem* getLastSameLevelItem(int level);
};