diff demos/browser/history.d @ 73:7bfd46c330dc

more porting
author mandel
date Fri, 22 May 2009 10:59:00 +0000
parents b149ef2cb18b
children 37caa90ce503
line wrap: on
line diff
--- 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();