[rkward-cvs] SF.net SVN: rkward: [1190] trunk/rkward/rkward/windows

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jan 22 14:03:59 UTC 2007


Revision: 1190
          http://svn.sourceforge.net/rkward/?rev=1190&view=rev
Author:   tfry
Date:     2007-01-22 06:03:58 -0800 (Mon, 22 Jan 2007)

Log Message:
-----------
more reliable goto anchor

Modified Paths:
--------------
    trunk/rkward/rkward/windows/rkhtmlwindow.cpp
    trunk/rkward/rkward/windows/rkhtmlwindow.h

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-01-22 12:34:04 UTC (rev 1189)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp	2007-01-22 14:03:58 UTC (rev 1190)
@@ -44,7 +44,7 @@
 
 RKHTMLWindow::RKHTMLWindow (QWidget *parent) : RKMDIWindow (parent, RKMDIWindow::HelpWindow) {
 	RK_TRACE (APP);
-	scroll_position=0;
+	scroll_position=-1;
 	
 	khtmlpart = new KHTMLPart (this, 0, 0, 0, KHTMLPart::BrowserViewGUI);
 	khtmlpart->setSelectable (true);
@@ -93,6 +93,19 @@
 	KStdAction::copy (khtmlpart->browserExtension (), SLOT (copy ()), action_collection, "copy");
 }
 
+void RKHTMLWindow::doGotoAnchor (const QString &anchor_name) {
+	RK_TRACE (APP);
+
+	goto_anchor_name = anchor_name;
+	QTimer::singleShot (0, this, SLOT (doGotoAnchorNow ()));
+}
+
+void RKHTMLWindow::doGotoAnchorNow () {
+	RK_TRACE (APP);
+
+	khtmlpart->gotoAnchor (goto_anchor_name);
+}
+
 void RKHTMLWindow::slotPrint () {
 	RK_TRACE (APP);
 
@@ -188,7 +201,7 @@
 
 void RKHTMLWindow::loadDone () {
 	RK_TRACE (APP);
-	khtmlpart->view()->setContentsPos (0, scroll_position);
+	if (scroll_position >= 0) khtmlpart->view()->setContentsPos (0, scroll_position);
 }
 
 //##################### BEGIN RKOutputWindow #####################
@@ -541,7 +554,7 @@
 
 		QString ref = url.ref ();
 		if (!ref.isEmpty ()) {
-			khtmlpart->gotoAnchor (ref);
+			doGotoAnchor (ref);
 		}
 
 		success = true;

Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-01-22 12:34:04 UTC (rev 1189)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h	2007-01-22 14:03:58 UTC (rev 1190)
@@ -61,6 +61,7 @@
 	KParts::Part *getPart ();
 /** Return current url */
 	KURL url ();
+	void doGotoAnchor (const QString &anchor_name);
 public slots:
 /** this is used for browsing only. Use openURL instead, when calling from outside. */
 	void slotOpenURLRequest (const KURL &url, const KParts::URLArgs &);
@@ -70,6 +71,7 @@
 private slots:
 /** This slot is called when the new page has finished loading. Sets scroll position to scroll_position */
 	void loadDone ();
+	void doGotoAnchorNow ();
 protected:
 /** Here we store the position of the scroll bar before refresh. Used to scroll to the same position after a reload */
 	int scroll_position;
@@ -85,6 +87,7 @@
 	KAction *forward;
 	KAction *print;
 	bool url_change_is_from_history;	// dirty!!!
+	QString goto_anchor_name;
 };
 
 /**


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list