summaryrefslogtreecommitdiffstats
path: root/src/kerrylabel.cpp
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2013-07-27 16:34:45 +0200
committerSlávek Banko <[email protected]>2013-07-27 16:34:45 +0200
commitd76ff81b7c1beffef0b84e570914c8f2d47834e6 (patch)
tree284b80ce7c5456fbb041f7979ac2c0baeead8902 /src/kerrylabel.cpp
downloadtork-d76ff81b7c1beffef0b84e570914c8f2d47834e6.tar.gz
tork-d76ff81b7c1beffef0b84e570914c8f2d47834e6.zip
Initial import of tork 0.33
Diffstat (limited to 'src/kerrylabel.cpp')
-rw-r--r--src/kerrylabel.cpp109
1 files changed, 109 insertions, 0 deletions
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 <[email protected]>
+ Copyright (C) 2000 Peter Putzer <[email protected]>
+ Copyright (C) 2005 Jaroslaw Staniek <[email protected]>
+
+ 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 <qdragobject.h>
+#include <kglobalsettings.h>
+#include <kurl.h>
+#include <krun.h>
+/*
+#include <konq_popupmenu.h>
+#include <konqbookmarkmanager.h>
+#include <knewmenu.h>
+*/
+
+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"