changeset 73:7bfd46c330dc

more porting
author mandel
date Fri, 22 May 2009 10:59:00 +0000
parents b149ef2cb18b
children 37caa90ce503
files demos/browser/TODO.txt demos/browser/autosaver.d demos/browser/bookmarks.d demos/browser/browsermainwindow.d demos/browser/chasewidget.d demos/browser/cookiejar.d demos/browser/downloadmanager.d demos/browser/edittableview.d demos/browser/edittreeview.d demos/browser/history.d demos/browser/main.d demos/browser/modelmenu.d demos/browser/networkaccessmanager.d demos/browser/searchlineedit.d demos/browser/settings.d demos/browser/squeezelabel.d demos/browser/tabwidget.d demos/browser/toolbarsearch.d demos/browser/urllineedit.d demos/browser/webview.d demos/browser/xbel.d
diffstat 21 files changed, 4945 insertions(+), 5133 deletions(-) [+]
line wrap: on
line diff
--- a/demos/browser/TODO.txt	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/TODO.txt	Fri May 22 10:59:00 2009 +0000
@@ -7,7 +7,7 @@
 - some '::' and most '->' have been replaced by '.'
 
 Todo:
-- *.ui files need to converted to source files and translated to D
 - imports need to be corrected
 - module declarations are probably missing
+- what about Q_PROPERTY/Q_UNUSED?
 - everything else...
--- a/demos/browser/autosaver.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/autosaver.d	Fri May 22 10:59:00 2009 +0000
@@ -40,75 +40,82 @@
 ****************************************************************************/
 module autosaver;
 
-import QtCore.QObject;
-import QtCore.QBasicTimer;
-import QtCore.QTime;
 
-import QtCore.QDir;
-import QtCore.QCoreApplication;
-import QtCore.QMetaObject;
+import qt.core.QObject;
+import qt.core.QBasicTimer;
+import qt.core.QTime;
+import qt.core.QDir;
+import qt.core.QCoreApplication;
+import qt.core.QMetaObject;
+
 import QtDebug;
 
+
 const uint AUTOSAVE_IN  = 1000 * 3  // seconds
 const uint MAXWAIT = 1000 * 15 // seconds
 
+
 /*
-    This class will call the save() slot on the parent object when the parent changes.
-    It will wait several seconds after changed() to combining multiple changes and
-    prevent continuous writing to disk.
-  */
+This class will call the save() slot on the parent object when the parent changes.
+It will wait several seconds after changed() to combining multiple changes and
+prevent continuous writing to disk.
+*/
+
 class AutoSaver : public QObject {
 
-Q_OBJECT
+public:
+
+	this(QObject parent)
+	{
+		super(parent);
+		assert(parent);
+	}
+	
+	~this();
+	{
+		if (m_timer.isActive())
+			qWarning() << "AutoSaver: still active when destroyed, changes not saved.";
+	}
+	
+	void saveIfNeccessary()
+	{
+		if (!m_timer.isActive())
+			return;
+		m_timer.stop();
+		m_firstChange = QTime();
+		if (!QMetaObject.invokeMethod(parent(), "save", Qt.DirectConnection)) {
+			qWarning() << "AutoSaver: error invoking slot save() on parent";
+		}
+	}
 
 public:
-    this(QObject *parent)
-{
-	super(parent);
-    Q_ASSERT(parent);
-}
-    ~this();
-{
-    if (m_timer.isActive())
-        qWarning() << "AutoSaver: still active when destroyed, changes not saved.";
-}
-    void saveIfNeccessary()
-{
-    if (!m_timer.isActive())
-        return;
-    m_timer.stop();
-    m_firstChange = QTime();
-    if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) {
-        qWarning() << "AutoSaver: error invoking slot save() on parent";
-    }
+
+	void changeOccurred();
+	{
+		if (m_firstChange.isNull())
+			m_firstChange.start();
+
+		if (m_firstChange.elapsed() > MAXWAIT) {
+			saveIfNeccessary();
+		} else {
+			m_timer.start(AUTOSAVE_IN, this);
+		}
+	}
+
+protected:
+
+	void timerEvent(QTimerEvent event)
+	{
+		if (event.timerId() == m_timer.timerId()) {
+			saveIfNeccessary();
+		} else {
+			QObject.timerEvent(event);
+		}
+	}
+
+private:
+
+	QBasicTimer m_timer;
+	QTime m_firstChange;
 }
 
-public slots:
-    void changeOccurred();
-{
-    if (m_firstChange.isNull())
-        m_firstChange.start();
-
-    if (m_firstChange.elapsed() > MAXWAIT) {
-        saveIfNeccessary();
-    } else {
-        m_timer.start(AUTOSAVE_IN, this);
-    }
-}
-
-protected:
-    void timerEvent(QTimerEvent *event)
-{
-    if (event.timerId() == m_timer.timerId()) {
-        saveIfNeccessary();
-    } else {
-        QObject::timerEvent(event);
-    }
-}
-
-
-private:
-    QBasicTimer m_timer;
-    QTime m_firstChange;
-}
-
--- a/demos/browser/bookmarks.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/bookmarks.d	Fri May 22 10:59:00 2009 +0000
@@ -75,744 +75,743 @@
 
 
 /*!
-    Bookmark manager, owner of the bookmarks, loads, saves and basic tasks
-  */
-
+Bookmark manager, owner of the bookmarks, loads, saves and basic tasks
+*/
 class BookmarksManager : public QObject
 {
-	
-   mixin Signal!("entryAdded", BookmarkNode item);
-     mixin Signal!("entryRemoved", BookmarkNode parent, int row, BookmarkNode item);
-     mixin Signal!("entryChanged", BookmarkNode item);
+	mixin Signal!("entryAdded", BookmarkNode item);
+	mixin Signal!("entryRemoved", BookmarkNode parent, int row, BookmarkNode item);
+	mixin Signal!("entryChanged", BookmarkNode item);
 
 public:
-    BookmarksManager(QObject parent = null)
-{
-	super(parent);
-	m_loaded = false;
-	m_saveTimer = new AutoSaver(this);
-	m_bookmarkRootNode = null;
-	m_bookmarkModel = null;
-    this.entryAdded.connect(&m_saveTimer.changeOccurred);
-    this.entryRemoved.connect(&m_saveTimer.changeOccurred);
-    this.entryChanged.connect(&m_saveTimer.changeOccurred);
-}
 
+	this(QObject parent = null)
+	{
+		super(parent);
+		m_loaded = false;
+		m_saveTimer = new AutoSaver(this);
+		m_bookmarkRootNode = null;
+		m_bookmarkModel = null;
+		this.entryAdded.connect(&m_saveTimer.changeOccurred);
+		this.entryRemoved.connect(&m_saveTimer.changeOccurred);
+		this.entryChanged.connect(&m_saveTimer.changeOccurred);
+	}
 
-    ~this()
-{
-    m_saveTimer.saveIfNeccessary();
-}
+	~this()
+	{
+		m_saveTimer.saveIfNeccessary();
+	}
 
+	void addBookmark(BookmarkNode parent, BookmarkNode node, int row = -1)
+	{
+		if (!m_loaded)
+			return;
+		assert(parent);
+		InsertBookmarksCommand command = new InsertBookmarksCommand(this, parent, node, row);
+		m_commands.push(command);
+	}
 
-    void addBookmark(BookmarkNode parent, BookmarkNode node, int row = -1)
-{
-    if (!m_loaded)
-        return;
-    assert(parent);
-    InsertBookmarksCommand command = new InsertBookmarksCommand(this, parent, node, row);
-    m_commands.push(command);
-}
 
+	void removeBookmark(BookmarkNode node);
+	{
+		if (!m_loaded)
+			return;
 
-    void removeBookmark(BookmarkNode node);
-{
-    if (!m_loaded)
-        return;
+		assert(node);
+		BookmarkNode parent = node.parent();
+		int row = parent.children().indexOf(node);
+		RemoveBookmarksCommand command = new RemoveBookmarksCommand(this, parent, row);
+		m_commands.push(command);
+	}
 
-    assert(node);
-    BookmarkNode parent = node.parent();
-    int row = parent.children().indexOf(node);
-    RemoveBookmarksCommand command = new RemoveBookmarksCommand(this, parent, row);
-    m_commands.push(command);
-}
+	void setTitle(BookmarkNode node, QString newTitle);
+	{
+		if (!m_loaded)
+			return;
 
-    void setTitle(BookmarkNode node, QString newTitle);
-{
-    if (!m_loaded)
-        return;
+		assert(node);
+		ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newTitle, true);
+		m_commands.push(command);
+	}
 
-    assert(node);
-    ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newTitle, true);
-    m_commands.push(command);
-}
 
+	void setUrl(BookmarkNode node, QString newUrl);
+	{
+		if (!m_loaded)
+			return;
 
-    void setUrl(BookmarkNode node, QString newUrl);
-{
-    if (!m_loaded)
-        return;
+		assert(node);
+		ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newUrl, false);
+		m_commands.push(command);
+	}
 
-    assert(node);
-    ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newUrl, false);
-    m_commands.push(command);
-}
 
+	void changeExpanded()
+	{
+		m_saveTimer.changeOccurred();
+	}
 
-void changeExpanded()
-{
-    m_saveTimer.changeOccurred();
-}
+	BookmarkNode bookmarks();
+	{
+		if (!m_loaded)
+			load();
+		return m_bookmarkRootNode;
+	}
 
-    BookmarkNode bookmarks();
-{
-    if (!m_loaded)
-        load();
-    return m_bookmarkRootNode;
-}
+	BookmarkNode menu();
+	{
+		if (!m_loaded)
+			load();
 
-    BookmarkNode menu();
-{
-    if (!m_loaded)
-        load();
+		for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
+			BookmarkNode node = m_bookmarkRootNode.children().at(i);
+			if (node.title == tr(BOOKMARKMENU))
+				return node;
+		}
+		assert(false);
+		return 0;
+	}
 
-    for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
-        BookmarkNode node = m_bookmarkRootNode.children().at(i);
-        if (node.title == tr(BOOKMARKMENU))
-            return node;
-    }
-    assert(false);
-    return 0;
-}
+	BookmarkNode toolbar();
+	{
+		if (!m_loaded)
+			load();
 
-    BookmarkNode toolbar();
-{
-    if (!m_loaded)
-        load();
+		for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
+			BookmarkNode node = m_bookmarkRootNode.children().at(i);
+			if (node.title == tr(BOOKMARKBAR))
+				return node;
+		}
+		assert(false);
+		return 0;
+	}
 
-    for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
-        BookmarkNode node = m_bookmarkRootNode.children().at(i);
-        if (node.title == tr(BOOKMARKBAR))
-            return node;
-    }
-    assert(false);
-    return 0;
-}
+	BookmarksModel bookmarksModel()
+	{
+		if (!m_bookmarkModel)
+			m_bookmarkModel = new BookmarksModel(this, this);
+		return m_bookmarkModel;
+	}
 
-BookmarksModel bookmarksModel()
-{
-    if (!m_bookmarkModel)
-        m_bookmarkModel = new BookmarksModel(this, this);
-    return m_bookmarkModel;
-}
+	QUndoStack undoRedoStack() { return m_commands; };
 
-    QUndoStack undoRedoStack() { return m_commands; };
+public:
 
-public slots:
-    void importBookmarks()
-{
-    QString fileName = QFileDialog.getOpenFileName(0, tr("Open File"),
-                                                     QString(),
-                                                     tr("XBEL (*.xbel *.xml)"));
-    if (fileName.isEmpty())
-        return;
+	void importBookmarks()
+	{
+		QString fileName = QFileDialog.getOpenFileName(0, tr("Open File"), QString(), tr("XBEL (*.xbel *.xml)"));
+		if (fileName.isEmpty())
+			return;
 
-    XbelReader reader;
-    BookmarkNode importRootNode = reader.read(fileName);
-    if (reader.error() != QXmlStreamReader.NoError) {
-        QMessageBox.warning(0, QLatin1String("Loading Bookmark"),
-            tr("Error when loading bookmarks on line %1, column %2:\n"
-               "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
-    }
+		XbelReader reader;
+		BookmarkNode importRootNode = reader.read(fileName);
+		if (reader.error() != QXmlStreamReader.NoError) {
+			QMessageBox.warning(0, QLatin1String("Loading Bookmark"),
+				tr("Error when loading bookmarks on line %1, column %2:\n"
+				"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
+		}
 
-    importRootNode.setType(BookmarkNode.Folder);
-    importRootNode.title = (tr("Imported %1").arg(QDate.currentDate().toString(Qt.SystemLocaleShortDate)));
-    addBookmark(menu(), importRootNode);
-}
+		importRootNode.setType(BookmarkNode.Folder);
+		importRootNode.title = (tr("Imported %1").arg(QDate.currentDate().toString(Qt.SystemLocaleShortDate)));
+		addBookmark(menu(), importRootNode);
+	}
 
 
-    void exportBookmarks()
-{
-    QString fileName = QFileDialog.getSaveFileName(0, tr("Save File"),
-                                tr("%1 Bookmarks.xbel").arg(QCoreApplication.applicationName()),
-                                tr("XBEL (*.xbel *.xml)"));
-    if (fileName.isEmpty())
-        return;
+	void exportBookmarks()
+	{
+		QString fileName = QFileDialog.getSaveFileName(0, tr("Save File"),
+				tr("%1 Bookmarks.xbel").arg(QCoreApplication.applicationName()),
+				tr("XBEL (*.xbel *.xml)"));
+		if (fileName.isEmpty())
+			return;
 
-    XbelWriter writer;
-    if (!writer.write(fileName, m_bookmarkRootNode))
-        QMessageBox.critical(0, tr("Export error"), tr("error saving bookmarks"));
-}
-
-private slots:
-    void save()
-{
-    if (!m_loaded)
-        return;
-
-    XbelWriter writer;
-    QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation);
-    QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
-    if (!writer.write(bookmarkFile, m_bookmarkRootNode))
-        qWarning() << "BookmarkManager: error saving to" << bookmarkFile;
-}
+		XbelWriter writer;
+		if (!writer.write(fileName, m_bookmarkRootNode))
+			QMessageBox.critical(0, tr("Export error"), tr("error saving bookmarks"));
+	}
 
 private:
-    void load()
-{
-    if (m_loaded)
-        return;
-    m_loaded = true;
 
-    QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation);
-    QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
-    if (!QFile.exists(bookmarkFile))
-        bookmarkFile = QLatin1String(":defaultbookmarks.xbel");
+	void save()
+	{
+		if (!m_loaded)
+			return;
 
-    XbelReader reader;
-    m_bookmarkRootNode = reader.read(bookmarkFile);
-    if (reader.error() != QXmlStreamReader.NoError) {
-        QMessageBox.warning(0, QLatin1String("Loading Bookmark"),
-            tr("Error when loading bookmarks on line %1, column %2:\n"
-               "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
-    }
+		XbelWriter writer;
+		QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation);
+		QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
+		if (!writer.write(bookmarkFile, m_bookmarkRootNode))
+			qWarning() << "BookmarkManager: error saving to" << bookmarkFile;
+	}
 
-    BookmarkNode toolbar = null;
-    BookmarkNode menu = null;
-    QList<BookmarkNode> others;
-    for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
-        BookmarkNode node = m_bookmarkRootNode.children().at(i);
-        if (node.type() == BookmarkNode.Folder) {
-            // Automatically convert
-            if (node.title == tr("Toolbar Bookmarks") && !toolbar) {
-                node.title = tr(BOOKMARKBAR);
-            }
-            if (node.title == tr(BOOKMARKBAR) && !toolbar) {
-                toolbar = node;
-            }
+private:
+	
+	void load()
+	{
+		if (m_loaded)
+			return;
+		m_loaded = true;
 
-            // Automatically convert
-            if (node.title == tr("Menu") && !menu) {
-                node.title = tr(BOOKMARKMENU);
-            }
-            if (node.title == tr(BOOKMARKMENU) && !menu) {
-                menu = node;
-            }
-        } else {
-            others.append(node);
-        }
-        m_bookmarkRootNode.remove(node);
-    }
-    assert(m_bookmarkRootNode.children().count() == 0);
-    if (!toolbar) {
-        toolbar = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode);
-        toolbar.title = tr(BOOKMARKBAR);
-    } else {
-        m_bookmarkRootNode.add(toolbar);
-    }
+		QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation);
+		QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel");
+		if (!QFile.exists(bookmarkFile))
+			bookmarkFile = QLatin1String(":defaultbookmarks.xbel");
 
-    if (!menu) {
-        menu = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode);
-        menu.title = tr(BOOKMARKMENU);
-    } else {
-        m_bookmarkRootNode.add(menu);
-    }
+		XbelReader reader;
+		m_bookmarkRootNode = reader.read(bookmarkFile);
+		if (reader.error() != QXmlStreamReader.NoError) {
+			QMessageBox.warning(0, QLatin1String("Loading Bookmark"),
+			tr("Error when loading bookmarks on line %1, column %2:\n"
+			"%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString()));
+		}
 
-    for (int i = 0; i < others.count(); ++i)
-        menu.add(others.at(i));
-}
+		BookmarkNode toolbar = null;
+		BookmarkNode menu = null;
+		QList<BookmarkNode> others;
+		for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) {
+			BookmarkNode node = m_bookmarkRootNode.children().at(i);
+			if (node.type() == BookmarkNode.Folder) {
+				// Automatically convert
+				if (node.title == tr("Toolbar Bookmarks") && !toolbar) {
+					node.title = tr(BOOKMARKBAR);
+				}
+				if (node.title == tr(BOOKMARKBAR) && !toolbar) {
+					toolbar = node;
+				}
 
+				// Automatically convert
+				if (node.title == tr("Menu") && !menu) {
+					node.title = tr(BOOKMARKMENU);
+				}
+				if (node.title == tr(BOOKMARKMENU) && !menu) {
+					menu = node;
+				}
+			} else {
+				others.append(node);
+			}
+			m_bookmarkRootNode.remove(node);
+		}
+		assert(m_bookmarkRootNode.children().count() == 0);
+		if (!toolbar) {
+			toolbar = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode);
+			toolbar.title = tr(BOOKMARKBAR);
+		} else {
+			m_bookmarkRootNode.add(toolbar);
+		}
 
-    bool m_loaded;
-    AutoSaver m_saveTimer;
-    BookmarkNode m_bookmarkRootNode;
-    BookmarksModel m_bookmarkModel;
-    QUndoStack m_commands;
+		if (!menu) {
+			menu = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode);
+			menu.title = tr(BOOKMARKMENU);
+		} else {
+			m_bookmarkRootNode.add(menu);
+		}
 
-    friend class RemoveBookmarksCommand;
-    friend class ChangeBookmarkCommand;
+		for (int i = 0; i < others.count(); ++i)
+			menu.add(others.at(i));
+	}
+
+	bool m_loaded;
+	AutoSaver m_saveTimer;
+	BookmarkNode m_bookmarkRootNode;
+	BookmarksModel m_bookmarkModel;
+	QUndoStack m_commands;
 }
 
 class RemoveBookmarksCommand : public QUndoCommand
 {
+public:
 
-public:
-    this(BookmarksManager m_bookmarkManagaer, BookmarkNode parent, int row)
-{
-	super(BookmarksManager.tr("Remove Bookmark"))
-	m_row = row;
-	m_bookmarkManagaer = m_bookmarkManagaer;
-	m_node = parent.children().value(row);
-	m_parent = parent;
-	m_done = false;
-}
+	this(BookmarksManager m_bookmarkManagaer, BookmarkNode parent, int row)
+	{
+		super(BookmarksManager.tr("Remove Bookmark"))
+		m_row = row;
+		m_bookmarkManagaer = m_bookmarkManagaer;
+		m_node = parent.children().value(row);
+		m_parent = parent;
+		m_done = false;
+	}
 
-~this()
-{
-    if (m_done && !m_node.parent()) {
-        delete m_node;
-    }
-}
+	~this()
+	{
+		if (m_done && !m_node.parent()) {
+			delete m_node;
+		}
+	}
 
-void undo()
-{
-    m_parent.add(m_node, m_row);
-    emit m_bookmarkManagaer.entryAdded(m_node);
-    m_done = false;
-}
+	void undo()
+	{
+		m_parent.add(m_node, m_row);
+		emit m_bookmarkManagaer.entryAdded(m_node);
+		m_done = false;
+	}
 
-void redo()
-{
-    m_parent.remove(m_node);
-    emit m_bookmarkManagaer.entryRemoved(m_parent, m_row, m_node);
-    m_done = true;
-}
+	void redo()
+	{
+		m_parent.remove(m_node);
+		emit m_bookmarkManagaer.entryRemoved(m_parent, m_row, m_node);
+		m_done = true;
+	}
 
 protected:
-    int m_row;
-    BookmarksManager m_bookmarkManagaer;
-    BookmarkNode m_node;
-    BookmarkNode m_parent;
-    bool m_done;
-};
+
+	int m_row;
+	BookmarksManager m_bookmarkManagaer;
+	BookmarkNode m_node;
+	BookmarkNode m_parent;
+	bool m_done;
+}
 
 class InsertBookmarksCommand : public RemoveBookmarksCommand
 {
+public:
+	this(BookmarksManager m_bookmarkManagaer, BookmarkNode parent, BookmarkNode node, int row)
+	{
+		super(m_bookmarkManagaer, parent, row);
 
-public:
-this(BookmarksManager m_bookmarkManagaer,
-                BookmarkNode parent, BookmarkNode node, int row)
-{
-	super(m_bookmarkManagaer, parent, row);
-	
-    setText(BookmarksManager.tr("Insert Bookmark"));
-    m_node = node;
-}
+		setText(BookmarksManager.tr("Insert Bookmark"));
+		m_node = node;
+	}
 
-    void undo() { RemoveBookmarksCommand.redo(); }
-    void redo() { RemoveBookmarksCommand.undo(); }
+	void undo() { RemoveBookmarksCommand.redo(); }
+	void redo() { RemoveBookmarksCommand.undo(); }
 }
 
 class ChangeBookmarkCommand : public QUndoCommand
 {
+public:
 
-public:
-    this(BookmarksManager m_bookmarkManagaer,
-        BookmarkNode node, QString newValue, bool title)
-{
-	super();
-	m_bookmarkManagaer = m_bookmarkManagaer;
-    m_title = title;
-    m_newValue = newValue;
-    m_node = node;
-    if (m_title) {
-        m_oldValue = m_node.title;
-        setText(BookmarksManager.tr("Name Change"));
-    } else {
-        m_oldValue = m_node.url;
-        setText(BookmarksManager.tr("Address Change"));
-    }
-}
+	this(BookmarksManager m_bookmarkManagaer, BookmarkNode node, QString newValue, bool title)
+	{
+		super();
+		m_bookmarkManagaer = m_bookmarkManagaer;
+		m_title = title;
+		m_newValue = newValue;
+		m_node = node;
+		if (m_title) {
+			m_oldValue = m_node.title;
+			setText(BookmarksManager.tr("Name Change"));
+		} else {
+			m_oldValue = m_node.url;
+			setText(BookmarksManager.tr("Address Change"));
+		}
+	}
 
-void undo()
-{
-    if (m_title)
-        m_node.title = m_oldValue;
-    else
-        m_node.url = m_oldValue;
-    emit m_bookmarkManagaer.entryChanged(m_node);
-}
+	void undo()
+	{
+		if (m_title)
+			m_node.title = m_oldValue;
+		else
+			m_node.url = m_oldValue;
+		emit m_bookmarkManagaer.entryChanged(m_node);
+	}
 
-void redo()
-{
-    if (m_title)
-        m_node.title = m_newValue;
-    else
-        m_node.url = m_newValue;
-    emit m_bookmarkManagaer.entryChanged(m_node);
-}
+	void redo()
+	{
+		if (m_title)
+			m_node.title = m_newValue;
+		else
+			m_node.url = m_newValue;
+		emit m_bookmarkManagaer.entryChanged(m_node);
+	}
 
 private:
-    BookmarksManager m_bookmarkManagaer;
-    bool m_title;
-    QString m_oldValue;
-    QString m_newValue;
-    BookmarkNode m_node;
+	
+	BookmarksManager m_bookmarkManagaer;
+	bool m_title;
+	QString m_oldValue;
+	QString m_newValue;
+	BookmarkNode m_node;
 }
 
 /*!
-    BookmarksModel is a QAbstractItemModel wrapper around the BookmarkManager
-  */
+BookmarksModel is a QAbstractItemModel wrapper around the BookmarkManager
+*/
 import qt.gui.QIcon;
 
 class BookmarksModel : public QAbstractItemModel
 {
+public:
+
+	void entryAdded(BookmarkNode item)
+	{
+		assert(item && item.parent());
+		int row = item.parent().children().indexOf(item);
+		BookmarkNode parent = item.parent();
+		// item was already added so remove beore beginInsertRows is called
+		parent.remove(item);
+		beginInsertRows(index(parent), row, row);
+		parent.add(item, row);
+		endInsertRows();
+	}
+
+
+	void entryRemoved(BookmarkNode parent, int row, BookmarkNode item);
+	{
+		// item was already removed, re-add so beginRemoveRows works
+		parent.add(item, row);
+		beginRemoveRows(index(parent), row, row);
+		parent.remove(item);
+		endRemoveRows();
+	}
+
+	void entryChanged(BookmarkNode item);
+	{
+		QModelIndex idx = index(item);
+		emit dataChanged(idx, idx);
+	}
 
 public:
-    void entryAdded(BookmarkNode item)
-{
-    assert(item && item.parent());
-    int row = item.parent().children().indexOf(item);
-    BookmarkNode parent = item.parent();
-    // item was already added so remove beore beginInsertRows is called
-    parent.remove(item);
-    beginInsertRows(index(parent), row, row);
-    parent.add(item, row);
-    endInsertRows();
-}
 
+	enum Roles {
+		TypeRole = Qt.UserRole + 1,
+		UrlRole = Qt.UserRole + 2,
+		UrlStringRole = Qt.UserRole + 3,
+		SeparatorRole = Qt.UserRole + 4
+	}
 
-    void entryRemoved(BookmarkNode parent, int row, BookmarkNode item);
-{
-    // item was already removed, re-add so beginRemoveRows works
-    parent.add(item, row);
-    beginRemoveRows(index(parent), row, row);
-    parent.remove(item);
-    endRemoveRows();
-}
+	BookmarksModel(BookmarksManager bookmarkManager, QObject parent = null)
+	{
+		super(parent)
+		m_endMacro = false;
+		m_bookmarksManager = bookmarkManager;
+		bookmarkManager.entryAdded.connect(&this.entryAdded);
+		bookmarkManager.entryRemoved.connect(&this.entryRemoved);
+		bookmarkManager.entryChanged.connect(&this.entryChanged);
+	}
+    
+    
+	BookmarksManager bookmarksManager() { return m_bookmarksManager; }
 
-    void entryChanged(BookmarkNode item);
-{
-    QModelIndex idx = index(item);
-    emit dataChanged(idx, idx);
-}
-public:
-    enum Roles {
-        TypeRole = Qt.UserRole + 1,
-        UrlRole = Qt.UserRole + 2,
-        UrlStringRole = Qt.UserRole + 3,
-        SeparatorRole = Qt.UserRole + 4
-    }
+	QVariant headerData(int section, Qt.Orientation orientation, int role = Qt.DisplayRole);
+	{
+		if (orientation == Qt.Horizontal && role == Qt.DisplayRole) {
+			switch (section) {
+				case 0: return tr("Title");
+				case 1: return tr("Address");
+			}
+		}
+		return QAbstractItemModel.headerData(section, orientation, role);
+	}
+    
+    
+	QVariant data(QModelIndex index, int role = Qt.DisplayRole)
+	{
+		if (!index.isValid() || index.model() != this)
+		return QVariant();
 
-    BookmarksModel(BookmarksManager bookmarkManager, QObject parent = null)
-{
-	super(parent)
-    m_endMacro = false;
-    m_bookmarksManager = bookmarkManager;
-    bookmarkManager.entryAdded.connect(&this.entryAdded);
-	bookmarkManager.entryRemoved.connect(&this.entryRemoved);
-	bookmarkManager.entryChanged.connect(&this.entryChanged);
-}
+		BookmarkNode bookmarkNode = node(index);
+		switch (role) {
+			case Qt.EditRole:
+			case Qt.DisplayRole:
+				if (bookmarkNode.type() == BookmarkNode.Separator) {
+					switch (index.column()) {
+						case 0: return QString(50, 0xB7);
+						case 1: return QString();
+					}
+				}
+
+				switch (index.column()) {
+					case 0: return bookmarkNode.title;
+					case 1: return bookmarkNode.url;
+				}
+				break;
+			case BookmarksModel.UrlRole:
+				return QUrl(bookmarkNode.url);
+				break;
+			case BookmarksModel.UrlStringRole:
+				return bookmarkNode.url;
+				break;
+			case BookmarksModel.TypeRole:
+				return bookmarkNode.type();
+				break;
+			case BookmarksModel.SeparatorRole:
+				return (bookmarkNode.type() == BookmarkNode.Separator);
+				break;
+			case Qt.DecorationRole:
+				if (index.column() == 0) {
+					if (bookmarkNode.type() == BookmarkNode.Folder)
+						return QApplication.style().standardIcon(QStyle.SP_DirIcon);
+					return BrowserApplication.instance().icon(bookmarkNode.url);
+				}
+		}
+
+		return QVariant();
+	}
+
+	int columnCount(QModelIndex parent = QModelIndex())
+	{
+		return (parent.column() > 0) ? 0 : 2;
+	}
+
+	int rowCount(QModelIndex parent = QModelIndex())
+	{
+		if (parent.column() > 0)
+			return 0;
+
+		if (!parent.isValid())
+			return m_bookmarksManager.bookmarks().children().count();
+
+		BookmarkNode item = static_cast<BookmarkNode>(parent.internalPointer());
+		return item.children().count();
+	}
+
+	QModelIndex index(int, int, QModelIndex& = QModelIndex())
+	{
+		if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent))
+			return QModelIndex();
+
+		// get the parent node
+		BookmarkNode parentNode = node(parent);
+		return createIndex(row, column, parentNode.children().at(row));
+	}
+
+	QModelIndex parent(QModelIndex& index= QModelIndex())
+	{
+		if (!index.isValid())
+			return QModelIndex();
+
+		BookmarkNode itemNode = node(index);
+		BookmarkNode parentNode = (itemNode ? itemNode.parent() : 0);
+		if (!parentNode || parentNode == m_bookmarksManager.bookmarks())
+			return QModelIndex();
+
+		// get the parent's row
+		BookmarkNode grandParentNode = parentNode.parent();
+		int parentRow = grandParentNode.children().indexOf(parentNode);
+		assert(parentRow >= 0);
+		return createIndex(parentRow, 0, parentNode);
+	}
+
+	Qt.ItemFlags flags(QModelIndex index)
+	{
+		if (!index.isValid())
+			return Qt.NoItemFlags;
+
+		Qt.ItemFlags flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled;
+
+		BookmarkNode bookmarkNode = node(index);
+
+		if (bookmarkNode != m_bookmarksManager.menu() && bookmarkNode != m_bookmarksManager.toolbar()) {
+			flags |= Qt.ItemIsDragEnabled;
+			if (bookmarkNode.type() != BookmarkNode.Separator)
+				flags |= Qt.ItemIsEditable;
+		}
+		if (hasChildren(index))
+			flags |= Qt.ItemIsDropEnabled;
+		return flags;
+	}
+
+	Qt.DropActions supportedDropActions ();
+	{
+		return Qt.CopyAction | Qt.MoveAction;
+	}
+
+
+	bool removeRows(int row, int count, QModelIndex parent = QModelIndex());
+	{
+		if (row < 0 || count <= 0 || row + count > rowCount(parent))
+			return false;
+
+		BookmarkNode bookmarkNode = node(parent);
+		for (int i = row + count - 1; i >= row; --i) {
+			BookmarkNode node = bookmarkNode.children().at(i);
+			if (node == m_bookmarksManager.menu() || node == m_bookmarksManager.toolbar())
+				continue;
+
+			m_bookmarksManager.removeBookmark(node);
+		}
+		if (m_endMacro) {
+			m_bookmarksManager.undoRedoStack().endMacro();
+			m_endMacro = false;
+		}
+		return true;
+	}
     
-    
-    inline BookmarksManager bookmarksManager() { return m_bookmarksManager; }
+	bool setData(QModelIndex index, QVariant value, int role = Qt.EditRole)
+	{
+		if (!index.isValid() || (flags(index) & Qt.ItemIsEditable) == 0)
+			return false;
 
-    QVariant headerData(int section, Qt.Orientation orientation, int role = Qt.DisplayRole);
-{
-    if (orientation == Qt.Horizontal && role == Qt.DisplayRole) {
-        switch (section) {
-            case 0: return tr("Title");
-            case 1: return tr("Address");
-        }
-    }
-    return QAbstractItemModel.headerData(section, orientation, role);
-}
-    
-    
-    QVariant data(QModelIndex index, int role = Qt.DisplayRole)
-{
-    if (!index.isValid() || index.model() != this)
-        return QVariant();
+		BookmarkNode item = node(index);
 
-    BookmarkNode bookmarkNode = node(index);
-    switch (role) {
-    case Qt.EditRole:
-    case Qt.DisplayRole:
-        if (bookmarkNode.type() == BookmarkNode.Separator) {
-            switch (index.column()) {
-            case 0: return QString(50, 0xB7);
-            case 1: return QString();
-            }
-        }
+		switch (role) {
+			case Qt.EditRole:
+			case Qt.DisplayRole:
+				if (index.column() == 0) {
+					m_bookmarksManager.setTitle(item, value.toString());
+					break;
+				}
+				if (index.column() == 1) {
+					m_bookmarksManager.setUrl(item, value.toString());
+					break;
+				}
+				return false;
+			case BookmarksModel.UrlRole:
+				m_bookmarksManager.setUrl(item, value.toUrl().toString());
+				break;
+			case BookmarksModel.UrlStringRole:
+				m_bookmarksManager.setUrl(item, value.toString());
+				break;
+			default:
+				break;
+				return false;
+		}
 
-        switch (index.column()) {
-        case 0: return bookmarkNode.title;
-        case 1: return bookmarkNode.url;
-        }
-        break;
-    case BookmarksModel.UrlRole:
-        return QUrl(bookmarkNode.url);
-        break;
-    case BookmarksModel.UrlStringRole:
-        return bookmarkNode.url;
-        break;
-    case BookmarksModel.TypeRole:
-        return bookmarkNode.type();
-        break;
-    case BookmarksModel.SeparatorRole:
-        return (bookmarkNode.type() == BookmarkNode.Separator);
-        break;
-    case Qt.DecorationRole:
-        if (index.column() == 0) {
-            if (bookmarkNode.type() == BookmarkNode.Folder)
-                return QApplication.style().standardIcon(QStyle.SP_DirIcon);
-            return BrowserApplication.instance().icon(bookmarkNode.url);
-        }
-    }
+		return true;
+	}
 
-    return QVariant();
-}
 
-    int columnCount(QModelIndex parent = QModelIndex())
-{
-    return (parent.column() > 0) ? 0 : 2;
-}
-
-    int rowCount(QModelIndex parent = QModelIndex())
-{
-    if (parent.column() > 0)
-        return 0;
-
-    if (!parent.isValid())
-        return m_bookmarksManager.bookmarks().children().count();
-
-    const BookmarkNode item = static_cast<BookmarkNode>(parent.internalPointer());
-    return item.children().count();
-}
-
-    QModelIndex index(int, int, QModelIndex& = QModelIndex())
-{
-    if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent))
-        return QModelIndex();
-
-    // get the parent node
-    BookmarkNode parentNode = node(parent);
-    return createIndex(row, column, parentNode.children().at(row));
-}
-
-    QModelIndex parent(QModelIndex& index= QModelIndex())
-{
-    if (!index.isValid())
-        return QModelIndex();
-
-    BookmarkNode itemNode = node(index);
-    BookmarkNode parentNode = (itemNode ? itemNode.parent() : 0);
-    if (!parentNode || parentNode == m_bookmarksManager.bookmarks())
-        return QModelIndex();
-
-    // get the parent's row
-    BookmarkNode grandParentNode = parentNode.parent();
-    int parentRow = grandParentNode.children().indexOf(parentNode);
-    assert(parentRow >= 0);
-    return createIndex(parentRow, 0, parentNode);
-}
-
-
-    Qt.ItemFlags flags(QModelIndex index)
-{
-    if (!index.isValid())
-        return Qt.NoItemFlags;
-
-    Qt.ItemFlags flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled;
-
-    BookmarkNode bookmarkNode = node(index);
-
-    if (bookmarkNode != m_bookmarksManager.menu() && bookmarkNode != m_bookmarksManager.toolbar()) {
-        flags |= Qt.ItemIsDragEnabled;
-        if (bookmarkNode.type() != BookmarkNode.Separator)
-            flags |= Qt.ItemIsEditable;
-    }
-    if (hasChildren(index))
-        flags |= Qt.ItemIsDropEnabled;
-    return flags;
-}
-
-    Qt.DropActions supportedDropActions ();
-{
-    return Qt.CopyAction | Qt.MoveAction;
-}
-
-
-    bool removeRows(int row, int count, QModelIndex parent = QModelIndex());
-{
-    if (row < 0 || count <= 0 || row + count > rowCount(parent))
-        return false;
-
-    BookmarkNode bookmarkNode = node(parent);
-    for (int i = row + count - 1; i >= row; --i) {
-        BookmarkNode node = bookmarkNode.children().at(i);
-        if (node == m_bookmarksManager.menu()
-            || node == m_bookmarksManager.toolbar())
-            continue;
-
-        m_bookmarksManager.removeBookmark(node);
-    }
-    if (m_endMacro) {
-        m_bookmarksManager.undoRedoStack().endMacro();
-        m_endMacro = false;
-    }
-    return true;
-}
-    
-    bool setData(QModelIndex index, QVariant value, int role = Qt.EditRole)
-{
-    if (!index.isValid() || (flags(index) & Qt.ItemIsEditable) == 0)
-        return false;
-
-    BookmarkNode item = node(index);
-
-    switch (role) {
-    case Qt.EditRole:
-    case Qt.DisplayRole:
-        if (index.column() == 0) {
-            m_bookmarksManager.setTitle(item, value.toString());
-            break;
-        }
-        if (index.column() == 1) {
-            m_bookmarksManager.setUrl(item, value.toString());
-            break;
-        }
-        return false;
-    case BookmarksModel.UrlRole:
-        m_bookmarksManager.setUrl(item, value.toUrl().toString());
-        break;
-    case BookmarksModel.UrlStringRole:
-        m_bookmarksManager.setUrl(item, value.toString());
-        break;
-    default:
-        break;
-        return false;
-    }
-
-    return true;
-}
-
-
-    QMimeData mimeData(QModelIndexList indexes);
-{
-    QMimeData mimeData = new QMimeData();
-    QByteArray data;
-    QDataStream stream(&data, QIODevice.WriteOnly);
-    foreach (QModelIndex index, indexes) {
-        if (index.column() != 0 || !index.isValid())
-            continue;
-        QByteArray encodedData;
-        QBuffer buffer(&encodedData);
-        buffer.open(QBuffer.ReadWrite);
-        XbelWriter writer;
-        const BookmarkNode parentNode = node(index);
-        writer.write(&buffer, parentNode);
-        stream << encodedData;
-    }
-    mimeData.setData(MIMETYPE, data);
-    return mimeData;
-}
+	QMimeData mimeData(QModelIndexList indexes);
+	{
+		QMimeData mimeData = new QMimeData();
+		QByteArray data;
+		auto stream = new QDataStream(&data, QIODevice.WriteOnly);
+		foreach (QModelIndex index, indexes) {
+			if (index.column() != 0 || !index.isValid())
+				continue;
+			QByteArray encodedData;
+			auto buffer = new QBuffer(&encodedData);
+			buffer.open(QBuffer.ReadWrite);
+			XbelWriter writer;
+			const BookmarkNode parentNode = node(index);
+			writer.write(&buffer, parentNode);
+			stream << encodedData;
+		}
+		mimeData.setData(MIMETYPE, data);
+		return mimeData;
+	}
 
 
 const char[] MIMETYPE = QLatin1String("application/bookmarks.xbel")
 
-QStringList mimeTypes()
-{
-    QStringList types;
-    types << MIMETYPE;
-    return types;
-}
+	QStringList mimeTypes()
+	{
+		QStringList types;
+		types << MIMETYPE;
+		return types;
+	}
 
-bool dropMimeData(QMimeData data,  Qt.DropAction action, int row, int column, QModelIndex parent)
-{
-    if (action == Qt.IgnoreAction)
-        return true;
+	bool dropMimeData(QMimeData data,  Qt.DropAction action, int row, int column, QModelIndex parent)
+	{
+		if (action == Qt.IgnoreAction)
+			return true;
 
-    if (!data.hasFormat(MIMETYPE) || column > 0)
-        return false;
+		if (!data.hasFormat(MIMETYPE) || column > 0)
+			return false;
 
-    QByteArray ba = data.data(MIMETYPE);
-    QDataStream stream(&ba, QIODevice.ReadOnly);
-    if (stream.atEnd())
-        return false;
+		QByteArray ba = data.data(MIMETYPE);
+		QDataStream stream(&ba, QIODevice.ReadOnly);
+		if (stream.atEnd())
+			return false;
 
-    QUndoStack undoStack = m_bookmarksManager.undoRedoStack();
-    undoStack.beginMacro(QLatin1String("Move Bookmarks"));
+		QUndoStack undoStack = m_bookmarksManager.undoRedoStack();
+		undoStack.beginMacro(QLatin1String("Move Bookmarks"));
 
-    while (!stream.atEnd()) {
-        QByteArray encodedData;
-        stream >> encodedData;
-        QBuffer buffer(&encodedData);
-        buffer.open(QBuffer.ReadOnly);
+		while (!stream.atEnd()) {
+			QByteArray encodedData;
+			stream >> encodedData;
+			QBuffer buffer(&encodedData);
+			buffer.open(QBuffer.ReadOnly);
 
-        XbelReader reader;
-        BookmarkNode rootNode = reader.read(&buffer);
-        QList<BookmarkNode> children = rootNode.children();
-        for (int i = 0; i < children.count(); ++i) {
-            BookmarkNode bookmarkNode = children.at(i);
-            rootNode.remove(bookmarkNode);
-            row = qMax(0, row);
-            BookmarkNode parentNode = node(parent);
-            m_bookmarksManager.addBookmark(parentNode, bookmarkNode, row);
-            m_endMacro = true;
-        }
-        delete rootNode;
-    }
-    return true;
-}
+			XbelReader reader;
+			BookmarkNode rootNode = reader.read(&buffer);
+			QList<BookmarkNode> children = rootNode.children();
+			for (int i = 0; i < children.count(); ++i) {
+				BookmarkNode bookmarkNode = children.at(i);
+				rootNode.remove(bookmarkNode);
+				row = qMax(0, row);
+				BookmarkNode parentNode = node(parent);
+				m_bookmarksManager.addBookmark(parentNode, bookmarkNode, row);
+				m_endMacro = true;
+			}
+			delete rootNode;
+		}
+		return true;
+	}
 
+	bool hasChildren(QModelIndex parent = QModelIndex())
+	{
+		if (!parent.isValid())
+			return true;
+		const BookmarkNode parentNode = node(parent);
+		return (parentNode.type() == BookmarkNode.Folder);
+	}
 
-    bool hasChildren(QModelIndex parent = QModelIndex())
-{
-    if (!parent.isValid())
-        return true;
-    const BookmarkNode parentNode = node(parent);
-    return (parentNode.type() == BookmarkNode.Folder);
-}
+	BookmarkNode node(QModelIndex index)
+	{
+		BookmarkNode itemNode = static_cast<BookmarkNode>(index.internalPointer());
+		if (!itemNode)
+			return m_bookmarksManager.bookmarks();
+		return itemNode;
+	}
 
-    BookmarkNode node(QModelIndex index)
-{
-    BookmarkNode itemNode = static_cast<BookmarkNode>(index.internalPointer());
-    if (!itemNode)
-        return m_bookmarksManager.bookmarks();
-    return itemNode;
-}
-
-    QModelIndex index(BookmarkNode node)
-{
-    BookmarkNode parent = node.parent();
-    if (!parent)
-        return QModelIndex();
-    return createIndex(parent.children().indexOf(node), 0, node);
-}
+	QModelIndex index(BookmarkNode node)
+	{
+		BookmarkNode parent = node.parent();
+		if (!parent)
+			return QModelIndex();
+		return createIndex(parent.children().indexOf(node), 0, node);
+	}
 
 private:
 
-    bool m_endMacro;
-    BookmarksManager m_bookmarksManager;
+	bool m_endMacro;
+	BookmarksManager m_bookmarksManager;
 }
 
 // Menu that is dynamically populated from the bookmarks
 import modelmenu;
+
 class BookmarksMenu : public ModelMenu
 {
-    mixin Signal!("openUrl", QUrl url);
+	mixin Signal!("openUrl", QUrl url);
 
 public:
-     BookmarksMenu(QWidget parent = null)
-{
-super(parent);	
-	m_bookmarksManager = 0;
-    this.activated.connect(&this.activated);
-    setMaxRows(-1);
-    setHoverRole(BookmarksModel.UrlStringRole);
-    setSeparatorRole(BookmarksModel.SeparatorRole);
-}
-     void setInitialActions(QList<QAction> actions);
-{
-    m_initialActions = actions;
-    for (int i = 0; i < m_initialActions.count(); ++i)
-        addAction(m_initialActions.at(i));
-}
+
+	BookmarksMenu(QWidget parent = null)
+	{
+		super(parent);	
+		m_bookmarksManager = 0;
+		this.activated.connect(&this.activated);
+		setMaxRows(-1);
+		setHoverRole(BookmarksModel.UrlStringRole);
+		setSeparatorRole(BookmarksModel.SeparatorRole);
+	}
+	
+	void setInitialActions(QList<QAction> actions);
+	{
+		m_initialActions = actions;
+		for (int i = 0; i < m_initialActions.count(); ++i)
+			addAction(m_initialActions.at(i));
+	}
+
 protected:
+
 	bool prePopulated()
-{
-    m_bookmarksManager = BrowserApplication.bookmarksManager();
-    setModel(m_bookmarksManager.bookmarksModel());
-    setRootIndex(m_bookmarksManager.bookmarksModel().index(1, 0));
-    // initial actions
-    for (int i = 0; i < m_initialActions.count(); ++i)
-        addAction(m_initialActions.at(i));
-    if (!m_initialActions.isEmpty())
-        addSeparator();
-    createMenu(model().index(0, 0), 1, this);
-    return true;
-}
-
-private slots:
-    void activated(QModelIndex index)
-{
-    emit openUrl(index.data(BookmarksModel.UrlRole).toUrl());
-}
+	{
+		m_bookmarksManager = BrowserApplication.bookmarksManager();
+		setModel(m_bookmarksManager.bookmarksModel());
+		setRootIndex(m_bookmarksManager.bookmarksModel().index(1, 0));
+		// initial actions
+		for (int i = 0; i < m_initialActions.count(); ++i)
+			addAction(m_initialActions.at(i));
+		if (!m_initialActions.isEmpty())
+			addSeparator();
+		createMenu(model().index(0, 0), 1, this);
+		return true;
+	}
 
 private:
-    BookmarksManager m_bookmarksManager;
-    QList<QAction> m_initialActions;
+
+	void activated(QModelIndex index)
+	{
+		emit openUrl(index.data(BookmarksModel.UrlRole).toUrl());
+	}
+
+private:
+
+	BookmarksManager m_bookmarksManager;
+	QList<QAction> m_initialActions;
 }
 
 /*
@@ -823,85 +822,89 @@
 
 class AddBookmarkProxyModel : public QSortFilterProxyModel
 {
-    Q_OBJECT
 public:
-    this(QObject  parent = null)
-{
-	super(parent);
-}
-    int columnCount(QModelIndex  parent = QModelIndex())
-{
-    return qMin(1, QSortFilterProxyModel.columnCount(parent));
-}
-protected:
-    bool filterAcceptsRow(int source_row, QModelIndex source_parent)
-{
-    QModelIndex idx = sourceModel().index(source_row, 0, source_parent);
-    return sourceModel().hasChildren(idx);
-}
+
+	this(QObject  parent = null)
+	{
+		super(parent);
+	}
+	
+	int columnCount(QModelIndex  parent = QModelIndex())
+	{
+		return qMin(1, QSortFilterProxyModel.columnCount(parent));
+	}
+
+	protected:
+
+	bool filterAcceptsRow(int source_row, QModelIndex source_parent)
+	{
+		QModelIndex idx = sourceModel().index(source_row, 0, source_parent);
+		return sourceModel().hasChildren(idx);
+	}
 }
 
 /*!
-    Add bookmark dialog
- */
+Add bookmark dialog
+*/
 
 import ui_addbookmarkdialog;
 
 class AddBookmarkDialog : public QDialog, public Ui_AddBookmarkDialog
 {
+public:
 
-public:
-    this(QString url, QString title, QWidget parent = null, BookmarksManager bookmarkManager = null)
- : QDialog(parent)
-{
-	m_url = url;
-    m_bookmarksManager = bookmarkManager;
-	
-    setWindowFlags(Qt.Sheet);
-    if (!m_bookmarksManager)
-        m_bookmarksManager = BrowserApplication.bookmarksManager();
-    setupUi(this);
-    QTreeView view = new QTreeView(this);
-    m_proxyModel = new AddBookmarkProxyModel(this);
-    BookmarksModel model = m_bookmarksManager.bookmarksModel();
-    m_proxyModel.setSourceModel(model);
-    view.setModel(m_proxyModel);
-    view.expandAll();
-    view.header().setStretchLastSection(true);
-    view.header().hide();
-    view.setItemsExpandable(false);
-    view.setRootIsDecorated(false);
-    view.setIndentation(10);
-    location.setModel(m_proxyModel);
-    view.show();
-    location.setView(view);
-    BookmarkNode menu = m_bookmarksManager.menu();
-    QModelIndex idx = m_proxyModel.mapFromSource(model.index(menu));
-    view.setCurrentIndex(idx);
-    location.setCurrentIndex(idx.row());
-    name.setText(title);
-}
+	this(QString url, QString title, QWidget parent = null, BookmarksManager bookmarkManager = null)
+	: QDialog(parent)
+	{
+		m_url = url;
+		m_bookmarksManager = bookmarkManager;
+
+		setWindowFlags(Qt.Sheet);
+		if (!m_bookmarksManager)
+			m_bookmarksManager = BrowserApplication.bookmarksManager();
+		setupUi(this);
+		QTreeView view = new QTreeView(this);
+		m_proxyModel = new AddBookmarkProxyModel(this);
+		BookmarksModel model = m_bookmarksManager.bookmarksModel();
+		m_proxyModel.setSourceModel(model);
+		view.setModel(m_proxyModel);
+		view.expandAll();
+		view.header().setStretchLastSection(true);
+		view.header().hide();
+		view.setItemsExpandable(false);
+		view.setRootIsDecorated(false);
+		view.setIndentation(10);
+		location.setModel(m_proxyModel);
+		view.show();
+		location.setView(view);
+		BookmarkNode menu = m_bookmarksManager.menu();
+		QModelIndex idx = m_proxyModel.mapFromSource(model.index(menu));
+		view.setCurrentIndex(idx);
+		location.setCurrentIndex(idx.row());
+		name.setText(title);
+	}
 
 private:
 	
-void accept()
-{
-    QModelIndex index = location.view().currentIndex();
-    index = m_proxyModel.mapToSource(index);
-    if (!index.isValid())
-        index = m_bookmarksManager.bookmarksModel().index(0, 0);
-    BookmarkNode parent = m_bookmarksManager.bookmarksModel().node(index);
-    BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark);
-    bookmark.url = m_url;
-    bookmark.title = name.text();
-    m_bookmarksManager.addBookmark(parent, bookmark);
-    QDialog.accept();
-}
+	void accept()
+	{
+		QModelIndex index = location.view().currentIndex();
+		index = m_proxyModel.mapToSource(index);
+		if (!index.isValid())
+			index = m_bookmarksManager.bookmarksModel().index(0, 0);
+		BookmarkNode parent = m_bookmarksManager.bookmarksModel().node(index);
+		BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark);
+		bookmark.url = m_url;
+		bookmark.title = name.text();
+		m_bookmarksManager.addBookmark(parent, bookmark);
+		QDialog.accept();
+	}
 
 private:
-    QString m_url;
-    BookmarksManager m_bookmarksManager;
-    AddBookmarkProxyModel m_proxyModel;
+
+	QString m_url;
+	BookmarksManager m_bookmarksManager;
+	AddBookmarkProxyModel m_proxyModel;
 }
 
 import ui_bookmarks;
@@ -909,239 +912,245 @@
 //class TreeProxyModel;
 class BookmarksDialog : public QDialog, public Ui_BookmarksDialog
 {
-	
-    mixin Signal!("openUrl", QUrl url);
+	mixin Signal!("openUrl", QUrl url);
 
 public:
-    this(QWidget parent = null, BookmarksManager manager = null)
-    : QDialog(parent)
-{
-    m_bookmarksManager = manager;
-    if (!m_bookmarksManager)
-        m_bookmarksManager = BrowserApplication.bookmarksManager();
-    setupUi(this);
 
-    tree.setUniformRowHeights(true);
-    tree.setSelectionBehavior(QAbstractItemView.SelectRows);
-    tree.setSelectionMode(QAbstractItemView.ContiguousSelection);
-    tree.setTextElideMode(Qt.ElideMiddle);
-    m_bookmarksModel = m_bookmarksManager.bookmarksModel();
-    m_proxyModel = new TreeProxyModel(this);
-    search.textChanged.connect(&m_proxyModel.setFilterFixedString);
-    removeButton.clicked.connect(&tree.removeOne);
-    m_proxyModel.setSourceModel(m_bookmarksModel);
-    tree.setModel(m_proxyModel);
-    tree.setDragDropMode(QAbstractItemView.InternalMove);
-    tree.setExpanded(m_proxyModel.index(0, 0), true);
-    tree.setAlternatingRowColors(true);
-   auto fm = new QFontMetrics(font());
-    int header = fm.width(QLatin1Char('m')) * 40;
-    tree.header().resizeSection(0, header);
-    tree.header().setStretchLastSection(true);
-    tree.activated.connect(&this.open);
-    tree.setContextMenuPolicy(Qt.CustomContextMenu);
-    tree.customContextMenuRequested.connect(&this.customContextMenuRequested);
-    addFolderButton.clicked.connect(&this.newFolder);
-    expandNodes(m_bookmarksManager.bookmarks());
-    setAttribute(Qt.WA_DeleteOnClose);
-}
-    ~this()
-{
-    if (saveExpandedNodes(tree.rootIndex()))
-        m_bookmarksManager.changeExpanded();
-}
+	this(QWidget parent = null, BookmarksManager manager = null)
+	: QDialog(parent)
+	{
+		m_bookmarksManager = manager;
+		if (!m_bookmarksManager)
+			m_bookmarksManager = BrowserApplication.bookmarksManager();
+		setupUi(this);
 
-private slots:
-    void customContextMenuRequested(QPoint pos)
-{
-    QMenu menu;
-    QModelIndex index = tree.indexAt(pos);
-    index = index.sibling(index.row(), 0);
-    if (index.isValid() && !tree.model().hasChildren(index)) {
-        menu.addAction(tr("Open"), this, SLOT(open()));
-        menu.addSeparator();
-    }
-    menu.addAction(tr("Delete"), tree, SLOT(removeOne()));
-    menu.exec(QCursor.pos());
-}
-void open()
-{
-    QModelIndex index = tree.currentIndex();
-    if (!index.parent().isValid())
-        return;
-    emit openUrl(index.sibling(index.row(), 1).data(BookmarksModel.UrlRole).toUrl());
-}
-
-    void newFolder()
-{
-    QModelIndex currentIndex = tree.currentIndex();
-    QModelIndex idx = currentIndex;
-    if (idx.isValid() && !idx.model().hasChildren(idx))
-        idx = idx.parent();
-    if (!idx.isValid())
-        idx = tree.rootIndex();
-    idx = m_proxyModel.mapToSource(idx);
-    BookmarkNode parent = m_bookmarksManager.bookmarksModel().node(idx);
-    BookmarkNode node = new BookmarkNode(BookmarkNode.Folder);
-    node.title = tr("New Folder");
-    m_bookmarksManager.addBookmark(parent, node, currentIndex.row() + 1);
-}
+		tree.setUniformRowHeights(true);
+		tree.setSelectionBehavior(QAbstractItemView.SelectRows);
+		tree.setSelectionMode(QAbstractItemView.ContiguousSelection);
+		tree.setTextElideMode(Qt.ElideMiddle);
+		m_bookmarksModel = m_bookmarksManager.bookmarksModel();
+		m_proxyModel = new TreeProxyModel(this);
+		search.textChanged.connect(&m_proxyModel.setFilterFixedString);
+		removeButton.clicked.connect(&tree.removeOne);
+		m_proxyModel.setSourceModel(m_bookmarksModel);
+		tree.setModel(m_proxyModel);
+		tree.setDragDropMode(QAbstractItemView.InternalMove);
+		tree.setExpanded(m_proxyModel.index(0, 0), true);
+		tree.setAlternatingRowColors(true);
+		auto fm = new QFontMetrics(font());
+		int header = fm.width(QLatin1Char('m')) * 40;
+		tree.header().resizeSection(0, header);
+		tree.header().setStretchLastSection(true);
+		tree.activated.connect(&this.open);
+		tree.setContextMenuPolicy(Qt.CustomContextMenu);
+		tree.customContextMenuRequested.connect(&this.customContextMenuRequested);
+		addFolderButton.clicked.connect(&this.newFolder);
+		expandNodes(m_bookmarksManager.bookmarks());
+		setAttribute(Qt.WA_DeleteOnClose);
+	}
+	
+	~this()
+	{
+		if (saveExpandedNodes(tree.rootIndex()))
+			m_bookmarksManager.changeExpanded();
+	}
 
 private:
-    void expandNodes(BookmarkNode node)
-{
-    for (int i = 0; i < node.children().count(); ++i) {
-        BookmarkNode childNode = node.children()[i];
-        if (childNode.expanded) {
-            QModelIndex idx = m_bookmarksModel.index(childNode);
-            idx = m_proxyModel.mapFromSource(idx);
-            tree.setExpanded(idx, true);
-            expandNodes(childNode);
-        }
-    }
-}
 
-bool saveExpandedNodes(QModelIndex parent)
-{
-    bool changed = false;
-    for (int i = 0; i < m_proxyModel.rowCount(parent); ++i) {
-        QModelIndex child = m_proxyModel.index(i, 0, parent);
-        QModelIndex sourceIndex = m_proxyModel.mapToSource(child);
-        BookmarkNode childNode = m_bookmarksModel.node(sourceIndex);
-        bool wasExpanded = childNode.expanded;
-        if (tree.isExpanded(child)) {
-            childNode.expanded = true;
-            changed |= saveExpandedNodes(child);
-        } else {
-            childNode.expanded = false;
-        }
-        changed |= (wasExpanded != childNode.expanded);
-    }
-    return changed;
-}
+	void customContextMenuRequested(QPoint pos)
+	{
+		QMenu menu;
+		QModelIndex index = tree.indexAt(pos);
+		index = index.sibling(index.row(), 0);
+		if (index.isValid() && !tree.model().hasChildren(index)) {
+			menu.addAction(tr("Open"), this, SLOT(open()));
+			menu.addSeparator();
+		}
+		menu.addAction(tr("Delete"), tree, SLOT(removeOne()));
+		menu.exec(QCursor.pos());
+	}
+	
+	void open()
+	{
+		QModelIndex index = tree.currentIndex();
+		if (!index.parent().isValid())
+			return;
+		emit openUrl(index.sibling(index.row(), 1).data(BookmarksModel.UrlRole).toUrl());
+	}
 
-    BookmarksManager m_bookmarksManager;
-    BookmarksModel m_bookmarksModel;
-    TreeProxyModel m_proxyModel;
+	void newFolder()
+	{
+		QModelIndex currentIndex = tree.currentIndex();
+		QModelIndex idx = currentIndex;
+		if (idx.isValid() && !idx.model().hasChildren(idx))
+			idx = idx.parent();
+		if (!idx.isValid())
+			idx = tree.rootIndex();
+		idx = m_proxyModel.mapToSource(idx);
+		BookmarkNode parent = m_bookmarksManager.bookmarksModel().node(idx);
+		BookmarkNode node = new BookmarkNode(BookmarkNode.Folder);
+		node.title = tr("New Folder");
+		m_bookmarksManager.addBookmark(parent, node, currentIndex.row() + 1);
+	}
+
+private:
+	void expandNodes(BookmarkNode node)
+	{
+		for (int i = 0; i < node.children().count(); ++i) {
+			BookmarkNode childNode = node.children()[i];
+			if (childNode.expanded) {
+				QModelIndex idx = m_bookmarksModel.index(childNode);
+				idx = m_proxyModel.mapFromSource(idx);
+				tree.setExpanded(idx, true);
+				expandNodes(childNode);
+			}
+		}
+	}
+
+	bool saveExpandedNodes(QModelIndex parent)
+	{
+		bool changed = false;
+		for (int i = 0; i < m_proxyModel.rowCount(parent); ++i) {
+			QModelIndex child = m_proxyModel.index(i, 0, parent);
+			QModelIndex sourceIndex = m_proxyModel.mapToSource(child);
+			BookmarkNode childNode = m_bookmarksModel.node(sourceIndex);
+			bool wasExpanded = childNode.expanded;
+			if (tree.isExpanded(child)) {
+				childNode.expanded = true;
+				changed |= saveExpandedNodes(child);
+			} else {
+				childNode.expanded = false;
+			}
+			changed |= (wasExpanded != childNode.expanded);
+		}
+		return changed;
+	}
+
+	BookmarksManager m_bookmarksManager;
+	BookmarksModel m_bookmarksModel;
+	TreeProxyModel m_proxyModel;
 }
 
 import qt.gui.QToolBar;
 
 class BookmarksToolBar : public QToolBar
 {
-    mixin Signal!("openUrl", QUrl url);
+mixin Signal!("openUrl", QUrl url);
 
 public:
-    BookmarksToolBar(BookmarksModel model, QWidget parent = null)
-{
-	super(tr("Bookmark"), parent);
-	m_bookmarksModel = model;
-    this.actionTriggered.connect(&this.triggered);
-    setRootIndex(model.index(0, 0));
-    m_bookmarksModel.modelReset.connect(&this.build);
-    m_bookmarksModel.rowsInserted.connect(&this.build);
-    m_bookmarksModel.rowsRemoved.connect(&this.build);
-    m_bookmarksModel.dataChanged.connect(&this.build);
-    setAcceptDrops(true);
-}
 
-    void setRootIndex(QModelIndex index);
-{
-    m_root = index;
-    build();
-}
+	this(BookmarksModel model, QWidget parent = null)
+	{
+		super(tr("Bookmark"), parent);
+		m_bookmarksModel = model;
+		this.actionTriggered.connect(&this.triggered);
+		setRootIndex(model.index(0, 0));
+		m_bookmarksModel.modelReset.connect(&this.build);
+		m_bookmarksModel.rowsInserted.connect(&this.build);
+		m_bookmarksModel.rowsRemoved.connect(&this.build);
+		m_bookmarksModel.dataChanged.connect(&this.build);
+		setAcceptDrops(true);
+	}
 
-    QModelIndex rootIndex()
-{
-    return m_root;
-}
+	void setRootIndex(QModelIndex index);
+	{
+		m_root = index;
+		build();
+	}
+
+	QModelIndex rootIndex()
+	{
+		return m_root;
+	}
 
 protected:
-    void dragEnterEvent(QDragEnterEvent event)
-{
-    const QMimeData mimeData = event.mimeData();
-    if (mimeData.hasUrls())
-        event.acceptProposedAction();
-    QToolBar.dragEnterEvent(event);
-}
 
-    void dropEvent(QDropEvent event)
-{
-    const QMimeData mimeData = event.mimeData();
-    if (mimeData.hasUrls() && mimeData.hasText()) {
-        QList<QUrl> urls = mimeData.urls();
-        QAction action = actionAt(event.pos());
-        QString dropText;
-        if (action)
-            dropText = action.text();
-        int row = -1;
-        QModelIndex parentIndex = m_root;
-        for (int i = 0; i < m_bookmarksModel.rowCount(m_root); ++i) {
-            QModelIndex idx = m_bookmarksModel.index(i, 0, m_root);
-            QString title = idx.data().toString();
-            if (title == dropText) {
-                row = i;
-                if (m_bookmarksModel.hasChildren(idx)) {
-                    parentIndex = idx;
-                    row = -1;
-                }
-                break;
-            }
-        }
-        BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark);
-        bookmark.url = urls.at(0).toString();
-        bookmark.title = mimeData.text();
+	void dragEnterEvent(QDragEnterEvent event)
+	{
+		const QMimeData mimeData = event.mimeData();
+		if (mimeData.hasUrls())
+			event.acceptProposedAction();
+		QToolBar.dragEnterEvent(event);
+	}
 
-        BookmarkNode parent = m_bookmarksModel.node(parentIndex);
-        BookmarksManager bookmarksManager = m_bookmarksModel.bookmarksManager();
-        bookmarksManager.addBookmark(parent, bookmark, row);
-        event.acceptProposedAction();
-    }
-    QToolBar.dropEvent(event);
-}
+	void dropEvent(QDropEvent event)
+	{
+		const QMimeData mimeData = event.mimeData();
+		if (mimeData.hasUrls() && mimeData.hasText()) {
+			QList<QUrl> urls = mimeData.urls();
+			QAction action = actionAt(event.pos());
+			QString dropText;
+			if (action)
+				dropText = action.text();
+			int row = -1;
+			QModelIndex parentIndex = m_root;
+			for (int i = 0; i < m_bookmarksModel.rowCount(m_root); ++i) {
+				QModelIndex idx = m_bookmarksModel.index(i, 0, m_root);
+				QString title = idx.data().toString();
+				if (title == dropText) {
+					row = i;
+					if (m_bookmarksModel.hasChildren(idx)) {
+						parentIndex = idx;
+						row = -1;
+					}
+					break;
+				}
+			}
+			BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark);
+			bookmark.url = urls.at(0).toString();
+			bookmark.title = mimeData.text();
 
-private slots:
-    void triggered(QAction action)
-{
-    QVariant v = action.data();
-    if (v.canConvert<QUrl>()) {
-        emit openUrl(v.toUrl());
-    }
-}
-
-    void activated(QModelIndex index)
-{
-    emit openUrl(index.data(BookmarksModel.UrlRole).toUrl());
-}
-
-
-    void build()
-{
-    clear();
-    for (int i = 0; i < m_bookmarksModel.rowCount(m_root); ++i) {
-        QModelIndex idx = m_bookmarksModel.index(i, 0, m_root);
-        if (m_bookmarksModel.hasChildren(idx)) {
-            QToolButton button = new QToolButton(this);
-            button.setPopupMode(QToolButton.InstantPopup);
-            button.setArrowType(Qt.DownArrow);
-            button.setText(idx.data().toString());
-            ModelMenu menu = new ModelMenu(this);
-            menu.activated.connect(&this.activated);
-            menu.setModel(m_bookmarksModel);
-            menu.setRootIndex(idx);
-            menu.addAction(new QAction(menu));
-            button.setMenu(menu);
-            button.setToolButtonStyle(Qt.ToolButtonTextOnly);
-            QAction a = addWidget(button);
-            a.setText(idx.data().toString());
-        } else {
-            QAction action = addAction(idx.data().toString());
-            action.setData(idx.data(BookmarksModel.UrlRole));
-        }
-    }
-}
+			BookmarkNode parent = m_bookmarksModel.node(parentIndex);
+			BookmarksManager bookmarksManager = m_bookmarksModel.bookmarksManager();
+			bookmarksManager.addBookmark(parent, bookmark, row);
+			event.acceptProposedAction();
+		}
+		QToolBar.dropEvent(event);
+	}
 
 private:
-    BookmarksModel m_bookmarksModel;
-    QPersistentModelIndex m_root;
+
+	void triggered(QAction action)
+	{
+		QVariant v = action.data();
+		if (v.canConvert<QUrl>()) {
+			emit openUrl(v.toUrl());
+		}
+	}
+
+	void activated(QModelIndex index)
+	{
+		emit openUrl(index.data(BookmarksModel.UrlRole).toUrl());
+	}
+
+	void build()
+	{
+		clear();
+		for (int i = 0; i < m_bookmarksModel.rowCount(m_root); ++i) {
+			QModelIndex idx = m_bookmarksModel.index(i, 0, m_root);
+			if (m_bookmarksModel.hasChildren(idx)) {
+				QToolButton button = new QToolButton(this);
+				button.setPopupMode(QToolButton.InstantPopup);
+				button.setArrowType(Qt.DownArrow);
+				button.setText(idx.data().toString());
+				ModelMenu menu = new ModelMenu(this);
+				menu.activated.connect(&this.activated);
+				menu.setModel(m_bookmarksModel);
+				menu.setRootIndex(idx);
+				menu.addAction(new QAction(menu));
+				button.setMenu(menu);
+				button.setToolButtonStyle(Qt.ToolButtonTextOnly);
+				QAction a = addWidget(button);
+				a.setText(idx.data().toString());
+			} else {
+				QAction action = addAction(idx.data().toString());
+				action.setData(idx.data(BookmarksModel.UrlRole));
+			}
+		}
+	}
+
+private:
+
+	BookmarksModel m_bookmarksModel;
+	QPersistentModelIndex m_root;
 }
--- a/demos/browser/browsermainwindow.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/browsermainwindow.d	Fri May 22 10:59:00 2009 +0000
@@ -38,12 +38,29 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module browsermainwindow:
 
-import QtGui.QMainWindow;
-import QtGui.QIcon;
-import QtCore.QUrl;
 
-import browsermainwindow;
+import qt.core.QUrl;
+import qt.core.QSettings;
+import qt.gui.QMainWindow;
+import qt.gui.QIcon;
+import qt.gui.QDesktopWidget;
+import qt.gui.QFileDialog;
+import qt.gui.QPlainTextEdit;
+import qt.gui.QPrintDialog;
+import qt.gui.QPrintPreviewDialog;
+import qt.gui.QPrinter;
+import qt.gui.QMenuBar;
+import qt.gui.QMessageBox;
+import qt.gui.QStatusBar;
+import qt.gui.QToolBar;
+import qt.gui.QInputDialog;
+
+import qt.core.QDebug;
+
+import qt.webkit.QWebFrame;
+import qt.webkit.QWebHistory;
 
 import autosaver;
 import bookmarks;
@@ -54,1020 +71,955 @@
 import settings;
 import tabwidget;
 import toolbarsearch;
+import webview;
 import ui_passworddialog;
-import webview;
 
-import QtCore.QSettings;
-
-import QtGui.QDesktopWidget;
-import QtGui.QFileDialog;
-import QtGui.QPlainTextEdit;
-import QtGui.QPrintDialog;
-import QtGui.QPrintPreviewDialog;
-import QtGui.QPrinter;
-import QtGui.QMenuBar;
-import QtGui.QMessageBox;
-import QtGui.QStatusBar;
-import QtGui.QToolBar;
-import QtGui.QInputDialog;
-
-import QtWebKit.QWebFrame;
-import QtWebKit.QWebHistory;
-
-import QtCore.QDebug;
-
-
-class AutoSaver;
-class BookmarksToolBar;
-class ChaseWidget;
-class QWebFrame;
-class TabWidget;
-class ToolbarSearch;
-class WebView;
 
 /*!
-    The MainWindow of the Browser Application.
+The MainWindow of the Browser Application.
 
-    Handles the tab widget and all the actions
- */
-class BrowserMainWindow : public QMainWindow {
-    Q_OBJECT
+Handles the tab widget and all the actions
+*/
+class BrowserMainWindow : public QMainWindow
+{
 	
 static const qint32 BrowserMainWindowMagic = 0xba;
-	
-public:
-    this(QWidget *parent = null, Qt.WindowFlags flags = 0);
-{
-	
-	super(parent, flags);
-	m_tabWidget = new TabWidget(this);
-	m_autoSaver = new AutoSaver(this);
-	m_historyBack = 0;
-	m_historyForward = 0;
-	m_stop = 0;
-	m_reload = 0;
-	
-    setAttribute(Qt.WA_DeleteOnClose, true);
-    statusBar().setSizeGripEnabled(true);
-    setupMenu();
-    setupToolBar();
-
-    QWidget *centralWidget = new QWidget(this);
-    BookmarksModel *boomarksModel = BrowserApplication::bookmarksManager().bookmarksModel();
-    m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this);
-    connect(m_bookmarksToolbar, SIGNAL(openUrl(const QUrl&)),
-            m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
-    connect(m_bookmarksToolbar.toggleViewAction(), SIGNAL(toggled(bool)),
-            this, SLOT(updateBookmarksToolbarActionText(bool)));
-
-    QVBoxLayout *layout = new QVBoxLayout;
-    layout.setSpacing(0);
-    layout.setMargin(0);
-version(Q_WS_MAC)
-{
-    layout.addWidget(m_bookmarksToolbar);
-    layout.addWidget(new QWidget); // <- OS X tab widget style bug
-} else {
-    addToolBarBreak();
-    addToolBar(m_bookmarksToolbar);
-}
-    layout.addWidget(m_tabWidget);
-    centralWidget.setLayout(layout);
-	setCentralWidget(centralWidget);
-
-    connect(m_tabWidget, SIGNAL(loadPage(const QString &)),
-        this, SLOT(loadPage(const QString &)));
-    connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)),
-        this, SLOT(slotUpdateWindowTitle(const QString &)));
-    connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)),
-            statusBar(), SLOT(showMessage(const QString&)));
-    connect(m_tabWidget, SIGNAL(linkHovered(const QString&)),
-            statusBar(), SLOT(showMessage(const QString&)));
-    connect(m_tabWidget, SIGNAL(loadProgress(int)),
-            this, SLOT(slotLoadProgress(int)));
-    connect(m_tabWidget, SIGNAL(tabsChanged()),
-            m_autoSaver, SLOT(changeOccurred()));
-    connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)),
-            this, SLOT(geometryChangeRequested(const QRect &)));
-    connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)),
-            this, SLOT(printRequested(QWebFrame *)));
-    connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)),
-            menuBar(), SLOT(setVisible(bool)));
-    connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)),
-            statusBar(), SLOT(setVisible(bool)));
-    connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)),
-            m_navigationBar, SLOT(setVisible(bool)));
-    connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)),
-            m_bookmarksToolbar, SLOT(setVisible(bool)));
-version(Q_WS_MAC) {
-    connect(m_tabWidget, SIGNAL(lastTabClosed()),
-            this, SLOT(close()));
-} else {
-    connect(m_tabWidget, SIGNAL(lastTabClosed()),
-            m_tabWidget, SLOT(newTab()));
-}
-
-    slotUpdateWindowTitle();
-    loadDefaultState();
-    m_tabWidget.newTab();
-
-    int size = m_tabWidget.lineEditStack().sizeHint().height();
-    m_navigationBar.setIconSize(QSize(size, size));
-
-}
-
-
-
-   ~this()
-{
-    m_autoSaver.changeOccurred();
-    m_autoSaver.saveIfNeccessary();
-}
-
-
-QSize sizeHint()
-{
-    QRect desktopRect = QApplication::desktop().screenGeometry();
-    QSize size = desktopRect.size() * qreal(0.9);
-    return size;
-}
 
 public:
-static QUrl guessUrlFromString(const QString &string)
-{
-    QString urlStr = string.trimmed();
-    QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
 
-    // Check if it looks like a qualified URL. Try parsing it and see.
-    bool hasSchema = test.exactMatch(urlStr);
-    if (hasSchema) {
-        QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode);
-        if (url.isValid())
-            return url;
-    }
+	this(QWidget parent = null, Qt.WindowFlags flags = 0);
+	{
+		super(parent, flags);
+		m_tabWidget = new TabWidget(this);
+		m_autoSaver = new AutoSaver(this);
+		m_historyBack = 0;
+		m_historyForward = 0;
+		m_stop = 0;
+		m_reload = 0;
 
-    // Might be a file.
-    if (QFile::exists(urlStr)) {
-        QFileInfo info(urlStr);
-        return QUrl::fromLocalFile(info.absoluteFilePath());
-    }
+		setAttribute(Qt.WA_DeleteOnClose, true);
+		statusBar().setSizeGripEnabled(true);
+		setupMenu();
+		setupToolBar();
 
-    // Might be a shorturl - try to detect the schema.
-    if (!hasSchema) {
-        int dotIndex = urlStr.indexOf(QLatin1Char('.'));
-        if (dotIndex != -1) {
-            QString prefix = urlStr.left(dotIndex).toLower();
-            QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : "http";
-            QUrl url =
-                QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode);
-            if (url.isValid())
-                return url;
-        }
-    }
+		QWidget centralWidget = new QWidget(this);
+		BookmarksModel boomarksModel = BrowserApplication.bookmarksManager().bookmarksModel();
+		m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this);
+		m_bookmarksToolba.openUrl.connect(&m_tabWidget.loadUrlInCurrentTab);
+		m_bookmarksToolbar.toggleViewAction.toggled.connect(&thisupdateBookmarksToolbarActionText);
 
-    // Fall back to QUrl's own tolerant parser.
-    QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode);
+		QVBoxLayout layout = new QVBoxLayout;
+		layout.setSpacing(0);
+		layout.setMargin(0);
+		version(Q_WS_MAC)
+		{
+			layout.addWidget(m_bookmarksToolbar);
+			layout.addWidget(new QWidget); // <- OS X tab widget style bug
+		} else {
+			addToolBarBreak();
+			addToolBar(m_bookmarksToolbar);
+		}
+		layout.addWidget(m_tabWidget);
+		centralWidget.setLayout(layout);
+		setCentralWidget(centralWidget);
 
-    // finally for cases where the user just types in a hostname add http
-    if (url.scheme().isEmpty())
-        url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode);
-    return url;
-}
+		m_tabWidget.loadPage.connect(&thisloadPage);
+		m_tabWidget.setCurrentTitle.connect(&this.slotUpdateWindowTitle);
+		m_tabWidget.showStatusBarMessage.connect(&statusBar().showMessage);
+		m_tabWidget.linkHovered.connect(&statusBar().showMessage);
+		m_tabWidget.loadProgress.connect(&this.slotLoadProgress);
+		m_tabWidget.tabsChanged.connect(&m_autoSaver.changeOccurred);
+		m_tabWidget.geometryChangeRequested.connect(&this.geometryChangeRequested);
+		m_tabWidget.printRequested.connect(&this.printRequested);
+		m_tabWidget.menuBarVisibilityChangeRequested.connect(&menuBar().setVisible);
+		m_tabWidget.statusBarVisibilityChangeRequested.connect(&statusBar().setVisible);
+		m_tabWidget.toolBarVisibilityChangeRequested.connect(&m_navigationBar.setVisible);
+		m_tabWidget.toolBarVisibilityChangeRequested.connect(&m_bookmarksToolbar.setVisible);
+		version(Q_WS_MAC) {
+			m_tabWidget.lastTabClosed().connect(&thisclose);
+		} else {
+			m_tabWidget.lastTabClosed().connect(&m_tabWidget.newTab);
+		}
 
+		slotUpdateWindowTitle();
+		loadDefaultState();
+		m_tabWidget.newTab();
 
+		int size = m_tabWidget.lineEditStack().sizeHint().height();
+		m_navigationBar.setIconSize(QSize(size, size));
+	}
 
-TabWidget* tabWidget()
-{
-    return m_tabWidget;
-}
+	~this()
+	{
+		m_autoSaver.changeOccurred();
+		m_autoSaver.saveIfNeccessary();
+	}
 
-WebView* currentTab()
-{
-    return m_tabWidget.currentWebView();
-}
 
-QByteArray saveState(bool withTabs)
-{
-    int version = 2;
-    QByteArray data;
-    QDataStream stream(&data, QIODevice::WriteOnly);
+	QSize sizeHint()
+	{
+		QRect desktopRect = QApplication.desktop().screenGeometry();
+		QSize size = desktopRect.size() * qreal(0.9);
+		return size;
+	}
 
-    stream << qint32(BrowserMainWindowMagic);
-    stream << qint32(version);
+public:
 
-    stream << size();
-    stream << !m_navigationBar.isHidden();
-    stream << !m_bookmarksToolbar.isHidden();
-    stream << !statusBar().isHidden();
-    if (withTabs)
-        stream << tabWidget().saveState();
-    else
-        stream << QByteArray();
-    return data;
-}
+	static QUrl guessUrlFromString(QString &string)
+	{
+		QString urlStr = string.trimmed();
+		QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
 
+		// Check if it looks like a qualified URL. Try parsing it and see.
+		bool hasSchema = test.exactMatch(urlStr);
+		if (hasSchema) {
+			QUrl url = QUrl.fromEncoded(urlStr.toUtf8(), QUrl.TolerantMode);
+			if (url.isValid())
+				return url;
+		}
 
-    bool restoreState(const QByteArray &state)
-{
-    int version = 2;
-    QByteArray sd = state;
-    QDataStream stream(&sd, QIODevice::ReadOnly);
-    if (stream.atEnd())
-        return false;
+		// Might be a file.
+		if (QFile.exists(urlStr)) {
+			QFileInfo info(urlStr);
+			return QUrl.fromLocalFile(info.absoluteFilePath());
+		}
 
-    qint32 marker;
-    qint32 v;
-    stream >> marker;
-    stream >> v;
-    if (marker != BrowserMainWindowMagic || v != version)
-        return false;
+		// Might be a shorturl - try to detect the schema.
+		if (!hasSchema) {
+			int dotIndex = urlStr.indexOf(QLatin1Char('.'));
+			if (dotIndex != -1) {
+				QString prefix = urlStr.left(dotIndex).toLower();
+				QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : "http";
+				QUrl url =
+				QUrl.fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl.TolerantMode);
+				if (url.isValid())
+					return url;
+			}
+		}
 
-    QSize size;
-    bool showToolbar;
-    bool showBookmarksBar;
-    bool showStatusbar;
-    QByteArray tabState;
+		// Fall back to QUrl's own tolerant parser.
+		QUrl url = QUrl.fromEncoded(string.toUtf8(), QUrl.TolerantMode);
 
-    stream >> size;
-    stream >> showToolbar;
-    stream >> showBookmarksBar;
-    stream >> showStatusbar;
-    stream >> tabState;
+		// finally for cases where the user just types in a hostname add http
+		if (url.scheme().isEmpty())
+			url = QUrl.fromEncoded("http://" + string.toUtf8(), QUrl.TolerantMode);
+		return url;
+	}
 
-    resize(size);
+	TabWidget tabWidget()
+	{
+		return m_tabWidget;
+	}
 
-    m_navigationBar.setVisible(showToolbar);
-    updateToolbarActionText(showToolbar);
+	WebView currentTab()
+	{
+		return m_tabWidget.currentWebView();
+	}
 
-    m_bookmarksToolbar.setVisible(showBookmarksBar);
-    updateBookmarksToolbarActionText(showBookmarksBar);
+	QByteArray saveState(bool withTabs)
+	{
+		int version = 2;
+		QByteArray data;
+		QDataStream stream(&data, QIODevice.WriteOnly);
 
-    statusBar().setVisible(showStatusbar);
-    updateStatusbarActionText(showStatusbar);
+		stream << qint32(BrowserMainWindowMagic);
+		stream << qint32(version);
 
-    if (!tabWidget().restoreState(tabState))
-        return false;
+		stream << size();
+		stream << !m_navigationBar.isHidden();
+		stream << !m_bookmarksToolbar.isHidden();
+		stream << !statusBar().isHidden();
+		if (withTabs)
+			stream << tabWidget().saveState();
+		else
+			stream << QByteArray();
+		return data;
+	}
 
-    return true;
-}
 
+	bool restoreState(QByteArray state)
+	{
+		int version_ = 2;
+		QByteArray sd = state;
+		QDataStream stream(&sd, QIODevice.ReadOnly);
+		if (stream.atEnd())
+			return false;
 
-public slots:
-void loadPage(const QString &page)
-{
-    QUrl url = guessUrlFromString(page);
-    loadUrl(url);
-}
+		qint32 marker;
+		qint32 v;
+		stream >> marker;
+		stream >> v;
+		if (marker != BrowserMainWindowMagic || v != version_)
+			return false;
 
+		QSize size;
+		bool showToolbar;
+		bool showBookmarksBar;
+		bool showStatusbar;
+		QByteArray tabState;
 
-void slotHome()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("MainWindow"));
-    QString home = settings.value(QLatin1String("home"), QLatin1String("http://qtsoftware.com/")).toString();
-    loadPage(home);
-}
+		stream >> size;
+		stream >> showToolbar;
+		stream >> showBookmarksBar;
+		stream >> showStatusbar;
+		stream >> tabState;
+
+		resize(size);
+
+		m_navigationBar.setVisible(showToolbar);
+		updateToolbarActionText(showToolbar);
+
+		m_bookmarksToolbar.setVisible(showBookmarksBar);
+		updateBookmarksToolbarActionText(showBookmarksBar);
+
+		statusBar().setVisible(showStatusbar);
+		updateStatusbarActionText(showStatusbar);
+
+		if (!tabWidget().restoreState(tabState))
+			return false;
+
+		return true;
+	}
+
+public:
+
+	void loadPage(QString page)
+	{
+		QUrl url = guessUrlFromString(page);
+		loadUrl(url);
+	}
+
+
+	void slotHome()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("MainWindow"));
+		QString home = settings.value(QLatin1String("home"), QLatin1String("http://qtsoftware.com/")).toString();
+		loadPage(home);
+	}
 
 protected:
-    void closeEvent(QCloseEvent *event);
-{
-    if (m_tabWidget.count() > 1) {
-        int ret = QMessageBox.warning(this, QString(),
-                           tr("Are you sure you want to close the window?"
-                              "  There are %1 tab open").arg(m_tabWidget.count()),
-                           QMessageBox.Yes | QMessageBox.No,
-                           QMessageBox.No);
-        if (ret == QMessageBox.No) {
-            event.ignore();
-            return;
-        }
-    }
-    event.accept();
-    deleteLater();
-}
 
-private slots:
-void save()
-{
-    BrowserApplication::instance().saveSession();
-
-    QSettings settings;
-    settings.beginGroup(QLatin1String("BrowserMainWindow"));
-    QByteArray data = saveState(false);
-    settings.setValue(QLatin1String("defaultState"), data);
-    settings.endGroup();
-}
-
-void slotLoadProgress(int progress)
-{
-    if (progress < 100 && progress > 0) {
-        m_chaseWidget.setAnimated(true);
-        disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger()));
-        if (m_stopIcon.isNull())
-            m_stopIcon = style().standardIcon(QStyle::SP_BrowserStop);
-        m_stopReload.setIcon(m_stopIcon);
-        connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger()));
-        m_stopReload.setToolTip(tr("Stop loading the current page"));
-    } else {
-        m_chaseWidget.setAnimated(false);
-        disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger()));
-        m_stopReload.setIcon(m_reloadIcon);
-        connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger()));
-        m_stopReload.setToolTip(tr("Reload the current page"));
-    }
-}
-
-    void slotUpdateStatusbar(const QString &string);
-{
-    statusBar().showMessage(string, 2000);
-}
-
-
-    void slotUpdateWindowTitle(const QString &title = QString())
-{
-    if (title.isEmpty()) {
-        setWindowTitle(tr("Qt Demo Browser"));
-    } else {
-version(Q_WS_MAC)
-{
-        setWindowTitle(title);
-} else {
-        setWindowTitle(tr("%1 - Qt Demo Browser", "Page title and Browser name").arg(title));
-}
-    }
-}
-
-    void loadUrl(const QUrl &url);
-{
-    if (!currentTab() || !url.isValid())
-        return;
-
-    m_tabWidget.currentLineEdit().setText(QString::fromUtf8(url.toEncoded()));
-    m_tabWidget.loadUrlInCurrentTab(url);
-}
-
-    void slotPreferences()
-{
-    SettingsDialog *s = new SettingsDialog(this);
-    s.show();
-}
-
-void slotFileNew()
-{
-    BrowserApplication::instance().newMainWindow();
-    BrowserMainWindow *mw = BrowserApplication::instance().mainWindow();
-    mw.slotHome();
-}
-
-void slotFileOpen()
-{
-    QString file = QFileDialog::getOpenFileName(this, tr("Open Web Resource"), QString(),
-            tr("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"));
-
-    if (file.isEmpty())
-        return;
-
-    loadPage(file);
-}
-
-    void slotFilePrintPreview();
-{
-version(QT_NO_PRINTER)
+	void closeEvent(QCloseEvent event);
 	{
-    if (!currentTab())
-        return;
-    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this);
-    connect(dialog, SIGNAL(paintRequested(QPrinter *)),
-            currentTab(), SLOT(print(QPrinter *)));
-    dialog.exec();
-}
-}
-
-
-    void slotFilePrint()
-{
-    if (!currentTab())
-        return;
-    printRequested(currentTab().page().mainFrame());
-}
-
-    void slotPrivateBrowsing()
-{
-    QWebSettings *settings = QWebSettings::globalSettings();
-    bool pb = settings.testAttribute(QWebSettings::PrivateBrowsingEnabled);
-    if (!pb) {
-        QString title = tr("Are you sure you want to turn on private browsing?");
-        QString text = tr("<b>%1</b><br><br>When private browsing in turned on,"
-            " webpages are not added to the history,"
-            " items are automatically removed from the Downloads window," \
-            " new cookies are not stored, current cookies can't be accessed," \
-            " site icons wont be stored, session wont be saved, " \
-            " and searches are not addded to the pop-up menu in the Google search box." \
-            "  Until you close the window, you can still click the Back and Forward buttons" \
-            " to return to the webpages you have opened.").arg(title);
-
-        QMessageBox.StandardButton button = QMessageBox.question(this, QString(), text,
-                               QMessageBox.Ok | QMessageBox.Cancel,
-                               QMessageBox.Ok);
-        if (button == QMessageBox.Ok) {
-            settings.setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
-        }
-    } else {
-        settings.setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
-
-        QList<BrowserMainWindow*> windows = BrowserApplication::instance().mainWindows();
-        for (int i = 0; i < windows.count(); ++i) {
-            BrowserMainWindow *window = windows.at(i);
-            window.m_lastSearch = QString::null;
-            window.tabWidget().clear();
-        }
-    }
-}
-
-    void slotFileSaveAs()
-{
-    BrowserApplication::downloadManager().download(currentTab().url(), true);
-}
-
-    void slotEditFind()
-{
-    if (!currentTab())
-        return;
-    bool ok;
-    QString search = QInputDialog::getText(this, tr("Find"),
-                                          tr("Text:"), QLineEdit::Normal,
-                                          m_lastSearch, &ok);
-    if (ok && !search.isEmpty()) {
-        m_lastSearch = search;
-        if (!currentTab().findText(m_lastSearch))
-            slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch));
-    }
-}
-
-void slotEditFindNext()
-{
-    if (!currentTab() && !m_lastSearch.isEmpty())
-        return;
-    currentTab().findText(m_lastSearch);
-}
-
-void slotEditFindPrevious()
-{
-    if (!currentTab() && !m_lastSearch.isEmpty())
-        return;
-    currentTab().findText(m_lastSearch, QWebPage::FindBackward);
-}
-
-
-    void slotShowBookmarksDialog();
-{
-    BookmarksDialog *dialog = new BookmarksDialog(this);
-    connect(dialog, SIGNAL(openUrl(const QUrl&)),
-            m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
-    dialog.show();
-}
-
-void slotAddBookmark()
-{
-    WebView *webView = currentTab();
-    QString url = webView.url().toString();
-    QString title = webView.title();
-    AddBookmarkDialog dialog(url, title);
-    dialog.exec();
-}
-
-void slotViewZoomIn()
-{
-    if (!currentTab())
-        return;
-    currentTab().setZoomFactor(currentTab().zoomFactor() + 0.1);
-}
-
-void BslotViewZoomOut()
-{
-    if (!currentTab())
-        return;
-    currentTab().setZoomFactor(currentTab().zoomFactor() - 0.1);
-}
-
-void slotViewResetZoom()
-{
-    if (!currentTab())
-        return;
-    currentTab().setZoomFactor(1.0);
-}
-
-void slotViewZoomTextOnly(bool enable)
-{
-    if (!currentTab())
-        return;
-    currentTab().page().settings().setAttribute(QWebSettings::ZoomTextOnly, enable);
-}
-
-
-    void slotViewToolbar()
-{
-    if (m_navigationBar.isVisible()) {
-        updateToolbarActionText(false);
-        m_navigationBar.close();
-    } else {
-        updateToolbarActionText(true);
-        m_navigationBar.show();
-    }
-    m_autoSaver.changeOccurred();
-}
-
-
-    void slotViewBookmarksBar()
-{
-    if (m_bookmarksToolbar.isVisible()) {
-        updateBookmarksToolbarActionText(false);
-        m_bookmarksToolbar.close();
-    } else {
-        updateBookmarksToolbarActionText(true);
-        m_bookmarksToolbar.show();
-    }
-    m_autoSaver.changeOccurred();
-}
-
-    void slotViewStatusbar()
-{
-    if (statusBar().isVisible()) {
-        updateStatusbarActionText(false);
-        statusBar().close();
-    } else {
-        updateStatusbarActionText(true);
-        statusBar().show();
-    }
-    m_autoSaver.changeOccurred();
-}
-
-void slotViewPageSource()
-{
-    if (!currentTab())
-        return;
-
-    QString markup = currentTab().page().mainFrame().toHtml();
-    QPlainTextEdit *view = new QPlainTextEdit(markup);
-    view.setWindowTitle(tr("Page Source of %1").arg(currentTab().title()));
-    view.setMinimumWidth(640);
-    view.setAttribute(Qt.WA_DeleteOnClose);
-    view.show();
-}
-
-
-void slotViewFullScreen(bool makeFullScreen)
-{
-    if (makeFullScreen) {
-        showFullScreen();
-    } else {
-        if (isMinimized())
-            showMinimized();
-        else if (isMaximized())
-            showMaximized();
-        else showNormal();
-    }
-}
-
-void slotWebSearch()
-{
-    m_toolbarSearch.lineEdit().selectAll();
-    m_toolbarSearch.lineEdit().setFocus();
-}
-
-
-    void slotToggleInspector(bool enable);
-{
-    QWebSettings::globalSettings().setAttribute(QWebSettings::DeveloperExtrasEnabled, enable);
-    if (enable) {
-        int result = QMessageBox.question(this, tr("Web Inspector"),
-                                           tr("The web inspector will only work correctly for pages that were loaded after enabling.\n"
-                                           "Do you want to reload all pages?"),
-                                           QMessageBox.Yes | QMessageBox.No);
-        if (result == QMessageBox.Yes) {
-            m_tabWidget.reloadAllTabs();
-        }
-    }
-}
-
-
-    void slotAboutApplication()
-{
-    QMessageBox.about(this, tr("About"), tr(
-        "Version %1"
-        "<p>This demo demonstrates Qt's "
-        "webkit facilities in action, providing an example "
-        "browser for you to experiment with.<p>"
-        "<p>QtWebKit is based on the Open Source WebKit Project developed at <a href=\"http://webkit.org/\">http://webkit.org/</a>."
-        ).arg(QCoreApplication::applicationVersion()));
-}
-
-    void slotDownloadManager()
-{
-    BrowserApplication::downloadManager().show();
-}
-
-    void slotSelectLineEdit();
-{
-    m_tabWidget.currentLineEdit().selectAll();
-    m_tabWidget.currentLineEdit().setFocus();
-}
-
-    void slotAboutToShowBackMenu();
-{
-    m_historyBackMenu.clear();
-    if (!currentTab())
-        return;
-    QWebHistory *history = currentTab().history();
-    int historyCount = history.count();
-    for (int i = history.backItems(historyCount).count() - 1; i >= 0; --i) {
-        QWebHistoryItem item = history.backItems(history.count()).at(i);
-        QAction *action = new QAction(this);
-        action.setData(-1*(historyCount-i-1));
-        QIcon icon = BrowserApplication::instance().icon(item.url());
-        action.setIcon(icon);
-        action.setText(item.title());
-        m_historyBackMenu.addAction(action);
-    }
-}
-
-
-    void slotAboutToShowForwardMenu();
-{
-    m_historyForwardMenu.clear();
-    if (!currentTab())
-        return;
-    QWebHistory *history = currentTab().history();
-    int historyCount = history.count();
-    for (int i = 0; i < history.forwardItems(history.count()).count(); ++i) {
-        QWebHistoryItem item = history.forwardItems(historyCount).at(i);
-        QAction *action = new QAction(this);
-        action.setData(historyCount-i);
-        QIcon icon = BrowserApplication::instance().icon(item.url());
-        action.setIcon(icon);
-        action.setText(item.title());
-        m_historyForwardMenu.addAction(action);
-    }
-}
-
-    void slotAboutToShowWindowMenu()
-{
-    m_windowMenu.clear();
-    m_windowMenu.addAction(m_tabWidget.nextTabAction());
-    m_windowMenu.addAction(m_tabWidget.previousTabAction());
-    m_windowMenu.addSeparator();
-    m_windowMenu.addAction(tr("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence(tr("Alt+Ctrl+L", "Download Manager")));
-
-    m_windowMenu.addSeparator();
-    QList<BrowserMainWindow*> windows = BrowserApplication::instance().mainWindows();
-    for (int i = 0; i < windows.count(); ++i) {
-        BrowserMainWindow *window = windows.at(i);
-        QAction *action = m_windowMenu.addAction(window.windowTitle(), this, SLOT(slotShowWindow()));
-        action.setData(i);
-        action.setCheckable(true);
-        if (window == this)
-            action.setChecked(true);
-    }
-}
-
-    void slotOpenActionUrl(QAction *action)
-{
-    int offset = action.data().toInt();
-    QWebHistory *history = currentTab().history();
-    if (offset < 0)
-        history.goToItem(history.backItems(-1*offset).first()); // back
-    else if (offset > 0)
-        history.goToItem(history.forwardItems(history.count() - offset + 1).back()); // forward
- }
-    void slotShowWindow()
-{
-    if (QAction *action = qobject_cast<QAction*>(sender())) {
-        QVariant v = action.data();
-        if (v.canConvert<int>()) {
-            int offset = qvariant_cast<int>(v);
-            QList<BrowserMainWindow*> windows = BrowserApplication::instance().mainWindows();
-            windows.at(offset).activateWindow();
-            windows.at(offset).currentTab().setFocus();
-        }
-    }
-}
-
-void slotSwapFocus()
-{
-    if (currentTab().hasFocus())
-        m_tabWidget.currentLineEdit().setFocus();
-    else
-        currentTab().setFocus();
-}
-
-void printRequested(QWebFrame *frame)
-{
-	version(QT_NO_PRINTER)
-	{
-		QPrinter printer;
-		QPrintDialog *dialog = new QPrintDialog(&printer, this);
-		dialog.setWindowTitle(tr("Print Document"));
-		if (dialog.exec() != QDialog::Accepted)
-			return;
-		frame.print(&printer);
+		if (m_tabWidget.count() > 1) {
+			int ret = QMessageBox.warning(this, QString(),
+				   tr("Are you sure you want to close the window?"
+				      "  There are %1 tab open").arg(m_tabWidget.count()),
+				   QMessageBox.Yes | QMessageBox.No,
+				   QMessageBox.No);
+			if (ret == QMessageBox.No) {
+				event.ignore();
+				return;
+			}
+		}
+		event.accept();
+		deleteLater();
 	}
-}
-
-    void geometryChangeRequested(const QRect &geometry)
-{
-    setGeometry(geometry);
-}
-
-
-    void updateToolbarActionText(bool visible)
-{
-    m_viewToolbar.setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar"));
-}
-    
-    void updateBookmarksToolbarActionText(bool visible)
-{
-    m_viewBookmarkBar.setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar"));
-}
-
 
 private:
-void loadDefaultState()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("BrowserMainWindow"));
-    QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray();
-    restoreState(data);
-    settings.endGroup();
-}
 
+	void save()
+	{
+		BrowserApplication.instance().saveSession();
 
-    void setupMenu();
-{
-    new QShortcut(QKeySequence(Qt.Key_F6), this, SLOT(slotSwapFocus()));
+		QSettings settings;
+		settings.beginGroup(QLatin1String("BrowserMainWindow"));
+		QByteArray data = saveState(false);
+		settings.setValue(QLatin1String("defaultState"), data);
+		settings.endGroup();
+	}
 
-    // File
-    QMenu *fileMenu = menuBar().addMenu(tr("&File"));
+	void slotLoadProgress(int progress)
+	{
+		if (progress < 100 && progress > 0) {
+			m_chaseWidget.setAnimated(true);
+			m_stopReload.triggered.disconnect(&m_reload.trigger);
+			if (m_stopIcon.isNull())
+				m_stopIcon = style().standardIcon(QStyle.SP_BrowserStop);
+			m_stopReload.setIcon(m_stopIcon);
+			m_stopReload.triggered.connect(&m_stop.trigger);
+			m_stopReload.setToolTip(tr("Stop loading the current page"));
+		} else {
+			m_chaseWidget.setAnimated(false);
+			m_stopReload.triggered.disconnect(m_stop.trigger);
+			m_stopReload.setIcon(m_reloadIcon);
+			m_stopReload.triggered.connect(&m_reload.trigger);
+			m_stopReload.setToolTip(tr("Reload the current page"));
+		}
+	}
 
-    fileMenu.addAction(tr("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New);
-    fileMenu.addAction(m_tabWidget.newTabAction());
-    fileMenu.addAction(tr("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open);
-    fileMenu.addAction(tr("Open &Location..."), this,
-                SLOT(slotSelectLineEdit()), QKeySequence(Qt.ControlModifier + Qt.Key_L));
-    fileMenu.addSeparator();
-    fileMenu.addAction(m_tabWidget.closeTabAction());
-    fileMenu.addSeparator();
-    fileMenu.addAction(tr("&Save As..."), this,
-                SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save));
-    fileMenu.addSeparator();
-    BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager();
-    fileMenu.addAction(tr("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks()));
-    fileMenu.addAction(tr("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks()));
-    fileMenu.addSeparator();
-    fileMenu.addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview()));
-    fileMenu.addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print);
-    fileMenu.addSeparator();
-    QAction *action = fileMenu.addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing()));
-    action.setCheckable(true);
-    fileMenu.addSeparator();
+	void slotUpdateStatusbar(QString &string);
+	{
+		statusBar().showMessage(string, 2000);
+	}
 
-version(Q_WS_MAC) {
-    fileMenu.addAction(tr("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt.CTRL | Qt.Key_Q));
-} else {
-    fileMenu.addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(Qt.CTRL | Qt.Key_Q));
-}
+	void slotUpdateWindowTitle(QString &title = QString())
+	{
+		if (title.isEmpty()) {
+			setWindowTitle(tr("Qt Demo Browser"));
+		} else {
+			version(Q_WS_MAC)
+			{
+				setWindowTitle(title);
+			} else {
+				setWindowTitle(tr("%1 - Qt Demo Browser", "Page title and Browser name").arg(title));
+			}
+		}
+	}
 
-    // Edit
-    QMenu *editMenu = menuBar().addMenu(tr("&Edit"));
-    QAction *m_undo = editMenu.addAction(tr("&Undo"));
-    m_undo.setShortcuts(QKeySequence::Undo);
-    m_tabWidget.addWebAction(m_undo, QWebPage::Undo);
-    QAction *m_redo = editMenu.addAction(tr("&Redo"));
-    m_redo.setShortcuts(QKeySequence::Redo);
-    m_tabWidget.addWebAction(m_redo, QWebPage::Redo);
-    editMenu.addSeparator();
-    QAction *m_cut = editMenu.addAction(tr("Cu&t"));
-    m_cut.setShortcuts(QKeySequence::Cut);
-    m_tabWidget.addWebAction(m_cut, QWebPage::Cut);
-    QAction *m_copy = editMenu.addAction(tr("&Copy"));
-    m_copy.setShortcuts(QKeySequence::Copy);
-    m_tabWidget.addWebAction(m_copy, QWebPage::Copy);
-    QAction *m_paste = editMenu.addAction(tr("&Paste"));
-    m_paste.setShortcuts(QKeySequence::Paste);
-    m_tabWidget.addWebAction(m_paste, QWebPage::Paste);
-    editMenu.addSeparator();
+	void loadUrl(QUrl &url);
+	{
+		if (!currentTab() || !url.isValid())
+			return;
 
-    QAction *m_find = editMenu.addAction(tr("&Find"));
-    m_find.setShortcuts(QKeySequence::Find);
-    connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind()));
-    new QShortcut(QKeySequence(Qt.Key_Slash), this, SLOT(slotEditFind()));
+			m_tabWidget.currentLineEdit().setText(QString.fromUtf8(url.toEncoded()));
+			m_tabWidget.loadUrlInCurrentTab(url);
+	}
 
-    QAction *m_findNext = editMenu.addAction(tr("&Find Next"));
-    m_findNext.setShortcuts(QKeySequence::FindNext);
-    connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext()));
+	void slotPreferences()
+	{
+		SettingsDialog s = new SettingsDialog(this);
+		s.show();
+	}
 
-    QAction *m_findPrevious = editMenu.addAction(tr("&Find Previous"));
-    m_findPrevious.setShortcuts(QKeySequence::FindPrevious);
-    connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious()));
+	void slotFileNew()
+	{
+		BrowserApplication.instance().newMainWindow();
+		BrowserMainWindow mw = BrowserApplication.instance().mainWindow();
+		mw.slotHome();
+	}
 
-    editMenu.addSeparator();
-    editMenu.addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,"));
+	void slotFileOpen()
+	{
+		QString file = QFileDialog.getOpenFileName(this, tr("Open Web Resource"), QString(),
+		tr("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"));
 
-    // View
-    QMenu *viewMenu = menuBar().addMenu(tr("&View"));
+		if (file.isEmpty())
+			return;
 
-    m_viewBookmarkBar = new QAction(this);
-    updateBookmarksToolbarActionText(true);
-    m_viewBookmarkBar.setShortcut(tr("Shift+Ctrl+B"));
-    connect(m_viewBookmarkBar, SIGNAL(triggered()), this, SLOT(slotViewBookmarksBar()));
-    viewMenu.addAction(m_viewBookmarkBar);
+		loadPage(file);
+	}
 
-    m_viewToolbar = new QAction(this);
-    updateToolbarActionText(true);
-    m_viewToolbar.setShortcut(tr("Ctrl+|"));
-    connect(m_viewToolbar, SIGNAL(triggered()), this, SLOT(slotViewToolbar()));
-    viewMenu.addAction(m_viewToolbar);
+	void slotFilePrintPreview();
+	{
+		version(QT_NO_PRINTER)
+		{
+			if (!currentTab())
+				return;
+			QPrintPreviewDialog dialog = new QPrintPreviewDialog(this);
+			dialog.paintRequested.connect(&currentTab.print);
+			dialog.exec();
+		}
+	}
 
-    m_viewStatusbar = new QAction(this);
-    updateStatusbarActionText(true);
-    m_viewStatusbar.setShortcut(tr("Ctrl+/"));
-    connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar()));
-    viewMenu.addAction(m_viewStatusbar);
+	void slotFilePrint()
+	{
+		if (!currentTab())
+			return;
+		printRequested(currentTab().page().mainFrame());
+	}
 
-    viewMenu.addSeparator();
+	void slotPrivateBrowsing()
+	{
+		QWebSettings settings = QWebSettings.globalSettings();
+		bool pb = settings.testAttribute(QWebSettings.PrivateBrowsingEnabled);
+		if (!pb) {
+			QString title = tr("Are you sure you want to turn on private browsing?");
+			QString text = tr("<b>%1</b><br><br>When private browsing in turned on,"
+			" webpages are not added to the history,"
+			" items are automatically removed from the Downloads window," \
+			" new cookies are not stored, current cookies can't be accessed," \
+			" site icons wont be stored, session wont be saved, " \
+			" and searches are not addded to the pop-up menu in the Google search box." \
+			"  Until you close the window, you can still click the Back and Forward buttons" \
+			" to return to the webpages you have opened.").arg(title);
 
-    m_stop = viewMenu.addAction(tr("&Stop"));
-    QList<QKeySequence> shortcuts;
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Period));
-    shortcuts.append(Qt.Key_Escape);
-    m_stop.setShortcuts(shortcuts);
-    m_tabWidget.addWebAction(m_stop, QWebPage::Stop);
+			QMessageBox.StandardButton button = QMessageBox.question(this, QString(), text,
+			       QMessageBox.Ok | QMessageBox.Cancel,
+			       QMessageBox.Ok);
+			if (button == QMessageBox.Ok) {
+				settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, true);
+			}
+		} else {
+			settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, false);
 
-    m_reload = viewMenu.addAction(tr("Reload Page"));
-    m_reload.setShortcuts(QKeySequence::Refresh);
-    m_tabWidget.addWebAction(m_reload, QWebPage::Reload);
+			QList<BrowserMainWindow*> windows = BrowserApplication.instance().mainWindows();
+			for (int i = 0; i < windows.count(); ++i) {
+				BrowserMainWindow window = windows.at(i);
+				window.m_lastSearch = QString.null;
+				window.tabWidget().clear();
+			}
+		}
+	}
 
-    viewMenu.addAction(tr("Zoom &In"), this, SLOT(slotViewZoomIn()), QKeySequence(Qt.CTRL | Qt.Key_Plus));
-    viewMenu.addAction(tr("Zoom &Out"), this, SLOT(slotViewZoomOut()), QKeySequence(Qt.CTRL | Qt.Key_Minus));
-    viewMenu.addAction(tr("Reset &Zoom"), this, SLOT(slotViewResetZoom()), QKeySequence(Qt.CTRL | Qt.Key_0));
-    QAction *zoomTextOnlyAction = viewMenu.addAction(tr("Zoom &Text Only"));
-    connect(zoomTextOnlyAction, SIGNAL(toggled(bool)), this, SLOT(slotViewZoomTextOnly(bool)));
-    zoomTextOnlyAction.setCheckable(true);
-    zoomTextOnlyAction.setChecked(false);
+	void slotFileSaveAs()
+	{
+		BrowserApplication.downloadManager().download(currentTab().url(), true);
+	}
 
-    viewMenu.addSeparator();
-    viewMenu.addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U"));
-    QAction *a = viewMenu.addAction(tr("&Full Screen"), this, SLOT(slotViewFullScreen(bool)),  Qt.Key_F11);
-    a.setCheckable(true);
+	void slotEditFind()
+	{
+		if (!currentTab())
+			return;
+		bool ok;
+		QString search = QInputDialog.getText(this, tr("Find"),
+			tr("Text:"), QLineEdit.Normal, m_lastSearch, &ok);
+		if (ok && !search.isEmpty()) {
+			m_lastSearch = search;
+			if (!currentTab().findText(m_lastSearch))
+				slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch));
+		}
+	}
 
-    // History
-    HistoryMenu *historyMenu = new HistoryMenu(this);
-    connect(historyMenu, SIGNAL(openUrl(const QUrl&)),
-            m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
-    connect(historyMenu, SIGNAL(hovered(const QString&)), this,
-            SLOT(slotUpdateStatusbar(const QString&)));
-    historyMenu.setTitle(tr("Hi&story"));
-    menuBar().addMenu(historyMenu);
-    QList<QAction*> historyActions;
+	void slotEditFindNext()
+	{
+		if (!currentTab() && !m_lastSearch.isEmpty())
+			return;
+		currentTab().findText(m_lastSearch);
+	}
 
-    m_historyBack = new QAction(tr("Back"), this);
-    m_tabWidget.addWebAction(m_historyBack, QWebPage::Back);
-    m_historyBack.setShortcuts(QKeySequence::Back);
-    m_historyBack.setIconVisibleInMenu(false);
+	void slotEditFindPrevious()
+	{
+		if (!currentTab() && !m_lastSearch.isEmpty())
+			return;
+		currentTab().findText(m_lastSearch, QWebPage.FindBackward);
+	}
 
-    m_historyForward = new QAction(tr("Forward"), this);
-    m_tabWidget.addWebAction(m_historyForward, QWebPage::Forward);
-    m_historyForward.setShortcuts(QKeySequence::Forward);
-    m_historyForward.setIconVisibleInMenu(false);
 
-    QAction *m_historyHome = new QAction(tr("Home"), this);
-    connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome()));
-    m_historyHome.setShortcut(QKeySequence(Qt.CTRL | Qt.SHIFT | Qt.Key_H));
+	void slotShowBookmarksDialog();
+	{
+		BookmarksDialog dialog = new BookmarksDialog(this);
+		dialog.openUrl.connect(&m_tabWidget.loadUrlInCurrentTab);
+		dialog.show();
+	}
 
-    m_restoreLastSession = new QAction(tr("Restore Last Session"), this);
-    connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession()));
-    m_restoreLastSession.setEnabled(BrowserApplication::instance().canRestoreSession());
+	void slotAddBookmark()
+	{
+		WebView webView = currentTab();
+		QString url = webView.url().toString();
+		QString title = webView.title();
+		AddBookmarkDialog dialog(url, title);
+		dialog.exec();
+	}
 
-    historyActions.append(m_historyBack);
-    historyActions.append(m_historyForward);
-    historyActions.append(m_historyHome);
-    historyActions.append(m_tabWidget.recentlyClosedTabsAction());
-    historyActions.append(m_restoreLastSession);
-    historyMenu.setInitialActions(historyActions);
+	void slotViewZoomIn()
+	{
+		if (!currentTab())
+			return;
+		currentTab().setZoomFactor(currentTab().zoomFactor() + 0.1);
+	}
 
-    // Bookmarks
-    BookmarksMenu *bookmarksMenu = new BookmarksMenu(this);
-    connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)),
-            m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
-    connect(bookmarksMenu, SIGNAL(hovered(const QString&)),
-            this, SLOT(slotUpdateStatusbar(const QString&)));
-    bookmarksMenu.setTitle(tr("&Bookmarks"));
-    menuBar().addMenu(bookmarksMenu);
+	void BslotViewZoomOut()
+	{
+		if (!currentTab())
+			return;
+		currentTab().setZoomFactor(currentTab().zoomFactor() - 0.1);
+	}
 
-    QList<QAction*> bookmarksActions;
+	void slotViewResetZoom()
+	{
+		if (!currentTab())
+			return;
+		currentTab().setZoomFactor(1.0);
+	}
 
-    QAction *showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this);
-    connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog()));
-    m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this);
-    m_addBookmark.setIconVisibleInMenu(false);
+	void slotViewZoomTextOnly(bool enable)
+	{
+		if (!currentTab())
+			return;
+		currentTab().page().settings().setAttribute(QWebSettings.ZoomTextOnly, enable);
+	}
 
-    connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark()));
-    m_addBookmark.setShortcut(QKeySequence(Qt.CTRL | Qt.Key_D));
+	void slotViewToolbar()
+	{
+		if (m_navigationBar.isVisible()) {
+			updateToolbarActionText(false);
+			m_navigationBar.close();
+		} else {
+			updateToolbarActionText(true);
+			m_navigationBar.show();
+		}
+		m_autoSaver.changeOccurred();
+	}
 
-    bookmarksActions.append(showAllBookmarksAction);
-    bookmarksActions.append(m_addBookmark);
-    bookmarksMenu.setInitialActions(bookmarksActions);
 
-    // Window
-    m_windowMenu = menuBar().addMenu(tr("&Window"));
-    connect(m_windowMenu, SIGNAL(aboutToShow()),
-            this, SLOT(slotAboutToShowWindowMenu()));
-    slotAboutToShowWindowMenu();
+	void slotViewBookmarksBar()
+	{
+		if (m_bookmarksToolbar.isVisible()) {
+			updateBookmarksToolbarActionText(false);
+			m_bookmarksToolbar.close();
+		} else {
+			updateBookmarksToolbarActionText(true);
+			m_bookmarksToolbar.show();
+		}
+		m_autoSaver.changeOccurred();
+	}
 
-    QMenu *toolsMenu = menuBar().addMenu(tr("&Tools"));
-    toolsMenu.addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search")));
-#ifndef Q_CC_MINGW
-    a = toolsMenu.addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool)));
-    a.setCheckable(true);
-#endif
+	void slotViewStatusbar()
+	{
+		if (statusBar().isVisible()) {
+			updateStatusbarActionText(false);
+			statusBar().close();
+		} else {
+			updateStatusbarActionText(true);
+			statusBar().show();
+		}
+		m_autoSaver.changeOccurred();
+	}
 
-    QMenu *helpMenu = menuBar().addMenu(tr("&Help"));
-    helpMenu.addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
-    helpMenu.addAction(tr("About &Demo Browser"), this, SLOT(slotAboutApplication()));
-}
+	void slotViewPageSource()
+	{
+		if (!currentTab())
+			return;
 
+		QString markup = currentTab().page().mainFrame().toHtml();
+		QPlainTextEdit view = new QPlainTextEdit(markup);
+		view.setWindowTitle(tr("Page Source of %1").arg(currentTab().title()));
+		view.setMinimumWidth(640);
+		view.setAttribute(Qt.WA_DeleteOnClose);
+		view.show();
+	}
 
-    void setupToolBar()
-{
-    setUnifiedTitleAndToolBarOnMac(true);
-    m_navigationBar = addToolBar(tr("Navigation"));
-    connect(m_navigationBar.toggleViewAction(), SIGNAL(toggled(bool)),
-            this, SLOT(updateToolbarActionText(bool)));
 
-    m_historyBack.setIcon(style().standardIcon(QStyle::SP_ArrowBack, 0, this));
-    m_historyBackMenu = new QMenu(this);
-    m_historyBack.setMenu(m_historyBackMenu);
-    connect(m_historyBackMenu, SIGNAL(aboutToShow()),
-            this, SLOT(slotAboutToShowBackMenu()));
-    connect(m_historyBackMenu, SIGNAL(triggered(QAction *)),
-            this, SLOT(slotOpenActionUrl(QAction *)));
-    m_navigationBar.addAction(m_historyBack);
+	void slotViewFullScreen(bool makeFullScreen)
+	{
+		if (makeFullScreen) {
+			showFullScreen();
+		} else {
+			if (isMinimized())
+				showMinimized();
+			else if (isMaximized())
+				showMaximized();
+			else showNormal();
+		}
+	}
 
-    m_historyForward.setIcon(style().standardIcon(QStyle::SP_ArrowForward, 0, this));
-    m_historyForwardMenu = new QMenu(this);
-    connect(m_historyForwardMenu, SIGNAL(aboutToShow()),
-            this, SLOT(slotAboutToShowForwardMenu()));
-    connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)),
-            this, SLOT(slotOpenActionUrl(QAction *)));
-    m_historyForward.setMenu(m_historyForwardMenu);
-    m_navigationBar.addAction(m_historyForward);
+	void slotWebSearch()
+	{
+		m_toolbarSearch.lineEdit().selectAll();
+		m_toolbarSearch.lineEdit().setFocus();
+	}
 
-    m_stopReload = new QAction(this);
-    m_reloadIcon = style().standardIcon(QStyle::SP_BrowserReload);
-    m_stopReload.setIcon(m_reloadIcon);
+	void slotToggleInspector(bool enable);
+	{
+		QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, enable);
+		if (enable) {
+			int result = QMessageBox.question(this, tr("Web Inspector"),
+						   tr("The web inspector will only work correctly for pages that were loaded after enabling.\n"
+						   "Do you want to reload all pages?"),
+						   QMessageBox.Yes | QMessageBox.No);
+			if (result == QMessageBox.Yes) {
+				m_tabWidget.reloadAllTabs();
+			}
+		}
+	}
 
-    m_navigationBar.addAction(m_stopReload);
+	void slotAboutApplication()
+	{
+		QMessageBox.about(this, tr("About"), tr(
+			"Version %1"
+			"<p>This demo demonstrates Qt's "
+			"webkit facilities in action, providing an example "
+			"browser for you to experiment with.<p>"
+			"<p>QtWebKit is based on the Open Source WebKit Project developed at <a href=\"http://webkit.org/\">http://webkit.org/</a>."
+			).arg(QCoreApplication.applicationVersion()));
+	}
 
-    m_navigationBar.addWidget(m_tabWidget.lineEditStack());
+	void slotDownloadManager()
+	{
+		BrowserApplication.downloadManager().show();
+	}
 
-    m_toolbarSearch = new ToolbarSearch(m_navigationBar);
-    m_navigationBar.addWidget(m_toolbarSearch);
-    connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&)));
+	void slotSelectLineEdit();
+	{
+		m_tabWidget.currentLineEdit().selectAll();
+		m_tabWidget.currentLineEdit().setFocus();
+	}
 
-    m_chaseWidget = new ChaseWidget(this);
-    m_navigationBar.addWidget(m_chaseWidget);
-}
+	void slotAboutToShowBackMenu();
+	{
+		m_historyBackMenu.clear();
+		if (!currentTab())
+			return;
+		QWebHistory history = currentTab().history();
+		int historyCount = history.count();
+		for (int i = history.backItems(historyCount).count() - 1; i >= 0; --i) {
+			QWebHistoryItem item = history.backItems(history.count()).at(i);
+			QAction action = new QAction(this);
+			action.setData(-1*(historyCount-i-1));
+			QIcon icon = BrowserApplication.instance().icon(item.url());
+			action.setIcon(icon);
+			action.setText(item.title());
+			m_historyBackMenu.addAction(action);
+		}
+	}
 
-    void updateStatusbarActionText(bool visible)
-{
-    m_viewStatusbar.setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar"));
-}
 
+	void slotAboutToShowForwardMenu();
+	{
+		m_historyForwardMenu.clear();
+		if (!currentTab())
+			return;
+		QWebHistory history = currentTab().history();
+		int historyCount = history.count();
+		for (int i = 0; i < history.forwardItems(history.count()).count(); ++i) {
+			QWebHistoryItem item = history.forwardItems(historyCount).at(i);
+			QAction action = new QAction(this);
+			action.setData(historyCount-i);
+			QIcon icon = BrowserApplication.instance().icon(item.url());
+			action.setIcon(icon);
+			action.setText(item.title());
+			m_historyForwardMenu.addAction(action);
+		}
+	}
+
+	void slotAboutToShowWindowMenu()
+	{
+		m_windowMenu.clear();
+		m_windowMenu.addAction(m_tabWidget.nextTabAction());
+		m_windowMenu.addAction(m_tabWidget.previousTabAction());
+		m_windowMenu.addSeparator();
+		m_windowMenu.addAction(tr("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence(tr("Alt+Ctrl+L", "Download Manager")));
+
+		m_windowMenu.addSeparator();
+		QList<BrowserMainWindow*> windows = BrowserApplication.instance().mainWindows();
+		for (int i = 0; i < windows.count(); ++i) {
+			BrowserMainWindow window = windows.at(i);
+			QAction action = m_windowMenu.addAction(window.windowTitle(), this, SLOT(slotShowWindow()));
+			action.setData(i);
+			action.setCheckable(true);
+			if (window == this)
+			action.setChecked(true);
+		}
+	}
+
+	void slotOpenActionUrl(QAction action)
+	{
+		int offset = action.data().toInt();
+		QWebHistory history = currentTab().history();
+		if (offset < 0)
+			history.goToItem(history.backItems(-1*offset).first()); // back
+		else if (offset > 0)
+			history.goToItem(history.forwardItems(history.count() - offset + 1).back()); // forward
+	}
+
+	void slotShowWindow()
+	{
+		if (QAction action = qobject_cast<QAction*>(sender())) {
+			QVariant v = action.data();
+			if (v.canConvert<int>()) {
+				int offset = qvariant_cast<int>(v);
+				QList<BrowserMainWindow*> windows = BrowserApplication.instance().mainWindows();
+				windows.at(offset).activateWindow();
+				windows.at(offset).currentTab().setFocus();
+			}
+		}
+	}
+
+	void slotSwapFocus()
+	{
+		if (currentTab().hasFocus())
+			m_tabWidget.currentLineEdit().setFocus();
+		else
+			currentTab().setFocus();
+	}
+
+	void printRequested(QWebFrame frame)
+	{
+		version(QT_NO_PRINTER)
+		{
+			QPrinter printer;
+			QPrintDialog dialog = new QPrintDialog(&printer, this);
+			dialog.setWindowTitle(tr("Print Document"));
+			if (dialog.exec() != QDialog.Accepted)
+				return;
+			frame.print(&printer);
+		}
+	}
+
+	void geometryChangeRequested(QRect &geometry)
+	{
+		setGeometry(geometry);
+	}
+
+
+	void updateToolbarActionText(bool visible)
+	{
+		m_viewToolbar.setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar"));
+	}
+    
+	void updateBookmarksToolbarActionText(bool visible)
+	{
+		m_viewBookmarkBar.setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar"));
+	}
 
 private:
-    QToolBar *m_navigationBar;
-    ToolbarSearch *m_toolbarSearch;
-    BookmarksToolBar *m_bookmarksToolbar;
-    ChaseWidget *m_chaseWidget;
-    TabWidget *m_tabWidget;
-    AutoSaver *m_autoSaver;
 
-    QAction *m_historyBack;
-    QMenu *m_historyBackMenu;
-    QAction *m_historyForward;
-    QMenu *m_historyForwardMenu;
-    QMenu *m_windowMenu;
+	void loadDefaultState()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("BrowserMainWindow"));
+		QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray();
+		restoreState(data);
+		settings.endGroup();
+	}
 
-    QAction *m_stop;
-    QAction *m_reload;
-    QAction *m_stopReload;
-    QAction *m_viewToolbar;
-    QAction *m_viewBookmarkBar;
-    QAction *m_viewStatusbar;
-    QAction *m_restoreLastSession;
-    QAction *m_addBookmark;
+	void setupMenu();
+	{
+		new QShortcut(QKeySequence(Qt.Key_F6), this, SLOT(slotSwapFocus()));
 
-    QIcon m_reloadIcon;
-    QIcon m_stopIcon;
+		// File
+		QMenu fileMenu = menuBar().addMenu(tr("&File"));
 
-    QString m_lastSearch;
+		fileMenu.addAction(tr("&New Window"), this, SLOT(slotFileNew()), QKeySequence.New);
+		fileMenu.addAction(m_tabWidget.newTabAction());
+		fileMenu.addAction(tr("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence.Open);
+		fileMenu.addAction(tr("Open &Location..."), this, SLOT(slotSelectLineEdit()), QKeySequence(Qt.ControlModifier + Qt.Key_L));
+		fileMenu.addSeparator();
+		fileMenu.addAction(m_tabWidget.closeTabAction());
+		fileMenu.addSeparator();
+		fileMenu.addAction(tr("&Save As..."), this,  SLOT(slotFileSaveAs()), QKeySequence(QKeySequence.Save));
+		fileMenu.addSeparator();
+		BookmarksManager bookmarksManager = BrowserApplication.bookmarksManager();
+		fileMenu.addAction(tr("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks()));
+		fileMenu.addAction(tr("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks()));
+		fileMenu.addSeparator();
+		fileMenu.addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview()));
+		fileMenu.addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence.Print);
+		fileMenu.addSeparator();
+		QAction action = fileMenu.addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing()));
+		action.setCheckable(true);
+		fileMenu.addSeparator();
+
+		version(Q_WS_MAC) {
+			fileMenu.addAction(tr("&Quit"), BrowserApplication.instance(), SLOT(quitBrowser()), QKeySequence(Qt.CTRL | Qt.Key_Q));
+		} else {
+			fileMenu.addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(Qt.CTRL | Qt.Key_Q));
+		}
+
+		// Edit
+		QMenu editMenu = menuBar().addMenu(tr("&Edit"));
+		QAction m_undo = editMenu.addAction(tr("&Undo"));
+		m_undo.setShortcuts(QKeySequence.Undo);
+		m_tabWidget.addWebAction(m_undo, QWebPage.Undo);
+		QAction m_redo = editMenu.addAction(tr("&Redo"));
+		m_redo.setShortcuts(QKeySequence.Redo);
+		m_tabWidget.addWebAction(m_redo, QWebPage.Redo);
+		editMenu.addSeparator();
+		QAction m_cut = editMenu.addAction(tr("Cu&t"));
+		m_cut.setShortcuts(QKeySequence.Cut);
+		m_tabWidget.addWebAction(m_cut, QWebPage.Cut);
+		QAction m_copy = editMenu.addAction(tr("&Copy"));
+		m_copy.setShortcuts(QKeySequence.Copy);
+		m_tabWidget.addWebAction(m_copy, QWebPage.Copy);
+		QAction m_paste = editMenu.addAction(tr("&Paste"));
+		m_paste.setShortcuts(QKeySequence.Paste);
+		m_tabWidget.addWebAction(m_paste, QWebPage.Paste);
+		editMenu.addSeparator();
+
+		QAction m_find = editMenu.addAction(tr("&Find"));
+		m_find.setShortcuts(QKeySequence.Find);
+		m_find.triggered().connect(&this.slotEditFind);
+		new QShortcut(QKeySequence(Qt.Key_Slash), this, SLOT(slotEditFind()));
+
+		QAction m_findNext = editMenu.addAction(tr("&Find Next"));
+		m_findNext.setShortcuts(QKeySequence.FindNext);
+		m_findNext.triggered().connect(&this.slotEditFindNext);
+
+		QAction m_findPrevious = editMenu.addAction(tr("&Find Previous"));
+		m_findPrevious.setShortcuts(QKeySequence.FindPrevious);
+		m_findPrevious.triggered().connect(&this.slotEditFindPrevious);
+
+		editMenu.addSeparator();
+		editMenu.addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,"));
+
+		// View
+		QMenu viewMenu = menuBar().addMenu(tr("&View"));
+
+		m_viewBookmarkBar = new QAction(this);
+		updateBookmarksToolbarActionText(true);
+		m_viewBookmarkBar.setShortcut(tr("Shift+Ctrl+B"));
+		m_viewBookmarkBar.triggered().connect(&this.slotViewBookmarksBar);
+		viewMenu.addAction(m_viewBookmarkBar);
+
+		m_viewToolbar = new QAction(this);
+		updateToolbarActionText(true);
+		m_viewToolbar.setShortcut(tr("Ctrl+|"));
+		m_viewToolbar.triggered().connect(&this.slotViewToolbar);
+		viewMenu.addAction(m_viewToolbar);
+
+		m_viewStatusbar = new QAction(this);
+		updateStatusbarActionText(true);
+		m_viewStatusbar.setShortcut(tr("Ctrl+/"));
+		m_viewStatusbar.triggered().connect(&this.slotViewStatusbar);
+		viewMenu.addAction(m_viewStatusbar);
+
+		viewMenu.addSeparator();
+
+		m_stop = viewMenu.addAction(tr("&Stop"));
+		QList<QKeySequence> shortcuts;
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Period));
+		shortcuts.append(Qt.Key_Escape);
+		m_stop.setShortcuts(shortcuts);
+		m_tabWidget.addWebAction(m_stop, QWebPage.Stop);
+
+		m_reload = viewMenu.addAction(tr("Reload Page"));
+		m_reload.setShortcuts(QKeySequence.Refresh);
+		m_tabWidget.addWebAction(m_reload, QWebPage.Reload);
+
+		viewMenu.addAction(tr("Zoom &In"), this, SLOT(slotViewZoomIn()), QKeySequence(Qt.CTRL | Qt.Key_Plus));
+		viewMenu.addAction(tr("Zoom &Out"), this, SLOT(slotViewZoomOut()), QKeySequence(Qt.CTRL | Qt.Key_Minus));
+		viewMenu.addAction(tr("Reset &Zoom"), this, SLOT(slotViewResetZoom()), QKeySequence(Qt.CTRL | Qt.Key_0));
+		QAction zoomTextOnlyAction = viewMenu.addAction(tr("Zoom &Text Only"));
+		zoomTextOnlyAction.toggled().connect(&this.slotViewZoomTextOnly);
+		zoomTextOnlyAction.setCheckable(true);
+		zoomTextOnlyAction.setChecked(false);
+
+		viewMenu.addSeparator();
+		viewMenu.addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U"));
+		QAction a = viewMenu.addAction(tr("&Full Screen"), this, SLOT(slotViewFullScreen(bool)),  Qt.Key_F11);
+		a.setCheckable(true);
+
+		// History
+		HistoryMenu historyMenu = new HistoryMenu(this);
+		historyMenu.openUrl.connect(&m_tabWidget.loadUrlInCurrentTab);
+		historyMenu.hovered.connect(&this.slotUpdateStatusbar);
+		historyMenu.setTitle(tr("Hi&story"));
+		menuBar().addMenu(historyMenu);
+		QList<QAction> historyActions;
+
+		m_historyBack = new QAction(tr("Back"), this);
+		m_tabWidget.addWebAction(m_historyBack, QWebPage.Back);
+		m_historyBack.setShortcuts(QKeySequence.Back);
+		m_historyBack.setIconVisibleInMenu(false);
+
+		m_historyForward = new QAction(tr("Forward"), this);
+		m_tabWidget.addWebAction(m_historyForward, QWebPage.Forward);
+		m_historyForward.setShortcuts(QKeySequence.Forward);
+		m_historyForward.setIconVisibleInMenu(false);
+
+		QAction m_historyHome = new QAction(tr("Home"), this);
+		m_historyHome.triggered().connect(&this.slotHome);
+		m_historyHome.setShortcut(QKeySequence(Qt.CTRL | Qt.SHIFT | Qt.Key_H));
+
+		m_restoreLastSession = new QAction(tr("Restore Last Session"), this);
+		m_restoreLastSession.triggered().connect(BrowserApplication.instance().restoreLastSession);
+		m_restoreLastSession.setEnabled(BrowserApplication.instance().canRestoreSession());
+
+		historyActions.append(m_historyBack);
+		historyActions.append(m_historyForward);
+		historyActions.append(m_historyHome);
+		historyActions.append(m_tabWidget.recentlyClosedTabsAction());
+		historyActions.append(m_restoreLastSession);
+		historyMenu.setInitialActions(historyActions);
+
+		// Bookmarks
+		BookmarksMenu bookmarksMenu = new BookmarksMenu(this);
+		bookmarksMenu.openUrl.connect(&m_tabWidget.loadUrlInCurrentTab);
+		bookmarksMenu.hovered.connect(&this.slotUpdateStatusbar);
+		bookmarksMenu.setTitle(tr("&Bookmarks"));
+		menuBar().addMenu(bookmarksMenu);
+
+		QList<QAction> bookmarksActions;
+
+		QAction showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this);
+		showAllBookmarksAction.triggered().connect(&this.slotShowBookmarksDialog);
+		m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this);
+		m_addBookmark.setIconVisibleInMenu(false);
+
+		m_addBookmark.triggered().connect(&this.slotAddBookmark);
+		m_addBookmark.setShortcut(QKeySequence(Qt.CTRL | Qt.Key_D));
+
+		bookmarksActions.append(showAllBookmarksAction);
+		bookmarksActions.append(m_addBookmark);
+		bookmarksMenu.setInitialActions(bookmarksActions);
+
+		// Window
+		m_windowMenu = menuBar().addMenu(tr("&Window"));
+		m_windowMenu.aboutToShow().connect(&this.slotAboutToShowWindowMenu);
+		slotAboutToShowWindowMenu();
+
+		QMenu toolsMenu = menuBar().addMenu(tr("&Tools"));
+		toolsMenu.addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search")));
+		version(Q_CC_MINGW)
+		{
+			a = toolsMenu.addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool)));
+			a.setCheckable(true);
+		}
+
+		QMenu helpMenu = menuBar().addMenu(tr("&Help"));
+		helpMenu.addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
+		helpMenu.addAction(tr("About &Demo Browser"), this, SLOT(slotAboutApplication()));
+	}
+
+	void setupToolBar()
+	{
+		setUnifiedTitleAndToolBarOnMac(true);
+		m_navigationBar = addToolBar(tr("Navigation"));
+		m_navigationBar.toggleViewAction().toggled.connect(&this.updateToolbarActionText);
+
+		m_historyBack.setIcon(style().standardIcon(QStyle.SP_ArrowBack, 0, this));
+		m_historyBackMenu = new QMenu(this);
+		m_historyBack.setMenu(m_historyBackMenu);
+		m_historyBackMenu.aboutToShow().connect(&this.slotAboutToShowBackMenu);
+		m_historyBackMenu.triggered.connect(&this.slotOpenActionUrl);
+		m_navigationBar.addAction(m_historyBack);
+
+		m_historyForward.setIcon(style().standardIcon(QStyle.SP_ArrowForward, 0, this));
+		m_historyForwardMenu = new QMenu(this);
+		m_historyForwardMenu.aboutToShow.connect(&this.slotAboutToShowForwardMenu);
+		m_historyForwardMenu.triggered.connect(&this.slotOpenActionUrl);
+		m_historyForward.setMenu(m_historyForwardMenu);
+		m_navigationBar.addAction(m_historyForward);
+
+		m_stopReload = new QAction(this);
+		m_reloadIcon = style().standardIcon(QStyle.SP_BrowserReload);
+		m_stopReload.setIcon(m_reloadIcon);
+
+		m_navigationBar.addAction(m_stopReload);
+
+		m_navigationBar.addWidget(m_tabWidget.lineEditStack());
+
+		m_toolbarSearch = new ToolbarSearch(m_navigationBar);
+		m_navigationBar.addWidget(m_toolbarSearch);
+		m_toolbarSearch.search.connect(&loadUrl);
+
+		m_chaseWidget = new ChaseWidget(this);
+		m_navigationBar.addWidget(m_chaseWidget);
+	}
+
+	void updateStatusbarActionText(bool visible)
+	{
+		m_viewStatusbar.setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar"));
+	}
+
+private:
+
+	QToolBar m_navigationBar;
+	ToolbarSearch m_toolbarSearch;
+	BookmarksToolBar m_bookmarksToolbar;
+	ChaseWidget m_chaseWidget;
+	TabWidget m_tabWidget;
+	AutoSaver m_autoSaver;
+
+	QAction m_historyBack;
+	QMenu m_historyBackMenu;
+	QAction m_historyForward;
+	QMenu m_historyForwardMenu;
+	QMenu m_windowMenu;
+
+	QAction m_stop;
+	QAction m_reload;
+	QAction m_stopReload;
+	QAction m_viewToolbar;
+	QAction m_viewBookmarkBar;
+	QAction m_viewStatusbar;
+	QAction m_restoreLastSession;
+	QAction m_addBookmark;
+
+	QIcon m_reloadIcon;
+	QIcon m_stopIcon;
+
+	QString m_lastSearch;
 }
--- a/demos/browser/chasewidget.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/chasewidget.d	Fri May 22 10:59:00 2009 +0000
@@ -42,133 +42,123 @@
 module chasewidget;
 
 
-import QtGui.QWidget;
+import qt.core.QSize;
+import qt.core.QPoint;
 
-import QtCore.QSize;
-import QtGui.QColor;
-import QtGui.QPixmap;
+import qt.gui.QColor;
+import qt.gui.QPixmap;
+import qt.gui.QWidget;
+import qt.gui.QApplication;
+import qt.gui.QHideEvent;
+import qt.gui.QPainter;
+import qt.gui.QPaintEvent;
+import qt.gui.QShowEvent;
 
-import QtCore.QPoint;
-
-import QtGui.QApplication;
-import QtGui.QHideEvent;
-import QtGui.QPainter;
-import QtGui.QPaintEvent;
-import QtGui.QShowEvent;
-
-/*
-QT_BEGIN_NAMESPACE
-class QHideEvent;
-class QShowEvent;
-class QPaintEvent;
-class QTimerEvent;
-QT_END_NAMESPACE
-*/
 
 class ChaseWidget : public QWidget
 {
-    Q_OBJECT
 public:
-    this(QWidget *parent = 0, QPixmap pixmap = QPixmap(), bool pixmapEnabled = false)
-{
-	super(parent);
-	m_segment = 0;
-     m_delay = 100;
-     m_step = 40;
-     m_timerId = -1;
-	 m_animated = false;
- m_pixmap = pixmap;
-     m_pixmapEnabled = pixmapEnabled;
-}
 
-    void setAnimated(bool value)
-{
-    if (m_animated == value)
-        return;
-    m_animated = value;
-    if (m_timerId != -1) {
-        killTimer(m_timerId);
-        m_timerId = -1;
-    }
-    if (m_animated) {
-        m_segment = 0;
-        m_timerId = startTimer(m_delay);
-    }
-    update();
-}
+	this(QWidget parent = null, QPixmap pixmap = QPixmap(), bool pixmapEnabled = false)
+	{
+		super(parent);
+		m_segment = 0;
+		m_delay = 100;
+		m_step = 40;
+		m_timerId = -1;
+		m_animated = false;
+		m_pixmap = pixmap;
+		m_pixmapEnabled = pixmapEnabled;
+	}
 
-    void setPixmapEnabled(bool enable);
-{
-    m_pixmapEnabled = enable;
-}
+	void setAnimated(bool value)
+	{
+		if (m_animated == value)
+			return;
+		m_animated = value;
+		if (m_timerId != -1) {
+			killTimer(m_timerId);
+			m_timerId = -1;
+		}
+		if (m_animated) {
+			m_segment = 0;
+			m_timerId = startTimer(m_delay);
+		}
+		update();
+	}
 
-
-    QSize sizeHint()
-{
-    return QSize(32, 32);
-}
+	void setPixmapEnabled(bool enable);
+	{
+		m_pixmapEnabled = enable;
+	}
+	
+	QSize sizeHint()
+	{
+		return QSize(32, 32);
+	}
 
 protected:
-    void paintEvent(QPaintEvent *event)
-{
-    Q_UNUSED(event);
-    QPainter p(this);
-    if (m_pixmapEnabled && !m_pixmap.isNull()) {
-        p.drawPixmap(0, 0, m_pixmap);
-        return;
-    }
 
-    int extent = qMin(width() - 8, height() - 8);
-    int displ = extent / 4;
-    int ext = extent / 4 - 1;
+	void paintEvent(QPaintEvent event)
+	{
+		//Q_UNUSED(event);
+		auto p = new QPainter(this);
+		if (m_pixmapEnabled && !m_pixmap.isNull()) {
+			p.drawPixmap(0, 0, m_pixmap);
+			return;
+		}
 
-    p.setRenderHint(QPainter::Antialiasing, true);
+		int extent = qMin(width() - 8, height() - 8);
+		int displ = extent / 4;
+		int ext = extent / 4 - 1;
 
-    if(m_animated)
-        p.setPen(Qt.gray);
-    else
-        p.setPen(QPen(palette().dark().color()));
+		p.setRenderHint(QPainter::Antialiasing, true);
 
-    p.translate(width() / 2, height() / 2); // center
+		if(m_animated)
+			p.setPen(Qt.gray);
+		else
+			p.setPen(QPen(palette().dark().color()));
 
-    for (int segment = 0; segment < segmentCount(); ++segment) {
-        p.rotate(QApplication::isRightToLeft() ? m_step : -m_step);
-        if(m_animated)
-            p.setBrush(colorForSegment(segment));
-        else
-            p.setBrush(palette().background());
-        p.drawEllipse(QRect(displ, -ext / 2, ext, ext));
-    }
-}
+		p.translate(width() / 2, height() / 2); // center
 
-    void timerEvent(QTimerEvent *event)
-{
-    if (event->timerId() == m_timerId) {
-        ++m_segment;
-        update();
-    }
-    QWidget.timerEvent(event);
-}
+		for (int segment = 0; segment < segmentCount(); ++segment) {
+			p.rotate(QApplication::isRightToLeft() ? m_step : -m_step);
+			if(m_animated)
+				p.setBrush(colorForSegment(segment));
+			else
+				p.setBrush(palette().background());
+			p.drawEllipse(QRect(displ, -ext / 2, ext, ext));
+		}
+	}
+
+	void timerEvent(QTimerEvent *event)
+	{
+		if (event->timerId() == m_timerId) {
+			++m_segment;
+			update();
+		}
+		QWidget.timerEvent(event);
+	}
 
 private:
-    int segmentCount()
-{
-    return 360 / m_step;
+
+	int segmentCount()
+	{
+		return 360 / m_step;
+	}
+
+	QColor colorForSegment(int seg)
+	{
+		int index = ((seg + m_segment) % segmentCount());
+		int comp = qMax(0, 255 - (index * (255 / segmentCount())));
+		return QColor(comp, comp, comp, 255);
+	}
+
+	int m_segment;
+	int m_delay;
+	int m_step;
+	int m_timerId;
+	bool m_animated;
+	QPixmap m_pixmap;
+	bool m_pixmapEnabled;
 }
-
-
-QColor colorForSegment(int seg)
-{
-    int index = ((seg + m_segment) % segmentCount());
-    int comp = qMax(0, 255 - (index * (255 / segmentCount())));
-    return QColor(comp, comp, comp, 255);
-}
-
-    int m_segment;
-    int m_delay;
-    int m_step;
-    int m_timerId;
-    bool m_animated;
-    QPixmap m_pixmap;
-    bool m_pixmapEnabled;
-}
--- a/demos/browser/cookiejar.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/cookiejar.d	Fri May 22 10:59:00 2009 +0000
@@ -40,45 +40,33 @@
 ****************************************************************************/
 module cookiejar;
 
-import QtNetwork.QNetworkCookieJar;
+import qt.network.QNetworkCookieJar;
+import qt.core.QDebug;
 
-import QtCore.QAbstractItemModel;
-import QtCore.QStringList;
+import qt.core.QAbstractItemModel;
+import qt.core.QStringList;
+import qt.core.QDateTime;
+import qt.core.QDir;
+import qt.core.QFile;
+import qt.core.QMetaEnum;
+import qt.core.QSettings;
+import qt.core.QUrl;
 
-import QtGui.QDialog;
-import QtGui.QTableView;
+import qt.gui.QDialog;
+import qt.gui.QTableView;
+import qt.gui.QCompleter;
+import qt.gui.QDesktopServices;
+import qt.gui.QFont;
+import qt.gui.QFontMetrics;
+import qt.gui.QHeaderView;
+import qt.gui.QKeyEvent;
+import qt.gui.QSortFilterProxyModel;
 
+import QtWebKit.QWebSettings;
 
 import cookiejar;
 import autosaver;
 
-import QtCore.QDateTime;
-import QtCore.QDir;
-import QtCore.QFile;
-import QtCore.QMetaEnum;
-import QtCore.QSettings;
-import QtCore.QUrl;
-
-import QtGui.QCompleter;
-import QtGui.QDesktopServices;
-import QtGui.QFont;
-import QtGui.QFontMetrics;
-import QtGui.QHeaderView;
-import QtGui.QKeyEvent;
-import QtGui.QSortFilterProxyModel;
-
-import QtWebKit.QWebSettings;
-
-import QtCore.QDebug;
-
-/*
-QT_BEGIN_NAMESPACE
-class QSortFilterProxyModel;
-class QKeyEvent;
-QT_END_NAMESPACE
-
-class AutoSaver;
-*/
 
 static const unsigned int JAR_VERSION = 23;
 
@@ -95,8 +83,8 @@
 {
 	list.clear();
 
-	quint32 version;
-	stream >> version;
+	quint32 version_;
+	stream >> version_;
 
 	if (version != JAR_VERSION)
 		return stream;
@@ -121,7 +109,6 @@
 	return stream;
 }
 
-
 class CookieJar : public QNetworkCookieJar
 {
 	mixin Signal!("cookiesChanged");
@@ -305,7 +292,7 @@
 		m_saveTimer.changeOccurred();
 	}
 
-public slots:
+public:
 
 	void clear()
 	{
--- a/demos/browser/downloadmanager.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/downloadmanager.d	Fri May 22 10:59:00 2009 +0000
@@ -38,624 +38,603 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+
 module downloadmanager;
 
+
+import qt.core.QFile;
+import qt.core.QTime;
+import qt.core.QMetaEnum;
+import qt.core.QSettings;
+import qt.core.QDebug;
+
+import qt.gui.QDesktopServices;
+import qt.gui.QFileDialog;
+import qt.gui.QHeaderView;
+import qt.gui.QFileIconProvider;
+
+import qt.network.QNetworkReply;
+import qt.webkit.QWebSettings;
+
+import math;
+import autosaver;
+import browserapplication;
+import networkaccessmanager;
 import ui_downloads;
 import ui_downloaditem;
 
-import QtNetwork.QNetworkReply;
-
-import QtCore.QFile;
-import QtCore.QTime;
-
-
-import autosaver;
-import browserapplication;
-import networkaccessmanager;
-
-import math;
-
-import QtCore.QMetaEnum;
-import QtCore.QSettings;
-
-import QtGui.QDesktopServices;
-import QtGui.QFileDialog;
-import QtGui.QHeaderView;
-import QtGui.QFileIconProvider;
-
-import QtCore.QDebug;
-
-import QtWebKit.QWebSettings;
-
-
 
 class DownloadItem : public QWidget, public Ui_DownloadItem
 {
-
     mixin Signal!("statusChanged");
 
 public:
  
-/*!
-    DownloadItem is a widget that is displayed in the download manager list.
-    It moves the data from the QNetworkReply into the QFile as well
-    as update the information/progressbar and report errors.
- */
-    this(QNetworkReply reply = null, bool requestFileName = false, QWidget parent = null)
-    {
-        super(parent);
-        m_reply = reply;
-        m_requestFileName = requestFileName;
-        m_bytesReceived = 0;
-        
-        setupUi(this);
-        QPalette p = downloadInfoLabel.palette();
-        p.setColor(QPalette.Text, Qt.darkGray);
-        downloadInfoLabel.setPalette(p);
-        progressBar.setMaximum(0);
-        tryAgainButton.hide();
-        stopButton.clicked.connect(&this.stop);
-        openButton.clicked.connect(&this.open);
-        tryAgainButton.clicked.connect(&this.tryAgain);
+	/*!
+	DownloadItem is a widget that is displayed in the download manager list.
+	It moves the data from the QNetworkReply into the QFile as well
+	as update the information/progressbar and report errors.
+	*/
+	this(QNetworkReply reply = null, bool requestFileName = false, QWidget parent = null)
+	{
+		super(parent);
+		m_reply = reply;
+		m_requestFileName = requestFileName;
+		m_bytesReceived = 0;
 
-        init();
-    }
+		setupUi(this);
+		QPalette p = downloadInfoLabel.palette();
+		p.setColor(QPalette.Text, Qt.darkGray);
+		downloadInfoLabel.setPalette(p);
+		progressBar.setMaximum(0);
+		tryAgainButton.hide();
+		stopButton.clicked.connect(&this.stop);
+		openButton.clicked.connect(&this.open);
+		tryAgainButton.clicked.connect(&this.tryAgain);
 
+		init();
+	}
 
-    bool downloading()
-    {
-        return (progressBar.isVisible());
-    }
+	bool downloading()
+	{
+		return (progressBar.isVisible());
+	}
 
+	bool downloadedSuccessfully()
+	{
+		return (stopButton.isHidden() && tryAgainButton.isHidden());
+	}
 
-    bool downloadedSuccessfully()
-    {
-        return (stopButton.isHidden() && tryAgainButton.isHidden());
-    }
-
-
-    QUrl m_url;
-
-    QFile m_output;
-    QNetworkReply *m_reply;
-
-private: // slots:
-    void stop()
-    {
-        setUpdatesEnabled(false);
-        stopButton.setEnabled(false);
-        stopButton.hide();
-        tryAgainButton.setEnabled(true);
-        tryAgainButton.show();
-        setUpdatesEnabled(true);
-        m_reply.abort();
-    }
-
-    void tryAgain()
-    {
-        if (!tryAgainButton.isEnabled())
-            return;
-
-        tryAgainButton.setEnabled(false);
-        tryAgainButton.setVisible(false);
-        stopButton.setEnabled(true);
-        stopButton.setVisible(true);
-        progressBar.setVisible(true);
-
-        QNetworkReply *r = BrowserApplication.networkAccessManager().get(QNetworkRequest(m_url));
-        if (m_reply)
-            m_reply.deleteLater();
-        if (m_output.exists())
-            m_output.remove();
-        m_reply = r;
-        init();
-        emit statusChanged();
-    }
-
-    void open()
-    {
-        QFileInfo info(m_output);
-        QUrl url = QUrl.fromLocalFile(info.absolutePath());
-        QDesktopServices.openUrl(url);
-    }
-
-    void downloadReadyRead()
-    {
-        if (m_requestFileName && m_output.fileName().isEmpty())
-            return;
-        if (!m_output.isOpen()) {
-            // in case someone else has already put a file there
-            if (!m_requestFileName)
-                getFileName();
-            if (!m_output.open(QIODevice.WriteOnly)) {
-                downloadInfoLabel.setText(tr("Error opening save file: %1")
-                        .arg(m_output.errorString()));
-                stopButton.click();
-                emit statusChanged();
-                return;
-            }
-            emit statusChanged();
-        }
-        if (-1 == m_output.write(m_reply.readAll())) {
-            downloadInfoLabel.setText(tr("Error saving: %1")
-                    .arg(m_output.errorString()));
-            stopButton.click();
-        }
-    }
-
-    void error(QNetworkReply.NetworkError code)
-    {
-        qDebug() << "DownloadItem::error" << m_reply.errorString() << m_url;
-        downloadInfoLabel.setText(tr("Network Error: %1").arg(m_reply.errorString()));
-        tryAgainButton.setEnabled(true);
-        tryAgainButton.setVisible(true);
-    }
-
-
-    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-    {
-        m_bytesReceived = bytesReceived;
-        if (bytesTotal == -1) {
-            progressBar.setValue(0);
-            progressBar.setMaximum(0);
-        } else {
-            progressBar.setValue(bytesReceived);
-            progressBar.setMaximum(bytesTotal);
-        }
-        updateInfoLabel();
-    }
-
-
-    void metaDataChanged()
-    {
-        qDebug() << "DownloadItem::metaDataChanged: not handled.";
-    }
-
-    void finished()
-    {
-        progressBar.hide();
-        stopButton.setEnabled(false);
-        stopButton.hide();
-        m_output.close();
-        updateInfoLabel();
-        emit statusChanged();
-    }
+	QUrl m_url;
+	QFile m_output;
+	QNetworkReply m_reply;
 
 private:
-    void getFileName()
-    {
-        QSettings settings;
-        settings.beginGroup(QLatin1String("downloadmanager"));
-        QString defaultLocation = QDesktopServices.storageLocation(QDesktopServices.DesktopLocation);
-        QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString();
-        if (!downloadDirectory.isEmpty())
-            downloadDirectory += QLatin1Char('/');
+	
+	void stop()
+	{
+		setUpdatesEnabled(false);
+		stopButton.setEnabled(false);
+		stopButton.hide();
+		tryAgainButton.setEnabled(true);
+		tryAgainButton.show();
+		setUpdatesEnabled(true);
+		m_reply.abort();
+	}
 
-        QString defaultFileName = saveFileName(downloadDirectory);
-        QString fileName = defaultFileName;
-        if (m_requestFileName) {
-            fileName = QFileDialog.getSaveFileName(this, tr("Save File"), defaultFileName);
-            if (fileName.isEmpty()) {
-                m_reply.close();
-                fileNameLabel.setText(tr("Download canceled: %1").arg(QFileInfo(defaultFileName).fileName()));
-                return;
-            }
-        }
-        m_output.setFileName(fileName);
-        fileNameLabel.setText(QFileInfo(m_output.fileName()).fileName());
-        if (m_requestFileName)
-            downloadReadyRead();
-    }
+	void tryAgain()
+	{
+		if (!tryAgainButton.isEnabled())
+			return;
 
-    void init()
-    {
-        if (!m_reply)
-            return;
+		tryAgainButton.setEnabled(false);
+		tryAgainButton.setVisible(false);
+		stopButton.setEnabled(true);
+		stopButton.setVisible(true);
+		progressBar.setVisible(true);
 
-        // attach to the m_reply
-        m_url = m_reply.url();
-        m_reply.setParent(this);
-        connect(m_reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));
-        connect(m_reply, SIGNAL(error(QNetworkReply.NetworkError)),
-                this, SLOT(error(QNetworkReply.NetworkError)));
-        connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)),
-                this, SLOT(downloadProgress(qint64, qint64)));
-        connect(m_reply, SIGNAL(metaDataChanged()),
-                this, SLOT(metaDataChanged()));
-        connect(m_reply, SIGNAL(finished()),
-                this, SLOT(finished()));
+		QNetworkReply r = BrowserApplication.networkAccessManager().get(QNetworkRequest(m_url));
+		if (m_reply)
+			m_reply.deleteLater();
+		if (m_output.exists())
+			m_output.remove();
+		m_reply = r;
+		init();
+		emit statusChanged();
+	}
 
-        // reset info
-        downloadInfoLabel.clear();
-        progressBar.setValue(0);
-        getFileName();
+	void open()
+	{
+		QFileInfo info(m_output);
+		QUrl url = QUrl.fromLocalFile(info.absolutePath());
+		QDesktopServices.openUrl(url);
+	}
 
-        // start timer for the download estimation
-        m_downloadTime.start();
+	void downloadReadyRead()
+	{
+		if (m_requestFileName && m_output.fileName().isEmpty())
+			return;
+		if (!m_output.isOpen()) {
+			// in case someone else has already put a file there
+			if (!m_requestFileName)
+				getFileName();
+			if (!m_output.open(QIODevice.WriteOnly)) {
+				downloadInfoLabel.setText(tr("Error opening save file: %1")
+					.arg(m_output.errorString()));
+				stopButton.click();
+				emit statusChanged();
+				return;
+			}
+			emit statusChanged();
+		}
+		if (-1 == m_output.write(m_reply.readAll())) {
+			downloadInfoLabel.setText(tr("Error saving: %1")
+				.arg(m_output.errorString()));
+			stopButton.click();
+		}
+	}
 
-        if (m_reply.error() != QNetworkReply.NoError) {
-            error(m_reply.error());
-            finished();
-        }
-    }
+	void error(QNetworkReply.NetworkError code)
+	{
+		qDebug() << "DownloadItem::error" << m_reply.errorString() << m_url;
+		downloadInfoLabel.setText(tr("Network Error: %1").arg(m_reply.errorString()));
+		tryAgainButton.setEnabled(true);
+		tryAgainButton.setVisible(true);
+	}
 
-    void updateInfoLabel()
-    {
-        if (m_reply.error() == QNetworkReply.NoError)
-            return;
+	void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
+	{
+		m_bytesReceived = bytesReceived;
+		if (bytesTotal == -1) {
+			progressBar.setValue(0);
+			progressBar.setMaximum(0);
+		} else {
+			progressBar.setValue(bytesReceived);
+			progressBar.setMaximum(bytesTotal);
+		}
+		updateInfoLabel();
+	}
 
-        qint64 bytesTotal = progressBar.maximum();
-        bool running = !downloadedSuccessfully();
+	void metaDataChanged()
+	{
+		qDebug() << "DownloadItem::metaDataChanged: not handled.";
+	}
 
-        // update info label
-        double speed = m_bytesReceived * 1000.0 / m_downloadTime.elapsed();
-        double timeRemaining = ((double)(bytesTotal - m_bytesReceived)) / speed;
-        QString timeRemainingString = tr("seconds");
-        if (timeRemaining > 60) {
-            timeRemaining = timeRemaining / 60;
-            timeRemainingString = tr("minutes");
-        }
-        timeRemaining = floor(timeRemaining);
+	void finished()
+	{
+		progressBar.hide();
+		stopButton.setEnabled(false);
+		stopButton.hide();
+		m_output.close();
+		updateInfoLabel();
+		emit statusChanged();
+	}
 
-        // When downloading the eta should never be 0
-        if (timeRemaining == 0)
-            timeRemaining = 1;
+private:
 
-        QString info;
-        if (running) {
-            QString remaining;
-            if (bytesTotal != 0)
-                remaining = tr("- %4 %5 remaining")
-                .arg(timeRemaining)
-                .arg(timeRemainingString);
-            info = QString(tr("%1 of %2 (%3/sec) %4"))
-                .arg(dataString(m_bytesReceived))
-                .arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal))
-                .arg(dataString((int)speed))
-                .arg(remaining);
-        } else {
-            if (m_bytesReceived == bytesTotal)
-                info = dataString(m_output.size());
-            else
-                info = tr("%1 of %2 - Stopped")
-                    .arg(dataString(m_bytesReceived))
-                    .arg(dataString(bytesTotal));
-        }
-        downloadInfoLabel.setText(info);
-    }
+	void getFileName()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("downloadmanager"));
+		QString defaultLocation = QDesktopServices.storageLocation(QDesktopServices.DesktopLocation);
+		QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString();
+		if (!downloadDirectory.isEmpty())
+			downloadDirectory += QLatin1Char('/');
 
-    QString dataString(int size)
-    {
-        QString unit;
-        if (size < 1024) {
-            unit = tr("bytes");
-        } else if (size < 1024*1024) {
-            size /= 1024;
-            unit = tr("kB");
-        } else {
-            size /= 1024*1024;
-            unit = tr("MB");
-        }
-        return QString(QLatin1String("%1 %2")).arg(size).arg(unit);
-    }
+		QString defaultFileName = saveFileName(downloadDirectory);
+		QString fileName = defaultFileName;
+		if (m_requestFileName) {
+			fileName = QFileDialog.getSaveFileName(this, tr("Save File"), defaultFileName);
+			if (fileName.isEmpty()) {
+				m_reply.close();
+				fileNameLabel.setText(tr("Download canceled: %1").arg(QFileInfo(defaultFileName).fileName()));
+				return;
+			}
+		}
+		m_output.setFileName(fileName);
+		fileNameLabel.setText(QFileInfo(m_output.fileName()).fileName());
+		if (m_requestFileName)
+			downloadReadyRead();
+	}
 
-    QString saveFileName(const QString &directory);
-    {
-        // Move this function into QNetworkReply to also get file name sent from the server
-        QString path = m_url.path();
-        QFileInfo info(path);
-        QString baseName = info.completeBaseName();
-        QString endName = info.suffix();
+	void init()
+	{
+		if (!m_reply)
+			return;
 
-        if (baseName.isEmpty()) {
-            baseName = QLatin1String("unnamed_download");
-            qDebug() << "DownloadManager:: downloading unknown file:" << m_url;
-        }
-        QString name = directory + baseName + QLatin1Char('.') + endName;
-        if (QFile.exists(name)) {
-            // already exists, don't overwrite
-            int i = 1;
-            do {
-                name = directory + baseName + QLatin1Char('-') + QString.number(i++) + QLatin1Char('.') + endName;
-            } while (QFile.exists(name));
-        }
-        return name;
-    }
+		// attach to the m_reply
+		m_url = m_reply.url();
+		m_reply.setParent(this);
+		m_reply.readyRead.connect(&this.downloadReadyRead);
+		m_reply.error.connect(&this.error);
+		m_reply.downloadProgress.connect(&this.downloadProgress);
+		m_reply.metaDataChanged.connect(&this.metaDataChanged);
+		m_reply.finished.connect(&this.finished);
 
-    bool m_requestFileName;
-    qint64 m_bytesReceived;
-    QTime m_downloadTime;
-};
+		// reset info
+		downloadInfoLabel.clear();
+		progressBar.setValue(0);
+		getFileName();
 
-class AutoSaver;
-class DownloadModel;
-QT_BEGIN_NAMESPACE
-class QFileIconProvider;
-QT_END_NAMESPACE
+		// start timer for the download estimation
+		m_downloadTime.start();
+
+		if (m_reply.error() != QNetworkReply.NoError) {
+			error(m_reply.error());
+			finished();
+		}
+	}
+
+	void updateInfoLabel()
+	{
+		if (m_reply.error() == QNetworkReply.NoError)
+			return;
+
+		qint64 bytesTotal = progressBar.maximum();
+		bool running = !downloadedSuccessfully();
+
+		// update info label
+		double speed = m_bytesReceived * 1000.0 / m_downloadTime.elapsed();
+		double timeRemaining = ((double)(bytesTotal - m_bytesReceived)) / speed;
+		QString timeRemainingString = tr("seconds");
+		if (timeRemaining > 60) {
+			timeRemaining = timeRemaining / 60;
+			timeRemainingString = tr("minutes");
+		}
+		timeRemaining = floor(timeRemaining);
+
+		// When downloading the eta should never be 0
+		if (timeRemaining == 0)
+			timeRemaining = 1;
+
+		QString info;
+		if (running) {
+			QString remaining;
+			if (bytesTotal != 0)
+				remaining = tr("- %4 %5 remaining")
+				.arg(timeRemaining)
+				.arg(timeRemainingString);
+			
+			info = QString(tr("%1 of %2 (%3/sec) %4"))
+				.arg(dataString(m_bytesReceived))
+				.arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal))
+				.arg(dataString((int)speed))
+				.arg(remaining);
+		} else {
+			if (m_bytesReceived == bytesTotal)
+				info = dataString(m_output.size());
+			else
+				info = tr("%1 of %2 - Stopped")
+				.arg(dataString(m_bytesReceived))
+				.arg(dataString(bytesTotal));
+		}
+		downloadInfoLabel.setText(info);
+	}
+
+	QString dataString(int size)
+	{
+		QString unit;
+		if (size < 1024) {
+			unit = tr("bytes");
+		} else if (size < 1024*1024) {
+			size /= 1024;
+			unit = tr("kB");
+		} else {
+			size /= 1024*1024;
+			unit = tr("MB");
+		}
+		return QString(QLatin1String("%1 %2")).arg(size).arg(unit);
+	}
+
+	QString saveFileName(QString &directory);
+	{
+		// Move this function into QNetworkReply to also get file name sent from the server
+		QString path = m_url.path();
+		QFileInfo info(path);
+		QString baseName = info.completeBaseName();
+		QString endName = info.suffix();
+
+		if (baseName.isEmpty()) {
+			baseName = QLatin1String("unnamed_download");
+			qDebug() << "DownloadManager:: downloading unknown file:" << m_url;
+		}
+		QString name = directory + baseName + QLatin1Char('.') + endName;
+		if (QFile.exists(name)) {
+			// already exists, don't overwrite
+			int i = 1;
+			do {
+				name = directory + baseName + QLatin1Char('-') + QString.number(i++) + QLatin1Char('.') + endName;
+			} while (QFile.exists(name));
+		}
+		return name;
+	}
+
+	bool m_requestFileName;
+	qint64 m_bytesReceived;
+	QTime m_downloadTime;
+}
+
 
 class DownloadManager : public QDialog, public Ui_DownloadDialog
 {
-    Q_OBJECT
-    Q_PROPERTY(RemovePolicy removePolicy READ removePolicy WRITE setRemovePolicy)
-    Q_ENUMS(RemovePolicy)
 
 public:
-    enum RemovePolicy {
-        Never,
-        Exit,
-        SuccessFullDownload
-    };
 
-    /*!
-    DownloadManager is a Dialog that contains a list of DownloadItems
+	enum RemovePolicy {
+		Never,
+		Exit,
+		SuccessFullDownload
+	};
 
-    It is a basic download manager.  It only downloads the file, doesn't do BitTorrent,
-    extract zipped files or anything fancy.
-  */
-this(QWidget *parent = null)
-    : QDialog(parent)
-    , m_autoSaver(new AutoSaver(this))
-    , m_manager(BrowserApplication.networkAccessManager())
-    , m_iconProvider(0)
-    , m_removePolicy(Never)
-{
-    setupUi(this);
-    downloadsView.setShowGrid(false);
-    downloadsView.verticalHeader().hide();
-    downloadsView.horizontalHeader().hide();
-    downloadsView.setAlternatingRowColors(true);
-    downloadsView.horizontalHeader().setStretchLastSection(true);
-    m_model = new DownloadModel(this);
-    downloadsView.setModel(m_model);
-    connect(cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup()));
-    load();
+	/*!
+	DownloadManager is a Dialog that contains a list of DownloadItems
+
+	It is a basic download manager.  It only downloads the file, doesn't do BitTorrent,
+	extract zipped files or anything fancy.
+	*/
+	this(QWidget parent = null) : QDialog(parent)
+	{
+		m_autoSaver = new AutoSaver(this);
+		m_manager = BrowserApplication.networkAccessManager();
+		m_iconProvider = 0;
+		m_removePolicy = RemovePolicy.Never;
+
+		setupUi(this);
+		downloadsView.setShowGrid(false);
+		downloadsView.verticalHeader().hide();
+		downloadsView.horizontalHeader().hide();
+		downloadsView.setAlternatingRowColors(true);
+		downloadsView.horizontalHeader().setStretchLastSection(true);
+		m_model = new DownloadModel(this);
+		downloadsView.setModel(m_model);
+		connect(cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup()));
+		load();
+	}
+
+	~this()
+	{
+		m_autoSaver.changeOccurred();
+		m_autoSaver.saveIfNeccessary();
+		if (m_iconProvider)
+			delete m_iconProvider;
+	}
+
+	int activeDownloads()
+	{
+		int count = 0;
+		for (int i = 0; i < m_downloads.count(); ++i) {
+			if (m_downloads.at(i).stopButton.isEnabled())
+				++count;
+		}
+		return count;
+	}
+
+	RemovePolicy removePolicy()
+	{
+		return m_removePolicy;
+	}
+
+	void setRemovePolicy(RemovePolicy policy)
+	{
+		if (policy == m_removePolicy)
+			return;
+		m_removePolicy = policy;
+		m_autoSaver.changeOccurred();
+	}
+
+public:
+
+	void download(QNetworkRequest request, bool requestFileName = false);
+	{
+		if (request.url().isEmpty())
+			return;
+		handleUnsupportedContent(m_manager.get(request), requestFileName);
+	}
+
+
+	void download(QUrl url, bool requestFileName = false)
+        {
+		download(QNetworkRequest(url), requestFileName);
+	}
+	
+	void handleUnsupportedContent(QNetworkReply reply, bool requestFileName = false);
+	{
+		if (!reply || reply.url().isEmpty())
+			return;
+		QVariant header = reply.header(QNetworkRequest.ContentLengthHeader);
+		bool ok;
+		int size = header.toInt(&ok);
+		if (ok && size == 0)
+			return;
+
+		qDebug() << "DownloadManager::handleUnsupportedContent" << reply.url() << "requestFileName" << requestFileName;
+		DownloadItem item = new DownloadItem(reply, requestFileName, this);
+		addItem(item);
+	}
+	
+	void cleanup()
+	{
+		if (m_downloads.isEmpty())
+			return;
+		m_model.removeRows(0, m_downloads.count());
+		updateItemCount();
+		if (m_downloads.isEmpty() && m_iconProvider) {
+			delete m_iconProvider;
+			m_iconProvider = 0;
+		}
+		m_autoSaver.changeOccurred();
+	}
+
+private:
+
+	void save()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("downloadmanager"));
+		QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy"));
+		settings.setValue(QLatin1String("removeDownloadsPolicy"), QLatin1String(removePolicyEnum.valueToKey(m_removePolicy)));
+		settings.setValue(QLatin1String("size"), size());
+		if (m_removePolicy == Exit)
+			return;
+
+		for (int i = 0; i < m_downloads.count(); ++i) {
+			QString key = QString(QLatin1String("download_%1_")).arg(i);
+			settings.setValue(key + QLatin1String("url"), m_downloads[i].m_url);
+			settings.setValue(key + QLatin1String("location"), QFileInfo(m_downloads[i].m_output).filePath());
+			settings.setValue(key + QLatin1String("done"), m_downloads[i].downloadedSuccessfully());
+		}
+		int i = m_downloads.count();
+		QString key = QString(QLatin1String("download_%1_")).arg(i);
+		while (settings.contains(key + QLatin1String("url"))) {
+			settings.remove(key + QLatin1String("url"));
+			settings.remove(key + QLatin1String("location"));
+			settings.remove(key + QLatin1String("done"));
+			key = QString(QLatin1String("download_%1_")).arg(++i);
+		}
+	}
+
+	void updateRow()
+	{
+		DownloadItem item = qobject_cast<DownloadItem*>(sender());
+		int row = m_downloads.indexOf(item);
+		if (-1 == row)
+			return;
+		if (!m_iconProvider)
+			m_iconProvider = new QFileIconProvider();
+		QIcon icon = m_iconProvider.icon(item.m_output.fileName());
+		if (icon.isNull())
+			icon = style().standardIcon(QStyle.SP_FileIcon);
+		item.fileIcon.setPixmap(icon.pixmap(48, 48));
+		downloadsView.setRowHeight(row, item.minimumSizeHint().height());
+
+		bool remove = false;
+		QWebSettings globalSettings = QWebSettings.globalSettings();
+		if (!item.downloading() && globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled))
+			remove = true;
+
+		if (item.downloadedSuccessfully() && removePolicy() == DownloadManager.SuccessFullDownload) {
+			remove = true;
+		}
+		if (remove)
+			m_model.removeRow(row);
+
+		cleanupButton.setEnabled(m_downloads.count() - activeDownloads() > 0);
+	}
+
+private:
+
+	void addItem(DownloadItem item)
+	{
+		item.statusChanged.connect(&this.updateRow);
+		int row = m_downloads.count();
+		m_model.beginInsertRows(QModelIndex(), row, row);
+		m_downloads.append(item);
+		m_model.endInsertRows();
+		updateItemCount();
+		if (row == 0)
+			show();
+		downloadsView.setIndexWidget(m_model.index(row, 0), item);
+		QIcon icon = style().standardIcon(QStyle.SP_FileIcon);
+		item.fileIcon.setPixmap(icon.pixmap(48, 48));
+		downloadsView.setRowHeight(row, item.sizeHint().height());
+	}
+
+
+	void updateItemCount()
+	{
+		int count = m_downloads.count();
+		itemCount.setText(count == 1 ? tr("1 Download") : tr("%1 Downloads").arg(count));
+	}
+
+	void load()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("downloadmanager"));
+		QSize size = settings.value(QLatin1String("size")).toSize();
+		if (size.isValid())
+			resize(size);
+		QByteArray value = settings.value(QLatin1String("removeDownloadsPolicy"), QLatin1String("Never")).toByteArray();
+		QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy"));
+		m_removePolicy = removePolicyEnum.keyToValue(value) == -1 ? Never :
+			static_cast<RemovePolicy>(removePolicyEnum.keyToValue(value));
+
+		int i = 0;
+		QString key = QString(QLatin1String("download_%1_")).arg(i);
+		while (settings.contains(key + QLatin1String("url"))) {
+			QUrl url = settings.value(key + QLatin1String("url")).toUrl();
+			QString fileName = settings.value(key + QLatin1String("location")).toString();
+			bool done = settings.value(key + QLatin1String("done"), true).toBool();
+			if (!url.isEmpty() && !fileName.isEmpty()) {
+				DownloadItem item = new DownloadItem(0, this);
+				item.m_output.setFileName(fileName);
+				item.fileNameLabel.setText(QFileInfo(item.m_output.fileName()).fileName());
+				item.m_url = url;
+				item.stopButton.setVisible(false);
+				item.stopButton.setEnabled(false);
+				item.tryAgainButton.setVisible(!done);
+				item.tryAgainButton.setEnabled(!done);
+				item.progressBar.setVisible(!done);
+				addItem(item);
+			}
+			key = QString(QLatin1String("download_%1_")).arg(++i);
+		}
+		cleanupButton.setEnabled(m_downloads.count() - activeDownloads() > 0);
+	}
+
+	AutoSaver m_autoSaver;
+	DownloadModel m_model;
+	QNetworkAccessManager m_manager;
+	QFileIconProvider m_iconProvider;
+	QList<DownloadItem> m_downloads;
+	RemovePolicy m_removePolicy;
 }
 
-    ~this()
-{
-    m_autoSaver.changeOccurred();
-    m_autoSaver.saveIfNeccessary();
-    if (m_iconProvider)
-        delete m_iconProvider;
-}
-
-    int activeDownloads()
-{
-    int count = 0;
-    for (int i = 0; i < m_downloads.count(); ++i) {
-        if (m_downloads.at(i).stopButton.isEnabled())
-            ++count;
-    }
-    return count;
-}
-
-    RemovePolicy removePolicy()
-{
-    return m_removePolicy;
-}
-
-    void setRemovePolicy(RemovePolicy policy)
-{
-    if (policy == m_removePolicy)
-        return;
-    m_removePolicy = policy;
-    m_autoSaver.changeOccurred();
-}
-
-
-public slots:
-    void download(const QNetworkRequest &request, bool requestFileName = false);
-{
-    if (request.url().isEmpty())
-        return;
-    handleUnsupportedContent(m_manager.get(request), requestFileName);
-}
-
-
-    inline void download(const QUrl &url, bool requestFileName = false)
-        { download(QNetworkRequest(url), requestFileName); }
-    void handleUnsupportedContent(QNetworkReply *reply, bool requestFileName = false);
-{
-    if (!reply || reply.url().isEmpty())
-        return;
-    QVariant header = reply.header(QNetworkRequest.ContentLengthHeader);
-    bool ok;
-    int size = header.toInt(&ok);
-    if (ok && size == 0)
-        return;
-
-    qDebug() << "DownloadManager::handleUnsupportedContent" << reply.url() << "requestFileName" << requestFileName;
-    DownloadItem *item = new DownloadItem(reply, requestFileName, this);
-    addItem(item);
-}
-	
-    void cleanup()
-{
-    if (m_downloads.isEmpty())
-        return;
-    m_model.removeRows(0, m_downloads.count());
-    updateItemCount();
-    if (m_downloads.isEmpty() && m_iconProvider) {
-        delete m_iconProvider;
-        m_iconProvider = 0;
-    }
-    m_autoSaver.changeOccurred();
-}
-
-private slots:
-    void save()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("downloadmanager"));
-    QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy"));
-    settings.setValue(QLatin1String("removeDownloadsPolicy"), QLatin1String(removePolicyEnum.valueToKey(m_removePolicy)));
-    settings.setValue(QLatin1String("size"), size());
-    if (m_removePolicy == Exit)
-        return;
-
-    for (int i = 0; i < m_downloads.count(); ++i) {
-        QString key = QString(QLatin1String("download_%1_")).arg(i);
-        settings.setValue(key + QLatin1String("url"), m_downloads[i].m_url);
-        settings.setValue(key + QLatin1String("location"), QFileInfo(m_downloads[i].m_output).filePath());
-        settings.setValue(key + QLatin1String("done"), m_downloads[i].downloadedSuccessfully());
-    }
-    int i = m_downloads.count();
-    QString key = QString(QLatin1String("download_%1_")).arg(i);
-    while (settings.contains(key + QLatin1String("url"))) {
-        settings.remove(key + QLatin1String("url"));
-        settings.remove(key + QLatin1String("location"));
-        settings.remove(key + QLatin1String("done"));
-        key = QString(QLatin1String("download_%1_")).arg(++i);
-    }
-}
-
-    void updateRow()
-{
-    DownloadItem *item = qobject_cast<DownloadItem*>(sender());
-    int row = m_downloads.indexOf(item);
-    if (-1 == row)
-        return;
-    if (!m_iconProvider)
-        m_iconProvider = new QFileIconProvider();
-    QIcon icon = m_iconProvider.icon(item.m_output.fileName());
-    if (icon.isNull())
-        icon = style().standardIcon(QStyle.SP_FileIcon);
-    item.fileIcon.setPixmap(icon.pixmap(48, 48));
-    downloadsView.setRowHeight(row, item.minimumSizeHint().height());
-
-    bool remove = false;
-    QWebSettings *globalSettings = QWebSettings.globalSettings();
-    if (!item.downloading()
-        && globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled))
-        remove = true;
-
-    if (item.downloadedSuccessfully()
-        && removePolicy() == DownloadManager.SuccessFullDownload) {
-        remove = true;
-    }
-    if (remove)
-        m_model.removeRow(row);
-
-    cleanupButton.setEnabled(m_downloads.count() - activeDownloads() > 0);
-}
-
-private:
-    void addItem(DownloadItem *item)
-{
-    connect(item, SIGNAL(statusChanged()), this, SLOT(updateRow()));
-    int row = m_downloads.count();
-    m_model.beginInsertRows(QModelIndex(), row, row);
-    m_downloads.append(item);
-    m_model.endInsertRows();
-    updateItemCount();
-    if (row == 0)
-        show();
-    downloadsView.setIndexWidget(m_model.index(row, 0), item);
-    QIcon icon = style().standardIcon(QStyle.SP_FileIcon);
-    item.fileIcon.setPixmap(icon.pixmap(48, 48));
-    downloadsView.setRowHeight(row, item.sizeHint().height());
-}
-
-
-    void updateItemCount()
-{
-    int count = m_downloads.count();
-    itemCount.setText(count == 1 ? tr("1 Download") : tr("%1 Downloads").arg(count));
-}
-
-DownloadModel.DownloadModel(DownloadManager *downloadManager, QObject *parent)
-    : QAbstractListModel(parent)
-    , m_downloadManager(downloadManager)
-{
-}
-
-    void load()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("downloadmanager"));
-    QSize size = settings.value(QLatin1String("size")).toSize();
-    if (size.isValid())
-        resize(size);
-    QByteArray value = settings.value(QLatin1String("removeDownloadsPolicy"), QLatin1String("Never")).toByteArray();
-    QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy"));
-    m_removePolicy = removePolicyEnum.keyToValue(value) == -1 ?
-                        Never :
-                        static_cast<RemovePolicy>(removePolicyEnum.keyToValue(value));
-
-    int i = 0;
-    QString key = QString(QLatin1String("download_%1_")).arg(i);
-    while (settings.contains(key + QLatin1String("url"))) {
-        QUrl url = settings.value(key + QLatin1String("url")).toUrl();
-        QString fileName = settings.value(key + QLatin1String("location")).toString();
-        bool done = settings.value(key + QLatin1String("done"), true).toBool();
-        if (!url.isEmpty() && !fileName.isEmpty()) {
-            DownloadItem *item = new DownloadItem(0, this);
-            item.m_output.setFileName(fileName);
-            item.fileNameLabel.setText(QFileInfo(item.m_output.fileName()).fileName());
-            item.m_url = url;
-            item.stopButton.setVisible(false);
-            item.stopButton.setEnabled(false);
-            item.tryAgainButton.setVisible(!done);
-            item.tryAgainButton.setEnabled(!done);
-            item.progressBar.setVisible(!done);
-            addItem(item);
-        }
-        key = QString(QLatin1String("download_%1_")).arg(++i);
-    }
-    cleanupButton.setEnabled(m_downloads.count() - activeDownloads() > 0);
-}
-
-    AutoSaver *m_autoSaver;
-    DownloadModel *m_model;
-    QNetworkAccessManager *m_manager;
-    QFileIconProvider *m_iconProvider;
-    QList<DownloadItem*> m_downloads;
-    RemovePolicy m_removePolicy;
-    friend class DownloadModel;
-};
 
 class DownloadModel : public QAbstractListModel
 {
-    friend class DownloadManager;
-    Q_OBJECT
+	
+public:
 
-public:
-    DownloadModel(DownloadManager *downloadManager, QObject *parent = 0);
-    QVariant data(const QModelIndex &index, int role = Qt.DisplayRole)
-{
-    if (index.row() < 0 || index.row() >= rowCount(index.parent()))
-        return QVariant();
-    if (role == Qt.ToolTipRole)
-        if (!m_downloadManager.m_downloads.at(index.row()).downloadedSuccessfully())
-            return m_downloadManager.m_downloads.at(index.row()).downloadInfoLabel.text();
-    return QVariant();
-}
+	this(DownloadManager downloadManager, QObject parent = null)
+	{
+		super(parent);
+		m_downloadManager = downloadManager;
+	}
 
-    int rowCount(const QModelIndex &parent = QModelIndex())
-{
-    return (parent.isValid()) ? 0 : m_downloadManager.m_downloads.count();
-}
+	QVariant data(QModelIndex index, int role = Qt.DisplayRole)
+	{
+		if (index.row() < 0 || index.row() >= rowCount(index.parent()))
+			return QVariant();
+		if (role == Qt.ToolTipRole)
+			if (!m_downloadManager.m_downloads.at(index.row()).downloadedSuccessfully())
+				return m_downloadManager.m_downloads.at(index.row()).downloadInfoLabel.text();
+		return QVariant();
+	}
 
+	int rowCount(QModelIndex parent = QModelIndex())
+	{
+		return (parent.isValid()) ? 0 : m_downloadManager.m_downloads.count();
+	}
 
-    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
-{
-    if (parent.isValid())
-        return false;
+	bool removeRows(int row, int count, QModelIndex parent = QModelIndex())
+	{
+		if (parent.isValid())
+			return false;
 
-    int lastRow = row + count - 1;
-    for (int i = lastRow; i >= row; --i) {
-        if (m_downloadManager.m_downloads.at(i).downloadedSuccessfully()
-            || m_downloadManager.m_downloads.at(i).tryAgainButton.isEnabled()) {
-            beginRemoveRows(parent, i, i);
-            m_downloadManager.m_downloads.takeAt(i).deleteLater();
-            endRemoveRows();
-        }
-    }
-    m_downloadManager.m_autoSaver.changeOccurred();
-    return true;
-}
+		int lastRow = row + count - 1;
+		for (int i = lastRow; i >= row; --i) {
+			if (m_downloadManager.m_downloads.at(i).downloadedSuccessfully()
+				|| m_downloadManager.m_downloads.at(i).tryAgainButton.isEnabled()) {
+				beginRemoveRows(parent, i, i);
+				m_downloadManager.m_downloads.takeAt(i).deleteLater();
+				endRemoveRows();
+			}
+		}
+		m_downloadManager.m_autoSaver.changeOccurred();
+		return true;
+	}
 
 private:
-    DownloadManager *m_downloadManager;
-
+	
+	DownloadManager m_downloadManager;
 }
--- a/demos/browser/edittableview.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/edittableview.d	Fri May 22 10:59:00 2009 +0000
@@ -42,45 +42,44 @@
 module edittableview;
 
 
-import QtGui.QTableView;
+import qt.gui.QTableView;
 
 
 class EditTableView : public QTableView
 {
-    Q_OBJECT
+public:
+
+	this(QWidget parent = null)
+	{
+		super(parent);
+	}
+
+	void keyPressEvent(QKeyEvent event)
+	{
+		if ((event.key() == Qt.Key_Delete || event.key() == Qt.Key_Backspace) && model()) {
+			removeOne();
+		} else {
+			QAbstractItemView.keyPressEvent(event);
+		}
+	}
 
 public:
-    EditTableView(QWidget *parent = null)
-{
-	super(parent);
+	
+	void removeOne()
+	{
+		if (!model() || !selectionModel())
+			return;
+		int row = currentIndex().row();
+		model().removeRow(row, rootIndex());
+		QModelIndex idx = model().index(row, 0, rootIndex());
+		if (!idx.isValid())
+			idx = model().index(row - 1, 0, rootIndex());
+		selectionModel().select(idx, QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows);
+	}
+	
+	void removeAll()
+	{
+		if (model())
+			model().removeRows(0, model().rowCount(rootIndex()), rootIndex());
+	}
 }
-
-    void keyPressEvent(QKeyEvent *event)
-{
-    if ((event.key() == Qt::Key_Delete
-        || event.key() == Qt::Key_Backspace)
-        && model()) {
-        removeOne();
-    } else {
-        QAbstractItemView::keyPressEvent(event);
-    }
-}
-
-public slots:
-    void removeOne()
-{
-    if (!model() || !selectionModel())
-        return;
-    int row = currentIndex().row();
-    model().removeRow(row, rootIndex());
-    QModelIndex idx = model().index(row, 0, rootIndex());
-    if (!idx.isValid())
-        idx = model().index(row - 1, 0, rootIndex());
-    selectionModel().select(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
-}
-    void removeAll()
-{
-    if (model())
-        model().removeRows(0, model().rowCount(rootIndex()), rootIndex());
-}
-}
--- a/demos/browser/edittreeview.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/edittreeview.d	Fri May 22 10:59:00 2009 +0000
@@ -42,43 +42,43 @@
 module edittreeview;
 
 
-import QtGui.QTreeView;
-import QtGui.QKeyEvent;
+import qt.gui.QTreeView;
+import qt.gui.QKeyEvent;
+
 
 class EditTreeView : public QTreeView
 {
-    Q_OBJECT
+public:
+
+	this(QWidget parent = null)
+	{
+		super(parent);
+	}
+	
+	void keyPressEvent(QKeyEvent event)
+	{
+		if ((event.key() == Qt.Key_Delete || event.key() == Qt.Key_Backspace) && model()) {
+			removeOne();
+		} else {
+			QAbstractItemView::keyPressEvent(event);
+		}
+	}
 
 public:
-this(QWidget *parent = null)
-{
-	super(parent);
+
+	void removeOne()
+	{
+		if (!model())
+			return;
+		QModelIndex ci = currentIndex();
+		int row = ci.row();
+		model().removeRow(row, ci.parent());
+	}
+
+	void removeAll()
+	{
+		if (!model())
+			return;
+		model().removeRows(0, model().rowCount(rootIndex()), rootIndex());
+	}
 }
-    void keyPressEvent(QKeyEvent *event)
-{
-    if ((event.key() == Qt::Key_Delete
-        || event.key() == Qt::Key_Backspace)
-        && model()) {
-        removeOne();
-    } else {
-        QAbstractItemView::keyPressEvent(event);
-    }
-}
-
-public slots:
-    void removeOne()
-{
-    if (!model())
-        return;
-    QModelIndex ci = currentIndex();
-    int row = ci.row();
-    model().removeRow(row, ci.parent());
-}
-
-    void removeAll()
-{
-    if (!model())
-        return;
-    model().removeRows(0, model().rowCount(rootIndex()), rootIndex());
-}
-}
--- a/demos/browser/history.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/history.d	Fri May 22 10:59:00 2009 +0000
@@ -63,8 +63,8 @@
 import qt.core.QTimer;
 import qt.core.QUrl;
 
-import QtWebKit.QWebHistoryInterface;
-import QtWebKit.QWebSettings;
+import qt.webkit.QWebHistoryInterface;
+import qtWebkit.QWebSettings;
 
 import QWebHistoryInterface;
 
@@ -110,8 +110,6 @@
 
 class HistoryManager : public QWebHistoryInterface
 {
-	//Q_PROPERTY(int historyLimit READ historyLimit WRITE setHistoryLimit)
-
 	mixin Signal!("historyReset");
 	mixin Signal!("entryAdded", HistoryItem item);
 	mixin Signal!("entryRemoved", HistoryItem item);
@@ -144,13 +142,11 @@
 		QWebHistoryInterface.setDefaultInterface(this);
 	}
 
-
 	~this()
 	{
 		m_saveTimer.saveIfNeccessary();
 	}
 
-
 	bool historyContains(QString &url)
 	{
 		return m_historyFilterModel.historyContains(url);
@@ -184,7 +180,6 @@
 		return m_historyLimit;
 	}
 
-
 	void setHistoryLimit(int limit)
 	{
 		if (m_historyLimit == limit)
@@ -194,13 +189,11 @@
 		m_saveTimer.changeOccurred();
 	}
 
-
 	QList<HistoryItem> history()
 	{
 		return m_history;
 	}
 
-
 	void setHistory(QList<HistoryItem> &history, bool loadedAndSorted = false);
 	{
 		m_history = history;
@@ -220,27 +213,23 @@
 		emit historyReset();
 	}
 
-
 	// History manager keeps around these models for use by the completer and other classes
 	HistoryModel historyModel();
 	{
 		return m_historyModel;
 	}
 
-
 	HistoryFilterModel historyFilterModel()
 	{
 		return m_historyFilterModel;
 	}
 
-
 	HistoryTreeModel historyTreeModel()
 	{
 		return m_historyTreeModel;
 	}
 
-
-public slots:
+public:
 
 	void clear()
 	{
@@ -445,6 +434,7 @@
 	HistoryTreeModel m_historyTreeModel;
 }
 
+
 class HistoryModel : public QAbstractTableModel
 {
 public:
@@ -473,7 +463,7 @@
 		DateTimeRole = Qt.UserRole + 2,
 		UrlRole = Qt.UserRole + 3,
 		UrlStringRole = Qt.UserRole + 4
-	}
+	};
 
 	this(HistoryManager history, QObject parent = null)
 	{
@@ -629,7 +619,6 @@
 		return createIndex(realRow, sourceIndex.column(), sourceModel().rowCount() - sourceIndex.row());
 	}
 
-
 	QModelIndex mapToSource(QModelIndex proxyIndex)
 	{
 		load();
@@ -718,7 +707,7 @@
 		return QAbstractProxyModel.data(index, role);
 	}
 
-private slots:
+private:
 
 	void sourceReset()
 	{
@@ -726,7 +715,6 @@
 		reset();
 	}
 
-
 	void sourceDataChanged(QModelIndex topLeft, QModelIndex bottomRight)
 	{
 		emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
@@ -739,7 +727,6 @@
 		sourceReset();
 	}
 
-
 	void sourceRowsInserted(QModelIndex parent, int start, int end)
 	{
 		assert(start == end && start == 0);
@@ -787,6 +774,7 @@
 	bool m_loaded;
 }
 
+
 /*
 The history menu
 - Removes the first twenty entries and puts them as children of the top level.
@@ -918,6 +906,7 @@
 	HistoryTreeModel m_treeModel;
 }
 
+
 // Menu that is dynamically populated from the history
 class HistoryMenu : public ModelMenu
 {
@@ -973,7 +962,8 @@
 		addAction(clearAction);
 	}
 
-private slots:
+private:
+
 	void activated(QModelIndex index)
 	{
 		emit openUrl(index.data(HistoryModel.UrlRole).toUrl());
@@ -986,7 +976,6 @@
 		dialog.show();
 	}
 
-
 private:
 
 	HistoryManager m_history;
@@ -999,8 +988,8 @@
 // exposes each url http://www.foo.com and it url starting at the host www.foo.com
 class HistoryCompletionModel : public QAbstractProxyModel
 {
+public:
 
-public:
 	this(QObject parent = null)
 	{
 		super(parent);
@@ -1008,9 +997,7 @@
 
 	QVariant data(QModelIndex index, int role)
 	{
-		if (sourceModel()
-		&& (role == Qt.EditRole || role == Qt.DisplayRole)
-		&& index.isValid()) {
+		if (sourceModel() && (role == Qt.EditRole || role == Qt.DisplayRole) && index.isValid()) {
 			QModelIndex idx = mapToSource(index);
 			idx = idx.sibling(idx.row(), 1);
 			QString urlString = idx.data(HistoryModel.UrlStringRole).toString();
@@ -1065,22 +1052,22 @@
 	{
 		if (sourceModel()) {
 			sourceModel.modelReset.disconnect(&this.sourceReset);
-			sourceModel.rowsInserted(QModelIndex , int, int).disconnect(&this.sourceReset);
-			sourceModel.rowsRemoved(QModelIndex , int, int).disconnect(&this.sourceReset);
+			sourceModel.rowsInserted.disconnect(&this.sourceReset);
+			sourceModel.rowsRemoved.disconnect(&this.sourceReset);
 		}
 
 		QAbstractProxyModel.setSourceModel(newSourceModel);
 
 		if (newSourceModel) {
 			newSourceModel.modelReset.connect(&this.sourceReset);
-			sourceModel.rowsInserted(QModelIndex , int, int).connect(&this.sourceReset);
-			sourceModel.rowsRemoved(QModelIndex , int, int).connect(&this.sourceReset);
+			sourceModel.rowsInserted.connect(&this.sourceReset);
+			sourceModel.rowsRemoved.connect(&this.sourceReset);
 		}
 
 		reset();
 	}
 
-private slots:
+private:
 
 	void sourceReset()
 	{
@@ -1088,6 +1075,7 @@
 	}
 }
 
+
 // proxy model for the history model that converts the list
 // into a tree, one top level node per day.
 // Used in the HistoryDialog.
@@ -1253,14 +1241,11 @@
 		return true;
 	}
 
-
 	QVariant headerData(int section, Qt.Orientation orientation, int role = Qt.DisplayRole)
 	{
 		return sourceModel().headerData(section, orientation, role);
 	}
 
-
-
 	void setSourceModel(QAbstractItemModel newSourceModel)
 	{
 		if (sourceModel()) {
@@ -1282,8 +1267,7 @@
 		reset();
 	}
 
-
-private slots:
+private:
 
 	void sourceReset()
 	{
@@ -1293,7 +1277,7 @@
 
 	void sourceRowsInserted(QModelIndex parent, int start, int end);
 	{
-		Q_UNUSED(parent); // Avoid warnings when compiling release
+		//Q_UNUSED(parent); // Avoid warnings when compiling release
 		assert(!parent.isValid());
 		if (start != 0 || start != end) {
 			m_sourceRowCache.clear();
@@ -1373,6 +1357,7 @@
 	QList<int> m_sourceRowCache;
 }
 
+
 // A modified QSortFilterProxyModel that always accepts the root nodes in the tree
 // so filtering is only done on the children.
 // Used in the HistoryDialog
@@ -1396,6 +1381,7 @@
 	}
 }
 
+
 import ui_history;
 
 class HistoryDialog : public QDialog, public Ui_HistoryDialog
@@ -1447,7 +1433,6 @@
 		menu.exec(QCursor.pos());
 	}
 
-
 	void open()
 	{
 		QModelIndex index = tree.currentIndex();
--- a/demos/browser/main.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/main.d	Fri May 22 10:59:00 2009 +0000
@@ -38,12 +38,15 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module main;
+
 
 import browserapplication;
 
+
 int main(char[][] args)
 {
-	Q_INIT_RESOURCE(data);
+	//Q_INIT_RESOURCE(data);
 	scope application = new BrowserApplication(args);
 	if (!application.isTheOnlyBrowser())
 		return 0;
--- a/demos/browser/modelmenu.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/modelmenu.d	Fri May 22 10:59:00 2009 +0000
@@ -38,217 +38,218 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module modelmenu;
 
-import QtGui.QMenu
-import QtCore.QAbstractItemModel;
 
-import modelmenu;
+import qt.gui.QMenu
+import qt.core.QAbstractItemModel;
 
-import QtCore.QAbstractItemModel;
+import qt.core.QAbstractItemModel;
 import qdebug;
 
 
-
 // A QMenu that is dynamically populated from a QAbstractItemModel
 class ModelMenu : public QMenu
 {
-    Q_OBJECT
-
-signals:
-    void activated(const QModelIndex &index);
-    void hovered(const QString &text);
+	
+mixin Signal!("activated", QModelIndex index);
+mixin Signal!("hovered", QString text);
 
 public:
-    ModelMenu(QWidget *parent = null)
-{
-	super(parent);
-	m_maxRows = 7;
-    m_firstSeparator = -1;
- m_maxWidth = -1;
-     m_hoverRole = 0;
-     m_separatorRole = 0;
- m_model = 0;
-    connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
-}
 
-    void setModel(QAbstractItemModel *model)
-{
-    m_model = model;
-}
+	this(QWidget parent = null)
+	{
+		super(parent);
+		m_maxRows = 7;
+		m_firstSeparator = -1;
+		m_maxWidth = -1;
+		m_hoverRole = 0;
+		m_separatorRole = 0;
+		m_model = 0;
+		this.aboutToShow.connect(&this.aboutToShow);
+	}
 
-    QAbstractItemModel *model() const
-{
-    return m_model;
-}
+	void setModel(QAbstractItemModel model)
+	{
+		m_model = model;
+	}
 
-    void setMaxRows(int max)
-{
-    m_maxRows = max;
-}
+	QAbstractItemModel model()
+	{
+		return m_model;
+	}
 
-    int maxRows() const
-{
-    return m_maxRows;
-}
+	void setMaxRows(int max)
+	{
+		m_maxRows = max;
+	}
 
-    void setFirstSeparator(int offset)
-{
-    m_firstSeparator = offset;
-}
+	int maxRows()
+	{
+		return m_maxRows;
+	}
 
-    int firstSeparator() const
-{
-    return m_firstSeparator;
-}
+	void setFirstSeparator(int offset)
+	{
+		m_firstSeparator = offset;
+	}	
 
-    void setRootIndex(const QModelIndex &index)
-{
-    m_root = index;
-}
-    QModelIndex rootIndex() const
-{
-    return m_root;
-}
+	int firstSeparator()
+	{
+		return m_firstSeparator;
+	}
 
-    void setHoverRole(int role)
-{
-    m_hoverRole = role;
-}
-    int hoverRole() const
-{
-    return m_hoverRole;
-}
+	void setRootIndex(QModelIndex index)
+	{
+		m_root = index;
+	}
+	
+	QModelIndex rootIndex()
+	{
+		return m_root;
+	}
 
-    void setSeparatorRole(int role)
-{
-    m_separatorRole = role;
-}
+	void setHoverRole(int role)
+	{
+		m_hoverRole = role;
+	}
+	
+	int hoverRole()
+	{
+		return m_hoverRole;
+	}
 
-    int separatorRole() const
-{
-    return m_separatorRole;
-}
+	void setSeparatorRole(int role)
+	{
+		m_separatorRole = role;
+	}
 
-    QAction *makeAction(const QIcon &icon, const QString &text, QObject *parent);
-{
-    QFontMetrics fm(font());
-    if (-1 == m_maxWidth)
-        m_maxWidth = fm.width(QLatin1Char('m')) * 30;
-    QString smallText = fm.elidedText(text, Qt.ElideMiddle, m_maxWidth);
-    return new QAction(icon, smallText, parent);
-}
+	int separatorRole()
+	{
+		return m_separatorRole;
+	}
+
+	QAction makeAction(QIcon icon, QString text, QObject parent);
+	{
+		QFontMetrics fm(font());
+		if (-1 == m_maxWidth)
+			m_maxWidth = fm.width(QLatin1Char('m')) * 30;
+		QString smallText = fm.elidedText(text, Qt.ElideMiddle, m_maxWidth);
+		return new QAction(icon, smallText, parent);
+	}
 
 protected:
-    // add any actions before the tree, return true if any actions are added.
-    virtual bool prePopulated()
-{
-    return false;
-}
-    // add any actions after the tree
-    virtual void postPopulated()
-{
-}
 
-    // put all of the children of parent into menu up to max
-    void createMenu(const QModelIndex &parent, int max, QMenu *parentMenu = null, QMenu *menu = null)
-{
-    if (!menu) {
-        QString title = parent.data().toString();
-        menu = new QMenu(title, this);
-        QIcon icon = qvariant_cast<QIcon>(parent.data(Qt.DecorationRole));
-        menu.setIcon(icon);
-        parentMenu.addMenu(menu);
-        QVariant v;
-        v.setValue(parent);
-        menu.menuAction().setData(v);
-        connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
-        return;
-    }
+	// add any actions before the tree, return true if any actions are added.
+	bool prePopulated()
+	{
+		return false;
+	}
+	
+	// add any actions after the tree
+	void postPopulated()
+	{
+	}
 
-    int end = m_model.rowCount(parent);
-    if (max != -1)
-        end = qMin(max, end);
+	// put all of the children of parent into menu up to max
+	void createMenu(QModelIndex parent, int max, QMenu parentMenu = null, QMenu menu = null)
+	{
+		if (!menu) {
+			QString title = parent.data().toString();
+			menu = new QMenu(title, this);
+			QIcon icon = qvariant_cast<QIcon>(parent.data(Qt.DecorationRole));
+			menu.setIcon(icon);
+			parentMenu.addMenu(menu);
+			QVariant v;
+			v.setValue(parent);
+			menu.menuAction().setData(v);
+			connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
+			return;
+		}
 
-    connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*)));
-    connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*)));
+		int end = m_model.rowCount(parent);
+		if (max != -1)
+			end = qMin(max, end);
 
-    for (int i = 0; i < end; ++i) {
-        QModelIndex idx = m_model.index(i, 0, parent);
-        if (m_model.hasChildren(idx)) {
-            createMenu(idx, -1, menu);
-        } else {
-            if (m_separatorRole != 0
-                && idx.data(m_separatorRole).toBool())
-                addSeparator();
-            else
-                menu.addAction(makeAction(idx));
-        }
-        if (menu == this && i == m_firstSeparator - 1)
-            addSeparator();
-    }
-}
+		menu.triggered.connect(&this.triggered);
+		menu.hovered.connect(&this.hovered);
 
-private slots:
-Q_DECLARE_METATYPE(QModelIndex)
-void aboutToShow()
-{
-    if (QMenu *menu = qobject_cast<QMenu*>(sender())) {
-        QVariant v = menu.menuAction().data();
-        if (v.canConvert<QModelIndex>()) {
-            QModelIndex idx = qvariant_cast<QModelIndex>(v);
-            createMenu(idx, -1, menu, menu);
-            disconnect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow()));
-            return;
-        }
-    }
-
-    clear();
-    if (prePopulated())
-        addSeparator();
-    int max = m_maxRows;
-    if (max != -1)
-        max += m_firstSeparator;
-    createMenu(m_root, max, this, this);
-    postPopulated();
-}
-
-
-    void triggered(QAction *action)
-{
-    QVariant v = action.data();
-    if (v.canConvert<QModelIndex>()) {
-        QModelIndex idx = qvariant_cast<QModelIndex>(v);
-        emit activated(idx);
-    }
-}
-
-    void hovered(QAction *action)
-{
-    QVariant v = action.data();
-    if (v.canConvert<QModelIndex>()) {
-        QModelIndex idx = qvariant_cast<QModelIndex>(v);
-        QString hoveredString = idx.data(m_hoverRole).toString();
-        if (!hoveredString.isEmpty())
-            emit hovered(hoveredString);
-    }
-}
+		for (int i = 0; i < end; ++i) {
+			QModelIndex idx = m_model.index(i, 0, parent);
+			if (m_model.hasChildren(idx)) {
+				createMenu(idx, -1, menu);
+			} else {
+				if (m_separatorRole != 0 && idx.data(m_separatorRole).toBool())
+					addSeparator();
+				else
+					menu.addAction(makeAction(idx));
+			}
+			if (menu == this && i == m_firstSeparator - 1)
+				addSeparator();
+		}
+	}
 
 private:
-    QAction *makeAction(const QModelIndex &index);
-{
-    QIcon icon = qvariant_cast<QIcon>(index.data(Qt.DecorationRole));
-    QAction *action = makeAction(icon, index.data().toString(), this);
-    QVariant v;
-    v.setValue(index);
-    action.setData(v);
-    return action;
+
+	void aboutToShow()
+	{
+		if (QMenu menu = qobject_cast<QMenu>(sender())) {
+			QVariant v = menu.menuAction().data();
+			if (v.canConvert<QModelIndex>()) {
+				QModelIndex idx = qvariant_cast<QModelIndex>(v);
+				createMenu(idx, -1, menu, menu);
+				menu.aboutToShow.disconnect(&this.aboutToShow);
+				return;
+			}
+		}
+
+		clear();
+		if (prePopulated())
+			addSeparator();
+		int max = m_maxRows;
+		if (max != -1)
+			max += m_firstSeparator;
+		createMenu(m_root, max, this, this);
+		postPopulated();
+	}
+
+	void triggered(QAction action)
+	{
+		QVariant v = action.data();
+		if (v.canConvert<QModelIndex>()) {
+			QModelIndex idx = qvariant_cast<QModelIndex>(v);
+			emit activated(idx);
+		}
+	}
+
+	void hovered(QAction action)
+	{
+		QVariant v = action.data();
+		if (v.canConvert<QModelIndex>()) {
+			QModelIndex idx = qvariant_cast<QModelIndex>(v);
+			QString hoveredString = idx.data(m_hoverRole).toString();
+			if (!hoveredString.isEmpty())
+				emit hovered(hoveredString);
+		}
+	}
+
+private:
+
+	QAction makeAction(QModelIndex index);
+	{
+		QIcon icon = qvariant_cast<QIcon>(index.data(Qt.DecorationRole));
+		QAction action = makeAction(icon, index.data().toString(), this);
+		QVariant v;
+		v.setValue(index);
+		action.setData(v);
+		return action;
+	}
+
+	int m_maxRows;
+	int m_firstSeparator;
+	int m_maxWidth;
+	int m_hoverRole;
+	int m_separatorRole;
+	QAbstractItemModel m_model;
+	QPersistentModelIndex m_root;
 }
-
-    int m_maxRows;
-    int m_firstSeparator;
-    int m_maxWidth;
-    int m_hoverRole;
-    int m_separatorRole;
-    QAbstractItemModel *m_model;
-    QPersistentModelIndex m_root;
-}
--- a/demos/browser/networkaccessmanager.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/networkaccessmanager.d	Fri May 22 10:59:00 2009 +0000
@@ -42,148 +42,143 @@
 module networkaccessmanager;
 
 
-import QtNetwork.QNetworkAccessManager;
+import qt.network.QNetworkAccessManager;
+
+import qt.core.QSettings;
+
+import qt.gui.QDesktopServices;
+import qt.gui.QDialog;
+import qt.gui.QMessageBox;
+import qt.gui.QStyle;
+import qt.gui.QTextDocument;
+
+import qt.network.QAuthenticator;
+import qt.network.QNetworkDiskCache;
+import qt.network.QNetworkProxy;
+import qt.network.QNetworkReply;
+import qt.network.QSslError;
 
 import browserapplication;
 import browsermainwindow;
 import ui_passworddialog;
 import ui_proxy;
 
-import QtCore.QSettings;
-
-import QtGui.QDesktopServices;
-import QtGui.QDialog;
-import QtGui.QMessageBox;
-import QtGui.QStyle;
-import QtGui.QTextDocument;
-
-import QtNetwork.QAuthenticator;
-import QtNetwork.QNetworkDiskCache;
-import QtNetwork.QNetworkProxy;
-import QtNetwork.QNetworkReply;
-import QtNetwork.QSslError;
-
 
 class NetworkAccessManager : public QNetworkAccessManager
 {
-    Q_OBJECT
+public:
+	this(QObject parent = null)
+	{
+		super(parent);
 
-public:
-    this(QObject *parent = null)
-{
-	super(parent);
-	
-    connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
-            SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
-    connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
-            SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));
-version(QT_NO_OPENSSL) {
-    connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
-            SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)));
-}
-    loadSettings();
+		this.authenticationRequired.connect(&authenticationRequired);
+		this.proxyAuthenticationRequired.connect(&proxyAuthenticationRequired);
+		version(QT_NO_OPENSSL) {
+			this.sslErrors.connect(&sslErrors);
+		}
+		loadSettings();
 
-    QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
-    QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
-    diskCache.setCacheDirectory(location);
-    setCache(diskCache);
-}
+		QNetworkDiskCache diskCache = new QNetworkDiskCache(this);
+		QString location = QDesktopServices.storageLocation(QDesktopServices.CacheLocation);
+		diskCache.setCacheDirectory(location);
+		setCache(diskCache);
+	}
 
 private:
     QList<QString> sslTrustedHostList;
 
-public slots:
-    void loadSettings()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("proxy"));
-    QNetworkProxy proxy;
-    if (settings.value(QLatin1String("enabled"), false).toBool()) {
-        if (settings.value(QLatin1String("type"), 0).toInt() == 0)
-            proxy = QNetworkProxy::Socks5Proxy;
-        else
-            proxy = QNetworkProxy::HttpProxy;
-        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
-        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
-        proxy.setUser(settings.value(QLatin1String("userName")).toString());
-        proxy.setPassword(settings.value(QLatin1String("password")).toString());
-    }
-    setProxy(proxy);
-}
+public:
 
+	void loadSettings()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("proxy"));
+		QNetworkProxy proxy;
+		if (settings.value(QLatin1String("enabled"), false).toBool()) {
+			if (settings.value(QLatin1String("type"), 0).toInt() == 0)
+				proxy = QNetworkProxy.Socks5Proxy;
+			else
+				proxy = QNetworkProxy.HttpProxy;
+			proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
+			proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
+			proxy.setUser(settings.value(QLatin1String("userName")).toString());
+			proxy.setPassword(settings.value(QLatin1String("password")).toString());
+		}
+		setProxy(proxy);
+	}
 
-private slots:
-    void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)
-{
-    BrowserMainWindow *mainWindow = BrowserApplication::instance().mainWindow();
+private:
 
-    QDialog dialog(mainWindow);
-    dialog.setWindowFlags(Qt::Sheet);
+	void authenticationRequired(QNetworkReply reply, QAuthenticator auth)
+	{
+		BrowserMainWindow mainWindow = BrowserApplication.instance().mainWindow();
 
-    Ui::PasswordDialog passwordDialog;
-    passwordDialog.setupUi(&dialog);
+		QDialog dialog(mainWindow);
+		dialog.setWindowFlags(Qt.Sheet);
 
-    passwordDialog.iconLabel.setText(QString());
-    passwordDialog.iconLabel.setPixmap(mainWindow.style().standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+		Ui.PasswordDialog passwordDialog;
+		passwordDialog.setupUi(&dialog);
 
-    QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
-    introMessage = introMessage.arg(Qt::escape(reply.url().toString())).arg(Qt::escape(reply.url().toString()));
-    passwordDialog.introLabel.setText(introMessage);
-    passwordDialog.introLabel.setWordWrap(true);
+		passwordDialog.iconLabel.setText(QString());
+		passwordDialog.iconLabel.setPixmap(mainWindow.style().standardIcon(QStyle.SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
 
-    if (dialog.exec() == QDialog::Accepted) {
-        auth.setUser(passwordDialog.userNameLineEdit.text());
-        auth.setPassword(passwordDialog.passwordLineEdit.text());
-    }
-}
+		QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
+		introMessage = introMessage.arg(Qt.escape(reply.url().toString())).arg(Qt.escape(reply.url().toString()));
+		passwordDialog.introLabel.setText(introMessage);
+		passwordDialog.introLabel.setWordWrap(true);
 
-void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
-{
-    BrowserMainWindow *mainWindow = BrowserApplication::instance().mainWindow();
+		if (dialog.exec() == QDialog.Accepted) {
+			auth.setUser(passwordDialog.userNameLineEdit.text());
+			auth.setPassword(passwordDialog.passwordLineEdit.text());
+		}
+	}
 
-    QDialog dialog(mainWindow);
-    dialog.setWindowFlags(Qt::Sheet);
+	void proxyAuthenticationRequired(const QNetworkProxy proxy, QAuthenticator auth)
+	{
+		BrowserMainWindow mainWindow = BrowserApplication.instance().mainWindow();
 
-    Ui::ProxyDialog proxyDialog;
-    proxyDialog.setupUi(&dialog);
+		QDialog dialog(mainWindow);
+		dialog.setWindowFlags(Qt.Sheet);
 
-    proxyDialog.iconLabel.setText(QString());
-    proxyDialog.iconLabel.setPixmap(mainWindow.style().standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+		Ui.ProxyDialog proxyDialog;
+		proxyDialog.setupUi(&dialog);
 
-    QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
-    introMessage = introMessage.arg(Qt::escape(proxy.hostName()));
-    proxyDialog.introLabel.setText(introMessage);
-    proxyDialog.introLabel.setWordWrap(true);
+		proxyDialog.iconLabel.setText(QString());
+		proxyDialog.iconLabel.setPixmap(mainWindow.style().standardIcon(QStyle.SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
 
-    if (dialog.exec() == QDialog::Accepted) {
-        auth.setUser(proxyDialog.userNameLineEdit.text());
-        auth.setPassword(proxyDialog.passwordLineEdit.text());
-    }
-}
+		QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
+		introMessage = introMessage.arg(Qt.escape(proxy.hostName()));
+		proxyDialog.introLabel.setText(introMessage);
+		proxyDialog.introLabel.setWordWrap(true);
+
+		if (dialog.exec() == QDialog.Accepted) {
+			auth.setUser(proxyDialog.userNameLineEdit.text());
+			auth.setPassword(proxyDialog.passwordLineEdit.text());
+		}
+	}
 
 version(QT_NO_OPENSSL) {
-void sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
-{
-    // check if SSL certificate has been trusted already
-    QString replyHost = reply.url().host() + ":" + reply.url().port();
-    if(! sslTrustedHostList.contains(replyHost)) {
-        BrowserMainWindow *mainWindow = BrowserApplication::instance().mainWindow();
+	void sslErrors(QNetworkReply reply, QList<QSslError> error)
+	{
+		// check if SSL certificate has been trusted already
+		QString replyHost = reply.url().host() + ":" + reply.url().port();
+		if(! sslTrustedHostList.contains(replyHost)) {
+			BrowserMainWindow mainWindow = BrowserApplication.instance().mainWindow();
 
-        QStringList errorStrings;
-        for (int i = 0; i < error.count(); ++i)
-            errorStrings += error.at(i).errorString();
-        QString errors = errorStrings.join(QLatin1String("\n"));
-        int ret = QMessageBox::warning(mainWindow, QCoreApplication::applicationName(),
-                tr("SSL Errors:\n\n%1\n\n%2\n\n"
-                        "Do you want to ignore these errors for this host?").arg(reply.url().toString()).arg(errors),
-                        QMessageBox::Yes | QMessageBox::No,
-                        QMessageBox::No);
-        if (ret == QMessageBox::Yes) {
-            reply.ignoreSslErrors();
-            sslTrustedHostList.append(replyHost);
-        }
-    }
-}
+			QStringList errorStrings;
+			for (int i = 0; i < error.count(); ++i)
+				errorStrings += error.at(i).errorString();
+			QString errors = errorStrings.join(QLatin1String("\n"));
+			int ret = QMessageBox.warning(mainWindow, QCoreApplication.applicationName(),
+				tr("SSL Errors:\n\n%1\n\n%2\n\n"
+				"Do you want to ignore these errors for this host?").arg(reply.url().toString()).arg(errors),
+				QMessageBox.Yes | QMessageBox.No, QMessageBox.No);
+			if (ret == QMessageBox.Yes) {
+				reply.ignoreSslErrors();
+				sslTrustedHostList.append(replyHost);
+			}
+		}
+	}
 }
 
 }
--- a/demos/browser/searchlineedit.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/searchlineedit.d	Fri May 22 10:59:00 2009 +0000
@@ -41,6 +41,7 @@
 
 module searchlineedit;
 
+
 import urllineedit;
 
 import qt.gui.QLineEdit;
@@ -51,19 +52,12 @@
 import qt.gui.QStyle;
 import qt.gui.QStyleOptionFrameV2;
 
-/*
-QT_BEGIN_NAMESPACE
-class QMenu;
-QT_END_NAMESPACE
-
-class SearchButton;
-*/
 
 /*
-    Clear button on the right hand side of the search widget.
-    Hidden by default
-    "A circle with an X in it"
- */
+Clear button on the right hand side of the search widget.
+Hidden by default
+"A circle with an X in it"
+*/
 class ClearButton : public QAbstractButton
 {
 public:
@@ -108,8 +102,8 @@
     Search icon on the left hand side of the search widget
     When a menu is set a down arrow appears
  */
-class SearchButton : public QAbstractButton {
-
+class SearchButton : public QAbstractButton
+{
 public:
 
 	SearchButton(QWidget parent = null)
@@ -160,6 +154,7 @@
 	QMenu m_menu;
 
 protected:
+
 	void mousePressEvent(QMouseEvent event)
 	{
 		if (m_menu && event.button() == Qt.LeftButton) {
@@ -176,17 +171,16 @@
 
 class SearchLineEdit : public ExLineEdit
 {
-    //Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText)
-
     mixin Signal!("textChanged", QString &text);
 
 public:
-/*
-    SearchLineEdit is an enhanced QLineEdit
-    - A Search icon on the left with optional menu
-    - When there is no text and doesn't have focus an "inactive text" is displayed
-    - When there is text a clear button is displayed on the right hand side
- */
+	
+	/*
+	SearchLineEdit is an enhanced QLineEdit
+	- A Search icon on the left with optional menu
+	- When there is no text and doesn't have focus an "inactive text" is displayed
+	- When there is text a clear button is displayed on the right hand side
+	*/
 	this(QWidget parent = null) : ExLineEdit(parent)
 	{
 		m_searchButton = new SearchButton(this);
@@ -227,6 +221,7 @@
 	}
 
 protected:
+
 	void resizeEvent(QResizeEvent event)
 	{
 		updateGeometries();
--- a/demos/browser/settings.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/settings.d	Fri May 22 10:59:00 2009 +0000
@@ -41,11 +41,12 @@
 module settings;
 
 
-import QtGui.QDialog;
-import ui_settings;
+import qt.core.QSettings;
 
+import qt.gui.qt.gui;
+import qt.gui.QDialog;
 
-import settings;
+import QtWebKit.QtWebKit;
 
 import browserapplication;
 import browsermainwindow;
@@ -53,287 +54,284 @@
 import history;
 import networkaccessmanager;
 import webview;
-
-import QtCore.QSettings;
-import QtGui.QtGui;
-import QtWebKit.QtWebKit;
+import ui_settings;
 
 
 class SettingsDialog : public QDialog, public Ui_Settings
 {
-    Q_OBJECT
+public:
+	
+	this(QWidget parent = null);
+	: QDialog(parent)
+	{
+		setupUi(this);
+		connect(exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions()));
+		connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage()));
+		connect(cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies()));
+		connect(standardFontButton, SIGNAL(clicked()), this, SLOT(chooseFont()));
+		connect(fixedFontButton, SIGNAL(clicked()), this, SLOT(chooseFixedFont()));
 
-public:
-    SettingsDialog(QWidget *parent = null);
-    : QDialog(parent)
-{
-    setupUi(this);
-    connect(exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions()));
-    connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage()));
-    connect(cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies()));
-    connect(standardFontButton, SIGNAL(clicked()), this, SLOT(chooseFont()));
-    connect(fixedFontButton, SIGNAL(clicked()), this, SLOT(chooseFixedFont()));
-
-    loadDefaults();
-    loadFromSettings();
-}
-    void accept();
-{
-    saveToSettings();
-    QDialog::accept();
-}
-
-private slots:
-    void loadDefaults()
-{
-    QWebSettings *defaultSettings = QWebSettings::globalSettings();
-    QString standardFontFamily = defaultSettings.fontFamily(QWebSettings::StandardFont);
-    int standardFontSize = defaultSettings.fontSize(QWebSettings::DefaultFontSize);
-    standardFont = QFont(standardFontFamily, standardFontSize);
-    standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize()));
-
-    QString fixedFontFamily = defaultSettings.fontFamily(QWebSettings::FixedFont);
-    int fixedFontSize = defaultSettings.fontSize(QWebSettings::DefaultFixedFontSize);
-    fixedFont = QFont(fixedFontFamily, fixedFontSize);
-    fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize()));
-
-    downloadsLocation.setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
-
-    enableJavascript.setChecked(defaultSettings.testAttribute(QWebSettings::JavascriptEnabled));
-    enablePlugins.setChecked(defaultSettings.testAttribute(QWebSettings::PluginsEnabled));
-}
-
-    void loadFromSettings()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("MainWindow"));
-    QString defaultHome = QLatin1String("http://qtsoftware.com");
-    homeLineEdit.setText(settings.value(QLatin1String("home"), defaultHome).toString());
-    settings.endGroup();
-
-    settings.beginGroup(QLatin1String("history"));
-    int historyExpire = settings.value(QLatin1String("historyExpire")).toInt();
-    int idx = 0;
-    switch (historyExpire) {
-    case 1: idx = 0; break;
-    case 7: idx = 1; break;
-    case 14: idx = 2; break;
-    case 30: idx = 3; break;
-    case 365: idx = 4; break;
-    case -1: idx = 5; break;
-    default:
-        idx = 5;
-    }
-    expireHistory.setCurrentIndex(idx);
-    settings.endGroup();
-
-    settings.beginGroup(QLatin1String("downloadmanager"));
-    QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation.text()).toString();
-    downloadsLocation.setText(downloadDirectory);
-    settings.endGroup();
-
-    settings.beginGroup(QLatin1String("general"));
-    openLinksIn.setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn.currentIndex()).toInt());
-
-    settings.endGroup();
-
-    // Appearance
-    settings.beginGroup(QLatin1String("websettings"));
-    fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
-    standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
-
-    standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize()));
-    fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize()));
-
-    enableJavascript.setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript.isChecked()).toBool());
-    enablePlugins.setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins.isChecked()).toBool());
-    userStyleSheet.setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString());
-    settings.endGroup();
-
-    // Privacy
-    settings.beginGroup(QLatin1String("cookies"));
-
-    CookieJar *jar = BrowserApplication::cookieJar();
-    QByteArray value = settings.value(QLatin1String("acceptCookies"), QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray();
-    QMetaEnum acceptPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("AcceptPolicy"));
-    CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ?
-                        CookieJar::AcceptOnlyFromSitesNavigatedTo :
-                        static_cast<CookieJar::AcceptPolicy>(acceptPolicyEnum.keyToValue(value));
-    switch(acceptCookies) {
-    case CookieJar::AcceptAlways:
-        acceptCombo.setCurrentIndex(0);
-        break;
-    case CookieJar::AcceptNever:
-        acceptCombo.setCurrentIndex(1);
-        break;
-    case CookieJar::AcceptOnlyFromSitesNavigatedTo:
-        acceptCombo.setCurrentIndex(2);
-        break;
-    }
-
-    value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("Expire")).toByteArray();
-    QMetaEnum keepPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("KeepPolicy"));
-    CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue(value) == -1 ?
-                        CookieJar::KeepUntilExpire :
-                        static_cast<CookieJar::KeepPolicy>(keepPolicyEnum.keyToValue(value));
-    switch(keepCookies) {
-    case CookieJar::KeepUntilExpire:
-        keepUntilCombo.setCurrentIndex(0);
-        break;
-    case CookieJar::KeepUntilExit:
-        keepUntilCombo.setCurrentIndex(1);
-        break;
-    case CookieJar::KeepUntilTimeLimit:
-        keepUntilCombo.setCurrentIndex(2);
-        break;
-    }
-    settings.endGroup();
-
-
-    // Proxy
-    settings.beginGroup(QLatin1String("proxy"));
-    proxySupport.setChecked(settings.value(QLatin1String("enabled"), false).toBool());
-    proxyType.setCurrentIndex(settings.value(QLatin1String("type"), 0).toInt());
-    proxyHostName.setText(settings.value(QLatin1String("hostName")).toString());
-    proxyPort.setValue(settings.value(QLatin1String("port"), 1080).toInt());
-    proxyUserName.setText(settings.value(QLatin1String("userName")).toString());
-    proxyPassword.setText(settings.value(QLatin1String("password")).toString());
-    settings.endGroup();
-}
-
-    void saveToSettings()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("MainWindow"));
-    settings.setValue(QLatin1String("home"), homeLineEdit.text());
-    settings.endGroup();
-
-    settings.beginGroup(QLatin1String("general"));
-    settings.setValue(QLatin1String("openLinksIn"), openLinksIn.currentIndex());
-    settings.endGroup();
-
-    settings.beginGroup(QLatin1String("history"));
-    int historyExpire = expireHistory.currentIndex();
-    int idx = -1;
-    switch (historyExpire) {
-    case 0: idx = 1; break;
-    case 1: idx = 7; break;
-    case 2: idx = 14; break;
-    case 3: idx = 30; break;
-    case 4: idx = 365; break;
-    case 5: idx = -1; break;
-    }
-    settings.setValue(QLatin1String("historyExpire"), idx);
-    settings.endGroup();
-
-    // Appearance
-    settings.beginGroup(QLatin1String("websettings"));
-    settings.setValue(QLatin1String("fixedFont"), fixedFont);
-    settings.setValue(QLatin1String("standardFont"), standardFont);
-    settings.setValue(QLatin1String("enableJavascript"), enableJavascript.isChecked());
-    settings.setValue(QLatin1String("enablePlugins"), enablePlugins.isChecked());
-    QString userStyleSheetString = userStyleSheet.text();
-    if (QFile::exists(userStyleSheetString))
-        settings.setValue(QLatin1String("userStyleSheet"), QUrl::fromLocalFile(userStyleSheetString));
-    else
-        settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString));
-    settings.endGroup();
-
-    //Privacy
-    settings.beginGroup(QLatin1String("cookies"));
-
-    CookieJar::KeepPolicy keepCookies;
-    switch(acceptCombo.currentIndex()) {
-    default:
-    case 0:
-        keepCookies = CookieJar::KeepUntilExpire;
-        break;
-    case 1:
-        keepCookies = CookieJar::KeepUntilExit;
-        break;
-    case 2:
-        keepCookies = CookieJar::KeepUntilTimeLimit;
-        break;
-    }
-    CookieJar *jar = BrowserApplication::cookieJar();
-    QMetaEnum acceptPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("AcceptPolicy"));
-    settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(keepCookies)));
-
-    CookieJar::KeepPolicy keepPolicy;
-    switch(keepUntilCombo.currentIndex()) {
-        default:
-    case 0:
-        keepPolicy = CookieJar::KeepUntilExpire;
-        break;
-    case 1:
-        keepPolicy = CookieJar::KeepUntilExit;
-        break;
-    case 2:
-        keepPolicy = CookieJar::KeepUntilTimeLimit;
-        break;
-    }
-
-    QMetaEnum keepPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("KeepPolicy"));
-    settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(keepPolicy)));
-
-    settings.endGroup();
-
-    // proxy
-    settings.beginGroup(QLatin1String("proxy"));
-    settings.setValue(QLatin1String("enabled"), proxySupport.isChecked());
-    settings.setValue(QLatin1String("type"), proxyType.currentIndex());
-    settings.setValue(QLatin1String("hostName"), proxyHostName.text());
-    settings.setValue(QLatin1String("port"), proxyPort.text());
-    settings.setValue(QLatin1String("userName"), proxyUserName.text());
-    settings.setValue(QLatin1String("password"), proxyPassword.text());
-    settings.endGroup();
-
-    BrowserApplication::instance().loadSettings();
-    BrowserApplication::networkAccessManager().loadSettings();
-    BrowserApplication::cookieJar().loadSettings();
-    BrowserApplication::historyManager().loadSettings();
-}
-
-    void setHomeToCurrentPage()
-{
-    BrowserMainWindow *mw = static_cast<BrowserMainWindow*>(parent());
-    WebView *webView = mw.currentTab();
-    if (webView)
-        homeLineEdit.setText(webView.url().toString());
-}
-
-    void showCookies()
-{
-    CookiesDialog *dialog = new CookiesDialog(BrowserApplication::cookieJar(), this);
-    dialog.exec();
-}
-    void showExceptions()
-{
-    CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(BrowserApplication::cookieJar(), this);
-    dialog.exec();
-}
-
-    void chooseFont()
-{
-    bool ok;
-    QFont font = QFontDialog::getFont(&ok, standardFont, this);
-    if ( ok ) {
-        standardFont = font;
-        standardLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize()));
-    }
-}
-
-    void chooseFixedFont()
-{
-    bool ok;
-    QFont font = QFontDialog::getFont(&ok, fixedFont, this);
-    if ( ok ) {
-        fixedFont = font;
-        fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize()));
-    }
-}
+		loadDefaults();
+		loadFromSettings();
+	}
+	
+	void accept();
+	{
+		saveToSettings();
+		QDialog.accept();
+	}
 
 private:
-    QFont standardFont;
-    QFont fixedFont;
+
+	void loadDefaults()
+	{
+		QWebSettings defaultSettings = QWebSettings.globalSettings();
+		QString standardFontFamily = defaultSettings.fontFamily(QWebSettings.StandardFont);
+		int standardFontSize = defaultSettings.fontSize(QWebSettings.DefaultFontSize);
+		standardFont = QFont(standardFontFamily, standardFontSize);
+		standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize()));
+
+		QString fixedFontFamily = defaultSettings.fontFamily(QWebSettings.FixedFont);
+		int fixedFontSize = defaultSettings.fontSize(QWebSettings.DefaultFixedFontSize);
+		fixedFont = QFont(fixedFontFamily, fixedFontSize);
+		fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize()));
+
+		downloadsLocation.setText(QDesktopServices.storageLocation(QDesktopServices.DesktopLocation));
+
+		enableJavascript.setChecked(defaultSettings.testAttribute(QWebSettings.JavascriptEnabled));
+		enablePlugins.setChecked(defaultSettings.testAttribute(QWebSettings.PluginsEnabled));
+	}
+
+	void loadFromSettings()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("MainWindow"));
+		QString defaultHome = QLatin1String("http://qtsoftware.com");
+		homeLineEdit.setText(settings.value(QLatin1String("home"), defaultHome).toString());
+		settings.endGroup();
+
+		settings.beginGroup(QLatin1String("history"));
+		int historyExpire = settings.value(QLatin1String("historyExpire")).toInt();
+		int idx = 0;
+		switch (historyExpire) {
+			case 1: idx = 0; break;
+			case 7: idx = 1; break;
+			case 14: idx = 2; break;
+			case 30: idx = 3; break;
+			case 365: idx = 4; break;
+			case -1: idx = 5; break;
+			default:
+				idx = 5;
+		}
+		expireHistory.setCurrentIndex(idx);
+		settings.endGroup();
+
+		settings.beginGroup(QLatin1String("downloadmanager"));
+		QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation.text()).toString();
+		downloadsLocation.setText(downloadDirectory);
+		settings.endGroup();
+
+		settings.beginGroup(QLatin1String("general"));
+		openLinksIn.setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn.currentIndex()).toInt());
+
+		settings.endGroup();
+
+		// Appearance
+		settings.beginGroup(QLatin1String("websettings"));
+		fixedFont = qVariantValue<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
+		standardFont = qVariantValue<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
+
+		standardLabel.setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize()));
+		fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize()));
+
+		enableJavascript.setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript.isChecked()).toBool());
+		enablePlugins.setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins.isChecked()).toBool());
+		userStyleSheet.setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString());
+		settings.endGroup();
+
+		// Privacy
+		settings.beginGroup(QLatin1String("cookies"));
+
+		CookieJar jar = BrowserApplication.cookieJar();
+		QByteArray value = settings.value(QLatin1String("acceptCookies"), QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray();
+		QMetaEnum acceptPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("AcceptPolicy"));
+		CookieJar.AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? CookieJar.AcceptOnlyFromSitesNavigatedTo :
+			cast(CookieJar.AcceptPolicy) acceptPolicyEnum.keyToValue(value);
+		switch(acceptCookies) {
+			case CookieJar.AcceptAlways:
+				acceptCombo.setCurrentIndex(0);
+				break;
+			case CookieJar.AcceptNever:
+				acceptCombo.setCurrentIndex(1);
+				break;
+			case CookieJar.AcceptOnlyFromSitesNavigatedTo:
+				acceptCombo.setCurrentIndex(2);
+				break;
+		}
+
+		value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("Expire")).toByteArray();
+		QMetaEnum keepPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("KeepPolicy"));
+		CookieJar.KeepPolicy keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? CookieJar.KeepUntilExpire :
+			cast(CookieJar.KeepPolicy)(keepPolicyEnum.keyToValue(value));
+		switch(keepCookies) {
+			case CookieJar.KeepUntilExpire:
+				keepUntilCombo.setCurrentIndex(0);
+				break;
+			case CookieJar.KeepUntilExit:
+				keepUntilCombo.setCurrentIndex(1);
+				break;
+			case CookieJar.KeepUntilTimeLimit:
+				keepUntilCombo.setCurrentIndex(2);
+				break;
+		}
+		settings.endGroup();
+
+		// Proxy
+		settings.beginGroup(QLatin1String("proxy"));
+		proxySupport.setChecked(settings.value(QLatin1String("enabled"), false).toBool());
+		proxyType.setCurrentIndex(settings.value(QLatin1String("type"), 0).toInt());
+		proxyHostName.setText(settings.value(QLatin1String("hostName")).toString());
+		proxyPort.setValue(settings.value(QLatin1String("port"), 1080).toInt());
+		proxyUserName.setText(settings.value(QLatin1String("userName")).toString());
+		proxyPassword.setText(settings.value(QLatin1String("password")).toString());
+		settings.endGroup();
+	}
+
+	void saveToSettings()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("MainWindow"));
+		settings.setValue(QLatin1String("home"), homeLineEdit.text());
+		settings.endGroup();
+
+		settings.beginGroup(QLatin1String("general"));
+		settings.setValue(QLatin1String("openLinksIn"), openLinksIn.currentIndex());
+		settings.endGroup();
+
+		settings.beginGroup(QLatin1String("history"));
+		int historyExpire = expireHistory.currentIndex();
+		int idx = -1;
+		switch (historyExpire) {
+			case 0: idx = 1; break;
+			case 1: idx = 7; break;
+			case 2: idx = 14; break;
+			case 3: idx = 30; break;
+			case 4: idx = 365; break;
+			case 5: idx = -1; break;
+		}
+		settings.setValue(QLatin1String("historyExpire"), idx);
+		settings.endGroup();
+
+		// Appearance
+		settings.beginGroup(QLatin1String("websettings"));
+		settings.setValue(QLatin1String("fixedFont"), fixedFont);
+		settings.setValue(QLatin1String("standardFont"), standardFont);
+		settings.setValue(QLatin1String("enableJavascript"), enableJavascript.isChecked());
+		settings.setValue(QLatin1String("enablePlugins"), enablePlugins.isChecked());
+		QString userStyleSheetString = userStyleSheet.text();
+		if (QFile.exists(userStyleSheetString))
+			settings.setValue(QLatin1String("userStyleSheet"), QUrl.fromLocalFile(userStyleSheetString));
+		else
+			settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString));
+		settings.endGroup();
+
+		//Privacy
+		settings.beginGroup(QLatin1String("cookies"));
+
+		CookieJar.KeepPolicy keepCookies;
+		switch(acceptCombo.currentIndex()) {
+			default:
+			case 0:
+				keepCookies = CookieJar.KeepUntilExpire;
+				break;
+			case 1:
+				keepCookies = CookieJar.KeepUntilExit;
+				break;
+			case 2:
+				keepCookies = CookieJar.KeepUntilTimeLimit;
+				break;
+		}
+		CookieJar jar = BrowserApplication.cookieJar();
+		QMetaEnum acceptPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("AcceptPolicy"));
+		settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(keepCookies)));
+
+		CookieJar.KeepPolicy keepPolicy;
+		switch(keepUntilCombo.currentIndex()) {
+			default:
+		case 0:
+			keepPolicy = CookieJar.KeepUntilExpire;
+			break;
+		case 1:
+			keepPolicy = CookieJar.KeepUntilExit;
+			break;
+		case 2:
+			keepPolicy = CookieJar.KeepUntilTimeLimit;
+			break;
+		}
+
+		QMetaEnum keepPolicyEnum = jar.staticMetaObject.enumerator(jar.staticMetaObject.indexOfEnumerator("KeepPolicy"));
+		settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(keepPolicy)));
+
+		settings.endGroup();
+
+		// proxy
+		settings.beginGroup(QLatin1String("proxy"));
+		settings.setValue(QLatin1String("enabled"), proxySupport.isChecked());
+		settings.setValue(QLatin1String("type"), proxyType.currentIndex());
+		settings.setValue(QLatin1String("hostName"), proxyHostName.text());
+		settings.setValue(QLatin1String("port"), proxyPort.text());
+		settings.setValue(QLatin1String("userName"), proxyUserName.text());
+		settings.setValue(QLatin1String("password"), proxyPassword.text());
+		settings.endGroup();
+
+		BrowserApplication.instance().loadSettings();
+		BrowserApplication.networkAccessManager().loadSettings();
+		BrowserApplication.cookieJar().loadSettings();
+		BrowserApplication.historyManager().loadSettings();
+	}
+
+	void setHomeToCurrentPage()
+	{
+		BrowserMainWindow mw = cast(BrowserMainWindow) parent();
+		WebView webView = mw.currentTab();
+		if (webView)
+			homeLineEdit.setText(webView.url().toString());
+	}
+
+	void showCookies()
+	{
+		CookiesDialog dialog = new CookiesDialog(BrowserApplication.cookieJar(), this);
+		dialog.exec();
+	}
+
+	void showExceptions()
+	{
+		CookiesExceptionsDialog dialog = new CookiesExceptionsDialog(BrowserApplication.cookieJar(), this);
+		dialog.exec();
+	}
+
+	void chooseFont()
+	{
+		bool ok;
+		QFont font = QFontDialog.getFont(&ok, standardFont, this);
+		if ( ok ) {
+			standardFont = font;
+			standardLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize()));
+		}
+	}
+
+	void chooseFixedFont()
+	{
+		bool ok;
+		QFont font = QFontDialog.getFont(&ok, fixedFont, this);
+		if ( ok ) {
+			fixedFont = font;
+			fixedLabel.setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize()));
+		}
+	}
+
+private:
+
+	QFont standardFont;
+	QFont fixedFont;
 }
--- a/demos/browser/squeezelabel.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/squeezelabel.d	Fri May 22 10:59:00 2009 +0000
@@ -46,26 +46,26 @@
 
 class SqueezeLabel : public QLabel
 {
-    Q_OBJECT
+public:
 
-public:
-this(QWidget *parent = null)
-{
-	super(parent);
-}
+	this(QWidget parent = null)
+	{
+		super(parent);
+	}
 
 protected:
-    void paintEvent(QPaintEvent *event)
-{
-    QFontMetrics fm = fontMetrics();
-    if (fm.width(text()) > contentsRect().width()) {
-        QString elided = fm.elidedText(text(), Qt.ElideMiddle, width());
-        QString oldText = text();
-        setText(elided);
-        QLabel.paintEvent(event);
-        setText(oldText);
-    } else {
-        QLabel.paintEvent(event);
-    }
+
+	void paintEvent(QPaintEvent event)
+	{
+		QFontMetrics fm = fontMetrics();
+		if (fm.width(text()) > contentsRect().width()) {
+			QString elided = fm.elidedText(text(), Qt.ElideMiddle, width());
+			QString oldText = text();
+			setText(elided);
+			QLabel.paintEvent(event);
+			setText(oldText);
+		} else {
+			QLabel.paintEvent(event);
+		}
+	}
 }
-}
--- a/demos/browser/tabwidget.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/tabwidget.d	Fri May 22 10:59:00 2009 +0000
@@ -39,11 +39,21 @@
 **
 ****************************************************************************/
 
-import QtGui.QTabBar;
+module tabwidget;
 
-import QtGui.QShortcut;
+import qt.gui.QTabBar;
+import qt.gui.QShortcut;
+import qt.gui.QClipboard;
+import qt.gui.QCompleter;
+import qt.gui.QListView;
+import qt.gui.QMenu;
+import qt.gui.QMessageBox;
+import qt.gui.QMouseEvent;
+import qt.gui.QStackedWidget;
+import qt.gui.QStyle;
+import qt.gui.QToolButton;
 
-import tabwidget;
+import qt.core.QDebug;
 
 import browserapplication;
 import browsermainwindow;
@@ -51,902 +61,844 @@
 import urllineedit;
 import webview;
 
-import QtGui.QClipboard;
-import QtGui.QCompleter;
-import QtGui.QListView;
-import QtGui.QMenu;
-import QtGui.QMessageBox;
-import QtGui.QMouseEvent;
-import QtGui.QStackedWidget;
-import QtGui.QStyle;
-import QtGui.QToolButton;
-
-import QtCore.QDebug;
-
 /*
-    Tab bar with a few more features such as a context menu and shortcuts
+Tab bar with a few more features such as a context menu and shortcuts
  */
 class TabBar : public QTabBar
 {
-    Q_OBJECT
-
-signals:
-    void newTab();
-    void cloneTab(int index);
-    void closeTab(int index);
-    void closeOtherTabs(int index)
-{
-    if (-1 == index)
-        return;
-    for (int i = count() - 1; i > index; --i)
-        closeTab(i);
-    for (int i = index - 1; i >= 0; --i)
-        closeTab(i);
-}
-
-    void reloadTab(int index);
-    void reloadAllTabs();
-    void tabMoveRequested(int fromIndex, int toIndex);
+	mixin Signal!("newTab");
+	mixin Signal!("cloneTab", int index);
+	mixin Signal!("closeTab", int index);
+	mixin Signal!("closeOtherTabs", int index);
+	mixin Signal!("reloadTab", int index);
+	mixin Signal!("reloadAllTabs");
+	mixin Signal!("tabMoveRequested", int fromIndex, int toIndex);
 
 public:
-    this(QWidget *parent = null)
-{
-	super(parent);
-    setContextMenuPolicy(Qt.CustomContextMenu);
-    setAcceptDrops(true);
-    connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
-            this, SLOT(contextMenuRequested(const QPoint &)));
 
-    QString alt = QLatin1String("Alt+%1");
-    for (int i = 1; i <= 10; ++i) {
-        int key = i;
-        if (key == 10)
-            key = 0;
-        QShortcut *shortCut = new QShortcut(alt.arg(key), this);
-        m_tabShortcuts.append(shortCut);
-        connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction()));
-    }
-    setTabsClosable(true);
-    connect(this, SIGNAL(tabCloseRequested(int)),
-            this, SIGNAL(closeTab(int)));
-    setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
-    setMovable(true);
-}
+	this(QWidget parent = null)
+	{
+		super(parent);
+		setContextMenuPolicy(Qt.CustomContextMenu);
+		setAcceptDrops(true);
+		this.customContextMenuRequested.connect(&this.contextMenuRequested);
+
+		QString alt = QLatin1String("Alt+%1");
+		for (int i = 1; i <= 10; ++i) {
+			int key = i;
+			if (key == 10)
+				key = 0;
+			QShortcut shortCut = new QShortcut(alt.arg(key), this);
+			m_tabShortcuts.append(shortCut);
+			shortCut.activated.connect(&this.selectTabAction);
+		}
+		setTabsClosable(true);
+		this.tabCloseRequested.connect(&this.closeTab);
+		setSelectionBehaviorOnRemove(QTabBar.SelectPreviousTab);
+		setMovable(true);
+	}
 
 protected:
-    void mousePressEvent(QMouseEvent* event)
-{
-    if (event.button() == Qt.LeftButton)
-        m_dragStartPos = event.pos();
-    QTabBar::mousePressEvent(event);
-}
 
-    void mouseMoveEvent(QMouseEvent* event)
-{
-    if (event.buttons() == Qt.LeftButton) {
-        int diffX = event.pos().x() - m_dragStartPos.x();
-        int diffY = event.pos().y() - m_dragStartPos.y();
-        if ((event.pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()
-            && diffX < 3 && diffX > -3
-            && diffY < -10) {
-            QDrag *drag = new QDrag(this);
-            QMimeData *mimeData = new QMimeData;
-            QList<QUrl> urls;
-            int index = tabAt(event.pos());
-            QUrl url = tabData(index).toUrl();
-            urls.append(url);
-            mimeData.setUrls(urls);
-            mimeData.setText(tabText(index));
-            mimeData.setData(QLatin1String("action"), "tab-reordering");
-            drag.setMimeData(mimeData);
-            drag.exec();
-        }
-    }
-    QTabBar::mouseMoveEvent(event);
-}
+	void mousePressEvent(QMouseEvent event)
+	{
+		if (event.button() == Qt.LeftButton)
+			m_dragStartPos = event.pos();
+		QTabBar.mousePressEvent(event);
+	}
 
-private slots:
-    void selectTabAction()
-{
-    if (QShortcut *shortCut = qobject_cast<QShortcut*>(sender())) {
-        int index = m_tabShortcuts.indexOf(shortCut);
-        if (index == 0)
-            index = 10;
-        setCurrentIndex(index);
-    }
-}
-    void cloneTab();
-{
-    if (QAction *action = qobject_cast<QAction*>(sender())) {
-        int index = action.data().toInt();
-        emit cloneTab(index);
-    }
-}
-
-    void closeTab();
-{
-    if (QAction *action = qobject_cast<QAction*>(sender())) {
-        int index = action.data().toInt();
-        emit closeTab(index);
-    }
-}
-
-    void closeOtherTabs()
-{
-    if (QAction *action = qobject_cast<QAction*>(sender())) {
-        int index = action.data().toInt();
-        emit closeOtherTabs(index);
-    }
-}
-
-void reloadTab()
-{
-    if (QAction *action = qobject_cast<QAction*>(sender())) {
-        int index = action.data().toInt();
-        emit reloadTab(index);
-    }
-}
-
-    void contextMenuRequested(const QPoint &position)
-{
-    QMenu menu;
-    menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab);
-    int index = tabAt(position);
-    if (-1 != index) {
-        QAction *action = menu.addAction(tr("Clone Tab"),
-                this, SLOT(cloneTab()));
-        action.setData(index);
-
-        menu.addSeparator();
-
-        action = menu.addAction(tr("&Close Tab"),
-                this, SLOT(closeTab()), QKeySequence::Close);
-        action.setData(index);
-
-        action = menu.addAction(tr("Close &Other Tabs"),
-                this, SLOT(closeOtherTabs()));
-        action.setData(index);
-
-        menu.addSeparator();
-
-        action = menu.addAction(tr("Reload Tab"),
-                this, SLOT(reloadTab()), QKeySequence::Refresh);
-        action.setData(index);
-    } else {
-        menu.addSeparator();
-    }
-    menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs()));
-    menu.exec(QCursor::pos());
-}
+	void mouseMoveEvent(QMouseEvent event)
+	{
+		if (event.buttons() == Qt.LeftButton) {
+			int diffX = event.pos().x() - m_dragStartPos.x();
+			int diffY = event.pos().y() - m_dragStartPos.y();
+			if ((event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance() && diffX < 3 && diffX > -3 && diffY < -10) {
+				QDrag drag = new QDrag(this);
+				QMimeData mimeData = new QMimeData;
+				QList<QUrl> urls;
+				int index = tabAt(event.pos());
+				QUrl url = tabData(index).toUrl();
+				urls.append(url);
+				mimeData.setUrls(urls);
+				mimeData.setText(tabText(index));
+				mimeData.setData(QLatin1String("action"), "tab-reordering");
+				drag.setMimeData(mimeData);
+				drag.exec();
+			}
+		}
+		QTabBar.mouseMoveEvent(event);
+	}
 
 private:
-    QList<QShortcut*> m_tabShortcuts;
-    friend class TabWidget;
 
-    QPoint m_dragStartPos;
-    int m_dragCurrentIndex;
+	void selectTabAction()
+	{
+		if (QShortcut shortCut = qobject_cast<QShortcut*>(sender())) {
+			int index = m_tabShortcuts.indexOf(shortCut);
+			if (index == 0)
+				index = 10;
+			setCurrentIndex(index);
+		}
+	}
+
+	void cloneTab();
+	{
+		if (QAction action = qobject_cast<QAction>(sender())) {
+			int index = action.data().toInt();
+			emit cloneTab(index);
+		}
+	}
+
+	void closeTab();
+	{
+		if (QAction action = qobject_cast<QAction>(sender())) {
+			int index = action.data().toInt();
+			emit closeTab(index);
+		}
+	}
+
+	void closeOtherTabs()
+	{
+		if (QAction action = qobject_cast<QAction>(sender())) {
+			int index = action.data().toInt();
+			emit closeOtherTabs(index);
+		}
+	}
+
+	void reloadTab()
+	{
+		if (QAction action = qobject_cast<QAction>(sender())) {
+			int index = action.data().toInt();
+			emit reloadTab(index);
+		}
+	}
+
+	void contextMenuRequested(QPoint position)
+	{
+		QMenu menu;
+		menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence.AddTab);
+		int index = tabAt(position);
+		if (-1 != index) {
+			QAction action = menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()));
+			action.setData(index);
+
+			menu.addSeparator();
+
+			action = menu.addAction(tr("&Close Tab"), this, SLOT(closeTab()), QKeySequence.Close);
+			action.setData(index);
+
+			action = menu.addAction(tr("Close &Other Tabs"), this, SLOT(closeOtherTabs()));
+			action.setData(index);
+
+			menu.addSeparator();
+
+			action = menu.addAction(tr("Reload Tab"), this, SLOT(reloadTab()), QKeySequence.Refresh);
+			action.setData(index);
+		} else {
+			menu.addSeparator();
+		}
+		menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs()));
+		menu.exec(QCursor.pos());
+	}
+
+	private:
+	QList<QShortcut> m_tabShortcuts;
+	friend class TabWidget;
+
+	QPoint m_dragStartPos;
+	int m_dragCurrentIndex;
 }
 
 import QtWebKit.QWebPage;
 
-/*
-QT_BEGIN_NAMESPACE
-class QAction;
-QT_END_NAMESPACE
-class WebView;
+/*!
+A proxy object that connects a single browser action
+to one child webpage action at a time.
+
+Example usage: used to keep the main window stop action in sync with
+the current tabs webview's stop action.
 */
+class WebActionMapper : public QObject
+{
+public:
+
+	this(QAction root, QWebPage.WebAction webAction, QObject parent)
+	{
+		super(parent);	
+		m_currentParent = 0;
+		m_root = root;
+		m_webAction = webAction;
+		if (!m_root)
+			return;
+		m_root.triggered.connect(&this.rootTriggered);
+		root.destroyed.connect(&this.rootDestroyed);
+		root.setEnabled(false);
+	}
+
+	QWebPage.WebAction webAction() const
+	{
+		return m_webAction;
+	}
+
+	void addChild(QAction action)
+	{
+		if (!action)
+			return;
+		action.changed.connect(&this.childChanged);
+	}
+
+	void updateCurrent(QWebPage currentParent)
+	{
+		if (m_currentParent)
+			m_currentParent.destroyed.disconnect(&this.currentDestroyed);
+
+		m_currentParent = currentParent;
+		if (!m_root)
+			return;
+		if (!m_currentParent) {
+			m_root.setEnabled(false);
+			m_root.setChecked(false);
+			return;
+		}
+		QAction source = m_currentParent.action(m_webAction);
+		m_root.setChecked(source.isChecked());
+		m_root.setEnabled(source.isEnabled());
+		m_currentParent.destroyed.connect(&this.currentDestroyed);
+	}
+
+private:
+
+	void rootTriggered()
+	{
+		if (m_currentParent) {
+			QAction gotoAction = m_currentParent.action(m_webAction);
+			gotoAction.trigger();
+		}
+	}
+
+	void childChanged()
+	{
+		if (QAction source = qobject_cast<QAction>(sender())) {
+			if (m_root && m_currentParent && source.parent() == m_currentParent) {
+					m_root.setChecked(source.isChecked());
+					m_root.setEnabled(source.isEnabled());
+			}
+		}
+	}
+
+	void rootDestroyed()
+	{
+		m_root = 0;
+	}
+	
+	void currentDestroyed()
+	{
+		updateCurrent(0);
+	}
+
+private:
+
+	QWebPage m_currentParent;
+	QAction m_root;
+	QWebPage.WebAction m_webAction;
+}
+
+
+import qt.core.QUrl;
+import qt.gui.QTabWidget;
+
 
 /*!
-    A proxy object that connects a single browser action
-    to one child webpage action at a time.
+TabWidget that contains WebViews and a stack widget of associated line edits.
 
-    Example usage: used to keep the main window stop action in sync with
-    the current tabs webview's stop action.
- */
-class WebActionMapper : public QObject
+Connects up the current tab's signals to this class's signal and uses WebActionMapper
+to proxy the actions.
+*/
+class TabWidget : public QTabWidget
 {
-    Q_OBJECT
+	// tab widget signals
+	mixin Singal!("loadPage", QString url);
+	mixin Singal!("tabsChanged");
+	mixin Singal!("lastTabClosed");
+
+	// current tab signals
+	mixin Singal!("setCurrentTitle", QString url);
+	mixin Singal!("showStatusBarMessage", QString message);
+	mixin Singal!("linkHovered", QString link);
+	mixin Singal!("loadProgress", int progress);
+	mixin Singal!("geometryChangeRequested", QRect geometry);
+	mixin Singal!("menuBarVisibilityChangeRequested", bool visible);
+	mixin Singal!("statusBarVisibilityChangeRequested", bool visible);
+	mixin Singal!("toolBarVisibilityChangeRequested", bool visible);
+	mixin Singal!("printRequested", QWebFrame frame);
 
 public:
-    this(QAction *root, QWebPage::WebAction webAction, QObject *parent)
-{
-super(parent);	
-	m_currentParent = 0;
-    m_root = root;
-    m_webAction = webAction;
-    if (!m_root)
-        return;
-    connect(m_root, SIGNAL(triggered()), this, SLOT(rootTriggered()));
-    connect(root, SIGNAL(destroyed(QObject *)), this, SLOT(rootDestroyed()));
-    root.setEnabled(false);
-}
 
-    QWebPage::WebAction webAction() const
-{
-    return m_webAction;
-}
+	this(QWidget parent = null)
+	{
+		QTabWidget(parent)
+		m_recentlyClosedTabsAction = 0;
+		m_newTabAction = 0;
+		m_closeTabAction = 0;
+		m_nextTabAction = 0;
+		m_previousTabAction = 0;
+		m_recentlyClosedTabsMenu = 0;
+		m_lineEditCompleter = 0;
+		m_lineEdits = 0;
+		m_tabBar = new TabBar(this);
 
-    void addChild(QAction *action)
-{
-    if (!action)
-        return;
-    connect(action, SIGNAL(changed()), this, SLOT(childChanged()));
-}
+		setElideMode(Qt.ElideRight);
 
+		m_tabBar.newTab.connect(&this.newTab);
+		m_tabBar.closeTab.connect(&this.closeTab(int)));
+		m_tabBar.cloneTab.connect(&this.cloneTab(int)));
+		m_tabBar.closeOtherTabs.connect(&this.closeOtherTabs(int)));
+		m_tabBar.reloadTab.connect(&this.reloadTab(int)));
+		m_tabBar.reloadAllTabs.connect(&this.reloadAllTabs()));
+		m_tabBar.tabMoved.connect(&this.moveTab(int, int)));
+		setTabBar(m_tabBar);
+		setDocumentMode(true);
 
-    void updateCurrent(QWebPage *currentParent)
-{
-    if (m_currentParent)
-        disconnect(m_currentParent, SIGNAL(destroyed(QObject *)),
-                   this, SLOT(currentDestroyed()));
+		// Actions
+		m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this);
+		m_newTabAction.setShortcuts(QKeySequence.AddTab);
+		m_newTabAction.setIconVisibleInMenu(false);
+		m_newTabAction.triggered.connect(&this.newTab);
 
-    m_currentParent = currentParent;
-    if (!m_root)
-        return;
-    if (!m_currentParent) {
-        m_root.setEnabled(false);
-        m_root.setChecked(false);
-        return;
-    }
-    QAction *source = m_currentParent.action(m_webAction);
-    m_root.setChecked(source.isChecked());
-    m_root.setEnabled(source.isEnabled());
-    connect(m_currentParent, SIGNAL(destroyed(QObject *)),
-            this, SLOT(currentDestroyed()));
-}
+		m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this);
+		m_closeTabAction.setShortcuts(QKeySequence.Close);
+		m_closeTabAction.setIconVisibleInMenu(false);
+		m_closeTabAction.triggered.connect(&this.closeTab);
 
-private slots:
-    void rootTriggered()
-{
-    if (m_currentParent) {
-        QAction *gotoAction = m_currentParent.action(m_webAction);
-        gotoAction.trigger();
-    }
-}
+		m_nextTabAction = new QAction(tr("Show Next Tab"), this);
+		QList<QKeySequence> shortcuts;
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceRight));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageDown));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketRight));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Less));
+		m_nextTabAction.setShortcuts(shortcuts);
+		m_nextTabAction.triggered.connect(&this.nextTab);
 
-    void childChanged()
-{
-    if (QAction *source = qobject_cast<QAction*>(sender())) {
-        if (m_root
-            && m_currentParent
-            && source.parent() == m_currentParent) {
-            m_root.setChecked(source.isChecked());
-            m_root.setEnabled(source.isEnabled());
-        }
-    }
-}
+		m_previousTabAction = new QAction(tr("Show Previous Tab"), this);
+		shortcuts.clear();
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceLeft));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageUp));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketLeft));
+		shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Greater));
+		m_previousTabAction.setShortcuts(shortcuts);
+		m_previousTabAction.triggered.connect(&this.previousTab);
 
-    void rootDestroyed()
-{
-    m_root = 0;
-}
-    void currentDestroyed()
-{
-    updateCurrent(0);
-}
+		m_recentlyClosedTabsMenu = new QMenu(this);
+		m_recentlyClosedTabsMenu.aboutToShow.connect(&this.aboutToShowRecentTabsMenu);
+		m_recentlyClosedTabsMenu.triggered.connect(&this.aboutToShowRecentTriggeredAction);
+		m_recentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this);
+		m_recentlyClosedTabsAction.setMenu(m_recentlyClosedTabsMenu);
+		m_recentlyClosedTabsAction.setEnabled(false);
 
-private:
-    QWebPage *m_currentParent;
-    QAction *m_root;
-    QWebPage::WebAction m_webAction;
-};
+		this.currentChanged.connect(&this.currentChanged);
 
-import QtCore.QUrl;
-import QtGui.QTabWidget;
-/*
-QT_BEGIN_NAMESPACE
-class QCompleter;
-class QLineEdit;
-class QMenu;
-class QStackedWidget;
-QT_END_NAMESPACE
-*/
+		m_lineEdits = new QStackedWidget(this);
+	}
 
-/*!
-    TabWidget that contains WebViews and a stack widget of associated line edits.
+	void clear()
+	{
+		// clear the recently closed tabs
+		m_recentlyClosedTabs.clear();
+		// clear the line edit history
+		for (int i = 0; i < m_lineEdits.count(); ++i) {
+			QLineEdit qLineEdit = lineEdit(i);
+			qLineEdit.setText(qLineEdit.text());
+		}
+	}
 
-    Connects up the current tab's signals to this class's signal and uses WebActionMapper
-    to proxy the actions.
- */
-class TabWidget : public QTabWidget
-{
-    Q_OBJECT
+	void addWebAction(QAction action, QWebPage.WebAction webAction)
+	{
+		if (!action)
+			return;
+		m_actions.append(new WebActionMapper(action, webAction, this));
+	}
 
-signals:
-    // tab widget signals
-    void loadPage(const QString &url);
-    void tabsChanged();
-    void lastTabClosed();
+	QAction newTabAction() const;
+	{
+		return m_newTabAction;
+	}
 
-    // current tab signals
-    void setCurrentTitle(const QString &url);
-    void showStatusBarMessage(const QString &message);
-    void linkHovered(const QString &link);
-    void loadProgress(int progress);
-    void geometryChangeRequested(const QRect &geometry);
-    void menuBarVisibilityChangeRequested(bool visible);
-    void statusBarVisibilityChangeRequested(bool visible);
-    void toolBarVisibilityChangeRequested(bool visible);
-    void printRequested(QWebFrame *frame);
+	QAction closeTabAction() const;
+	{
+		return m_closeTabAction;
+	}
+	
+	QAction recentlyClosedTabsAction() const;
+	{
+		return m_recentlyClosedTabsAction;
+	}
 
-public:
-    this(QWidget *parent = null)
-{
-	QTabWidget(parent)
-	m_recentlyClosedTabsAction = 0;
-	m_newTabAction = 0;
-	m_closeTabAction = 0;
-	m_nextTabAction = 0;
-	m_previousTabAction = 0;
-	m_recentlyClosedTabsMenu = 0;
-	m_lineEditCompleter = 0;
-	m_lineEdits = 0;
-	m_tabBar = new TabBar(this);
-	
-	
-    setElideMode(Qt.ElideRight);
+	QAction nextTabAction() const
+	{
+		return m_nextTabAction;
+	}
 
-    connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab()));
-    connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
-    connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int)));
-    connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int)));
-    connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int)));
-    connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs()));
-    connect(m_tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int)));
-    setTabBar(m_tabBar);
-    setDocumentMode(true);
+	QAction previousTabAction() const
+	{
+		return m_previousTabAction;
+	}
 
-    // Actions
-    m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this);
-    m_newTabAction.setShortcuts(QKeySequence::AddTab);
-    m_newTabAction.setIconVisibleInMenu(false);
-    connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab()));
+	QWidget lineEditStack() const
+	{
+		return m_lineEdits;
+	}
 
-    m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this);
-    m_closeTabAction.setShortcuts(QKeySequence::Close);
-    m_closeTabAction.setIconVisibleInMenu(false);
-    connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab()));
+	QLineEdit currentLineEdit() const
+	{
+		return lineEdit(m_lineEdits.currentIndex());
+	}
 
-    m_nextTabAction = new QAction(tr("Show Next Tab"), this);
-    QList<QKeySequence> shortcuts;
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceRight));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageDown));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketRight));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Less));
-    m_nextTabAction.setShortcuts(shortcuts);
-    connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab()));
+	WebView currentWebView() const
+	{
+		return webView(currentIndex());
+	}
 
-    m_previousTabAction = new QAction(tr("Show Previous Tab"), this);
-    shortcuts.clear();
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BraceLeft));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_PageUp));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_BracketLeft));
-    shortcuts.append(QKeySequence(Qt.CTRL | Qt.Key_Greater));
-    m_previousTabAction.setShortcuts(shortcuts);
-    connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab()));
+	WebView webView(int index) const
+	{
+		QWidget widget = this.widget(index);
+		if (WebView webView = qobject_cast<WebView>(widget)) {
+			return webView;
+		} else {
+			// optimization to delay creating the first webview
+			if (count() == 1) {
+				TabWidget that = const_cast<TabWidget>(this);
+				that.setUpdatesEnabled(false);
+				that.newTab();
+				that.closeTab(0);
+				that.setUpdatesEnabled(true);
+				return currentWebView();
+			}
+		}
+		return 0;
+	}
 
-    m_recentlyClosedTabsMenu = new QMenu(this);
-    connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()),
-            this, SLOT(aboutToShowRecentTabsMenu()));
-    connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)),
-            this, SLOT(aboutToShowRecentTriggeredAction(QAction *)));
-    m_recentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this);
-    m_recentlyClosedTabsAction.setMenu(m_recentlyClosedTabsMenu);
-    m_recentlyClosedTabsAction.setEnabled(false);
+	QLineEdit lineEdit(int index) const
+	{
+		UrlLineEdit urlLineEdit = qobject_cast<UrlLineEdit>(m_lineEdits.widget(index));
+		if (urlLineEdit)
+			return urlLineEdit.lineEdit();
+		return 0;
+	}
 
-    connect(this, SIGNAL(currentChanged(int)),
-            this, SLOT(currentChanged(int)));
-
-    m_lineEdits = new QStackedWidget(this);
-}
-
-    void clear()
-{
-    // clear the recently closed tabs
-    m_recentlyClosedTabs.clear();
-    // clear the line edit history
-    for (int i = 0; i < m_lineEdits.count(); ++i) {
-        QLineEdit *qLineEdit = lineEdit(i);
-        qLineEdit.setText(qLineEdit.text());
-    }
-}
-
-    void addWebAction(QAction *action, QWebPage::WebAction webAction)
-{
-    if (!action)
-        return;
-    m_actions.append(new WebActionMapper(action, webAction, this));
-}
-
-
-    QAction *newTabAction() const;
-{
-    return m_newTabAction;
-}
-
-    QAction *closeTabAction() const;
-{
-    return m_closeTabAction;
-}
-    QAction *recentlyClosedTabsAction() const;
-{
-    return m_recentlyClosedTabsAction;
-}
-
-    QAction *nextTabAction() const
-{
-    return m_nextTabAction;
-}
-    QAction *previousTabAction() const
-{
-    return m_previousTabAction;
-}
-
-    QWidget *lineEditStack() const
-{
-    return m_lineEdits;
-}
-
-    QLineEdit *currentLineEdit() const
-{
-    return lineEdit(m_lineEdits.currentIndex());
-}
-
-    WebView *currentWebView() const
-{
-    return webView(currentIndex());
-}
-
-    WebView *webView(int index) const
-{
-    QWidget *widget = this.widget(index);
-    if (WebView *webView = qobject_cast<WebView*>(widget)) {
-        return webView;
-    } else {
-        // optimization to delay creating the first webview
-        if (count() == 1) {
-            TabWidget *that = const_cast<TabWidget*>(this);
-            that.setUpdatesEnabled(false);
-            that.newTab();
-            that.closeTab(0);
-            that.setUpdatesEnabled(true);
-            return currentWebView();
-        }
-    }
-    return 0;
-}
-
-    QLineEdit *lineEdit(int index) const
-{
-    UrlLineEdit *urlLineEdit = qobject_cast<UrlLineEdit*>(m_lineEdits.widget(index));
-    if (urlLineEdit)
-        return urlLineEdit.lineEdit();
-    return 0;
-}
-
-    int webViewIndex(WebView *webView) const
-{
-    int index = indexOf(webView);
-    return index;
-}
+	int webViewIndex(WebView webView) const
+	{
+		int index = indexOf(webView);
+		return index;
+	}
 
     
 static const qint32 TabWidgetMagic = 0xaa;
 
-QByteArray saveState() const;
-{
-    int version = 1;
-    QByteArray data;
-    QDataStream stream(&data, QIODevice::WriteOnly);
+	QByteArray saveState() const;
+	{
+		int version = 1;
+		QByteArray data;
+		QDataStream stream(data, QIODevice.WriteOnly);
 
-    stream << qint32(TabWidgetMagic);
-    stream << qint32(version);
+		stream << qint32(TabWidgetMagic);
+		stream << qint32(version);
 
-    QStringList tabs;
-    for (int i = 0; i < count(); ++i) {
-        if (WebView *tab = qobject_cast<WebView*>(widget(i))) {
-            tabs.append(tab.url().toString());
-        } else {
-            tabs.append(QString::null);
-        }
-    }
-    stream << tabs;
-    stream << currentIndex();
-    return data;
-}
+		QStringList tabs;
+		for (int i = 0; i < count(); ++i) {
+			if (WebView tab = qobject_cast<WebView>(widget(i))) {
+				tabs.append(tab.url().toString());
+			} else {
+				tabs.append(QString.null);
+			}
+		}
+		stream << tabs;
+		stream << currentIndex();
+		return data;
+	}
 
-    bool restoreState(const QByteArray &state)
-{
-    int version = 1;
-    QByteArray sd = state;
-    QDataStream stream(&sd, QIODevice::ReadOnly);
-    if (stream.atEnd())
-        return false;
+	bool restoreState(QByteArray state)
+	{
+		int version_ = 1;
+		QByteArray sd = state;
+		QDataStream stream(sd, QIODevice.ReadOnly);
+		if (stream.atEnd())
+			return false;
 
-    qint32 marker;
-    qint32 v;
-    stream >> marker;
-    stream >> v;
-    if (marker != TabWidgetMagic || v != version)
-        return false;
+		qint32 marker;
+		qint32 v;
+		stream >> marker;
+		stream >> v;
+		if (marker != TabWidgetMagic || v != version_)
+			return false;
 
-    QStringList openTabs;
-    stream >> openTabs;
+		QStringList openTabs;
+		stream >> openTabs;
 
-    for (int i = 0; i < openTabs.count(); ++i) {
-        if (i != 0)
-            newTab();
-        loadPage(openTabs.at(i));
-    }
+		for (int i = 0; i < openTabs.count(); ++i) {
+			if (i != 0)
+				newTab();
+			loadPage(openTabs.at(i));
+		}
 
-    int currentTab;
-    stream >> currentTab;
-    setCurrentIndex(currentTab);
+		int currentTab;
+		stream >> currentTab;
+		setCurrentIndex(currentTab);
 
-    return true;
-}
+		return true;
+	}
 
 protected:
-    void mouseDoubleClickEvent(QMouseEvent *event);
-{
-    if (!childAt(event.pos())
-            // Remove the line below when QTabWidget does not have a one pixel frame
-            && event.pos().y() < (tabBar().y() + tabBar().height())) {
-        newTab();
-        return;
-    }
-    QTabWidget::mouseDoubleClickEvent(event);
-}
 
+	void mouseDoubleClickEvent(QMouseEvent event);
+	{
+		if (!childAt(event.pos())
+			// Remove the line below when QTabWidget does not have a one pixel frame
+			&& event.pos().y() < (tabBar().y() + tabBar().height())) {
+			newTab();
+			return;
+		}
+		QTabWidget.mouseDoubleClickEvent(event);
+	}
 
-    void contextMenuEvent(QContextMenuEvent *event)
-{
-    if (!childAt(event.pos())) {
-        m_tabBar.contextMenuRequested(event.pos());
-        return;
-    }
-    QTabWidget::contextMenuEvent(event);
-}
 
-    void mouseReleaseEvent(QMouseEvent *event)
-{
-    if (event.button() == Qt.MidButton && !childAt(event.pos())
-            // Remove the line below when QTabWidget does not have a one pixel frame
-            && event.pos().y() < (tabBar().y() + tabBar().height())) {
-        QUrl url(QApplication::clipboard().text(QClipboard::Selection));
-        if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
-            WebView *webView = newTab();
-            webView.setUrl(url);
-        }
-    }
-}
+	void contextMenuEvent(QContextMenuEvent event)
+	{
+		if (!childAt(event.pos())) {
+			m_tabBar.contextMenuRequested(event.pos());
+			return;
+		}
+		QTabWidget.contextMenuEvent(event);
+	}
 
-public slots:
-    void loadUrlInCurrentTab(const QUrl &url)
-{
-    WebView *webView = currentWebView();
-    if (webView) {
-        webView.loadUrl(url);
-        webView.setFocus();
-    }
-}
+	void mouseReleaseEvent(QMouseEvent event)
+	{
+		if (event.button() == Qt.MidButton && !childAt(event.pos())
+		// Remove the line below when QTabWidget does not have a one pixel frame
+		&& event.pos().y() < (tabBar().y() + tabBar().height())) {
+			QUrl url(QApplication.clipboard().text(QClipboard.Selection));
+			if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
+				WebView webView = newTab();
+				webView.setUrl(url);
+			}
+		}
+	}
 
-    WebView *newTab(bool makeCurrent = true)
-{
-    // line edit
-    UrlLineEdit *urlLineEdit = new UrlLineEdit;
-    QLineEdit *lineEdit = urlLineEdit.lineEdit();
-    if (!m_lineEditCompleter && count() > 0) {
-        HistoryCompletionModel *completionModel = new HistoryCompletionModel(this);
-        completionModel.setSourceModel(BrowserApplication::historyManager().historyFilterModel());
-        m_lineEditCompleter = new QCompleter(completionModel, this);
-        // Should this be in Qt by default?
-        QAbstractItemView *popup = m_lineEditCompleter.popup();
-        QListView *listView = qobject_cast<QListView*>(popup);
-        if (listView)
-            listView.setUniformItemSizes(true);
-    }
-    lineEdit.setCompleter(m_lineEditCompleter);
-    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
-    m_lineEdits.addWidget(urlLineEdit);
-    m_lineEdits.setSizePolicy(lineEdit.sizePolicy());
+public:
 
-    // optimization to delay creating the more expensive WebView, history, etc
-    if (count() == 0) {
-        QWidget *emptyWidget = new QWidget;
-        QPalette p = emptyWidget.palette();
-        p.setColor(QPalette::Window, palette().color(QPalette::Base));
-        emptyWidget.setPalette(p);
-        emptyWidget.setAutoFillBackground(true);
-        disconnect(this, SIGNAL(currentChanged(int)),
-            this, SLOT(currentChanged(int)));
-        addTab(emptyWidget, tr("(Untitled)"));
-        connect(this, SIGNAL(currentChanged(int)),
-            this, SLOT(currentChanged(int)));
-        return 0;
-    }
+	void loadUrlInCurrentTab(QUrl url)
+	{
+		WebView webView = currentWebView();
+		if (webView) {
+			webView.loadUrl(url);
+			webView.setFocus();
+		}
+	}
 
-    // webview
-    WebView *webView = new WebView;
-    urlLineEdit.setWebView(webView);
-    connect(webView, SIGNAL(loadStarted()),
-            this, SLOT(webViewLoadStarted()));
-    connect(webView, SIGNAL(loadFinished(bool)),
-            this, SLOT(webViewIconChanged()));
-    connect(webView, SIGNAL(iconChanged()),
-            this, SLOT(webViewIconChanged()));
-    connect(webView, SIGNAL(titleChanged(const QString &)),
-            this, SLOT(webViewTitleChanged(const QString &)));
-    connect(webView, SIGNAL(urlChanged(const QUrl &)),
-            this, SLOT(webViewUrlChanged(const QUrl &)));
-    connect(webView.page(), SIGNAL(windowCloseRequested()),
-            this, SLOT(windowCloseRequested()));
-    connect(webView.page(), SIGNAL(geometryChangeRequested(const QRect &)),
-            this, SIGNAL(geometryChangeRequested(const QRect &)));
-    connect(webView.page(), SIGNAL(printRequested(QWebFrame *)),
-            this, SIGNAL(printRequested(QWebFrame *)));
-    connect(webView.page(), SIGNAL(menuBarVisibilityChangeRequested(bool)),
-            this, SIGNAL(menuBarVisibilityChangeRequested(bool)));
-    connect(webView.page(), SIGNAL(statusBarVisibilityChangeRequested(bool)),
-            this, SIGNAL(statusBarVisibilityChangeRequested(bool)));
-    connect(webView.page(), SIGNAL(toolBarVisibilityChangeRequested(bool)),
-            this, SIGNAL(toolBarVisibilityChangeRequested(bool)));
-    addTab(webView, tr("(Untitled)"));
-    if (makeCurrent)
-        setCurrentWidget(webView);
+	WebView newTab(bool makeCurrent = true)
+	{
+		// line edit
+		UrlLineEdit urlLineEdit = new UrlLineEdit;
+		QLineEdit lineEdit = urlLineEdit.lineEdit();
+		if (!m_lineEditCompleter && count() > 0) {
+			HistoryCompletionModel completionModel = new HistoryCompletionModel(this);
+			completionModel.setSourceModel(BrowserApplication.historyManager().historyFilterModel());
+			m_lineEditCompleter = new QCompleter(completionModel, this);
+			// Should this be in Qt by default?
+			QAbstractItemView popup = m_lineEditCompleter.popup();
+			QListView listView = qobject_cast<QListView*>(popup);
+			if (listView)
+				listView.setUniformItemSizes(true);
+		}
+		lineEdit.setCompleter(m_lineEditCompleter);
+		lineEdit.returnPressed.connect(&this.lineEditReturnPressed);
+		m_lineEdits.addWidget(urlLineEdit);
+		m_lineEdits.setSizePolicy(lineEdit.sizePolicy());
 
-    // webview actions
-    for (int i = 0; i < m_actions.count(); ++i) {
-        WebActionMapper *mapper = m_actions[i];
-        mapper.addChild(webView.page().action(mapper.webAction()));
-    }
+		// optimization to delay creating the more expensive WebView, history, etc
+		if (count() == 0) {
+			QWidget emptyWidget = new QWidget;
+			QPalette p = emptyWidget.palette();
+			p.setColor(QPalette.Window, palette().color(QPalette.Base));
+			emptyWidget.setPalette(p);
+			emptyWidget.setAutoFillBackground(true);
+			this.currentChanged.disconnect(&this.currentChanged);
+			addTab(emptyWidget, tr("(Untitled)"));
+			this.currentChanged.connect(&this.currentChanged);
+			return 0;
+		}
 
-    if (count() == 1)
-        currentChanged(currentIndex());
-    emit tabsChanged();
-    return webView;
-}
+		// webview
+		WebView webView = new WebView;
+		urlLineEdit.setWebView(webView);
+		webView.loadStarted().connect(&this.webViewLoadStarted);
+		webView.loadFinished.connect(&this.webViewIconChanged);
+		webView.iconChanged.connect(&this.webViewIconChanged);
+		webView.titleChanged.connect(&this.webViewTitleChanged);
+		webView.urlChanged.connect(&this.webViewUrlChanged);
+		webView.page().windowCloseRequested.connect(&this.windowCloseRequested);
+		webView.page().geometryChangeRequested.connect(&this.geometryChangeRequested);
+		webView.page().printRequested.connect(&this.printRequested);
+		webView.page().menuBarVisibilityChangeRequested.connect(&this.menuBarVisibilityChangeRequested);
+		webView.page().statusBarVisibilityChangeRequested.connect(&this.statusBarVisibilityChangeRequested);
+		webView.page().toolBarVisibilityChangeRequested.connect(&this.toolBarVisibilityChangeRequested);
+		addTab(webView, tr("(Untitled)"));
+		if (makeCurrent)
+			setCurrentWidget(webView);
 
+		// webview actions
+		for (int i = 0; i < m_actions.count(); ++i) {
+			WebActionMapper mapper = m_actions[i];
+			mapper.addChild(webView.page().action(mapper.webAction()));
+		}
 
-// When index is -1 index chooses the current tab
-    void cloneTab(int index = -1)
-{
-    if (index < 0)
-        index = currentIndex();
-    if (index < 0 || index >= count())
-        return;
-    WebView *tab = newTab(false);
-    tab.setUrl(webView(index).url());
-}
+		if (count() == 1)
+			currentChanged(currentIndex());
+		emit tabsChanged();
+		return webView;
+	}
 
+	// When index is -1 index chooses the current tab
+	void cloneTab(int index = -1)
+	{
+		if (index < 0)
+			index = currentIndex();
+		if (index < 0 || index >= count())
+			return;
+		WebView tab = newTab(false);
+		tab.setUrl(webView(index).url());
+	}
 
+	// When index is -1 index chooses the current tab
+	void closeTab(int index = -1);
+	{
+		if (index < 0)
+			index = currentIndex();
+		if (index < 0 || index >= count())
+			return;
 
-// When index is -1 index chooses the current tab
-void closeTab(int index = -1);
-{
-    if (index < 0)
-        index = currentIndex();
-    if (index < 0 || index >= count())
-        return;
+		bool hasFocus = false;
+		if (WebView tab = webView(index)) {
+			if (tab.isModified()) {
+				QMessageBox closeConfirmation(tab);
+				closeConfirmation.setWindowFlags(Qt.Sheet);
+				closeConfirmation.setWindowTitle(tr("Do you really want to close this page?"));
+				closeConfirmation.setInformativeText(tr("You have modified this page and when closing it you would lose the modification.\n"
+							     "Do you really want to close this page?\n"));
+				closeConfirmation.setIcon(QMessageBox.Question);
+				closeConfirmation.addButton(QMessageBox.Yes);
+				closeConfirmation.addButton(QMessageBox.No);
+				closeConfirmation.setEscapeButton(QMessageBox.No);
+				if (closeConfirmation.exec() == QMessageBox.No)
+				return;
+			}
+			hasFocus = tab.hasFocus();
 
-    bool hasFocus = false;
-    if (WebView *tab = webView(index)) {
-        if (tab.isModified()) {
-            QMessageBox closeConfirmation(tab);
-            closeConfirmation.setWindowFlags(Qt.Sheet);
-            closeConfirmation.setWindowTitle(tr("Do you really want to close this page?"));
-            closeConfirmation.setInformativeText(tr("You have modified this page and when closing it you would lose the modification.\n"
-                                                     "Do you really want to close this page?\n"));
-            closeConfirmation.setIcon(QMessageBox::Question);
-            closeConfirmation.addButton(QMessageBox::Yes);
-            closeConfirmation.addButton(QMessageBox::No);
-            closeConfirmation.setEscapeButton(QMessageBox::No);
-            if (closeConfirmation.exec() == QMessageBox::No)
-                return;
-        }
-        hasFocus = tab.hasFocus();
+			m_recentlyClosedTabsAction.setEnabled(true);
+			m_recentlyClosedTabs.prepend(tab.url());
+			if (m_recentlyClosedTabs.size() >= TabWidget.m_recentlyClosedTabsSize)
+				m_recentlyClosedTabs.removeLast();
+		}
+		QWidget lineEdit = m_lineEdits.widget(index);
+		m_lineEdits.removeWidget(lineEdit);
+		lineEdit.deleteLater();
+		QWidget webView = widget(index);
+		removeTab(index);
+		webView.deleteLater();
+		emit tabsChanged();
+		if (hasFocus && count() > 0)
+			currentWebView().setFocus();
+		if (count() == 0)
+			emit lastTabClosed();
+	}
 
-        m_recentlyClosedTabsAction.setEnabled(true);
-        m_recentlyClosedTabs.prepend(tab.url());
-        if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize)
-            m_recentlyClosedTabs.removeLast();
-    }
-    QWidget *lineEdit = m_lineEdits.widget(index);
-    m_lineEdits.removeWidget(lineEdit);
-    lineEdit.deleteLater();
-    QWidget *webView = widget(index);
-    removeTab(index);
-    webView.deleteLater();
-    emit tabsChanged();
-    if (hasFocus && count() > 0)
-        currentWebView().setFocus();
-    if (count() == 0)
-        emit lastTabClosed();
-}
+	void closeOtherTabs(int index)
+	{
+		if (-1 == index)
+			return;
+		for (int i = count() - 1; i > index; --i)
+			closeTab(i);
+		for (int i = index - 1; i >= 0; --i)
+			closeTab(i);
+	}
 
-    void closeOtherTabs(int index);
-// When index is -1 index chooses the current tab
-    void reloadTab(int index = -1);
-{
-    if (index < 0)
-        index = currentIndex();
-    if (index < 0 || index >= count())
-        return;
+	// When index is -1 index chooses the current tab
+	void reloadTab(int index = -1);
+	{
+		if (index < 0)
+			index = currentIndex();
+		if (index < 0 || index >= count())
+			return;
 
-    QWidget *widget = this.widget(index);
-    if (WebView *tab = qobject_cast<WebView*>(widget))
-        tab.reload();
-}
+		QWidget widget = this.widget(index);
+		if (WebView tab = qobject_cast<WebView>(widget))
+			tab.reload();
+	}
 
-    void reloadAllTabs();
-{
-    for (int i = 0; i < count(); ++i) {
-        QWidget *tabWidget = widget(i);
-        if (WebView *tab = qobject_cast<WebView*>(tabWidget)) {
-            tab.reload();
-        }
-    }
-}
-    void nextTab()
-{
-    int next = currentIndex() + 1;
-    if (next == count())
-        next = 0;
-    setCurrentIndex(next);
-}
+	void reloadAllTabs();
+	{
+		for (int i = 0; i < count(); ++i) {
+			QWidget tabWidget = widget(i);
+			if (WebView tab = qobject_cast<WebView>(tabWidget)) {
+				tab.reload();
+			}
+		}
+	}
+	
+	void nextTab()
+	{
+		int next = currentIndex() + 1;
+		if (next == count())
+			next = 0;
+		setCurrentIndex(next);
+	}
 
-
-    void previousTab()
-{
-    int next = currentIndex() - 1;
-    if (next < 0)
-        next = count() - 1;
-    setCurrentIndex(next);
-}
-
-private slots:
-    void currentChanged(int index)
-{
-    WebView *webView = this.webView(index);
-    if (!webView)
-        return;
-
-    assert(m_lineEdits.count() == count());
-
-    WebView *oldWebView = this.webView(m_lineEdits.currentIndex());
-    if (oldWebView) {
-        disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)),
-                this, SIGNAL(showStatusBarMessage(const QString&)));
-        disconnect(oldWebView.page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
-                this, SIGNAL(linkHovered(const QString&)));
-        disconnect(oldWebView, SIGNAL(loadProgress(int)),
-                this, SIGNAL(loadProgress(int)));
-    }
-
-    connect(webView, SIGNAL(statusBarMessage(const QString&)),
-            this, SIGNAL(showStatusBarMessage(const QString&)));
-    connect(webView.page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
-            this, SIGNAL(linkHovered(const QString&)));
-    connect(webView, SIGNAL(loadProgress(int)),
-            this, SIGNAL(loadProgress(int)));
-
-    for (int i = 0; i < m_actions.count(); ++i) {
-        WebActionMapper *mapper = m_actions[i];
-        mapper.updateCurrent(webView.page());
-    }
-    emit setCurrentTitle(webView.title());
-    m_lineEdits.setCurrentIndex(index);
-    emit loadProgress(webView.progress());
-    emit showStatusBarMessage(webView.lastStatusBarText());
-    if (webView.url().isEmpty())
-        m_lineEdits.currentWidget().setFocus();
-    else
-        webView.setFocus();
-}
-
-    void aboutToShowRecentTabsMenu()
-{
-    m_recentlyClosedTabsMenu.clear();
-    for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) {
-        QAction *action = new QAction(m_recentlyClosedTabsMenu);
-        action.setData(m_recentlyClosedTabs.at(i));
-        QIcon icon = BrowserApplication::instance().icon(m_recentlyClosedTabs.at(i));
-        action.setIcon(icon);
-        action.setText(m_recentlyClosedTabs.at(i).toString());
-        m_recentlyClosedTabsMenu.addAction(action);
-    }
-}
-
-    void aboutToShowRecentTriggeredAction(QAction *action)
-{
-    QUrl url = action.data().toUrl();
-    loadUrlInCurrentTab(url);
-}
-
-    void webViewLoadStarted()
-{
-    WebView *webView = qobject_cast<WebView*>(sender());
-    int index = webViewIndex(webView);
-    if (-1 != index) {
-        QIcon icon(QLatin1String(":loading.gif"));
-        setTabIcon(index, icon);
-    }
-}
-
-    void webViewIconChanged()
-{
-    WebView *webView = qobject_cast<WebView*>(sender());
-    int index = webViewIndex(webView);
-    if (-1 != index) {
-        QIcon icon = BrowserApplication::instance().icon(webView.url());
-        setTabIcon(index, icon);
-    }
-}
-
-    void webViewTitleChanged(const QString &title)
-{
-    WebView *webView = qobject_cast<WebView*>(sender());
-    int index = webViewIndex(webView);
-    if (-1 != index) {
-        setTabText(index, title);
-    }
-    if (currentIndex() == index)
-        emit setCurrentTitle(title);
-    BrowserApplication::historyManager().updateHistoryItem(webView.url(), title);
-}
-
-    void webViewUrlChanged(const QUrl &url)
-{
-    WebView *webView = qobject_cast<WebView*>(sender());
-    int index = webViewIndex(webView);
-    if (-1 != index) {
-        m_tabBar.setTabData(index, url);
-    }
-    emit tabsChanged();
-}
-
-    void lineEditReturnPressed()
-{
-    if (QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender())) {
-        emit loadPage(lineEdit.text());
-        if (m_lineEdits.currentWidget() == lineEdit)
-            currentWebView().setFocus();
-    }
-}
-
-    void windowCloseRequested()
-{
-    WebPage *webPage = qobject_cast<WebPage*>(sender());
-    WebView *webView = qobject_cast<WebView*>(webPage.view());
-    int index = webViewIndex(webView);
-    if (index >= 0) {
-        if (count() == 1)
-            webView.webPage().mainWindow().close();
-        else
-            closeTab(index);
-    }
-}
-
-    void moveTab(int fromIndex, int toIndex)
-{
-    QWidget *lineEdit = m_lineEdits.widget(fromIndex);
-    m_lineEdits.removeWidget(lineEdit);
-    m_lineEdits.insertWidget(toIndex, lineEdit);
-}
+	void previousTab()
+	{
+		int next = currentIndex() - 1;
+		if (next < 0)
+			next = count() - 1;
+		setCurrentIndex(next);
+	}
 
 private:
-    QAction *m_recentlyClosedTabsAction;
-    QAction *m_newTabAction;
-    QAction *m_closeTabAction;
-    QAction *m_nextTabAction;
-    QAction *m_previousTabAction;
 
-    QMenu *m_recentlyClosedTabsMenu;
-    static const int m_recentlyClosedTabsSize = 10;
-    QList<QUrl> m_recentlyClosedTabs;
-    QList<WebActionMapper*> m_actions;
+	void currentChanged(int index)
+	{
+		WebView webView = this.webView(index);
+		if (!webView)
+			return;
 
-    QCompleter *m_lineEditCompleter;
-    QStackedWidget *m_lineEdits;
-    TabBar *m_tabBar;
+		assert(m_lineEdits.count() == count());
+
+		WebView oldWebView = this.webView(m_lineEdits.currentIndex());
+		if (oldWebView) {
+			oldWebView.statusBarMessage.disconnect(&this.showStatusBarMessage);
+			oldWebView.page().linkHovered.disconnect(&this.linkHovered);
+			oldWebView.loadProgress().disconnect(&this.loadProgress);
+		}
+
+		webView.statusBarMessage.connect(&this.showStatusBarMessage);
+		webView.page().linkHovered.connect(&this.linkHovered);
+		webView.loadProgress.connect(&this.loadProgress);
+
+		for (int i = 0; i < m_actions.count(); ++i) {
+			WebActionMapper mapper = m_actions[i];
+			mapper.updateCurrent(webView.page());
+		}
+		emit setCurrentTitle(webView.title());
+		m_lineEdits.setCurrentIndex(index);
+		emit loadProgress(webView.progress());
+		emit showStatusBarMessage(webView.lastStatusBarText());
+		if (webView.url().isEmpty())
+			m_lineEdits.currentWidget().setFocus();
+		else
+			webView.setFocus();
+	}
+
+	void aboutToShowRecentTabsMenu()
+	{
+		m_recentlyClosedTabsMenu.clear();
+		for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) {
+			QAction action = new QAction(m_recentlyClosedTabsMenu);
+			action.setData(m_recentlyClosedTabs.at(i));
+			QIcon icon = BrowserApplication.instance().icon(m_recentlyClosedTabs.at(i));
+			action.setIcon(icon);
+			action.setText(m_recentlyClosedTabs.at(i).toString());
+			m_recentlyClosedTabsMenu.addAction(action);
+		}
+	}
+
+	void aboutToShowRecentTriggeredAction(QAction action)
+	{
+		QUrl url = action.data().toUrl();
+		loadUrlInCurrentTab(url);
+	}
+
+	void webViewLoadStarted()
+	{
+		WebView webView = qobject_cast<WebView>(sender());
+		int index = webViewIndex(webView);
+		if (-1 != index) {
+			QIcon icon(QLatin1String(":loading.gif"));
+			setTabIcon(index, icon);
+		}
+	}
+
+	void webViewIconChanged()
+	{
+		WebView webView = qobject_cast<WebView>(sender());
+		int index = webViewIndex(webView);
+		if (-1 != index) {
+			QIcon icon = BrowserApplication.instance().icon(webView.url());
+			setTabIcon(index, icon);
+		}
+	}
+
+	void webViewTitleChanged(QString title)
+	{
+		WebView webView = qobject_cast<WebView>(sender());
+		int index = webViewIndex(webView);
+		if (-1 != index) {
+			setTabText(index, title);
+		}
+		if (currentIndex() == index)
+			emit setCurrentTitle(title);
+		BrowserApplication.historyManager().updateHistoryItem(webView.url(), title);
+	}
+
+	void webViewUrlChanged(QUrl url)
+	{
+		WebView webView = qobject_cast<WebView>(sender());
+		int index = webViewIndex(webView);
+		if (-1 != index) {
+			m_tabBar.setTabData(index, url);
+		}
+		emit tabsChanged();
+	}
+
+	void lineEditReturnPressed()
+	{
+		if (QLineEdit lineEdit = qobject_cast<QLineEdit*>(sender())) {
+			emit loadPage(lineEdit.text());
+			if (m_lineEdits.currentWidget() == lineEdit)
+				currentWebView().setFocus();
+		}
+	}
+
+	void windowCloseRequested()
+	{
+		WebPage webPage = qobject_cast<WebPage>(sender());
+		WebView webView = qobject_cast<WebView>(webPage.view());
+		int index = webViewIndex(webView);
+		if (index >= 0) {
+			if (count() == 1)
+				webView.webPage().mainWindow().close();
+			else
+				closeTab(index);
+		}
+	}
+
+	void moveTab(int fromIndex, int toIndex)
+	{
+		QWidget lineEdit = m_lineEdits.widget(fromIndex);
+		m_lineEdits.removeWidget(lineEdit);
+		m_lineEdits.insertWidget(toIndex, lineEdit);
+	}
+
+private:
+
+	QAction m_recentlyClosedTabsAction;
+	QAction m_newTabAction;
+	QAction m_closeTabAction;
+	QAction m_nextTabAction;
+	QAction m_previousTabAction;
+
+	QMenu m_recentlyClosedTabsMenu;
+	static const int m_recentlyClosedTabsSize = 10;
+	QList<QUrl> m_recentlyClosedTabs;
+	QList<WebActionMapper> m_actions;
+
+	QCompleter m_lineEditCompleter;
+	QStackedWidget m_lineEdits;
+	TabBar m_tabBar;
 }
--- a/demos/browser/toolbarsearch.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/toolbarsearch.d	Fri May 22 10:59:00 2009 +0000
@@ -40,152 +40,143 @@
 ****************************************************************************/
 module toolbarsearch;
 
+
+import qt.core.QSettings;
+import qt.core.QUrl;
+
+import qt.gui.QCompleter;
+import qt.gui.QMenu;
+import qt.gui.QStringListModel;
+
+import QtWebKit.QWebSettings;
+
 import searchlineedit;
-
 import autosaver;
 
-import QtCore.QSettings;
-import QtCore.QUrl;
-
-import QtGui.QCompleter;
-import QtGui.QMenu;
-import QtGui.QStringListModel;
-
-import QtWebKit/QWebSettings;
-
-/*
-QT_BEGIN_NAMESPACE
-class QUrl;
-class QAction;
-class QStringListModel;
-QT_END_NAMESPACE
-
-class AutoSaver;
-*/
 
 class ToolbarSearch : public SearchLineEdit
 {
-    Q_OBJECT
+	mixin Signal!("search", QUrl url)
 
-signals:
-    void search(const QUrl &url);
+	public:
+
+	/*
+	ToolbarSearch is a very basic search widget that also contains a small history.
+	Searches are turned into urls that use Google to perform search
+	*/
+	this(QWidget parent = null)
+	{
+		super(parent)
+		m_autosaver = new AutoSaver(this);
+		m_maxSavedSearches = 10;
+		m_stringListModel = new QStringListModel(this);
+
+		QMenu m = menu();
+		m.aboutToShow().connect(&this.aboutToShowMenu);
+		m.triggered.connect(&this.triggeredMenuAction);
+
+		QCompleter completer = new QCompleter(m_stringListModel, this);
+		completer.setCompletionMode(QCompleter::InlineCompletion);
+		lineEdit().setCompleter(completer);
+
+		lineEdit().returnPressed.connect(&searchNow);
+		setInactiveText(tr("Google"));
+		load();
+	}
+	
+	~this()
+	{
+		m_autosaver.saveIfNeccessary();
+	}
 
 public:
-	
-/*
-    ToolbarSearch is a very basic search widget that also contains a small history.
-    Searches are turned into urls that use Google to perform search
- */
-this(QWidget *parent = null)
- 
-{
-	super(parent)
-     m_autosaver = new AutoSaver(this);
-     m_maxSavedSearches = 10;
-     m_stringListModel = new QStringListModel(this);
-	
-    QMenu *m = menu();
-    connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu()));
-    connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*)));
 
-    QCompleter *completer = new QCompleter(m_stringListModel, this);
-    completer.setCompletionMode(QCompleter::InlineCompletion);
-    lineEdit().setCompleter(completer);
+	void clear()
+	{
+		m_stringListModel.setStringList(QStringList());
+		m_autosaver.changeOccurred();
+	}
 
-    connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow()));
-    setInactiveText(tr("Google"));
-    load();
-}
-    ~this()
-{
-    m_autosaver.saveIfNeccessary();
-}
+	void searchNow()
+	{
+		QString searchText = lineEdit().text();
+		QStringList newList = m_stringListModel.stringList();
+		if (newList.contains(searchText))
+			newList.removeAt(newList.indexOf(searchText));
+		newList.prepend(searchText);
+		if (newList.size() >= m_maxSavedSearches)
+			newList.removeLast();
 
-public slots:
-    void clear()
-{
-    m_stringListModel.setStringList(QStringList());
-    m_autosaver.changeOccurred();;
-}
+		QWebSettings globalSettings = QWebSettings::globalSettings();
+		if (!globalSettings.testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
+			m_stringListModel.setStringList(newList);
+			m_autosaver.changeOccurred();
+		}
 
-    void searchNow()
-{
-    QString searchText = lineEdit().text();
-    QStringList newList = m_stringListModel.stringList();
-    if (newList.contains(searchText))
-        newList.removeAt(newList.indexOf(searchText));
-    newList.prepend(searchText);
-    if (newList.size() >= m_maxSavedSearches)
-        newList.removeLast();
-
-    QWebSettings *globalSettings = QWebSettings::globalSettings();
-    if (!globalSettings.testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
-        m_stringListModel.setStringList(newList);
-        m_autosaver.changeOccurred();
-    }
-
-    QUrl url(QLatin1String("http://www.google.com/search"));
-    url.addQueryItem(QLatin1String("q"), searchText);
-    url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8"));
-    url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8"));
-    url.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser"));
-    emit search(url);
-}
-
-private slots:
-    void save()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("toolbarsearch"));
-    settings.setValue(QLatin1String("recentSearches"), m_stringListModel.stringList());
-    settings.setValue(QLatin1String("maximumSaved"), m_maxSavedSearches);
-    settings.endGroup();
-}
-
-
-    void aboutToShowMenu()
-{
-    lineEdit().selectAll();
-    QMenu *m = menu();
-    m.clear();
-    QStringList list = m_stringListModel.stringList();
-    if (list.isEmpty()) {
-        m.addAction(tr("No Recent Searches"));
-        return;
-    }
-
-    QAction *recent = m.addAction(tr("Recent Searches"));
-    recent.setEnabled(false);
-    for (int i = 0; i < list.count(); ++i) {
-        QString text = list.at(i);
-        m.addAction(text).setData(text);
-    }
-    m.addSeparator();
-    m.addAction(tr("Clear Recent Searches"), this, SLOT(clear()));
-}
-
-    void triggeredMenuAction(QAction *action)
-{
-    QVariant v = action.data();
-    if (v.canConvert<QString>()) {
-        QString text = v.toString();
-        lineEdit().setText(text);
-        searchNow();
-    }
-}
+		QUrl url(QLatin1String("http://www.google.com/search"));
+		url.addQueryItem(QLatin1String("q"), searchText);
+		url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8"));
+		url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8"));
+		url.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser"));
+		emit search(url);
+	}
 
 private:
-    void load()
-{
-    QSettings settings;
-    settings.beginGroup(QLatin1String("toolbarsearch"));
-    QStringList list = settings.value(QLatin1String("recentSearches")).toStringList();
-    m_maxSavedSearches = settings.value(QLatin1String("maximumSaved"), m_maxSavedSearches).toInt();
-    m_stringListModel.setStringList(list);
-    settings.endGroup();
+
+	void save()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("toolbarsearch"));
+		settings.setValue(QLatin1String("recentSearches"), m_stringListModel.stringList());
+		settings.setValue(QLatin1String("maximumSaved"), m_maxSavedSearches);
+		settings.endGroup();
+	}
+
+
+	void aboutToShowMenu()
+	{
+		lineEdit().selectAll();
+		QMenu m = menu();
+		m.clear();
+		QStringList list = m_stringListModel.stringList();
+		if (list.isEmpty()) {
+			m.addAction(tr("No Recent Searches"));
+			return;
+		}
+
+		QAction recent = m.addAction(tr("Recent Searches"));
+		recent.setEnabled(false);
+		for (int i = 0; i < list.count(); ++i) {
+			QString text = list.at(i);
+			m.addAction(text).setData(text);
+		}
+		m.addSeparator();
+		m.addAction(tr("Clear Recent Searches"), this, SLOT(clear()));
+	}
+
+	void triggeredMenuAction(QAction action)
+	{
+		QVariant v = action.data();
+		if (v.canConvert<QString>()) {
+			QString text = v.toString();
+			lineEdit().setText(text);
+			searchNow();
+		}
+	}
+
+private:
+
+	void load()
+	{
+		QSettings settings;
+		settings.beginGroup(QLatin1String("toolbarsearch"));
+		QStringList list = settings.value(QLatin1String("recentSearches")).toStringList();
+		m_maxSavedSearches = settings.value(QLatin1String("maximumSaved"), m_maxSavedSearches).toInt();
+		m_stringListModel.setStringList(list);
+		settings.endGroup();
+	}
+
+	AutoSaver m_autosaver;
+	int m_maxSavedSearches;
+	QStringListModel m_stringListModel;
 }
-
-    AutoSaver *m_autosaver;
-    int m_maxSavedSearches;
-    QStringListModel *m_stringListModel;
-}
--- a/demos/browser/urllineedit.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/urllineedit.d	Fri May 22 10:59:00 2009 +0000
@@ -41,338 +41,328 @@
 
 module urllineedit;
 
-import QtCore.QUrl;
-import QtGui.QWidget;
-import QtGui.QStyleOptionFrame;
+import qt.core.QUrl;
+import qt.core.QEvent;
+import qt.core.QDebug;
+
+import qt.gui.QWidget;
+import qt.gui.QStyleOptionFrame;
+import qt.gui.QApplication;
+import qt.gui.QCompleter;
+import qt.gui.QFocusEvent;
+import qt.gui.QHBoxLayout;
+import qt.gui.QLabel;
+import qt.gui.QLineEdit;
+import qt.gui.QPainter;
+import qt.gui.QStyle;
+import qt.gui.QStyleOptionFrameV2;
 
 import browserapplication;
 import searchlineedit;
 import webview;
 
-import QtCore.QEvent;
 
-import QtGui.QApplication;
-import QtGui.QCompleter;
-import QtGui.QFocusEvent;
-import QtGui.QHBoxLayout;
-import QtGui.QLabel;
-import QtGui.QLineEdit;
-import QtGui.QPainter;
-import QtGui.QStyle;
-import QtGui.QStyleOptionFrameV2;
-
-import QtCore.QDebug;
-
-
-/*
-QT_BEGIN_NAMESPACE
-class QLineEdit;
-QT_END_NAMESPACE
-
-class ClearButton;
-*/
 class ExLineEdit : public QWidget
 {
-    Q_OBJECT
+public:
 
-public:
-    this(QWidget *parent = null)
-{
-	super(parent);
+	this(QWidget parent = null)
+	{
+		super(parent);
+
+		m_leftWidget = 0;
+		m_lineEdit = new QLineEdit(this);
+		m_clearButton = 0;
+
+		setFocusPolicy(m_lineEdit.focusPolicy());
+		setAttribute(Qt.WA_InputMethodEnabled);
+		setSizePolicy(m_lineEdit.sizePolicy());
+		setBackgroundRole(m_lineEdit.backgroundRole());
+		setMouseTracking(true);
+		setAcceptDrops(true);
+		setAttribute(Qt.WA_MacShowFocusRect, true);
+		QPalette p = m_lineEdit.palette();
+		setPalette(p);
+
+		// line edit
+		m_lineEdit.setFrame(false);
+		m_lineEdit.setFocusProxy(this);
+		m_lineEdit.setAttribute(Qt.WA_MacShowFocusRect, false);
+		QPalette clearPalette = m_lineEdit.palette();
+		clearPalette.setBrush(QPalette.Base, QBrush(Qt.transparent));
+		m_lineEdit.setPalette(clearPalette);
+
+		// clearButton
+		m_clearButton = new ClearButton(this);
+		m_clearButton.clicked.connect(&m_lineEdit.clear);
+		m_lineEdit.textChanged.connect(&m_clearButton.textChanged);
+	}
+
+	QLineEdit lineEdit() { return m_lineEdit; }
+
+	void setLeftWidget(QWidget widget)
+	{
+		m_leftWidget = widget;
+	}
+
+	QWidget leftWidget()
+	{
+		return m_leftWidget;
+	}
+
+	QSize sizeHint()
+	{
+		m_lineEdit.setFrame(true);
+		QSize size = m_lineEdit.sizeHint();
+		m_lineEdit.setFrame(false);
+		return size;
+	}
+
+	QVariant inputMethodQuery(Qt.InputMethodQuery property)
+	{
+		return m_lineEdit.inputMethodQuery(property);
+	}
+
+protected:
+
+	void focusInEvent(QFocusEvent event)
+	{
+		m_lineEdit.event(event);
+		QWidget.focusInEvent(event);
+	}
+
+	void focusOutEvent(QFocusEvent event)
+	{
+		m_lineEdit.event(event);
+
+		if (m_lineEdit.completer()) {
+			m_lineEdit.completer().activated.connect(& m_lineEdit.setText);
+			m_lineEdit.completer().highlighted.connect(&m_lineEdit._q_completionHighlighted);
+		}
+		QWidget.focusOutEvent(event);
+	}
+
+	void keyPressEvent(QKeyEvent event)
+	{
+		m_lineEdit.event(event);
+	}
+
+	void paintEvent(QPaintEvent event)
+	{
+		QPainter p(this);
+		QStyleOptionFrameV2 panel;
+		initStyleOption(&panel);
+		style().drawPrimitive(QStyle.PE_PanelLineEdit, &panel, &p, this);
+	}
+
+	void resizeEvent(QResizeEvent event)
+	{
+		assert(m_leftWidget);
+		updateGeometries();
+		QWidget.resizeEvent(event);
+	}
+
+	void inputMethodEvent(QInputMethodEvent e)
+	{
+		m_lineEdit.event(e);
+	}
+
+	bool event(QEvent event)
+	{
+		if (event.type() == QEvent.ShortcutOverride)
+			return m_lineEdit.event(event);
+		return QWidget.event(event);
+	}
+
+protected:
+
+	void updateGeometries()
+	{
+		QStyleOptionFrameV2 panel;
+		initStyleOption(&panel);
+		QRect rect = style().subElementRect(QStyle.SE_LineEditContents, &panel, this);
+
+		int height = rect.height();
+		int width = rect.width();
+
+		int m_leftWidgetHeight = m_leftWidget.height();
+		m_leftWidget.setGeometry(rect.x() + 2,          rect.y() + (height - m_leftWidgetHeight)/2,
+		m_leftWidget.width(), m_leftWidget.height());
+
+		int clearButtonWidth = this.height();
+		m_lineEdit.setGeometry(m_leftWidget.x() + m_leftWidget.width(),        0,
+		width - clearButtonWidth - m_leftWidget.width(), this.height());
+
+		m_clearButton.setGeometry(this.width() - clearButtonWidth, 0,
+		clearButtonWidth, this.height());
+	}
+
+	void initStyleOption(QStyleOptionFrameV2 option)
+	{
+		option.initFrom(this);
+		option.rect = contentsRect();
+		option.lineWidth = style().pixelMetric(QStyle.PM_DefaultFrameWidth, option, this);
+		option.midLineWidth = 0;
+		option.state |= QStyle.State_Sunken;
+		if (m_lineEdit.isReadOnly())
+			option.state |= QStyle.State_ReadOnly;
+		version(QT_KEYPAD_NAVIGATION)
+		{
+			if (hasEditFocus())
+				option.state |= QStyle.State_HasEditFocus;
+		}
+		else
+		{
+			option.features = QStyleOptionFrameV2.None;
+		}
+	}
 	
-	m_leftWidget = 0;
-     m_lineEdit = new QLineEdit(this);
-     m_clearButton = 0;
-	
-    setFocusPolicy(m_lineEdit.focusPolicy());
-    setAttribute(Qt.WA_InputMethodEnabled);
-    setSizePolicy(m_lineEdit.sizePolicy());
-    setBackgroundRole(m_lineEdit.backgroundRole());
-    setMouseTracking(true);
-    setAcceptDrops(true);
-    setAttribute(Qt.WA_MacShowFocusRect, true);
-    QPalette p = m_lineEdit.palette();
-    setPalette(p);
-
-    // line edit
-    m_lineEdit.setFrame(false);
-    m_lineEdit.setFocusProxy(this);
-    m_lineEdit.setAttribute(Qt.WA_MacShowFocusRect, false);
-    QPalette clearPalette = m_lineEdit.palette();
-    clearPalette.setBrush(QPalette::Base, QBrush(Qt.transparent));
-    m_lineEdit.setPalette(clearPalette);
-
-    // clearButton
-    m_clearButton = new ClearButton(this);
-    connect(m_clearButton, SIGNAL(clicked()),
-            m_lineEdit, SLOT(clear()));
-    connect(m_lineEdit, SIGNAL(textChanged(const QString&)),
-            m_clearButton, SLOT(textChanged(const QString&)));
+	QWidget m_leftWidget;
+	QLineEdit m_lineEdit;
+	ClearButton m_clearButton;
 }
 
-    inline QLineEdit *lineEdit() { return m_lineEdit; }
-
-    void setLeftWidget(QWidget *widget)
-{
-    m_leftWidget = widget;
-}
-
-    QWidget *leftWidget()
-{
-    return m_leftWidget;
-}
-
-    QSize sizeHint()
-{
-    m_lineEdit.setFrame(true);
-    QSize size = m_lineEdit.sizeHint();
-    m_lineEdit.setFrame(false);
-    return size;
-}
-
-    QVariant inputMethodQuery(Qt.InputMethodQuery property)
-{
-    return m_lineEdit.inputMethodQuery(property);
-}
-
-protected:
-    void focusInEvent(QFocusEvent *event)
-{
-    m_lineEdit.event(event);
-    QWidget::focusInEvent(event);
-}
-
-    void focusOutEvent(QFocusEvent *event)
-{
-    m_lineEdit.event(event);
-
-    if (m_lineEdit.completer()) {
-        connect(m_lineEdit.completer(), SIGNAL(activated(QString)),
-                         m_lineEdit, SLOT(setText(QString)));
-        connect(m_lineEdit.completer(), SIGNAL(highlighted(QString)),
-                         m_lineEdit, SLOT(_q_completionHighlighted(QString)));
-    }
-    QWidget::focusOutEvent(event);
-}
-
-    void keyPressEvent(QKeyEvent *event)
-{
-    m_lineEdit.event(event);
-}
-
-    void paintEvent(QPaintEvent *event)
-{
-    QPainter p(this);
-    QStyleOptionFrameV2 panel;
-    initStyleOption(&panel);
-    style().drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this);
-}
-
-    void resizeEvent(QResizeEvent *event)
-{
-    Q_ASSERT(m_leftWidget);
-    updateGeometries();
-    QWidget::resizeEvent(event);
-}
-
-    void inputMethodEvent(QInputMethodEvent *e)
-{
-    m_lineEdit.event(e);
-}
-
-    bool event(QEvent *event)
-{
-    if (event.type() == QEvent::ShortcutOverride)
-        return m_lineEdit.event(event);
-    return QWidget::event(event);
-}
-
-protected:
-    void updateGeometries()
-{
-    QStyleOptionFrameV2 panel;
-    initStyleOption(&panel);
-    QRect rect = style().subElementRect(QStyle::SE_LineEditContents, &panel, this);
-
-    int height = rect.height();
-    int width = rect.width();
-
-    int m_leftWidgetHeight = m_leftWidget.height();
-    m_leftWidget.setGeometry(rect.x() + 2,          rect.y() + (height - m_leftWidgetHeight)/2,
-                              m_leftWidget.width(), m_leftWidget.height());
-
-    int clearButtonWidth = this.height();
-    m_lineEdit.setGeometry(m_leftWidget.x() + m_leftWidget.width(),        0,
-                            width - clearButtonWidth - m_leftWidget.width(), this.height());
-
-    m_clearButton.setGeometry(this.width() - clearButtonWidth, 0,
-                               clearButtonWidth, this.height());
-}
-
-    void initStyleOption(QStyleOptionFrameV2 *option)
-{
-    option.initFrom(this);
-    option.rect = contentsRect();
-    option.lineWidth = style().pixelMetric(QStyle::PM_DefaultFrameWidth, option, this);
-    option.midLineWidth = 0;
-    option.state |= QStyle::State_Sunken;
-    if (m_lineEdit.isReadOnly())
-        option.state |= QStyle::State_ReadOnly;
-version(QT_KEYPAD_NAVIGATION)
-    if (hasEditFocus())
-        option.state |= QStyle::State_HasEditFocus;
-}
-    option.features = QStyleOptionFrameV2::None;
-}
-
-    QWidget *m_leftWidget;
-    QLineEdit *m_lineEdit;
-    ClearButton *m_clearButton;
-};
 
 class UrlIconLabel : public QLabel
 {
+public:
 
-public:
-    this(QWidget *parent)
-{
-	super(parent);
-	m_webView = 0;
-    setMinimumWidth(16);
-    setMinimumHeight(16);
+	this(QWidget parent)
+	{
+		super(parent);
+		m_webView = 0;
+		setMinimumWidth(16);
+		setMinimumHeight(16);
+	}
+
+	WebView m_webView;
+
+protected:
+
+	void mousePressEvent(QMouseEvent event)
+	{
+		if (event.button() == Qt.LeftButton)
+			m_dragStartPos = event.pos();
+		QLabel.mousePressEvent(event);
+	}
+
+	void mouseMoveEvent(QMouseEvent event)
+	{
+		if (event.buttons() == Qt.LeftButton
+				&& (event.pos() - m_dragStartPos).manhattanLength() > QApplication.startDragDistance()
+				&& m_webView) {
+			QDrag drag = new QDrag(this);
+			QMimeData mimeData = new QMimeData;
+			mimeData.setText(QString.fromUtf8(m_webView.url().toEncoded()));
+			QList<QUrl> urls;
+			urls.append(m_webView.url());
+			mimeData.setUrls(urls);
+			drag.setMimeData(mimeData);
+			drag.exec();
+		}
+	}
+
+private:
+
+	QPoint m_dragStartPos;
 }
 
 
-    WebView *m_webView;
+class UrlLineEdit : public ExLineEdit
+{
+public:
+
+	this(QWidget parent = null)
+	{
+		super(parent);
+		m_webView = 0;
+		m_iconLabel = 0;
+		// icon
+		m_iconLabel = new UrlIconLabel(this);
+		m_iconLabel.resize(16, 16);
+		setLeftWidget(m_iconLabel);
+		m_defaultBaseColor = palette().color(QPalette.Base);
+
+		webViewIconChanged();
+	}
+	
+	void setWebView(WebView webView)
+	{
+		assert(!m_webView);
+		m_webView = webView;
+		m_iconLabel.m_webView = webView;
+		webView.urlChanged.connect(&this.webViewUrlChanged);
+		webView.loadFinished.connect(&this.webViewIconChanged);
+		webView.iconChanged.connect(&this.webViewIconChanged);
+		webView.loadProgress.connect(&this.update);
+	}
 
 protected:
-    void mousePressEvent(QMouseEvent *event)
-{
-    if (event.button() == Qt.LeftButton)
-        m_dragStartPos = event.pos();
-    QLabel::mousePressEvent(event);
-}
 
-    void mouseMoveEvent(QMouseEvent *event)
-{
-    if (event.buttons() == Qt.LeftButton
-        && (event.pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()
-         && m_webView) {
-        QDrag *drag = new QDrag(this);
-        QMimeData *mimeData = new QMimeData;
-        mimeData.setText(QString::fromUtf8(m_webView.url().toEncoded()));
-        QList<QUrl> urls;
-        urls.append(m_webView.url());
-        mimeData.setUrls(urls);
-        drag.setMimeData(mimeData);
-        drag.exec();
-    }
-}
+	void paintEvent(QPaintEvent event)
+	{
+		QPalette p = palette();
+		if (m_webView && m_webView.url().scheme() == QLatin1String("https")) {
+			QColor lightYellow(248, 248, 210);
+			p.setBrush(QPalette.Base, generateGradient(lightYellow));
+		} else {
+			p.setBrush(QPalette.Base, m_defaultBaseColor);
+		}
+		setPalette(p);
+		ExLineEdit.paintEvent(event);
+
+		QPainter painter(this);
+		QStyleOptionFrameV2 panel;
+		initStyleOption(&panel);
+		QRect backgroundRect = style().subElementRect(QStyle.SE_LineEditContents, &panel, this);
+		if (m_webView && !hasFocus()) {
+			int progress = m_webView.progress();
+			QColor loadingColor = QColor(116, 192, 250);
+			painter.setBrush(generateGradient(loadingColor));
+			painter.setPen(Qt.transparent);
+			int mid = backgroundRect.width() / 100 * progress;
+			QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
+			painter.drawRect(progressRect);
+		}
+	}
+
+	void focusOutEvent(QFocusEvent event);
+	{
+		if (m_lineEdit.text().isEmpty() && m_webView)
+			m_lineEdit.setText(QString.fromUtf8(m_webView.url().toEncoded()));
+		ExLineEdit.focusOutEvent(event);
+	}
 
 private:
-    QPoint m_dragStartPos;
+	
+	void webViewUrlChanged(QUrl url)
+	{
+		m_lineEdit.setText(QString.fromUtf8(url.toEncoded()));
+		m_lineEdit.setCursorPosition(0);
+	}
 
-}
-
-
-//class UrlIconLabel;
-//class WebView;
-class UrlLineEdit : public ExLineEdit
-{
-    Q_OBJECT
-
-public:
-    this(QWidget *parent = null)
-{
-	super(parent);
-	m_webView = 0;
-	m_iconLabel = 0;
-    // icon
-    m_iconLabel = new UrlIconLabel(this);
-    m_iconLabel.resize(16, 16);
-    setLeftWidget(m_iconLabel);
-    m_defaultBaseColor = palette().color(QPalette::Base);
-
-    webViewIconChanged();
-}
-    void setWebView(WebView *webView)
-{
-    Q_ASSERT(!m_webView);
-    m_webView = webView;
-    m_iconLabel.m_webView = webView;
-    connect(webView, SIGNAL(urlChanged(const QUrl &)),
-        this, SLOT(webViewUrlChanged(const QUrl &)));
-    connect(webView, SIGNAL(loadFinished(bool)),
-        this, SLOT(webViewIconChanged()));
-    connect(webView, SIGNAL(iconChanged()),
-        this, SLOT(webViewIconChanged()));
-    connect(webView, SIGNAL(loadProgress(int)),
-        this, SLOT(update()));
-}
-
-protected:
-    void paintEvent(QPaintEvent *event)
-{
-    QPalette p = palette();
-    if (m_webView && m_webView.url().scheme() == QLatin1String("https")) {
-        QColor lightYellow(248, 248, 210);
-        p.setBrush(QPalette::Base, generateGradient(lightYellow));
-    } else {
-        p.setBrush(QPalette::Base, m_defaultBaseColor);
-    }
-    setPalette(p);
-    ExLineEdit::paintEvent(event);
-
-    QPainter painter(this);
-    QStyleOptionFrameV2 panel;
-    initStyleOption(&panel);
-    QRect backgroundRect = style().subElementRect(QStyle::SE_LineEditContents, &panel, this);
-    if (m_webView && !hasFocus()) {
-        int progress = m_webView.progress();
-        QColor loadingColor = QColor(116, 192, 250);
-        painter.setBrush(generateGradient(loadingColor));
-        painter.setPen(Qt.transparent);
-        int mid = backgroundRect.width() / 100 * progress;
-        QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
-        painter.drawRect(progressRect);
-    }
-}
-
-    void focusOutEvent(QFocusEvent *event);
-{
-    if (m_lineEdit.text().isEmpty() && m_webView)
-        m_lineEdit.setText(QString::fromUtf8(m_webView.url().toEncoded()));
-    ExLineEdit::focusOutEvent(event);
-}
-
-private slots:
-    void webViewUrlChanged(const QUrl &url)
-{
-    m_lineEdit.setText(QString::fromUtf8(url.toEncoded()));
-    m_lineEdit.setCursorPosition(0);
-}
-
-    void webViewIconChanged()
-{
-    QUrl url = (m_webView)  ? m_webView.url() : QUrl();
-    QIcon icon = BrowserApplication::instance().icon(url);
-    QPixmap pixmap(icon.pixmap(16, 16));
-    m_iconLabel.setPixmap(pixmap);
-}
+	void webViewIconChanged()
+	{
+		QUrl url = (m_webView)  ? m_webView.url() : QUrl();
+		QIcon icon = BrowserApplication.instance().icon(url);
+		QPixmap pixmap(icon.pixmap(16, 16));
+		m_iconLabel.setPixmap(pixmap);
+	}
 
 private:
-    QLinearGradient generateGradient(const QColor &color)
-{
-    QLinearGradient gradient(0, 0, 0, height());
-    gradient.setColorAt(0, m_defaultBaseColor);
-    gradient.setColorAt(0.15, color.lighter(120));
-    gradient.setColorAt(0.5, color);
-    gradient.setColorAt(0.85, color.lighter(120));
-    gradient.setColorAt(1, m_defaultBaseColor);
-    return gradient;
+
+	QLinearGradient generateGradient(QColor color)
+	{
+		QLinearGradient gradient(0, 0, 0, height());
+		gradient.setColorAt(0, m_defaultBaseColor);
+		gradient.setColorAt(0.15, color.lighter(120));
+		gradient.setColorAt(0.5, color);
+		gradient.setColorAt(0.85, color.lighter(120));
+		gradient.setColorAt(1, m_defaultBaseColor);
+		return gradient;
+	}
+
+	WebView m_webView;
+	UrlIconLabel m_iconLabel;
+	QColor m_defaultBaseColor;
 }
-
-    WebView *m_webView;
-    UrlIconLabel *m_iconLabel;
-    QColor m_defaultBaseColor;
-}
--- a/demos/browser/webview.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/webview.d	Fri May 22 10:59:00 2009 +0000
@@ -38,8 +38,19 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+module webview;
+
+import qt.gui.QClipboard;
+import qt.gui.QMenu;
+import qt.gui.QMessageBox;
+import qt.gui.QMouseEvent;
+
+import qt.core.QDebug;
+import qt.core.QBuffer;
 
 import QtWebKit.QWebView;
+import QtWebKit.QWebHitTestResult;
+import QtUiTools.QUiLoader;
 
 import browserapplication;
 import browsermainwindow;
@@ -47,308 +58,278 @@
 import downloadmanager;
 import networkaccessmanager;
 import tabwidget;
-import webview;
 
-import QtGui.QClipboard;
-import QtGui.QMenu;
-import QtGui.QMessageBox;
-import QtGui.QMouseEvent;
 
-import QtWebKit.QWebHitTestResult;
-
-import QtUiTools.QUiLoader;
-
-import QtCore.QDebug;
-import QtCore.QBuffer;
-
-/*
-QT_BEGIN_NAMESPACE
-class QAuthenticator;
-class QMouseEvent;
-class QNetworkProxy;
-class QNetworkReply;
-class QSslError;
-QT_END_NAMESPACE
-
-class BrowserMainWindow;
-*/
-
-class WebPage : public QWebPage {
-    Q_OBJECT
-
-signals:
-    void loadingUrl(const QUrl &url);
+class WebPage : public QWebPage
+{
+	mixin Signal!("loadingUrl", QUrl url);
 
 public:
-    this(QObject *parent = null)
-{
-	super(parent);
-	m_keyboardModifiers = Qt.NoModifier;
-     m_pressedButtons = Qt.NoButton;
-     m_openInNewTab = false;
-    setNetworkAccessManager(BrowserApplication::networkAccessManager());
-    connect(this, SIGNAL(unsupportedContent(QNetworkReply *)),
-            this, SLOT(handleUnsupportedContent(QNetworkReply *)));
-}
-    BrowserMainWindow *mainWindow()
-{
-    QObject *w = this.parent();
-    while (w) {
-        if (BrowserMainWindow *mw = qobject_cast<BrowserMainWindow*>(w))
-            return mw;
-        w = w.parent();
-    }
-    return BrowserApplication::instance().mainWindow();
-}
+
+	this(QObject parent = null)
+	{
+		super(parent);
+		m_keyboardModifiers = Qt.NoModifier;
+		m_pressedButtons = Qt.NoButton;
+		m_openInNewTab = false;
+		setNetworkAccessManager(BrowserApplication.networkAccessManager());
+		this.unsupportedContent.connect(&this.handleUnsupportedContent);
+	}
+	
+	BrowserMainWindow mainWindow()
+	{
+		QObject w = this.parent();
+		while (w) {
+			if (BrowserMainWindow mw = qobject_cast<BrowserMainWindow>(w))
+				return mw;
+			w = w.parent();
+		}
+		return BrowserApplication.instance().mainWindow();
+	}
 
 protected:
-    bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type);
-{
-    // ctrl open in new tab
-    // ctrl-shift open in new tab and select
-    // ctrl-alt open in new window
-    if (type == QWebPage::NavigationTypeLinkClicked
-        && (m_keyboardModifiers & Qt.ControlModifier
-            || m_pressedButtons == Qt.MidButton)) {
-        bool newWindow = (m_keyboardModifiers & Qt.AltModifier);
-        WebView *webView;
-        if (newWindow) {
-            BrowserApplication::instance().newMainWindow();
-            BrowserMainWindow *newMainWindow = BrowserApplication::instance().mainWindow();
-            webView = newMainWindow.currentTab();
-            newMainWindow.raise();
-            newMainWindow.activateWindow();
-            webView.setFocus();
-        } else {
-            bool selectNewTab = (m_keyboardModifiers & Qt.ShiftModifier);
-            webView = mainWindow().tabWidget().newTab(selectNewTab);
-        }
-        webView.load(request);
-        m_keyboardModifiers = Qt.NoModifier;
-        m_pressedButtons = Qt.NoButton;
-        return false;
-    }
-    if (frame == mainFrame()) {
-        m_loadingUrl = request.url();
-        emit loadingUrl(m_loadingUrl);
-    }
-    return QWebPage::acceptNavigationRequest(frame, request, type);
-}
 
-QWebPage *createWindow(QWebPage::WebWindowType type)
-{
-    Q_UNUSED(type);
-    if (m_keyboardModifiers & Qt.ControlModifier || m_pressedButtons == Qt.MidButton)
-        m_openInNewTab = true;
-    if (m_openInNewTab) {
-        m_openInNewTab = false;
-        return mainWindow().tabWidget().newTab().page();
-    }
-    BrowserApplication::instance().newMainWindow();
-    BrowserMainWindow *mainWindow = BrowserApplication::instance().mainWindow();
-    return mainWindow.currentTab().page();
-}
+	bool acceptNavigationRequest(QWebFrame frame, QNetworkRequest request, NavigationType type);
+	{
+		// ctrl open in new tab
+		// ctrl-shift open in new tab and select
+		// ctrl-alt open in new window
+		if (type == QWebPage.NavigationTypeLinkClicked
+			&& (m_keyboardModifiers & Qt.ControlModifier
+			|| m_pressedButtons == Qt.MidButton)) {
+			bool newWindow = (m_keyboardModifiers & Qt.AltModifier);
+			WebView webView;
+			if (newWindow) {
+				BrowserApplication.instance().newMainWindow();
+				BrowserMainWindow newMainWindow = BrowserApplication.instance().mainWindow();
+				webView = newMainWindow.currentTab();
+				newMainWindow.raise();
+				newMainWindow.activateWindow();
+				webView.setFocus();
+			} else {
+				bool selectNewTab = (m_keyboardModifiers & Qt.ShiftModifier);
+				webView = mainWindow().tabWidget().newTab(selectNewTab);
+			}
+			webView.load(request);
+			m_keyboardModifiers = Qt.NoModifier;
+			m_pressedButtons = Qt.NoButton;
+			return false;
+		}
+		if (frame == mainFrame()) {
+			m_loadingUrl = request.url();
+			emit loadingUrl(m_loadingUrl);
+		}
+		return QWebPage.acceptNavigationRequest(frame, request, type);
+	}
 
-version(QT_NO_UITOOLS) {} else
-{
-	QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
+	QWebPage createWindow(QWebPage.WebWindowType type)
 	{
-	    Q_UNUSED(url);
-	    Q_UNUSED(paramNames);
-	    Q_UNUSED(paramValues);
-	    QUiLoader loader;
-	    return loader.createWidget(classId, view());
+		//Q_UNUSED(type);
+		if (m_keyboardModifiers & Qt.ControlModifier || m_pressedButtons == Qt.MidButton)
+			m_openInNewTab = true;
+		if (m_openInNewTab) {
+			m_openInNewTab = false;
+			return mainWindow().tabWidget().newTab().page();
+		}
+		BrowserApplication.instance().newMainWindow();
+		BrowserMainWindow mainWindow = BrowserApplication.instance().mainWindow();
+		return mainWindow.currentTab().page();
 	}
-}
 
-
-
-private slots:
-    void handleUnsupportedContent(QNetworkReply *reply)
-{
-    if (reply.error() == QNetworkReply::NoError) {
-        BrowserApplication::downloadManager().handleUnsupportedContent(reply);
-        return;
-    }
-
-    QFile file(QLatin1String(":/notfound.html"));
-    bool isOpened = file.open(QIODevice::ReadOnly);
-    Q_ASSERT(isOpened);
-    QString title = tr("Error loading page: %1").arg(reply.url().toString());
-    QString html = QString(QLatin1String(file.readAll()))
-                        .arg(title)
-                        .arg(reply.errorString())
-                        .arg(reply.url().toString());
-
-    QBuffer imageBuffer;
-    imageBuffer.open(QBuffer::ReadWrite);
-    QIcon icon = view().style().standardIcon(QStyle::SP_MessageBoxWarning, 0, view());
-    QPixmap pixmap = icon.pixmap(QSize(32,32));
-    if (pixmap.save(&imageBuffer, "PNG")) {
-        html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
-                     QString(QLatin1String(imageBuffer.buffer().toBase64())));
-    }
-
-    QList<QWebFrame*> frames;
-    frames.append(mainFrame());
-    while (!frames.isEmpty()) {
-        QWebFrame *frame = frames.takeFirst();
-        if (frame.url() == reply.url()) {
-            frame.setHtml(html, reply.url());
-            return;
-        }
-        QList<QWebFrame *> children = frame.childFrames();
-        foreach(QWebFrame *frame, children)
-            frames.append(frame);
-    }
-    if (m_loadingUrl == reply.url()) {
-        mainFrame().setHtml(html, reply.url());
-    }
-}
+	version(QT_NO_UITOOLS) {} else
+	{
+		QObject createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
+		{
+			//Q_UNUSED(url);
+			//Q_UNUSED(paramNames);
+			//Q_UNUSED(paramValues);
+			QUiLoader loader;
+			return loader.createWidget(classId, view());
+		}
+	}
 
 private:
-    friend class WebView;
 
-    // set the webview mousepressedevent
-    Qt.KeyboardModifiers m_keyboardModifiers;
-    Qt.MouseButtons m_pressedButtons;
-    bool m_openInNewTab;
-    QUrl m_loadingUrl;
+	void handleUnsupportedContent(QNetworkReply reply)
+	{
+		if (reply.error() == QNetworkReply.NoError) {
+			BrowserApplication.downloadManager().handleUnsupportedContent(reply);
+			return;
+		}
+
+		QFile file(QLatin1String(":/notfound.html"));
+		bool isOpened = file.open(QIODevice.ReadOnly);
+		Q_ASSERT(isOpened);
+		QString title = tr("Error loading page: %1").arg(reply.url().toString());
+		QString html = QString(QLatin1String(file.readAll()))
+			.arg(title)
+			.arg(reply.errorString())
+			.arg(reply.url().toString());
+
+		QBuffer imageBuffer;
+		imageBuffer.open(QBuffer.ReadWrite);
+		QIcon icon = view().style().standardIcon(QStyle.SP_MessageBoxWarning, 0, view());
+		QPixmap pixmap = icon.pixmap(QSize(32,32));
+		if (pixmap.save(&imageBuffer, "PNG")) {
+			html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
+			QString(QLatin1String(imageBuffer.buffer().toBase64())));
+		}
+
+		QList<QWebFrame*> frames;
+		frames.append(mainFrame());
+		while (!frames.isEmpty()) {
+			QWebFrame frame = frames.takeFirst();
+			if (frame.url() == reply.url()) {
+				frame.setHtml(html, reply.url());
+				return;
+			}
+			QList<QWebFrame > children = frame.childFrames();
+			foreach(QWebFrame frame, children)
+				frames.append(frame);
+		}
+		if (m_loadingUrl == reply.url()) {
+			mainFrame().setHtml(html, reply.url());
+		}
+	}
+
+private:
+
+	// set the webview mousepressedevent
+	Qt.KeyboardModifiers m_keyboardModifiers;
+	Qt.MouseButtons m_pressedButtons;
+	bool m_openInNewTab;
+	QUrl m_loadingUrl;
 };
 
-class WebView : public QWebView {
-    Q_OBJECT
+class WebView : public QWebView
+{
+public:
+	
+	WebView(QWidget parent = null)
+	{
+		super(parent);
+		m_progress = 0;
+		m_page = new WebPage(this);
+		setPage(m_page);
+		page().statusBarMessage.connect(&setStatusBarText);
+		this.loadProgress.connect(&this.setProgress);
+		this.loadFinished.connect(&this.loadFinished);
+		page().loadingUrl.connect(&this.urlChanged);
+		page().downloadRequested.connect(&this.downloadRequested);
+		page().setForwardUnsupportedContent(true);
+	}
 
-public:
-    WebView(QWidget *parent = null)
-    : QWebView(parent)
-    , m_progress(0)
-    , m_page(new WebPage(this))
-{
-    setPage(m_page);
-    connect(page(), SIGNAL(statusBarMessage(const QString&)),
-            SLOT(setStatusBarText(const QString&)));
-    connect(this, SIGNAL(loadProgress(int)),
-            this, SLOT(setProgress(int)));
-    connect(this, SIGNAL(loadFinished(bool)),
-            this, SLOT(loadFinished()));
-    connect(page(), SIGNAL(loadingUrl(const QUrl&)),
-            this, SIGNAL(urlChanged(const QUrl &)));
-    connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)),
-            this, SLOT(downloadRequested(const QNetworkRequest &)));
-    page().setForwardUnsupportedContent(true);
+	WebPage webPage() { return m_page; }
 
-}
+	void loadUrl(QUrl url)
+	{
+		m_initialUrl = url;
+		load(url);
+	}
 
-    WebPage *webPage() const { return m_page; }
+	QUrl url() const
+	{
+		QUrl url = QWebView.url();
+		if (!url.isEmpty())
+			return url;
+		return m_initialUrl;
+	}
 
-    void loadUrl(const QUrl &url)
-{
-    m_initialUrl = url;
-    load(url);
-}
-    
-    QUrl url() const
-{
-    QUrl url = QWebView::url();
-    if (!url.isEmpty())
-        return url;
+	QString lastStatusBarText()
+	{
+		return m_statusBarText;
+	}
 
-    return m_initialUrl;
-}
-
-    QString lastStatusBarText() const
-{
-    return m_statusBarText;
-}
-
-    inline int progress() const { return m_progress; }
+	int progress() const { return m_progress; }
 
 protected:
-    void mousePressEvent(QMouseEvent *event);
-{
-    m_page.m_pressedButtons = event.buttons();
-    m_page.m_keyboardModifiers = event.modifiers();
-    QWebView::mousePressEvent(event);
+
+	void mousePressEvent(QMouseEvent event);
+	{
+		m_page.m_pressedButtons = event.buttons();
+		m_page.m_keyboardModifiers = event.modifiers();
+		QWebView.mousePressEvent(event);
+	}
+
+	void mouseReleaseEvent(QMouseEvent event)
+	{
+		QWebView.mouseReleaseEvent(event);
+		if (!event.isAccepted() && (m_page.m_pressedButtons & Qt.MidButton)) {
+			QUrl url(QApplication.clipboard().text(QClipboard.Selection));
+			if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
+				setUrl(url);
+			}
+		}
+	}
+
+	void contextMenuEvent(QContextMenuEvent event)
+	{
+		QWebHitTestResult r = page().mainFrame().hitTestContent(event.pos());
+		if (!r.linkUrl().isEmpty()) {
+			QMenu menu(this);
+			menu.addAction(pageAction(QWebPage.OpenLinkInNewWindow));
+			menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
+			menu.addSeparator();
+			menu.addAction(pageAction(QWebPage.DownloadLinkToDisk));
+			// Add link to bookmarks...
+			menu.addSeparator();
+			menu.addAction(pageAction(QWebPage.CopyLinkToClipboard));
+			if (page().settings().testAttribute(QWebSettings.DeveloperExtrasEnabled))
+				menu.addAction(pageAction(QWebPage.InspectElement));
+			menu.exec(mapToGlobal(event.pos()));
+			return;
+		}
+		QWebView.contextMenuEvent(event);
+	}
+
+	void wheelEvent(QWheelEvent event)
+	{
+		if (QApplication.keyboardModifiers() & Qt.ControlModifier) {
+			int numDegrees = event.delta() / 8;
+			int numSteps = numDegrees / 15;
+			setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
+			event.accept();
+			return;
+		}
+		QWebView.wheelEvent(event);
+	}
+
+
+private:
+
+	void setProgress(int progress)
+	{
+		m_progress = progress;
+	}
+
+	void loadFinished()
+	{
+		if (100 != m_progress) {
+			qWarning() << "Received finished signal while progress is still:" << progress() << "Url:" << url();
+		}
+		m_progress = 0;
+	}
+
+	void setStatusBarText(QString string)
+	{
+		m_statusBarText = string;
+	}
+
+	void downloadRequested(QNetworkRequest request)
+	{
+		BrowserApplication.downloadManager().download(request);
+	}
+
+	void openLinkInNewTab()
+	{
+		m_page.m_openInNewTab = true;
+		pageAction(QWebPage.OpenLinkInNewWindow).trigger();
+	}
+	
+private:
+
+	QString m_statusBarText;
+	QUrl m_initialUrl;
+	int m_progress;
+	WebPage m_page;
 }
-
-    void mouseReleaseEvent(QMouseEvent *event)
-{
-    QWebView::mouseReleaseEvent(event);
-    if (!event.isAccepted() && (m_page.m_pressedButtons & Qt.MidButton)) {
-        QUrl url(QApplication::clipboard().text(QClipboard::Selection));
-        if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
-            setUrl(url);
-        }
-    }
-}
-
-    void contextMenuEvent(QContextMenuEvent *event)
-{
-    QWebHitTestResult r = page().mainFrame().hitTestContent(event.pos());
-    if (!r.linkUrl().isEmpty()) {
-        QMenu menu(this);
-        menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow));
-        menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
-        menu.addSeparator();
-        menu.addAction(pageAction(QWebPage::DownloadLinkToDisk));
-        // Add link to bookmarks...
-        menu.addSeparator();
-        menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
-        if (page().settings().testAttribute(QWebSettings::DeveloperExtrasEnabled))
-            menu.addAction(pageAction(QWebPage::InspectElement));
-        menu.exec(mapToGlobal(event.pos()));
-        return;
-    }
-    QWebView::contextMenuEvent(event);
-}
-
-    void wheelEvent(QWheelEvent *event)
-{
-    if (QApplication::keyboardModifiers() & Qt.ControlModifier) {
-        int numDegrees = event.delta() / 8;
-        int numSteps = numDegrees / 15;
-        setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
-        event.accept();
-        return;
-    }
-    QWebView::wheelEvent(event);
-}
-
-
-private slots:
-    void setProgress(int progress)
-{
-    m_progress = progress;
-}
-
-    void loadFinished()
-{
-    if (100 != m_progress) {
-        qWarning() << "Recieved finished signal while progress is still:" << progress()
-                   << "Url:" << url();
-    }
-    m_progress = 0;
-}
-
-    void setStatusBarText(const QString &string)
-{
-    m_statusBarText = string;
-}
-
-    void downloadRequested(const QNetworkRequest &request)
-{
-    BrowserApplication::downloadManager().download(request);
-}
-
-    void openLinkInNewTab()
-{
-    m_page.m_openInNewTab = true;
-    pageAction(QWebPage::OpenLinkInNewWindow).trigger();
-}
-private:
-    QString m_statusBarText;
-    QUrl m_initialUrl;
-    int m_progress;
-    WebPage *m_page;
-}
--- a/demos/browser/xbel.d	Wed May 20 22:44:31 2009 +0000
+++ b/demos/browser/xbel.d	Fri May 22 10:59:00 2009 +0000
@@ -41,319 +41,317 @@
 
 module xbel;
 
-import QtCore.QXmlStreamReader;
-import QtCore.QDateTime;
 
+import qt.core.QXmlStreamReader;
+import qt.core.QDateTime;
+import qt.core.QFile;
 
-import QtCore.QFile;
 
 class BookmarkNode
 {
 public:
-    enum Type {
-        Root,
-        Folder,
-        Bookmark,
-        Separator
-    };
 
-    this(Type type = Root, BookmarkNode *parent = null)
-{
-	 expanded = false;
-   m_parent = parent;
-   m_type = type;
-	
-    if (parent)
-        parent.add(this);
-}
-    
-    ~this()
-{
-    if (m_parent)
-        m_parent.remove(this);
-    qDeleteAll(m_children);
-    m_parent = 0;
-    m_type = BookmarkNode::Root;
-}
+	enum Type {
+	Root,
+	Folder,
+	Bookmark,
+	Separator
+	};
 
-    bool operator==(const BookmarkNode &other)
-{
-    if (url != other.url
-        || title != other.title
-        || desc != other.desc
-        || expanded != other.expanded
-        || m_type != other.m_type
-        || m_children.count() != other.m_children.count())
-        return false;
+	this(Type type = Root, BookmarkNode parent = null)
+	{
+		expanded = false;
+		m_parent = parent;
+		m_type = type;
 
-    for (int i = 0; i < m_children.count(); ++i)
-        if (!((*(m_children[i])) == (*(other.m_children[i]))))
-            return false;
-    return true;
-}
+		if (parent)
+			parent.add(this);
+	}
 
-    Type type() const
-{
-    return m_type;
-}
+	~this()
+	{
+		if (m_parent)
+			m_parent.remove(this);
+		qDeleteAll(m_children);
+		m_parent = 0;
+		m_type = BookmarkNode.Root;
+	}
 
-    void setType(Type type)
-{
-    m_type = type;
-}
+	bool operator==(BookmarkNode other)
+	{
+		if (url != other.url || title != other.title || desc != other.desc || expanded != other.expanded
+			|| m_type != other.m_type || m_children.count() != other.m_children.count())
+			return false;
 
-    QList<BookmarkNode *> children() const
-{
-    return m_children;
-}
+		for (int i = 0; i < m_children.count(); ++i)
+			if (!((*(m_children[i])) == (*(other.m_children[i]))))
+				return false;
+		return true;
+	}
 
+	Type type() const
+	{
+		return m_type;
+	}
 
-    BookmarkNode *parent() const
-{
-    return m_parent;
-}
+	void setType(Type type)
+	{
+		m_type = type;
+	}
 
-    void add(BookmarkNode *child, int offset = -1)
-{
-    Q_ASSERT(child.m_type != Root);
-    if (child.m_parent)
-        child.m_parent.remove(child);
-    child.m_parent = this;
-    if (-1 == offset)
-        offset = m_children.size();
-    m_children.insert(offset, child);
-}
+	QList<BookmarkNode > children() const
+	{
+		return m_children;
+	}
 
-    void remove(BookmarkNode *child)
-{
-    child.m_parent = 0;
-    m_children.removeAll(child);
-}
 
-    QString url;
-    QString title;
-    QString desc;
-    bool expanded;
+	BookmarkNode parent() const
+	{
+		return m_parent;
+	}
+
+	void add(BookmarkNode child, int offset = -1)
+	{
+		assert(child.m_type != Root);
+		if (child.m_parent)
+			child.m_parent.remove(child);
+		child.m_parent = this;
+		if (-1 == offset)
+			offset = m_children.size();
+		m_children.insert(offset, child);
+	}
+
+	void remove(BookmarkNode child)
+	{
+		child.m_parent = 0;
+		m_children.removeAll(child);
+	}
+
+	QString url;
+	QString title;
+	QString desc;
+	bool expanded;
 
 private:
-    BookmarkNode *m_parent;
-    Type m_type;
-    QList<BookmarkNode *> m_children;
 
-};
+	BookmarkNode m_parent;
+	Type m_type;
+	QList<BookmarkNode> m_children;
+}
 
 class XbelReader : public QXmlStreamReader
 {
 public:
-this()
-{
+
+	this()
+	{
+	}
+
+	BookmarkNode read(QString fileName)
+	{
+		QFile file(fileName);
+		if (!file.exists()) {
+			return new BookmarkNode(BookmarkNode.Root);
+		}
+		file.open(QFile.ReadOnly);
+		return read(&file);
+	}
+
+	BookmarkNode read(QIODevice device)
+	{
+		BookmarkNode root = new BookmarkNode(BookmarkNode.Root);
+		setDevice(device);
+		while (!atEnd()) {
+			readNext();
+			if (isStartElement()) {
+				QString version_ = attributes().value(QLatin1String("version")).toString();
+				if (name() == QLatin1String("xbel") && (version_.isEmpty() || version_ == QLatin1String("1.0"))) {
+					readXBEL(root);
+				} else {
+					raiseError(QObject.tr("The file is not an XBEL version 1.0 file."));
+				}
+			}
+		}
+		return root;
+	}
+
+private:
+	void skipUnknownElement()
+	{
+		assert(isStartElement());
+
+		while (!atEnd()) {
+			readNext();
+
+			if (isEndElement())
+				break;
+
+			if (isStartElement())
+				skipUnknownElement();
+		}
+	}
+
+	void readXBEL(BookmarkNode parent)
+	{
+		assert(isStartElement() && name() == QLatin1String("xbel"));
+
+		while (!atEnd()) {
+			readNext();
+			if (isEndElement())
+				break;
+
+			if (isStartElement()) {
+				if (name() == QLatin1String("folder"))
+					readFolder(parent);
+				else if (name() == QLatin1String("bookmark"))
+					readBookmarkNode(parent);
+				else if (name() == QLatin1String("separator"))
+					readSeparator(parent);
+				else
+					skipUnknownElement();
+			}
+		}
+	}
+
+	void readTitle(BookmarkNode parent)
+	{
+		assert(isStartElement() && name() == QLatin1String("title"));
+		parent.title = readElementText();
+	}
+
+	void readDescription(BookmarkNode parent)
+	{
+		assert(isStartElement() && name() == QLatin1String("desc"));
+		parent.desc = readElementText();
+	}
+
+	void readSeparator(BookmarkNode parent)
+	{
+		new BookmarkNode(BookmarkNode.Separator, parent);
+		// empty elements have a start and end element
+		readNext();
+	}
+
+
+	void readFolder(BookmarkNode parent)
+	{
+		assert(isStartElement() && name() == QLatin1String("folder"));
+
+		BookmarkNode folder = new BookmarkNode(BookmarkNode.Folder, parent);
+		folder.expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no"));
+
+		while (!atEnd()) {
+			readNext();
+
+			if (isEndElement())
+				break;
+
+			if (isStartElement()) {
+				if (name() == QLatin1String("title"))
+					readTitle(folder);
+				else if (name() == QLatin1String("desc"))
+					readDescription(folder);
+				else if (name() == QLatin1String("folder"))
+					readFolder(folder);
+				else if (name() == QLatin1String("bookmark"))
+					readBookmarkNode(folder);
+				else if (name() == QLatin1String("separator"))
+					readSeparator(folder);
+				else
+					skipUnknownElement();
+			}
+		}
+	}
+
+	void readBookmarkNode(BookmarkNode parent)
+	{
+		assert(isStartElement() && name() == QLatin1String("bookmark"));
+		BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark, parent);
+		bookmark.url = attributes().value(QLatin1String("href")).toString();
+		while (!atEnd()) {
+			readNext();
+			if (isEndElement())
+				break;
+
+			if (isStartElement()) {
+				if (name() == QLatin1String("title"))
+					readTitle(bookmark);
+				else if (name() == QLatin1String("desc"))
+					readDescription(bookmark);
+				else
+					skipUnknownElement();
+			}
+		}
+		if (bookmark.title.isEmpty())
+			bookmark.title = QObject.tr("Unknown title");
+	}
 }
 
-BookmarkNode *read(const QString &fileName)
-{
-    QFile file(fileName);
-    if (!file.exists()) {
-        return new BookmarkNode(BookmarkNode::Root);
-    }
-    file.open(QFile::ReadOnly);
-    return read(&file);
-}
-
-BookmarkNode *read(QIODevice *device)
-{
-    BookmarkNode *root = new BookmarkNode(BookmarkNode::Root);
-    setDevice(device);
-    while (!atEnd()) {
-        readNext();
-        if (isStartElement()) {
-            QString version = attributes().value(QLatin1String("version")).toString();
-            if (name() == QLatin1String("xbel")
-                && (version.isEmpty() || version == QLatin1String("1.0"))) {
-                readXBEL(root);
-            } else {
-                raiseError(QObject::tr("The file is not an XBEL version 1.0 file."));
-            }
-        }
-    }
-    return root;
-}
-
-private:
-    void skipUnknownElement()
-{
-    Q_ASSERT(isStartElement());
-
-    while (!atEnd()) {
-        readNext();
-
-        if (isEndElement())
-            break;
-