qeditor_texthint.cpp
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 00018 * 00019 */ 00020 00021 #include "qeditor_texthint.h" 00022 #include "qeditor.h" 00023 #include "qeditor_view.h" 00024 00025 #include <private/qrichtext_p.h> 00026 #include <klocale.h> 00027 00028 QEditorTextHint::QEditorTextHint( QEditorView* editorView ) 00029 : QToolTip( editorView->editor() ), m_editorView( editorView ) 00030 { 00031 } 00032 00033 QEditorTextHint::~QEditorTextHint() 00034 { 00035 } 00036 00037 void QEditorTextHint::maybeTip( const QPoint& pt ) 00038 { 00039 QEditor* ed = m_editorView->editor(); 00040 QPoint contentsPt = ed->viewportToContents( pt ); 00041 00042 QTextCursor c; 00043 c.place( contentsPt, ed->document()->firstParagraph() ); 00044 00045 int line = c.paragraph()->paragId(); 00046 int column = c.index(); 00047 00048 QString textHint = m_editorView->computeTextHint( line, column ); 00049 00050 if( !textHint.isNull() ) 00051 tip( QRect(pt, QSize(100,30)), textHint ); 00052 } 00053