• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

selection.cpp

Go to the documentation of this file.
00001 //
00002 // selection.cpp
00003 //
00004 // Part of KDVI - A previewer for TeX DVI files.
00005 //
00006 // (C) 2001--2004 Stefan Kebekus
00007 // Distributed under the GPL
00008 
00009 #include <config.h>
00010 
00011 #include <qapplication.h>
00012 #include <qclipboard.h>
00013 
00014 #include "selection.h"
00015 
00016 TextSelection::TextSelection()
00017   : page(PageNumber::invalidPage),
00018     selectedText(QString::null)
00019 {}
00020 
00021 
00022 void TextSelection::set(const PageNumber& pageNr, Q_INT32 start, Q_INT32 end, const QString& text)
00023 {
00024   page              = pageNr;
00025   selectedTextStart = start;
00026   selectedTextEnd   = end;
00027   if (page != 0)
00028     selectedText = text;
00029   else
00030     selectedText = QString::null;
00031 
00032   if (page != 0) {
00033     QApplication::clipboard()->setSelectionMode(true);
00034     QApplication::clipboard()->setText(selectedText);
00035   }
00036 }
00037 
00038 
00039 bool TextSelection::operator== (const TextSelection& s) const
00040 {
00041   // We don't check if the strings are equal because for corretly constructed selection objects this is always
00042   // the case if the following condition holds.
00043   return (page == s.page && selectedTextStart == s.selectedTextStart && selectedTextEnd == s.selectedTextEnd);
00044 }
00045 
00046 
00047 bool TextSelection::operator!= (const TextSelection& s) const
00048 {
00049   return !(*this == s);
00050 }
00051 
00052 
00053 void TextSelection::copyText() const
00054 {
00055   if (!isEmpty()) {
00056     QApplication::clipboard()->setSelectionMode(false);
00057     QApplication::clipboard()->setText(selectedText);
00058   }
00059 }
00060 
00061 
00062 void TextSelection::clear()
00063 {
00064   set(0, -1, -1, QString::null);
00065 }
00066 

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal