[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenetwork/kopete/kopete/chatwindow
From: John Tapsell <john () geola ! co ! uk>
Date: 2005-01-10 22:56:26
Message-ID: 20050110225626.230781CF30 () office ! kde ! org
[Download RAW message or body]
CVS commit by johnflux:
* When you select text including emoticons, then paste from selection clipboard, it \
copies the smiley image as the smiley text.
* When you select text and copy it to clipboard, then paste into say OpenOffice, it \
pastes with full html formatting, colors and images and all :)
BUG:61676
BUGCC:71476
M +41 -5 chatmessagepart.cpp 1.12
M +8 -2 chatmessagepart.h 1.6
--- kdenetwork/kopete/kopete/chatwindow/chatmessagepart.cpp #1.11:1.12
@@ -36,4 +36,5 @@
#include <klocale.h>
#include <kmessagebox.h>
+#include <kmultipledrag.h>
#include <kpopupmenu.h>
#include <krootpixmap.h>
@@ -613,16 +614,19 @@ void ChatMessagePart::slotScrollView()
}
-void ChatMessagePart::copy()
+void ChatMessagePart::copy(bool justselection /* default false */)
{
/*
- * The objective of this function is to keep the text of emoticons (of or \
latex image) when copying. + * The objective of this function is to keep the \
text of emoticons (or of latex image) when copying.
* see Bug 61676
+ * This also copies the text as type text/html
* RangeImpl::toHTML was not implemented before KDE 3.4
*/
QString text;
+ QString htmltext;
#if KDE_IS_VERSION(3,3,90)
- text=Kopete::Message::unescape( selection().toHTML().string() \
).stripWhiteSpace(); + htmltext = selectedTextAsHTML();
+ text=Kopete::Message::unescape( htmltext ).stripWhiteSpace();
// Message::unsescape will replace image by his title attribute
// stripWhiteSpace is for removing the newline added by the <!DOCTYPE> and \
other xml things of RangeImpl::toHTML @@ -737,7 +741,34 @@ void \
ChatMessagePart::copy() //END: copied from KHTMLPart::selectedText
#endif
+ if(text.isEmpty()) return;
+
+ disconnect( kapp->clipboard(), SIGNAL( selectionChanged()), this, SLOT( \
slotClearSelection())); +
+#ifndef QT_NO_MIMECLIPBOARD
+ if(justselection)
+ {
+ QTextDrag *textdrag = new QTextDrag(text, 0L);
+ KMultipleDrag *drag = new KMultipleDrag( );
+ drag->addDragObject( textdrag );
+ if(!htmltext.isEmpty()) {
+ htmltext.replace( QChar( 0xa0 ), ' ' );
+ QTextDrag *htmltextdrag = new QTextDrag(htmltext, 0L);
+ htmltextdrag->setSubtype("html");
+ drag->addDragObject( htmltextdrag );
+ }
+ QApplication::clipboard()->setData( drag, QClipboard::Clipboard );
+ QApplication::clipboard()->setText( text, QClipboard::Selection ); \
+ } else
+ {
+ QApplication::clipboard()->setText( text, QClipboard::Selection ); \
+ }
+#else
+ if(!justselection)
QApplication::clipboard()->setText( text, QClipboard::Clipboard );
QApplication::clipboard()->setText( text, QClipboard::Selection );
+#endif
+ connect( kapp->clipboard(), SIGNAL( selectionChanged()), SLOT( \
slotClearSelection())); +
}
@@ -817,4 +848,9 @@ void ChatMessagePart::slotUpdateBackgrou
}
+void ChatMessagePart::khtmlDrawContentsEvent( khtml::DrawContentsEvent * event) \
//virtual +{
+ KHTMLPart::khtmlDrawContentsEvent(event);
+ copy(true /*selection only*/);
+}
void ChatMessagePart::slotCloseView( bool force )
{
--- kdenetwork/kopete/kopete/chatwindow/chatmessagepart.h #1.5:1.6
@@ -55,7 +55,10 @@ public slots:
* Initiates a copy action
* If there is text selected in the HTML view, that text is copied
- * Otherwise, the entire edit area is copied.
+ * Otherwise if @p justselection is false, the entire edit area is copied.
+ *
+ * @param justselection If this is true, then the text will be only copied \
to the selection buffer only. + * In this mode, if \
nothing is selected, then nothing is copied.
*/
- void copy();
+ void copy(bool justselection = false);
/**
@@ -126,4 +129,7 @@ private slots:
void slotCloseView( bool force = false );
+protected:
+ virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
+
private:
Kopete::ChatSession *m_manager;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic