changeset 85:5c8c9c5d9ee1

more porting
author mandel
date Mon, 25 May 2009 14:10:44 +0000
parents 2edf95ad41e5
children bee1446909c5
files demos/browser/autosaver.d demos/browser/cookiejar.d demos/browser/downloadmanager.d demos/browser/history.d demos/browser/urllineedit.d demos/browser/webview.d demos/browser/xbel.d
diffstat 7 files changed, 49 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/demos/browser/autosaver.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/autosaver.d	Mon May 25 14:10:44 2009 +0000
@@ -46,9 +46,9 @@
 import qt.core.QTime;
 import qt.core.QDir;
 import qt.core.QCoreApplication;
-import qt.core.QMetaObject;
+//import qt.core.QMetaObject;
 
-import QtDebug;
+//import QtDebug;
 
 
 const uint AUTOSAVE_IN  = 1000 * 3;  // seconds
@@ -83,9 +83,11 @@
 			return;
 		m_timer.stop();
 		m_firstChange = QTime();
-		if (!QMetaObject.invokeMethod(parent(), "save", Qt.DirectConnection)) {
-			qWarning() << "AutoSaver: error invoking slot save() on parent";
-		}
+		
+		//TODO!
+		//if (!QMetaObject.invokeMethod(parent(), "save", Qt.DirectConnection)) {
+		//	qWarning() << "AutoSaver: error invoking slot save() on parent";
+		//}
 	}
 
 public:
--- a/demos/browser/cookiejar.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/cookiejar.d	Mon May 25 14:10:44 2009 +0000
@@ -344,14 +344,14 @@
 			if (cookies[i].isSessionCookie())
 			cookies.removeAt(i);
 		}
-		cookieSettings.setValue("cookies", qVariantFromValue<QNetworkCookie[] >(cookies));
+		//cookieSettings.setValue("cookies", qVariantFromValue<QNetworkCookie[] >(cookies)); //TODO!
 		cookieSettings.beginGroup("Exceptions");
 		cookieSettings.setValue("block", m_exceptions_block);
 		cookieSettings.setValue("allow", m_exceptions_allow);
 		cookieSettings.setValue("allowForSession", m_exceptions_allowForSession);
 
 		// save cookie settings
-		QSettings settings;
+		auto settings = new QSettings;
 		settings.beginGroup("cookies");
 		QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy"));
 		settings.setValue("acceptCookies", acceptPolicyEnum.valueToKey(m_acceptCookies));
@@ -672,7 +672,7 @@
 		return QVariant();
 	}
 
-	int columnCount(QModelIndex parent = QModelIndex());
+	int columnCount(QModelIndex parent = QModelIndex())
 	{
 		return (parent.isValid()) ? 0 : 2;
 	}
--- a/demos/browser/downloadmanager.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/downloadmanager.d	Mon May 25 14:10:44 2009 +0000
@@ -217,7 +217,7 @@
 		string defaultLocation = QDesktopServices.storageLocation(QDesktopServices.DesktopLocation);
 		string downloadDirectory = settings.value("downloadDirectory", defaultLocation).toString();
 		if (!downloadDirectory.isEmpty())
-			downloadDirectory ~= QLatin1Char('/');
+			downloadDirectory ~= "/";
 
 		string defaultFileName = saveFileName(downloadDirectory);
 		string fileName = defaultFileName;
@@ -334,12 +334,12 @@
 			baseName = "unnamed_download";
 			qDebug() << "DownloadManager:: downloading unknown file:" << m_url;
 		}
-		string name = directory ~ baseName ~ QLatin1Char('.') ~ endName;
+		string name = directory ~ baseName ~ "." ~ endName;
 		if (QFile.exists(name)) {
 			// already exists, don't overwrite
 			int i = 1;
 			do {
-				name = directory ~ baseName ~ QLatin1Char('-') ~ QString.number(i++) ~ QLatin1Char('.') ~ endName;
+				name = directory ~ baseName ~ "-" ~ .toString(i++) ~ "." ~ endName;
 			} while (QFile.exists(name));
 		}
 		return name;
