24 #include <tqdragobject.h>
27 #include <kurlcompletion.h>
29 #include <libtdepim/maillistdrag.h>
30 #include <libtdepim/kvcarddrag.h>
31 #include <libkcal/icaldrag.h>
33 #include "lineedit.moc"
43 : KLineEdit(parent, name),
46 mSetCursorAtEnd(false)
52 : KLineEdit(parent, name),
55 mSetCursorAtEnd(false)
64 setCompletionMode(TDEGlobalSettings::CompletionShell);
65 KURLCompletion* comp =
new KURLCompletion(KURLCompletion::FileCompletion);
66 comp->setReplaceHome(
true);
67 setCompletionObject(comp);
68 setAutoDeleteCompletionObject(
true);
71 setCompletionMode(TDEGlobalSettings::CompletionNone);
78 void LineEdit::focusInEvent(TQFocusEvent* e)
81 e->setReason(TQFocusEvent::Other);
82 KLineEdit::focusInEvent(e);
92 KLineEdit::setText(text);
93 setCursorPosition(mSetCursorAtEnd ? text.length() : 0);
96 void LineEdit::dragEnterEvent(TQDragEnterEvent* e)
98 if (KCal::ICalDrag::canDecode(e))
100 e->accept(TQTextDrag::canDecode(e)
101 || KURLDrag::canDecode(e)
102 || (mType != Url && KPIM::MailListDrag::canDecode(e))
106 void LineEdit::dropEvent(TQDropEvent* e)
109 TQStringList newEmails;
111 KPIM::MailList mailList;
113 TDEABC::Addressee::List addrList;
116 && e->provides(KPIM::MailListDrag::format())
117 && KPIM::MailListDrag::decode(e, mailList))
120 if (mailList.count())
123 newText = mailList.first().from();
125 setText(mailList.first().subject());
129 else if (mType == Emails
133 for (TDEABC::Addressee::List::Iterator it = addrList.begin(); it != addrList.end(); ++it)
135 TQString em((*it).fullEmail());
137 newEmails.append(em);
140 else if (KURLDrag::decode(e, files) && files.count())
147 setText(files.first().prettyURL());
152 TQString mailto = TQString::fromLatin1(
"mailto");
153 for (KURL::List::Iterator it = files.begin(); it != files.end(); ++it)
155 if ((*it).protocol() == mailto)
156 newEmails.append((*it).path());
161 newText = files.first().prettyURL();
165 else if (TQTextDrag::decode(e, txt))
171 TQString mailto = TQString::fromLatin1(
"mailto:");
172 newEmails = TQStringList::split(TQRegExp(
"[\r\n]+"), txt);
173 for (TQStringList::Iterator it = newEmails.begin(); it != newEmails.end(); ++it)
175 if ((*it).startsWith(mailto))
184 int newline = txt.find(
'\n');
185 newText = (newline >= 0) ? txt.left(newline) : txt;
189 if (newEmails.count())
191 newText = newEmails.join(
",");
192 int c = cursorPosition();
194 newText.prepend(
",");
195 if (c <
static_cast<int>(text().length()))
198 if (!newText.isEmpty())
static bool canDecode(TQMimeSource *e)
static bool decode(TQMimeSource *e, TQString &content)
Type
Types of drag and drop content which will be accepted.
LineEdit(Type type, TQWidget *parent=0, const char *name=0)
Constructor.
virtual void setText(const TQString &str)
Sets the contents of the line edit to be str.