From d76ff81b7c1beffef0b84e570914c8f2d47834e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 27 Jul 2013 16:34:45 +0200 Subject: Initial import of tork 0.33 --- src/kerrylabel.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/kerrylabel.cpp (limited to 'src/kerrylabel.cpp') diff --git a/src/kerrylabel.cpp b/src/kerrylabel.cpp new file mode 100644 index 0000000..4169138 --- /dev/null +++ b/src/kerrylabel.cpp @@ -0,0 +1,109 @@ +/* This file is part of the KDE libraries + Copyright (C) 1998 Kurt Granroth + Copyright (C) 2000 Peter Putzer + Copyright (C) 2005 Jaroslaw Staniek + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kerrylabel.h" +#include "hitwidget.h" + +#include +#include +#include +#include +/* +#include +#include +#include +*/ + +KerryLabel::KerryLabel (QWidget* parent, const char* name) + : KURLLabel (parent, name) +{ + dragInfo.state = diNone; +} + +void KerryLabel::mousePressEvent(QMouseEvent* ev) +{ + if (!url().isEmpty()) + { + if ( ev->button() == LeftButton) + { + dragInfo.state = diPending; + dragInfo.start = ev->pos(); + } + else if (ev->button() == RightButton) + { + ev->accept(); + //popupMenu( mapToGlobal(ev->pos()) ); + return; + } + } + KURLLabel::mousePressEvent(ev); +} + +void KerryLabel::mouseMoveEvent(QMouseEvent* ev) +{ + if (dragInfo.state == diPending) { + int distance = KGlobalSettings::dndEventDelay(); + if ( ev->x() > dragInfo.start.x() + distance || ev->x() < dragInfo.start.x() - distance || + ev->y() > dragInfo.start.y() + distance || ev->y() < dragInfo.start.y() - distance) { + doDrag(); + } + return; + } + KURLLabel::mouseMoveEvent(ev); +} + +void KerryLabel::mouseReleaseEvent(QMouseEvent* ev) +{ + if ( ev->button() == LeftButton) + { + dragInfo.state = diNone; + } + KURLLabel::mouseReleaseEvent(ev); +} + +void KerryLabel::doDrag() +{ + dragInfo.state = diDragging; + const KURL kuri = KURL(url()); + dragInfo.dragObject = new QTextDrag("'"+kuri.url().replace("file://",QString::null)+"'", this); + dragInfo.dragObject->dragCopy(); + // Don't delete the QTextDrag object. Qt will delete it when it's done with it. +} + +// void KerryLabel::popupMenu( const QPoint &_global ) +// { +// KFileItem item( ((HitWidget*)parent())->uri(),((HitWidget*)parent())->mimetype(),KFileItem::Unknown); +// KFileItemList _items; +// _items.append( &item ); +// +// const KURL kurl(url()); +// KActionCollection act(this); +// +// KonqPopupMenu * popupMenu = new KonqPopupMenu( KonqBookmarkManager::self(), _items, +// kurl, act, (KNewMenu*)NULL, this, +// item.isLocalFile() ? KonqPopupMenu::ShowProperties : KonqPopupMenu::NoFlags, +// KParts::BrowserExtension::DefaultPopupItems ); +// +// if (popupMenu->count()) +// popupMenu->exec( _global ); +// delete popupMenu; +// } + +#include "kerrylabel.moc" -- cgit v1.2.1