--- a/demos/browser/history.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/history.d	Mon May 25 14:10:44 2009 +0000
@@ -82,11 +82,11 @@
 
 	this() {}
 
-	this(string u, QDateTime d = QDateTime(), string t = null)
+	this(string u, QDateTime d = null, string t = null)
 	{
 		title = t;
 		url = u;
-		dateTime = d;
+		dateTime = d ? d : new QDateTime();
 	}
 
 	//bool operator==(HistoryItem &other)
@@ -673,7 +673,7 @@
 		return createIndex(row, column, m_sourceRow[row]);
 	}
 
-	QModelIndex parent(QModelIndex index= QModelIndex())
+	QModelIndex parent(QModelIndex index = QModelIndex())
 	{
 		return QModelIndex();
 	}
@@ -1038,7 +1038,7 @@
 		return createIndex(row, column, 0);
 	}
 
-	QModelIndex parent(QModelIndex index= QModelIndex())
+	QModelIndex parent(QModelIndex index = QModelIndex())
 	{
 		return QModelIndex();
 	}
@@ -1157,11 +1157,13 @@
 		if (m_sourceRowCache.length == 0)
 			rowCount(QModelIndex());
 
-		int[].iterator it;
-		it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row());
-		if (*it != sourceIndex.row())
+		//int[].iterator it;
+		//it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row());
+		int it = 0;
+		it = qLowerBound(m_sourceRowCache, sourceIndex.row());
+		if (it != sourceIndex.row())
 			--it;
-		int dateRow = qMax(0, it - m_sourceRowCache.begin());
+		int dateRow = qMax(0, it);
 		int row = sourceIndex.row() - m_sourceRowCache[dateRow];
 		return createIndex(row, sourceIndex.column(), dateRow + 1);
 	}
@@ -1290,18 +1292,20 @@
 		if (m_sourceRowCache.length == 0)
 			return;
 		for (int i = end; i >= start;) {
-			int[]::iterator it;
-			it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i);
+			//int[]::iterator it;
+			//it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i);
+			int it;
+			it = qLowerBound(m_sourceRowCache, i);
 			// playing it safe
-			if (it == m_sourceRowCache.end()) {
-				m_sourceRowCache = null;
+			if (it == m_sourceRowCache.length) {
+				m_sourceRowCache.length = 0;
 				reset();
 				return;
 			}
 
-			if (*it != i)
+			if (it != i)
 				--it;
-			int row = qMax(0, it - m_sourceRowCache.begin());
+			int row = qMax(0, it);
 			int offset = m_sourceRowCache[row];
 			QModelIndex dateParent = index(row, 0);
 			// If we can remove all the rows in the date do that and skip over them
@@ -1402,7 +1406,7 @@
 		tree.header().setStretchLastSection(true);
 		tree.activated(QModelIndex).connect(this.open);
 		tree.setContextMenuPolicy(Qt.CustomContextMenu);
-		tree.customContextMenuRequested(QPoint).connect(&this.customContextMenuRequested(QPoint));
+		tree.customContextMenuRequested.connect(&this.customContextMenuRequested);
 	}
 
 private:
