summaryrefslogtreecommitdiffstats
path: root/kalarm/lib/lineedit.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kalarm/lib/lineedit.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kalarm/lib/lineedit.h')
-rw-r--r--kalarm/lib/lineedit.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/kalarm/lib/lineedit.h b/kalarm/lib/lineedit.h
new file mode 100644
index 000000000..57f8378ee
--- /dev/null
+++ b/kalarm/lib/lineedit.h
@@ -0,0 +1,94 @@
+/*
+ * lineedit.h - line edit widget with extra drag and drop options
+ * Program: kalarm
+ * Copyright (C) 2003 - 2005 by David Jarvie <software@astrojar.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef LINEEDIT_H
+#define LINEEDIT_H
+
+#include <klineedit.h>
+
+
+/**
+ * @short Line edit widget with extra drag and drop options.
+ *
+ * The LineEdit class is a line edit widget which accepts specified types of drag and
+ * drop content.
+ *
+ * The widget will always accept drag and drop of text, except text/calendar mime type,
+ * and of URLs. It will accept additional mime types depending on its configuration:
+ * Text type accepts email address lists.
+ * Email type accepts email address lists and VCard data (e.g. from KAddressBook).
+ *
+ * The class also provides an option to prevent its contents being selected when the
+ * widget receives focus.
+ *
+ * @author David Jarvie <software@astrojar.org.uk>
+ */
+class LineEdit : public KLineEdit
+{
+ Q_OBJECT
+ public:
+ /** Types of drag and drop content which will be accepted.
+ * @li Text - the line edit contains general text. It accepts text, a URL
+ * or an email from KMail (the subject line is used). If multiple
+ * URLs or emails are dropped, only the first is used; the
+ * rest are ignored.
+ * @li Url - the line edit contains a URL. It accepts text or a URL. If
+ * multiple URLs are dropped, only the first URL is used; the
+ * rest are ignored.
+ * @li Emails - the line edit contains email addresses. It accepts text,
+ * mailto: URLs, emails from KMail (the From address is used)
+ * or vcard data (e.g. from KAddressBook). If multiple emails
+ * are dropped, only the first is used; the rest are ignored.
+ *
+ */
+ enum Type { Text, Url, Emails };
+ /** Constructor.
+ * @param type The content type for the line edit.
+ * @param parent The parent object of this widget.
+ * @param name The name of this widget.
+ */
+ explicit LineEdit(Type type, QWidget* parent = 0, const char* name = 0);
+ /** Constructs a line edit whose content type is Text.
+ * @param parent The parent object of this widget.
+ * @param name The name of this widget.
+ */
+ explicit LineEdit(QWidget* parent = 0, const char* name = 0);
+ /** Prevents the line edit's contents being selected when the widget receives focus. */
+ void setNoSelect() { mNoSelect = true; }
+ /** Sets whether the cursor should be set at the beginning or end of the text when
+ * setText() is called.
+ */
+ void setCursorAtEnd(bool end = true) { mSetCursorAtEnd = end; }
+ public slots:
+ /** Sets the contents of the line edit to be @p str. */
+ virtual void setText(const QString& str);
+ protected:
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dropEvent(QDropEvent*);
+ private:
+ void init();
+
+ Type mType;
+ bool mNoSelect;
+ bool mSetCursorAtEnd; // setText() should position cursor at end
+};
+
+#endif // LINEEDIT_H