Git commit 6367aa17b1716a2074c0675e4fbabbec3bc50c77 by Christoph Cullmann.
Committed on 04/11/2012 at 18:19.
Pushed by cullmann into branch 'master'.
GUI: "Clipboard History" menu in edit/popup
allows you to paste the latest xx things you copied/cutted, atm history size 10
M +3-1part/data/katepartui.rc
M +1-3part/document/katedocument.cpp
M +1-1part/document/katedocument.h
M +28 -1part/utils/kateglobal.cpp
M +26 -0part/utils/kateglobal.h
M +16 -4part/view/kateview.cpp
M +3-2part/view/kateview.h
M +44 -0part/view/kateviewhelpers.cpp
M +16 -0part/view/kateviewhelpers.h
M +1-1part/view/kateviewinternal.cpp
http://commits.kde.org/kate/6367aa17b1716a2074c0675e4fbabbec3bc50c77
diff --git a/part/data/katepartui.rc b/part/data/katepartui.rc
index f5cdcb1..7e55a52 100644
--- a/part/data/katepartui.rc
+++ b/part/data/katepartui.rc
@@ -1,5 +1,5 @@
-
+
&File
@@ -16,6 +16,7 @@
+
@@ -130,6 +131,7 @@
+
diff --git a/part/document/katedocument.cpp b/part/document/katedocument.cpp
index f9462b5..21e0a77 100644
--- a/part/document/katedocument.cpp
+++ b/part/document/katedocument.cpp
@@ -2825,10 +2825,8 @@ void KateDocument::del( KateView *view, const
KTextEditor::Cursor& c )
}
}
-void KateDocument::paste ( KateView* view, QClipboard::Mode mode )
+void KateDocument::paste ( KateView* view, const QString &s )
{
- QString s = QApplication::clipboard()->text(mode);
-
if (s.isEmpty())
return;
diff --git a/part/document/katedocument.h b/part/document/katedocument.h
index b7a97aa..327049c 100644
--- a/part/document/katedocument.h
+++ b/part/document/katedocument.h
@@ -725,7 +725,7 @@ Q_SIGNALS:
void del( KateView *view, const KTextEditor::Cursor& );
void transpose( const KTextEditor::Cursor& );
-void paste ( KateView* view, QClipboard::Mode = QClipboard::Clipboard );
+void paste ( KateView* view, const QString &s );
public:
void indent ( KTextEditor::Range range, int change );
diff --git a/part/utils/kateglobal.cpp b/part/utils/kateglobal.cpp
index 36133ee..c4df0e8 100644
--- a/part/utils/kateglobal.cpp
+++ b/part/utils/kateglobal.cpp
@@ -49,8 +49,8 @@
#include
#include
-
#include
+#include
KateGlobal *KateGlobal::s_self = 0;
@@ -542,4 +542,31 @@ void KateGlobal::updateColorPalette()
m_rendererConfig->updateConfig();
}
+void KateGlobal::copyToClipboard (const QString &text)
+{
+ /**
+ * empty => nop
+ */
+ if (text.isEmpty())
+return;
+
+ /**
+ * move to clipboard
+ */
+ QApplication::clipboard()->setText (text, QClipboard::Clipboard);
+
+ /**
+ * remember in history
+ * cut after 10 entries
+ */
+ m_clipboardHistory.prepend (text);
+ if (m_clipboardHistory.size () > 10)
+m_clipboardHistory.removeLast ();
+
+ /**
+ * notify about change
+ */
+ emit clipboardHistoryChanged ();
+}
+
// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/part/utils/kateglobal.h b/part/utils/kateglobal.h
index 0464de6..491e8f8 100644
--- a/part/utils/kateglobal.h
+++ b/part/utils/kateglobal.h
@@ -410,6 +410,27 @@ class KATEPART_TESTS_EXPORT KateGlobal : public
KTextEditor::Editor, public KTex
KTextEditor::TemplateScript* registerTemplateScript (QObject* owner, const
QString& script);
void unregisterTemplateScript(KTextEditor::TemplateScript* templateScript);
+/**
+ * Copy text to clipboard an remember it in the history
+ * @param text text to copy to clipboard, does nothing if empty!
+ */
+void copyToClipboard (const QString &text);
+
+/**
+ * Clipboard history, filled with text we ever copied
+ * to clipboard via copyToClipboard.
+ */
+const QStringList &clipboardHistory () const
+{
+return m_clipboardHistory;
+}
+
+ Q_SIGNALS:
+/**
+ * Emitted if the history of clipboard changes via copyToClipboard
+ */
+void clipboardHistoryChanged ();
+
private Q_SLOTS:
void updateColorPalette();
@@ -535,6 +556,11 @@ class KATEPART_TESTS_EXPORT KateGlobal : public
KTextEditor::Editor, public KTex
* session config
*/
KSharedConfig::Ptr m_sessionConfig;
+
+/**
+ * clipboard history
+ */
+QStringList m_clipboardHistory;
};
#endif
diff --git a/part/view/kateview.cpp b/part/view/kateview.cpp
index e9822d9..dafe153 100644
--- a/part/view/kateview.cpp
+++ b/part/view/kateview.cpp
@@ -346,7 +346,10 @@ void KateView::setupActions()
m_copy = a = ac->addAction(KStandardAction::Copy, this, SLOT(copy()));
a->setWhatsThis(i18n( "Use this command to copy the currently selected text
to the system clipboard."));
-
+
+ m_pasteMenu = ac->addAction("edit_paste_menu", new KatePasteMenu
(i18n("Clipboard &History"), this));
+ connect (KateGlobal::self(), SIGNAL(clipboardHistoryChanged()), this,
SLOT(slotClipboardHistoryChang