diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kviewshell/selection.cpp | |
download | tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.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/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kviewshell/selection.cpp')
-rw-r--r-- | kviewshell/selection.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/kviewshell/selection.cpp b/kviewshell/selection.cpp new file mode 100644 index 00000000..be288fe0 --- /dev/null +++ b/kviewshell/selection.cpp @@ -0,0 +1,66 @@ +// +// selection.cpp +// +// Part of KDVI - A previewer for TeX DVI files. +// +// (C) 2001--2004 Stefan Kebekus +// Distributed under the GPL + +#include <config.h> + +#include <qapplication.h> +#include <qclipboard.h> + +#include "selection.h" + +TextSelection::TextSelection() + : page(PageNumber::invalidPage), + selectedText(QString::null) +{} + + +void TextSelection::set(const PageNumber& pageNr, Q_INT32 start, Q_INT32 end, const QString& text) +{ + page = pageNr; + selectedTextStart = start; + selectedTextEnd = end; + if (page != 0) + selectedText = text; + else + selectedText = QString::null; + + if (page != 0) { + QApplication::clipboard()->setSelectionMode(true); + QApplication::clipboard()->setText(selectedText); + } +} + + +bool TextSelection::operator== (const TextSelection& s) const +{ + // We don't check if the strings are equal because for corretly constructed selection objects this is always + // the case if the following condition holds. + return (page == s.page && selectedTextStart == s.selectedTextStart && selectedTextEnd == s.selectedTextEnd); +} + + +bool TextSelection::operator!= (const TextSelection& s) const +{ + return !(*this == s); +} + + +void TextSelection::copyText() const +{ + if (!isEmpty()) { + QApplication::clipboard()->setSelectionMode(false); + QApplication::clipboard()->setText(selectedText); + } +} + + +void TextSelection::clear() +{ + set(0, -1, -1, QString::null); +} + |