--- a/demos/browser/urllineedit.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/urllineedit.d	Mon May 25 14:10:44 2009 +0000
@@ -149,7 +149,7 @@
 
 	void paintEvent(QPaintEvent event)
 	{
-		QPainter p(this);
+		auto p = new QPainter(this);
 		QStyleOptionFrameV2 panel;
 		initStyleOption(&panel);
 		style().drawPrimitive(QStyle.PE_PanelLineEdit, &panel, &p, this);
@@ -303,7 +303,7 @@
 	{
 		QPalette p = palette();
 		if (m_webView && m_webView.url().scheme() == "https") {
-			QColor lightYellow(248, 248, 210);
+			auto lightYellow = new QColor(248, 248, 210);
 			p.setBrush(QPalette.Base, generateGradient(lightYellow));
 		} else {
 			p.setBrush(QPalette.Base, m_defaultBaseColor);
@@ -321,7 +321,7 @@
 			painter.setBrush(generateGradient(loadingColor));
 			painter.setPen(Qt.transparent);
 			int mid = backgroundRect.width() / 100 * progress;
-			QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
+			QRect progressRect = QRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
 			painter.drawRect(progressRect);
 		}
 	}
@@ -343,9 +343,9 @@
 
 	void webViewIconChanged()
 	{
-		QUrl url = (m_webView)  ? m_webView.url() : new QUrl();
+		QUrl url = m_webView ? m_webView.url() : new QUrl();
 		QIcon icon = BrowserApplication.instance().icon(url);
-		QPixmap pixmap(icon.pixmap(16, 16));
+		auto pixmap = new QPixmap(icon.pixmap(16, 16));
 		m_iconLabel.setPixmap(pixmap);
 	}
 
@@ -353,7 +353,7 @@
 
 	QLinearGradient generateGradient(QColor color)
 	{
-		QLinearGradient gradient(0, 0, 0, height());
+		auto gradient = new QLinearGradient(0, 0, 0, height());
 		gradient.setColorAt(0, m_defaultBaseColor);
 		gradient.setColorAt(0.15, color.lighter(120));
 		gradient.setColorAt(0.5, color);
--- a/demos/browser/webview.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/webview.d	Mon May 25 14:10:44 2009 +0000
@@ -137,7 +137,7 @@
 
 	version(QT_NO_UITOOLS) {} else
 	{
-		QObject createPlugin(string classId, QUrl url, string[] paramNames, string[] paramValues);
+		QObject createPlugin(string classId, QUrl url, string[] paramNames, string[] paramValues)
 		{
 			auto loader = new QUiLoader;
 			return loader.createWidget(classId, view());
@@ -195,13 +195,13 @@
 	Qt.MouseButtons m_pressedButtons;
 	bool m_openInNewTab;
 	QUrl m_loadingUrl;
-};
+}
 
 class WebView : public QWebView
 {
 public:
 	
-	WebView(QWidget parent = null)
+	this(QWidget parent = null)
 	{
 		super(parent);
 		m_progress = 0;
@@ -236,7 +236,10 @@
 		return m_statusBarText;
 	}
 
-	int progress() const { return m_progress; }
+	int progress()
+	{
+		return m_progress;
+	}
 
 protected:
 
@@ -251,7 +254,7 @@
 	{
 		QWebView.mouseReleaseEvent(event);
 		if (!event.isAccepted() && (m_page.m_pressedButtons & Qt.MidButton)) {
-			QUrl url(QApplication.clipboard().text(QClipboard.Selection));
+			auto url = new QUrl(QApplication.clipboard().text(QClipboard.Selection));
 			if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) {
 				setUrl(url);
 			}
@@ -262,7 +265,7 @@
 	{
 		QWebHitTestResult r = page().mainFrame().hitTestContent(event.pos());
 		if (!r.linkUrl().isEmpty()) {
-			QMenu menu(this);
+			auto menu = new QMenu(this);
 			menu.addAction(pageAction(QWebPage.OpenLinkInNewWindow));
 			menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
 			menu.addSeparator();
--- a/demos/browser/xbel.d	Sun May 24 20:14:50 2009 +0000
+++ b/demos/browser/xbel.d	Mon May 25 14:10:44 2009 +0000
@@ -203,9 +203,9 @@
 			if (isStartElement()) {
 				if (name() == "folder")
 					readFolder(parent);
-				else if (name() == ("bookmark")
+				else if (name() == "bookmark")
 					readBookmarkNode(parent);
-				else if (name() == ("separator")
+				else if (name() == "separator")
 					readSeparator(parent);
 				else
 					skipUnknownElement();