clean code: remove useless method

this methods related to win32 getText which has been removed
This commit is contained in:
xiaoyifang 2022-03-18 22:22:48 +08:00
parent 99077318e3
commit 2851533645
4 changed files with 2 additions and 158 deletions

View file

@ -2697,148 +2697,6 @@ void ArticleView::on_ftsSearchNext_clicked()
performFtsFindOperation( false ); performFtsFindOperation( false );
} }
#ifdef Q_OS_WIN32
void ArticleView::readTag( const QString & from, QString & to, int & count )
{
QChar ch, prev_ch;
bool inQuote = false, inDoublequote = false;
to.append( ch = prev_ch = from[ count++ ] );
while( count < from.size() )
{
ch = from[ count ];
if( ch == '>' && !( inQuote || inDoublequote ) )
{
to.append( ch );
break;
}
if( ch == '\'' )
inQuote = !inQuote;
if( ch == '\"' )
inDoublequote = !inDoublequote;
to.append( prev_ch = ch );
count++;
}
}
QString ArticleView::insertSpans( QString const & html )
{
QChar ch;
QString newContent;
bool inSpan = false, escaped = false;
/// Enclose every word in string (exclude tags) with <span></span>
for( int i = 0; i < html.size(); i++ )
{
ch = html[ i ];
if( ch == '&' )
{
escaped = true;
if( inSpan )
{
newContent.append( "</span>" );
inSpan = false;
}
newContent.append( ch );
continue;
}
if( ch == '<' ) // Skip tag
{
escaped = false;
if( inSpan )
{
newContent.append( "</span>" );
inSpan = false;
}
readTag( html, newContent, i );
continue;
}
if( escaped )
{
if( ch == ';' )
escaped = false;
newContent.append( ch );
continue;
}
if( !inSpan && ( ch.isLetterOrNumber() || ch.isLowSurrogate() ) )
{
newContent.append( "<span>");
inSpan = true;
}
if( inSpan && !( ch.isLetterOrNumber() || ch.isLowSurrogate() ) )
{
newContent.append( "</span>");
inSpan = false;
}
if( ch.isLowSurrogate() )
{
newContent.append( ch );
ch = html[ ++i ];
}
newContent.append( ch );
if( ch == '-' && !( html[ i + 1 ] == ' ' || ( i > 0 && html[ i - 1 ] == ' ' ) ) )
newContent.append( "<span style=\"font-size:0pt\"> </span>" );
}
if( inSpan )
newContent.append( "</span>" );
return newContent;
}
QString ArticleView::checkElement( QWebEnginePage & page, QPoint const & pt )
{
return runJavaScriptSync(&page, QString(
" var a= document.elementFromPoint(%1,%2);"
"var nodename=a.nodeName.toLowerCase();"
"if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")"
"{"
" return '';"
"}"
"return a.textContent;")
.arg(pt.x())
.arg(pt.y()));
}
QString ArticleView::wordAtPoint( int x, int y )
{
QString word;
if( popupView )
return word;
QPoint pos = mapFromGlobal( QPoint( x, y ) );
//todo
QWebEnginePage *frame = ui.definition->page();
if( !frame )
return word;
QPointF scrollPoint=frame->scrollPosition();
QPoint posWithScroll = pos + QPoint((int)scrollPoint.x(),(int)scrollPoint.y());
/// Find target HTML element
QString nodeValue = runJavaScriptSync(frame, QString(
"var a= document.elementFromPoint(%1,%2);"
"var nodename=a.nodeName.toLowerCase();"
"if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")"
"{"
" return '';"
"}"
"return a.textContent;")
.arg(posWithScroll.x())
.arg(posWithScroll.y()));
return nodeValue;
}
#endif
ResourceToSaveHandler::ResourceToSaveHandler(ArticleView * view, QString const & fileName ) : ResourceToSaveHandler::ResourceToSaveHandler(ArticleView * view, QString const & fileName ) :
QObject( view ), QObject( view ),
fileName( fileName ), fileName( fileName ),

View file

@ -190,7 +190,7 @@ public:
if(!qFuzzyCompare(existedFactor,factor)){ if(!qFuzzyCompare(existedFactor,factor)){
qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor; qDebug()<<"zoom factor ,existed:"<<existedFactor<<"set:"<<factor;
ui.definition->setZoomFactor( factor ); ui.definition->setZoomFactor( factor );
ui.definition->page()->setZoomFactor(factor); //ui.definition->page()->setZoomFactor(factor);
} }
} }
@ -410,18 +410,6 @@ private:
// We need this to hide the search bar when we're showed // We need this to hide the search bar when we're showed
void showEvent( QShowEvent * ); void showEvent( QShowEvent * );
#ifdef Q_OS_WIN32
/// Search inside web page for word under cursor
private:
QString insertSpans( QString const & html );
void readTag( QString const & from, QString & to, int & count );
QString checkElement( QWebEnginePage & elem, const QPoint & pt );
public:
QString wordAtPoint( int x, int y );
#endif
}; };
class ResourceToSaveHandler: public QObject class ResourceToSaveHandler: public QObject

View file

@ -16,8 +16,7 @@
ArticleWebView::ArticleWebView( QWidget *parent ): ArticleWebView::ArticleWebView( QWidget *parent ):
QWebEngineView( parent ), QWebEngineView( parent ),
midButtonPressed( false ), midButtonPressed( false ),
selectionBySingleClick( false ), selectionBySingleClick( false )
showInspectorDirectly( true )
{ {
} }

View file

@ -66,7 +66,6 @@ private:
bool midButtonPressed; bool midButtonPressed;
bool selectionBySingleClick; bool selectionBySingleClick;
bool showInspectorDirectly;
//MouseDbClickEvent will also emit MousePressEvent which conflict the single click event. //MouseDbClickEvent will also emit MousePressEvent which conflict the single click event.
//this variable used to distinguish the single click and real double click. //this variable used to distinguish the single click and real double click.