22 #include "lineedit.moc"
25 #include <kabc/vcarddrag.h>
27 #include <kcalutils/icaldrag.h>
29 #include <kcal/icaldrag.h>
33 #include <kurlcompletion.h>
38 #include <QDragEnterEvent>
40 #include <QFocusEvent>
53 mSetCursorAtEnd(false)
62 mSetCursorAtEnd(false)
71 setCompletionMode(KGlobalSettings::CompletionShell);
72 KUrlCompletion* comp =
new KUrlCompletion(KUrlCompletion::FileCompletion);
73 comp->setReplaceHome(
true);
74 setCompletionObject(comp);
75 setAutoDeleteCompletionObject(
true);
78 setCompletionMode(KGlobalSettings::CompletionNone);
87 QFocusEvent newe(QEvent::FocusIn, (mNoSelect ? Qt::OtherFocusReason : e->reason()));
88 KLineEdit::focusInEvent(&newe);
101 KLineEdit::setText(text);
102 setCursorPosition(mSetCursorAtEnd ? text.length() : 0);
116 ok = (data->hasText()
130 QStringList newEmails;
132 KABC::Addressee::List addrList;
139 if (mailList.count())
142 newText = mailList.first().from();
144 setText(mailList.first().subject());
152 for (KABC::Addressee::List::Iterator it = addrList.begin(); it != addrList.end(); ++it)
154 QString em((*it).fullEmail());
156 newEmails.append(em);
166 setText(files.first().prettyUrl());
171 QString mailto = QLatin1String(
"mailto");
172 for (KUrl::List::Iterator it = files.begin(); it != files.end(); ++it)
174 if ((*it).protocol() == mailto)
175 newEmails.append((*it).path());
180 newText = files.first().prettyUrl();
184 else if (data->hasText())
187 QString txt = data->text();
191 QString mailto = QLatin1String(
"mailto:");
192 newEmails = txt.split(QRegExp(QLatin1String(
"[\r\n]+")), QString::SkipEmptyParts);
193 for (QStringList::Iterator it = newEmails.begin(); it != newEmails.end(); ++it)
195 if ((*it).startsWith(mailto))
204 int newline = txt.indexOf(QLatin1Char(
'\n'));
205 newText = (newline >= 0) ? txt.left(newline) : txt;
209 if (newEmails.count())
211 newText = newEmails.join(QLatin1String(
","));
212 int c = cursorPosition();
214 newText.prepend(QLatin1String(
","));
215 if (c < static_cast<int>(
text().length()))
216 newText.append(QLatin1String(
","));
218 if (!newText.isEmpty())
Type
Types of drag and drop content which will be accepted.
virtual void setText(const QString &str)
Sets the contents of the line edit to be str.
virtual QByteArray text(quint32 serialNumber) const =0
QString text() const
Return the entered text.
static MailList fromMimeData(const QMimeData *md)
static bool canDecode(const QMimeData *md)
virtual void dropEvent(QDropEvent *)
virtual void focusInEvent(QFocusEvent *)
virtual void dragEnterEvent(QDragEnterEvent *)
LineEdit(Type type, QWidget *parent=0)
Constructor.