# HG changeset patch # User mandel # Date 1242859471 0 # Node ID b149ef2cb18bfa44c2722846df9cd6ad8dbe7208 # Parent 9071511f7a5ba36b604fc80aa6538f7953643d6c more porting diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/addbookmarkdialog.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/addbookmarkdialog.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,98 @@ + + AddBookmarkDialog + + + + 0 + 0 + 240 + 168 + + + + Add Bookmark + + + + + + Type a name for the bookmark, and choose where to keep it. + + + Qt::PlainText + + + true + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 2 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + false + + + + + + + + + buttonBox + accepted() + AddBookmarkDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddBookmarkDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/bookmarks.d --- a/demos/browser/bookmarks.d Wed May 20 21:06:33 2009 +0000 +++ b/demos/browser/bookmarks.d Wed May 20 22:44:31 2009 +0000 @@ -39,34 +39,36 @@ ** ****************************************************************************/ -import QtCore.QObject; -import QtCore.QAbstractItemModel; - -import QtGui.QUndoCommand; +module bookmarks; +import qt.core.QObject; +import qt.core.QAbstractItemModel; + +import qt.gui.QUndoCommand; + +import qt.core.QBuffer; +import qt.core.QFile; +import qt.core.QMimeData; + +import qt.gui.QDesktopServices; +import qt.gui.QDragEnterEvent; +import qt.gui.QFileDialog; +import qt.gui.QHeaderView; +import qt.gui.QIcon; +import qt.gui.QMessageBox; +import qt.gui.QToolButton; + +import QtWebKit.QWebSettings; + +import qt.core.QDebug; + import bookmarks; - import autosaver; import browserapplication; import history; import xbel; -import QtCore.QBuffer; -import QtCore.QFile; -import QtCore.QMimeData; - -import QtGui.QDesktopServices; -import QtGui.QDragEnterEvent; -import QtGui.QFileDialog; -import QtGui.QHeaderView; -import QtGui.QIcon; -import QtGui.QMessageBox; -import QtGui.QToolButton; - -import QtWebKit.QWebSettings; - -import QtCore.QDebug; const char[] BOOKMARKBAR = "Bookmarks Bar"; const char[] BOOKMARKMENU = "Bookmarks Menu"; @@ -75,34 +77,25 @@ /*! Bookmark manager, owner of the bookmarks, loads, saves and basic tasks */ - /* -class AutoSaver; -class BookmarkNode; -class BookmarksModel; -*/ + class BookmarksManager : public QObject { - Q_OBJECT - -signals: - void entryAdded(BookmarkNode *item); - void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); - void 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) + BookmarksManager(QObject parent = null) { super(parent); m_loaded = false; m_saveTimer = new AutoSaver(this); m_bookmarkRootNode = null; m_bookmarkModel = null; - connect(this, SIGNAL(entryAdded(BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); - connect(this, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); - connect(this, SIGNAL(entryChanged(BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); + this.entryAdded.connect(&m_saveTimer.changeOccurred); + this.entryRemoved.connect(&m_saveTimer.changeOccurred); + this.entryChanged.connect(&m_saveTimer.changeOccurred); } @@ -112,46 +105,46 @@ } - void addBookmark(BookmarkNode *parent, BookmarkNode *node, int row = -1) + void addBookmark(BookmarkNode parent, BookmarkNode node, int row = -1) { if (!m_loaded) return; - Q_ASSERT(parent); - InsertBookmarksCommand *command = new InsertBookmarksCommand(this, parent, node, row); + assert(parent); + InsertBookmarksCommand command = new InsertBookmarksCommand(this, parent, node, row); m_commands.push(command); } - void removeBookmark(BookmarkNode *node); + void removeBookmark(BookmarkNode node); { if (!m_loaded) return; - Q_ASSERT(node); - BookmarkNode *parent = node.parent(); + assert(node); + BookmarkNode parent = node.parent(); int row = parent.children().indexOf(node); - RemoveBookmarksCommand *command = new RemoveBookmarksCommand(this, parent, row); + RemoveBookmarksCommand command = new RemoveBookmarksCommand(this, parent, row); m_commands.push(command); } - void setTitle(BookmarkNode *node, QString &newTitle); + void setTitle(BookmarkNode node, QString newTitle); { if (!m_loaded) return; - Q_ASSERT(node); - ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newTitle, true); + assert(node); + ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newTitle, true); m_commands.push(command); } - void setUrl(BookmarkNode *node, QString &newUrl); + void setUrl(BookmarkNode node, QString newUrl); { if (!m_loaded) return; - Q_ASSERT(node); - ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newUrl, false); + assert(node); + ChangeBookmarkCommand command = new ChangeBookmarkCommand(this, node, newUrl, false); m_commands.push(command); } @@ -161,84 +154,84 @@ m_saveTimer.changeOccurred(); } - BookmarkNode *bookmarks(); + BookmarkNode bookmarks(); { if (!m_loaded) load(); return m_bookmarkRootNode; } - BookmarkNode *menu(); + BookmarkNode menu(); { if (!m_loaded) load(); for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode.children().at(i); + BookmarkNode node = m_bookmarkRootNode.children().at(i); if (node.title == tr(BOOKMARKMENU)) return node; } - Q_ASSERT(false); + assert(false); return 0; } - BookmarkNode *toolbar(); + BookmarkNode toolbar(); { if (!m_loaded) load(); for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode.children().at(i); + BookmarkNode node = m_bookmarkRootNode.children().at(i); if (node.title == tr(BOOKMARKBAR)) return node; } - Q_ASSERT(false); + assert(false); return 0; } -BookmarksModel* bookmarksModel() +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 slots: void importBookmarks() { - QString fileName = QFileDialog::getOpenFileName(0, tr("Open File"), + 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"), + 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))); + 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()), + 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")); + QMessageBox.critical(0, tr("Export error"), tr("error saving bookmarks")); } private slots: @@ -248,7 +241,7 @@ return; XbelWriter writer; - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); if (!writer.write(bookmarkFile, m_bookmarkRootNode)) qWarning() << "BookmarkManager: error saving to" << bookmarkFile; @@ -261,25 +254,25 @@ return; m_loaded = true; - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation); QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); - if (!QFile::exists(bookmarkFile)) + if (!QFile.exists(bookmarkFile)) bookmarkFile = QLatin1String(":defaultbookmarks.xbel"); XbelReader reader; m_bookmarkRootNode = reader.read(bookmarkFile); - if (reader.error() != QXmlStreamReader::NoError) { - QMessageBox::warning(0, QLatin1String("Loading Bookmark"), + 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())); } - BookmarkNode *toolbar = null; - BookmarkNode *menu = null; - QList others; + BookmarkNode toolbar = null; + BookmarkNode menu = null; + QList others; for (int i = m_bookmarkRootNode.children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode.children().at(i); - if (node.type() == BookmarkNode::Folder) { + 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); @@ -300,16 +293,16 @@ } m_bookmarkRootNode.remove(node); } - Q_ASSERT(m_bookmarkRootNode.children().count() == 0); + assert(m_bookmarkRootNode.children().count() == 0); if (!toolbar) { - toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); + toolbar = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode); toolbar.title = tr(BOOKMARKBAR); } else { m_bookmarkRootNode.add(toolbar); } if (!menu) { - menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); + menu = new BookmarkNode(BookmarkNode.Folder, m_bookmarkRootNode); menu.title = tr(BOOKMARKMENU); } else { m_bookmarkRootNode.add(menu); @@ -321,22 +314,22 @@ bool m_loaded; - AutoSaver *m_saveTimer; - BookmarkNode *m_bookmarkRootNode; - BookmarksModel *m_bookmarkModel; + AutoSaver m_saveTimer; + BookmarkNode m_bookmarkRootNode; + BookmarksModel m_bookmarkModel; QUndoStack m_commands; friend class RemoveBookmarksCommand; friend class ChangeBookmarkCommand; -}; +} class RemoveBookmarksCommand : public QUndoCommand { public: - this(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row) + this(BookmarksManager m_bookmarkManagaer, BookmarkNode parent, int row) { - super(BookmarksManager::tr("Remove Bookmark")) + super(BookmarksManager.tr("Remove Bookmark")) m_row = row; m_bookmarkManagaer = m_bookmarkManagaer; m_node = parent.children().value(row); @@ -367,9 +360,9 @@ protected: int m_row; - BookmarksManager *m_bookmarkManagaer; - BookmarkNode *m_node; - BookmarkNode *m_parent; + BookmarksManager m_bookmarkManagaer; + BookmarkNode m_node; + BookmarkNode m_parent; bool m_done; }; @@ -377,25 +370,25 @@ { public: -this(BookmarksManager *m_bookmarkManagaer, - BookmarkNode *parent, BookmarkNode *node, int row) +this(BookmarksManager m_bookmarkManagaer, + BookmarkNode parent, BookmarkNode node, int row) { super(m_bookmarkManagaer, parent, row); - setText(BookmarksManager::tr("Insert Bookmark")); + 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: - this(BookmarksManager *m_bookmarkManagaer, - BookmarkNode *node, QString &newValue, bool title) + this(BookmarksManager m_bookmarkManagaer, + BookmarkNode node, QString newValue, bool title) { super(); m_bookmarkManagaer = m_bookmarkManagaer; @@ -404,10 +397,10 @@ m_node = node; if (m_title) { m_oldValue = m_node.title; - setText(BookmarksManager::tr("Name Change")); + setText(BookmarksManager.tr("Name Change")); } else { m_oldValue = m_node.url; - setText(BookmarksManager::tr("Address Change")); + setText(BookmarksManager.tr("Address Change")); } } @@ -430,27 +423,27 @@ } private: - BookmarksManager *m_bookmarkManagaer; + BookmarksManager m_bookmarkManagaer; bool m_title; QString m_oldValue; QString m_newValue; - BookmarkNode *m_node; + BookmarkNode m_node; } /*! BookmarksModel is a QAbstractItemModel wrapper around the BookmarkManager */ -import QtGui/QIcon; +import qt.gui.QIcon; + class BookmarksModel : public QAbstractItemModel { - Q_OBJECT -public slots: - void entryAdded(BookmarkNode *item) +public: + void entryAdded(BookmarkNode item) { - Q_ASSERT(item && item.parent()); + assert(item && item.parent()); int row = item.parent().children().indexOf(item); - BookmarkNode *parent = item.parent(); + BookmarkNode parent = item.parent(); // item was already added so remove beore beginInsertRows is called parent.remove(item); beginInsertRows(index(parent), row, row); @@ -459,7 +452,7 @@ } - void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); + void entryRemoved(BookmarkNode parent, int row, BookmarkNode item); { // item was already removed, re-add so beginRemoveRows works parent.add(item, row); @@ -468,7 +461,7 @@ endRemoveRows(); } - void entryChanged(BookmarkNode *item); + void entryChanged(BookmarkNode item); { QModelIndex idx = index(item); emit dataChanged(idx, idx); @@ -479,23 +472,20 @@ UrlRole = Qt.UserRole + 2, UrlStringRole = Qt.UserRole + 3, SeparatorRole = Qt.UserRole + 4 - }; + } - BookmarksModel(BookmarksManager *bookmarkManager, QObject *parent = null) + BookmarksModel(BookmarksManager bookmarkManager, QObject parent = null) { super(parent) m_endMacro = false; m_bookmarksManager = bookmarkManager; - connect(bookmarkManager, SIGNAL(entryAdded(BookmarkNode *)), - this, SLOT(entryAdded(BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), - this, SLOT(entryRemoved(BookmarkNode *, int, BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryChanged(BookmarkNode *)), - this, SLOT(entryChanged(BookmarkNode *))); + bookmarkManager.entryAdded.connect(&this.entryAdded); + bookmarkManager.entryRemoved.connect(&this.entryRemoved); + bookmarkManager.entryChanged.connect(&this.entryChanged); } - inline BookmarksManager *bookmarksManager() { return m_bookmarksManager; } + inline BookmarksManager bookmarksManager() { return m_bookmarksManager; } QVariant headerData(int section, Qt.Orientation orientation, int role = Qt.DisplayRole); { @@ -505,20 +495,20 @@ case 1: return tr("Address"); } } - return QAbstractItemModel::headerData(section, orientation, role); + return QAbstractItemModel.headerData(section, orientation, role); } - QVariant data(QModelIndex &index, int role = Qt.DisplayRole) + QVariant data(QModelIndex index, int role = Qt.DisplayRole) { if (!index.isValid() || index.model() != this) return QVariant(); - BookmarkNode *bookmarkNode = node(index); + BookmarkNode bookmarkNode = node(index); switch (role) { case Qt.EditRole: case Qt.DisplayRole: - if (bookmarkNode.type() == BookmarkNode::Separator) { + if (bookmarkNode.type() == BookmarkNode.Separator) { switch (index.column()) { case 0: return QString(50, 0xB7); case 1: return QString(); @@ -530,35 +520,35 @@ case 1: return bookmarkNode.url; } break; - case BookmarksModel::UrlRole: + case BookmarksModel.UrlRole: return QUrl(bookmarkNode.url); break; - case BookmarksModel::UrlStringRole: + case BookmarksModel.UrlStringRole: return bookmarkNode.url; break; - case BookmarksModel::TypeRole: + case BookmarksModel.TypeRole: return bookmarkNode.type(); break; - case BookmarksModel::SeparatorRole: - return (bookmarkNode.type() == BookmarkNode::Separator); + 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); + 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()) + int columnCount(QModelIndex parent = QModelIndex()) { return (parent.column() > 0) ? 0 : 2; } - int rowCount(QModelIndex &parent = QModelIndex()) + int rowCount(QModelIndex parent = QModelIndex()) { if (parent.column() > 0) return 0; @@ -566,7 +556,7 @@ if (!parent.isValid()) return m_bookmarksManager.bookmarks().children().count(); - const BookmarkNode *item = static_cast(parent.internalPointer()); + const BookmarkNode item = static_cast(parent.internalPointer()); return item.children().count(); } @@ -576,7 +566,7 @@ return QModelIndex(); // get the parent node - BookmarkNode *parentNode = node(parent); + BookmarkNode parentNode = node(parent); return createIndex(row, column, parentNode.children().at(row)); } @@ -585,32 +575,31 @@ if (!index.isValid()) return QModelIndex(); - BookmarkNode *itemNode = node(index); - BookmarkNode *parentNode = (itemNode ? itemNode.parent() : 0); + 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(); + BookmarkNode grandParentNode = parentNode.parent(); int parentRow = grandParentNode.children().indexOf(parentNode); - Q_ASSERT(parentRow >= 0); + assert(parentRow >= 0); return createIndex(parentRow, 0, parentNode); } - Qt.ItemFlags flags(QModelIndex &index) + Qt.ItemFlags flags(QModelIndex index) { if (!index.isValid()) return Qt.NoItemFlags; Qt.ItemFlags flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled; - BookmarkNode *bookmarkNode = node(index); + BookmarkNode bookmarkNode = node(index); - if (bookmarkNode != m_bookmarksManager.menu() - && bookmarkNode != m_bookmarksManager.toolbar()) { + if (bookmarkNode != m_bookmarksManager.menu() && bookmarkNode != m_bookmarksManager.toolbar()) { flags |= Qt.ItemIsDragEnabled; - if (bookmarkNode.type() != BookmarkNode::Separator) + if (bookmarkNode.type() != BookmarkNode.Separator) flags |= Qt.ItemIsEditable; } if (hasChildren(index)) @@ -624,14 +613,14 @@ } - bool removeRows(int row, int count, QModelIndex &parent = QModelIndex()); + bool removeRows(int row, int count, QModelIndex parent = QModelIndex()); { if (row < 0 || count <= 0 || row + count > rowCount(parent)) return false; - BookmarkNode *bookmarkNode = node(parent); + BookmarkNode bookmarkNode = node(parent); for (int i = row + count - 1; i >= row; --i) { - BookmarkNode *node = bookmarkNode.children().at(i); + BookmarkNode node = bookmarkNode.children().at(i); if (node == m_bookmarksManager.menu() || node == m_bookmarksManager.toolbar()) continue; @@ -645,12 +634,12 @@ return true; } - bool setData(QModelIndex &index, QVariant &value, int role = Qt.EditRole) + bool setData(QModelIndex index, QVariant value, int role = Qt.EditRole) { if (!index.isValid() || (flags(index) & Qt.ItemIsEditable) == 0) return false; - BookmarkNode *item = node(index); + BookmarkNode item = node(index); switch (role) { case Qt.EditRole: @@ -664,10 +653,10 @@ break; } return false; - case BookmarksModel::UrlRole: + case BookmarksModel.UrlRole: m_bookmarksManager.setUrl(item, value.toUrl().toString()); break; - case BookmarksModel::UrlStringRole: + case BookmarksModel.UrlStringRole: m_bookmarksManager.setUrl(item, value.toString()); break; default: @@ -679,19 +668,19 @@ } - QMimeData *mimeData(QModelIndexList &indexes); + QMimeData mimeData(QModelIndexList indexes); { - QMimeData *mimeData = new QMimeData(); + QMimeData mimeData = new QMimeData(); QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); + 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); + buffer.open(QBuffer.ReadWrite); XbelWriter writer; - const BookmarkNode *parentNode = node(index); + const BookmarkNode parentNode = node(index); writer.write(&buffer, parentNode); stream << encodedData; } @@ -700,7 +689,7 @@ } -#define MIMETYPE QLatin1String("application/bookmarks.xbel") +const char[] MIMETYPE = QLatin1String("application/bookmarks.xbel") QStringList mimeTypes() { @@ -709,37 +698,36 @@ return types; } -bool dropMimeData(QMimeData *data, Qt.DropAction action, int row, int column, QModelIndex &parent) +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) + if (!data.hasFormat(MIMETYPE) || column > 0) return false; QByteArray ba = data.data(MIMETYPE); - QDataStream stream(&ba, QIODevice::ReadOnly); + QDataStream stream(&ba, QIODevice.ReadOnly); if (stream.atEnd()) return false; - QUndoStack *undoStack = m_bookmarksManager.undoRedoStack(); + QUndoStack undoStack = m_bookmarksManager.undoRedoStack(); undoStack.beginMacro(QLatin1String("Move Bookmarks")); while (!stream.atEnd()) { QByteArray encodedData; stream >> encodedData; QBuffer buffer(&encodedData); - buffer.open(QBuffer::ReadOnly); + buffer.open(QBuffer.ReadOnly); XbelReader reader; - BookmarkNode *rootNode = reader.read(&buffer); - QList children = rootNode.children(); + BookmarkNode rootNode = reader.read(&buffer); + QList children = rootNode.children(); for (int i = 0; i < children.count(); ++i) { - BookmarkNode *bookmarkNode = children.at(i); + BookmarkNode bookmarkNode = children.at(i); rootNode.remove(bookmarkNode); row = qMax(0, row); - BookmarkNode *parentNode = node(parent); + BookmarkNode parentNode = node(parent); m_bookmarksManager.addBookmark(parentNode, bookmarkNode, row); m_endMacro = true; } @@ -749,25 +737,25 @@ } - bool hasChildren(QModelIndex &parent = QModelIndex()) + bool hasChildren(QModelIndex parent = QModelIndex()) { if (!parent.isValid()) return true; - const BookmarkNode *parentNode = node(parent); - return (parentNode.type() == BookmarkNode::Folder); + const BookmarkNode parentNode = node(parent); + return (parentNode.type() == BookmarkNode.Folder); } - BookmarkNode *node(QModelIndex &index) + BookmarkNode node(QModelIndex index) { - BookmarkNode *itemNode = static_cast(index.internalPointer()); + BookmarkNode itemNode = static_cast(index.internalPointer()); if (!itemNode) return m_bookmarksManager.bookmarks(); return itemNode; } - QModelIndex index(BookmarkNode *node) + QModelIndex index(BookmarkNode node) { - BookmarkNode *parent = node.parent(); + BookmarkNode parent = node.parent(); if (!parent) return QModelIndex(); return createIndex(parent.children().indexOf(node), 0, node); @@ -776,30 +764,26 @@ private: bool m_endMacro; - BookmarksManager *m_bookmarksManager; + BookmarksManager m_bookmarksManager; } // Menu that is dynamically populated from the bookmarks import modelmenu; class BookmarksMenu : public ModelMenu { - Q_OBJECT - -signals: - void openUrl(QUrl &url); + mixin Signal!("openUrl", QUrl url); public: - BookmarksMenu(QWidget *parent = null) + BookmarksMenu(QWidget parent = null) { super(parent); m_bookmarksManager = 0; - connect(this, SIGNAL(activated(QModelIndex &)), - this, SLOT(activated(QModelIndex &))); + this.activated.connect(&this.activated); setMaxRows(-1); - setHoverRole(BookmarksModel::UrlStringRole); - setSeparatorRole(BookmarksModel::SeparatorRole); + setHoverRole(BookmarksModel.UrlStringRole); + setSeparatorRole(BookmarksModel.SeparatorRole); } - void setInitialActions(QList actions); + void setInitialActions(QList actions); { m_initialActions = actions; for (int i = 0; i < m_initialActions.count(); ++i) @@ -808,7 +792,7 @@ protected: bool prePopulated() { - m_bookmarksManager = BrowserApplication::bookmarksManager(); + m_bookmarksManager = BrowserApplication.bookmarksManager(); setModel(m_bookmarksManager.bookmarksModel()); setRootIndex(m_bookmarksManager.bookmarksModel().index(1, 0)); // initial actions @@ -821,35 +805,36 @@ } private slots: - void activated(QModelIndex &index) + void activated(QModelIndex index) { - emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); + emit openUrl(index.data(BookmarksModel.UrlRole).toUrl()); } private: - BookmarksManager *m_bookmarksManager; - QList m_initialActions; + BookmarksManager m_bookmarksManager; + QList m_initialActions; } /* Proxy model that filters out the bookmarks so only the folders are left behind. Used in the add bookmark dialog combobox. */ -import QtGui/QSortFilterProxyModel; +import qt.gui.QSortFilterProxyModel; + class AddBookmarkProxyModel : public QSortFilterProxyModel { Q_OBJECT public: - this(QObject * parent = null) + this(QObject parent = null) { super(parent); } - int columnCount(QModelIndex & parent = QModelIndex()) + int columnCount(QModelIndex parent = QModelIndex()) { - return qMin(1, QSortFilterProxyModel::columnCount(parent)); + return qMin(1, QSortFilterProxyModel.columnCount(parent)); } protected: - bool filterAcceptsRow(int source_row, QModelIndex &source_parent) + bool filterAcceptsRow(int source_row, QModelIndex source_parent) { QModelIndex idx = sourceModel().index(source_row, 0, source_parent); return sourceModel().hasChildren(idx); @@ -859,26 +844,26 @@ /*! Add bookmark dialog */ + import ui_addbookmarkdialog; + class AddBookmarkDialog : public QDialog, public Ui_AddBookmarkDialog { - Q_OBJECT public: - this(QString &url, QString &title, QWidget *parent = null, BookmarksManager *bookmarkManager = null) + 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(); + m_bookmarksManager = BrowserApplication.bookmarksManager(); setupUi(this); - QTreeView *view = new QTreeView(this); + QTreeView view = new QTreeView(this); m_proxyModel = new AddBookmarkProxyModel(this); - BookmarksModel *model = m_bookmarksManager.bookmarksModel(); + BookmarksModel model = m_bookmarksManager.bookmarksModel(); m_proxyModel.setSourceModel(model); view.setModel(m_proxyModel); view.expandAll(); @@ -890,13 +875,14 @@ location.setModel(m_proxyModel); view.show(); location.setView(view); - BookmarkNode *menu = m_bookmarksManager.menu(); + BookmarkNode menu = m_bookmarksManager.menu(); QModelIndex idx = m_proxyModel.mapFromSource(model.index(menu)); view.setCurrentIndex(idx); location.setCurrentIndex(idx.row()); name.setText(title); } -private slots: + +private: void accept() { @@ -904,18 +890,18 @@ 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); + 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(); + QDialog.accept(); } private: QString m_url; - BookmarksManager *m_bookmarksManager; - AddBookmarkProxyModel *m_proxyModel; + BookmarksManager m_bookmarksManager; + AddBookmarkProxyModel m_proxyModel; } import ui_bookmarks; @@ -923,45 +909,39 @@ //class TreeProxyModel; class BookmarksDialog : public QDialog, public Ui_BookmarksDialog { - Q_OBJECT - -signals: - void openUrl(QUrl &url); + + mixin Signal!("openUrl", QUrl url); public: - this(QWidget *parent = null, BookmarksManager *manager = null) + this(QWidget parent = null, BookmarksManager manager = null) : QDialog(parent) { m_bookmarksManager = manager; if (!m_bookmarksManager) - m_bookmarksManager = BrowserApplication::bookmarksManager(); + m_bookmarksManager = BrowserApplication.bookmarksManager(); setupUi(this); tree.setUniformRowHeights(true); - tree.setSelectionBehavior(QAbstractItemView::SelectRows); - tree.setSelectionMode(QAbstractItemView::ContiguousSelection); + tree.setSelectionBehavior(QAbstractItemView.SelectRows); + tree.setSelectionMode(QAbstractItemView.ContiguousSelection); tree.setTextElideMode(Qt.ElideMiddle); m_bookmarksModel = m_bookmarksManager.bookmarksModel(); m_proxyModel = new TreeProxyModel(this); - connect(search, SIGNAL(textChanged(QString)), - m_proxyModel, SLOT(setFilterFixedString(QString))); - connect(removeButton, SIGNAL(clicked()), tree, SLOT(removeOne())); + 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.setDragDropMode(QAbstractItemView.InternalMove); tree.setExpanded(m_proxyModel.index(0, 0), true); tree.setAlternatingRowColors(true); - QFontMetrics fm(font()); + auto fm = new QFontMetrics(font()); int header = fm.width(QLatin1Char('m')) * 40; tree.header().resizeSection(0, header); tree.header().setStretchLastSection(true); - connect(tree, SIGNAL(activated(QModelIndex&)), - this, SLOT(open())); + tree.activated.connect(&this.open); tree.setContextMenuPolicy(Qt.CustomContextMenu); - connect(tree, SIGNAL(customContextMenuRequested(QPoint &)), - this, SLOT(customContextMenuRequested(QPoint &))); - connect(addFolderButton, SIGNAL(clicked()), - this, SLOT(newFolder())); + tree.customContextMenuRequested.connect(&this.customContextMenuRequested); + addFolderButton.clicked.connect(&this.newFolder); expandNodes(m_bookmarksManager.bookmarks()); setAttribute(Qt.WA_DeleteOnClose); } @@ -972,7 +952,7 @@ } private slots: - void customContextMenuRequested(QPoint &pos) + void customContextMenuRequested(QPoint pos) { QMenu menu; QModelIndex index = tree.indexAt(pos); @@ -982,14 +962,14 @@ menu.addSeparator(); } menu.addAction(tr("Delete"), tree, SLOT(removeOne())); - menu.exec(QCursor::pos()); + 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()); + emit openUrl(index.sibling(index.row(), 1).data(BookmarksModel.UrlRole).toUrl()); } void newFolder() @@ -1001,17 +981,17 @@ if (!idx.isValid()) idx = tree.rootIndex(); idx = m_proxyModel.mapToSource(idx); - BookmarkNode *parent = m_bookmarksManager.bookmarksModel().node(idx); - BookmarkNode *node = new BookmarkNode(BookmarkNode::Folder); + 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) + void expandNodes(BookmarkNode node) { for (int i = 0; i < node.children().count(); ++i) { - BookmarkNode *childNode = node.children()[i]; + BookmarkNode childNode = node.children()[i]; if (childNode.expanded) { QModelIndex idx = m_bookmarksModel.index(childNode); idx = m_proxyModel.mapFromSource(idx); @@ -1021,13 +1001,13 @@ } } -bool saveExpandedNodes(QModelIndex &parent) +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); + BookmarkNode childNode = m_bookmarksModel.node(sourceIndex); bool wasExpanded = childNode.expanded; if (tree.isExpanded(child)) { childNode.expanded = true; @@ -1040,34 +1020,32 @@ return changed; } - BookmarksManager *m_bookmarksManager; - BookmarksModel *m_bookmarksModel; - TreeProxyModel *m_proxyModel; -}; + BookmarksManager m_bookmarksManager; + BookmarksModel m_bookmarksModel; + TreeProxyModel m_proxyModel; +} -import QtGui/QToolBar; +import qt.gui.QToolBar; + class BookmarksToolBar : public QToolBar { - Q_OBJECT - -signals: - void openUrl(QUrl &url); + mixin Signal!("openUrl", QUrl url); public: - BookmarksToolBar(BookmarksModel *model, QWidget *parent = null) + BookmarksToolBar(BookmarksModel model, QWidget parent = null) { super(tr("Bookmark"), parent); m_bookmarksModel = model; - connect(this, SIGNAL(actionTriggered(QAction*)), this, SLOT(triggered(QAction*))); + this.actionTriggered.connect(&this.triggered); setRootIndex(model.index(0, 0)); - connect(m_bookmarksModel, SIGNAL(modelReset()), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(rowsInserted(QModelIndex &, int, int)), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(rowsRemoved(QModelIndex &, int, int)), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(dataChanged(QModelIndex &, QModelIndex &)), this, SLOT(build())); + 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); + void setRootIndex(QModelIndex index); { m_root = index; build(); @@ -1079,20 +1057,20 @@ } protected: - void dragEnterEvent(QDragEnterEvent *event) + void dragEnterEvent(QDragEnterEvent event) { - const QMimeData *mimeData = event.mimeData(); + const QMimeData mimeData = event.mimeData(); if (mimeData.hasUrls()) event.acceptProposedAction(); - QToolBar::dragEnterEvent(event); + QToolBar.dragEnterEvent(event); } - void dropEvent(QDropEvent *event) + void dropEvent(QDropEvent event) { - const QMimeData *mimeData = event.mimeData(); + const QMimeData mimeData = event.mimeData(); if (mimeData.hasUrls() && mimeData.hasText()) { QList urls = mimeData.urls(); - QAction *action = actionAt(event.pos()); + QAction action = actionAt(event.pos()); QString dropText; if (action) dropText = action.text(); @@ -1110,20 +1088,20 @@ break; } } - BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark); + BookmarkNode bookmark = new BookmarkNode(BookmarkNode.Bookmark); bookmark.url = urls.at(0).toString(); bookmark.title = mimeData.text(); - BookmarkNode *parent = m_bookmarksModel.node(parentIndex); - BookmarksManager *bookmarksManager = m_bookmarksModel.bookmarksManager(); + BookmarkNode parent = m_bookmarksModel.node(parentIndex); + BookmarksManager bookmarksManager = m_bookmarksModel.bookmarksManager(); bookmarksManager.addBookmark(parent, bookmark, row); event.acceptProposedAction(); } - QToolBar::dropEvent(event); + QToolBar.dropEvent(event); } private slots: - void triggered(QAction *action) + void triggered(QAction action) { QVariant v = action.data(); if (v.canConvert()) { @@ -1131,9 +1109,9 @@ } } - void activated(QModelIndex &index) + void activated(QModelIndex index) { - emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); + emit openUrl(index.data(BookmarksModel.UrlRole).toUrl()); } @@ -1143,28 +1121,27 @@ 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); + QToolButton button = new QToolButton(this); + button.setPopupMode(QToolButton.InstantPopup); button.setArrowType(Qt.DownArrow); button.setText(idx.data().toString()); - ModelMenu *menu = new ModelMenu(this); - connect(menu, SIGNAL(activated(QModelIndex &)), - this, SLOT(activated(QModelIndex &))); + 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); + QAction a = addWidget(button); a.setText(idx.data().toString()); } else { - QAction *action = addAction(idx.data().toString()); - action.setData(idx.data(BookmarksModel::UrlRole)); + QAction action = addAction(idx.data().toString()); + action.setData(idx.data(BookmarksModel.UrlRole)); } } } private: - BookmarksModel *m_bookmarksModel; + BookmarksModel m_bookmarksModel; QPersistentModelIndex m_root; } diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/bookmarks.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/bookmarks.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,106 @@ + + BookmarksDialog + + + + 0 + 0 + 758 + 450 + + + + Bookmarks + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Add Folder + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTreeView + QTreeView +
edittreeview.h
+
+
+ + + + buttonBox + accepted() + BookmarksDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/cookies.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/cookies.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,106 @@ + + CookiesDialog + + + + 0 + 0 + 550 + 370 + + + + Cookies + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All Cookies + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTableView + QTableView +
edittableview.h
+
+
+ + + + buttonBox + accepted() + CookiesDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/cookiesexceptions.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/cookiesexceptions.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,184 @@ + + CookiesExceptionsDialog + + + + 0 + 0 + 466 + 446 + + + + Cookie Exceptions + + + + + + New Exception + + + + + + + + Domain: + + + + + + + + + + + + + + Qt::Horizontal + + + + 81 + 25 + + + + + + + + false + + + Block + + + + + + + false + + + Allow For Session + + + + + + + false + + + Allow + + + + + + + + + + + + Exceptions + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTableView + QTableView +
edittableview.h
+
+
+ + + + buttonBox + accepted() + CookiesExceptionsDialog + accept() + + + 381 + 428 + + + 336 + 443 + + + + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/downloaditem.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/downloaditem.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,134 @@ + + DownloadItem + + + + 0 + 0 + 423 + 110 + + + + Form + + + + 0 + + + + + + 0 + 0 + + + + Ico + + + + + + + + + + 0 + 0 + + + + Filename + + + + + + + 0 + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + Qt::Vertical + + + + 17 + 1 + + + + + + + + false + + + Try Again + + + + + + + Stop + + + + + + + Open + + + + + + + Qt::Vertical + + + + 17 + 5 + + + + + + + + + + + SqueezeLabel + QWidget +
squeezelabel.h
+
+
+ + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/downloads.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/downloads.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,83 @@ + + DownloadDialog + + + + 0 + 0 + 332 + 252 + + + + Downloads + + + + 0 + + + 0 + + + + + + + + + + false + + + Clean up + + + + + + + Qt::Horizontal + + + + 58 + 24 + + + + + + + + + + 0 Items + + + + + + + Qt::Horizontal + + + + 148 + 20 + + + + + + + + + EditTableView + QTableView +
edittableview.h
+
+
+ + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/history.d --- a/demos/browser/history.d Wed May 20 21:06:33 2009 +0000 +++ b/demos/browser/history.d Wed May 20 22:44:31 2009 +0000 @@ -38,40 +38,36 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + module history; -import QtCore.QBuffer; -import QtCore.QDir; -import QtCore.QFile; -import QtCore.QFileInfo; -import QtCore.QSettings; -import QtCore.QTemporaryFile; -import QtCore.QTextStream; +import qt.gui.QClipboard; +import qt.gui.QDesktopServices; +import qt.gui.QHeaderView; +import qt.gui.QStyle; +import qt.gui.QSortFilterProxyModel; -import QtCore.QtAlgorithms; - -import QtGui.QClipboard; -import QtGui.QDesktopServices; -import QtGui.QHeaderView; -import QtGui.QStyle; +import qt.core.QtAlgorithms; +import qt.core.QBuffer; +import qt.core.QDir; +import qt.core.QFile; +import qt.core.QFileInfo; +import qt.core.QSettings; +import qt.core.QTemporaryFile; +import qt.core.QTextStream; +import qt.core.QDebug; +import qt.core.QDateTime; +import qt.core.QHash; +import qt.core.QObject; +import qt.core.QTimer; +import qt.core.QUrl; import QtWebKit.QWebHistoryInterface; import QtWebKit.QWebSettings; -import QtCore.QDebug; - -import QtCore.QDateTime; -import QtCore.QHash; -import QtCore.QObject; -import QtCore.QTimer; -import QtCore.QUrl; - -import QtGui.QSortFilterProxyModel; - import QWebHistoryInterface; - import autosaver import browserapplication; import modelmenu; diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/history.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/history.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,106 @@ + + HistoryDialog + + + + 0 + 0 + 758 + 450 + + + + History + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTreeView + QTreeView +
edittreeview.h
+
+
+ + + + buttonBox + accepted() + HistoryDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + +
diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/passworddialog.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/passworddialog.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,111 @@ + + PasswordDialog + + + + 0 + 0 + 399 + 148 + + + + Authentication Required + + + + + + + + DUMMY ICON + + + + + + + + 0 + 0 + + + + INTRO TEXT DUMMY + + + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + PasswordDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + PasswordDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/proxy.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/proxy.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,104 @@ + + ProxyDialog + + + + 0 + 0 + 369 + 144 + + + + Proxy Authentication + + + + + + ICON + + + + + + + Connect to proxy + + + true + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ProxyDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProxyDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/searchlineedit.d --- a/demos/browser/searchlineedit.d Wed May 20 21:06:33 2009 +0000 +++ b/demos/browser/searchlineedit.d Wed May 20 22:44:31 2009 +0000 @@ -39,18 +39,17 @@ ** ****************************************************************************/ +module searchlineedit; + import urllineedit; -import QtGui.QLineEdit; -import QtGui.QAbstractButton; - -import searchlineedit; - -import QtGui.QPainter; -import QtGui.QMouseEvent; -import QtGui.QMenu; -import QtGui.QStyle; -import QtGui.QStyleOptionFrameV2; +import qt.gui.QLineEdit; +import qt.gui.QAbstractButton; +import qt.gui.QPainter; +import qt.gui.QMouseEvent; +import qt.gui.QMenu; +import qt.gui.QStyle; +import qt.gui.QStyleOptionFrameV2; /* QT_BEGIN_NAMESPACE @@ -67,46 +66,42 @@ */ class ClearButton : public QAbstractButton { - Q_OBJECT +public: -public: - this(QWidget *parent = null) -{ - super(parent); - setCursor(Qt.ArrowCursor); - setToolTip(tr("Clear")); - setVisible(false); - setFocusPolicy(Qt.NoFocus); -} - void paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter painter(this); - int height = this.height(); + this(QWidget parent = null) + { + super(parent); + setCursor(Qt.ArrowCursor); + setToolTip(tr("Clear")); + setVisible(false); + setFocusPolicy(Qt.NoFocus); + } + + void paintEvent(QPaintEvent *event) + { + //Q_UNUSED(event); + QPainter painter(this); + int height = this.height(); - painter.setRenderHint(QPainter::Antialiasing, true); - QColor color = palette().color(QPalette.Mid); - painter.setBrush(isDown() - ? palette().color(QPalette.Dark) - : palette().color(QPalette.Mid)); - painter.setPen(painter.brush().color()); - int size = width(); - int offset = size / 5; - int radius = size - offset * 2; - painter.drawEllipse(offset, offset, radius, radius); + painter.setRenderHint(QPainter.Antialiasing, true); + QColor color = palette().color(QPalette.Mid); + painter.setBrush(isDown() ? palette().color(QPalette.Dark) : palette().color(QPalette.Mid)); + painter.setPen(painter.brush().color()); + int size = width(); + int offset = size / 5; + int radius = size - offset * 2; + painter.drawEllipse(offset, offset, radius, radius); - painter.setPen(palette().color(QPalette.Base)); - int border = offset * 2; - painter.drawLine(border, border, width() - border, height - border); - painter.drawLine(border, height - border, width() - border, border); -} + painter.setPen(palette().color(QPalette.Base)); + int border = offset * 2; + painter.drawLine(border, border, width() - border, height - border); + painter.drawLine(border, height - border, width() - border, border); + } -public slots: - void textChanged(QString &text) -{ - setVisible(!text.isEmpty()); -} - + void textChanged(QString &text) + { + setVisible(!text.isEmpty()); + } } /* @@ -114,75 +109,76 @@ When a menu is set a down arrow appears */ class SearchButton : public QAbstractButton { + public: - SearchButton(QWidget *parent = null) -{ - super(parent); - m_menu = 0; - setObjectName(QLatin1String("SearchButton")); - setCursor(Qt.ArrowCursor); - setFocusPolicy(Qt.NoFocus); -} - void paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainterPath myPath; + SearchButton(QWidget parent = null) + { + super(parent); + m_menu = 0; + setObjectName(QLatin1String("SearchButton")); + setCursor(Qt.ArrowCursor); + setFocusPolicy(Qt.NoFocus); + } - int radius = (height() / 5) * 2; - QRect circle(height() / 3 - 1, height() / 4, radius, radius); - myPath.addEllipse(circle); + void paintEvent(QPaintEvent event) + { + //Q_UNUSED(event); + QPainterPath myPath; + + int radius = (height() / 5) * 2; + QRect circle(height() / 3 - 1, height() / 4, radius, radius); + myPath.addEllipse(circle); - myPath.arcMoveTo(circle, 300); - QPointF c = myPath.currentPosition(); - int diff = height() / 7; - myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff); + myPath.arcMoveTo(circle, 300); + QPointF c = myPath.currentPosition(); + int diff = height() / 7; + myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt.darkGray, 2)); - painter.drawPath(myPath); + QPainter painter(this); + painter.setRenderHint(QPainter.Antialiasing, true); + painter.setPen(QPen(Qt.darkGray, 2)); + painter.drawPath(myPath); - if (m_menu) { - QPainterPath dropPath; - dropPath.arcMoveTo(circle, 320); - QPointF c = dropPath.currentPosition(); - c = QPointF(c.x() + 3.5, c.y() + 0.5); - dropPath.moveTo(c); - dropPath.lineTo(c.x() + 4, c.y()); - dropPath.lineTo(c.x() + 2, c.y() + 2); - dropPath.closeSubpath(); - painter.setPen(Qt.darkGray); - painter.setBrush(Qt.darkGray); - painter.setRenderHint(QPainter::Antialiasing, false); - painter.drawPath(dropPath); - } - painter.end(); -} - QMenu *m_menu; + if (m_menu) { + QPainterPath dropPath; + dropPath.arcMoveTo(circle, 320); + QPointF c = dropPath.currentPosition(); + c = QPointF(c.x() + 3.5, c.y() + 0.5); + dropPath.moveTo(c); + dropPath.lineTo(c.x() + 4, c.y()); + dropPath.lineTo(c.x() + 2, c.y() + 2); + dropPath.closeSubpath(); + painter.setPen(Qt.darkGray); + painter.setBrush(Qt.darkGray); + painter.setRenderHint(QPainter.Antialiasing, false); + painter.drawPath(dropPath); + } + painter.end(); + } + + QMenu m_menu; protected: - void mousePressEvent(QMouseEvent *event) -{ - if (m_menu && event.button() == Qt.LeftButton) { - QWidget *p = parentWidget(); - if (p) { - QPoint r = p.mapToGlobal(QPoint(0, p.height())); - m_menu.exec(QPoint(r.x() + height() / 2, r.y())); - } - event.accept(); - } - QAbstractButton::mousePressEvent(event); -} + void mousePressEvent(QMouseEvent event) + { + if (m_menu && event.button() == Qt.LeftButton) { + QWidget p = parentWidget(); + if (p) { + QPoint r = p.mapToGlobal(QPoint(0, p.height())); + m_menu.exec(QPoint(r.x() + height() / 2, r.y())); + } + event.accept(); + } + QAbstractButton.mousePressEvent(event); + } } class SearchLineEdit : public ExLineEdit { - Q_OBJECT - Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText) + //Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText) -signals: - void textChanged(QString &text); + mixin Signal!("textChanged", QString &text); public: /* @@ -191,82 +187,81 @@ - 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)) -{ - connect(lineEdit(), SIGNAL(textChanged(QString &)), - this, SIGNAL(textChanged(QString &))); - setLeftWidget(m_searchButton); - m_inactiveText = tr("Search"); + this(QWidget parent = null) : ExLineEdit(parent) + { + m_searchButton = new SearchButton(this); + lineEdit.textChanged.connect(&this.textChanged); + setLeftWidget(m_searchButton); + m_inactiveText = tr("Search"); - QSizePolicy policy = sizePolicy(); - setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); -} + QSizePolicy policy = sizePolicy(); + setSizePolicy(QSizePolicy.Preferred, policy.verticalPolicy()); + } - QString inactiveText() -{ - return m_inactiveText; -} + QString inactiveText() + { + return m_inactiveText; + } - void setInactiveText(QString &text) -{ - m_inactiveText = text; -} + void setInactiveText(QString &text) + { + m_inactiveText = text; + } - QMenu *menu() -{ - if (!m_searchButton.m_menu) { - m_searchButton.m_menu = new QMenu(m_searchButton); - if (isVisible()) - (const_cast(this)).updateGeometries(); - } - return m_searchButton.m_menu; -} + QMenu menu() + { + if (!m_searchButton.m_menu) { + m_searchButton.m_menu = new QMenu(m_searchButton); + if (isVisible()) + (const_cast(this)).updateGeometries(); + } + return m_searchButton.m_menu; + } - void setMenu(QMenu *menu) -{ - if (m_searchButton.m_menu) - m_searchButton.m_menu.deleteLater(); - m_searchButton.m_menu = menu; - updateGeometries(); -} + void setMenu(QMenu menu) + { + if (m_searchButton.m_menu) + m_searchButton.m_menu.deleteLater(); + m_searchButton.m_menu = menu; + updateGeometries(); + } protected: - void resizeEvent(QResizeEvent *event) -{ - updateGeometries(); - ExLineEdit.resizeEvent(event); -} + void resizeEvent(QResizeEvent event) + { + updateGeometries(); + ExLineEdit.resizeEvent(event); + } - void paintEvent(QPaintEvent *event) -{ - if (lineEdit().text().isEmpty() && !hasFocus() && !m_inactiveText.isEmpty()) { - ExLineEdit.paintEvent(event); - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - QRect r = style().subElementRect(QStyle::SE_LineEditContents, &panel, this); - QFontMetrics fm = fontMetrics(); - int horizontalMargin = lineEdit().x(); - QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2, - r.width() - 2 * horizontalMargin, fm.height()); - QPainter painter(this); - painter.setPen(palette().brush(QPalette.Disabled, QPalette.Text).color()); - painter.drawText(lineRect, Qt.AlignLeft|Qt.AlignVCenter, m_inactiveText); - } else { - ExLineEdit.paintEvent(event); - } -} + void paintEvent(QPaintEvent event) + { + if (lineEdit().text().isEmpty() && !hasFocus() && !m_inactiveText.isEmpty()) { + ExLineEdit.paintEvent(event); + QStyleOptionFrameV2 panel; + initStyleOption(&panel); + QRect r = style().subElementRect(QStyle.SE_LineEditContents, &panel, this); + QFontMetrics fm = fontMetrics(); + int horizontalMargin = lineEdit().x(); + QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2, r.width() - 2 * horizontalMargin, fm.height()); + QPainter painter(this); + painter.setPen(palette().brush(QPalette.Disabled, QPalette.Text).color()); + painter.drawText(lineRect, Qt.AlignLeft|Qt.AlignVCenter, m_inactiveText); + } else { + ExLineEdit.paintEvent(event); + } + } private: - void updateGeometries() -{ - int menuHeight = height(); - int menuWidth = menuHeight + 1; - if (!m_searchButton.m_menu) - menuWidth = (menuHeight / 5) * 4; - m_searchButton.resize(QSize(menuWidth, menuHeight)); + + void updateGeometries() + { + int menuHeight = height(); + int menuWidth = menuHeight + 1; + if (!m_searchButton.m_menu) + menuWidth = (menuHeight / 5) * 4; + m_searchButton.resize(QSize(menuWidth, menuHeight)); + } + + SearchButton m_searchButton; + QString m_inactiveText; } - - SearchButton *m_searchButton; - QString m_inactiveText; -} diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/settings.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/browser/settings.ui Wed May 20 22:44:31 2009 +0000 @@ -0,0 +1,614 @@ + + Settings + + + + 0 + 0 + 657 + 322 + + + + Settings + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + 0 + + + + + 0 + 0 + 627 + 243 + + + + General + + + + + + Home: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Set to current page + + + + + + + Qt::Horizontal + + + + 280 + 18 + + + + + + + + Remove history items: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + After one day + + + + + After one week + + + + + After two weeks + + + + + After one month + + + + + After one year + + + + + Manually + + + + + + + + Save downloads to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Open links from applications: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + In a tab in the current window + + + + + In a new window + + + + + + + + Qt::Vertical + + + + 391 + 262 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Appearance + + + + + + Standard font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + Times 16 + + + Qt::AlignCenter + + + + + + + Select... + + + + + + + Fixed-width font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QFrame::StyledPanel + + + Courier 13 + + + Qt::AlignCenter + + + + + + + Select... + + + + + + + Qt::Vertical + + + + 20 + 93 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Privacy + + + + + + Web Content + + + + + + Enable Plugins + + + true + + + + + + + Enable Javascript + + + true + + + + + + + + + + Cookies + + + + + + Accept Cookies: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Always + + + + + Never + + + + + Only from sites you navigate to + + + + + + + + Exceptions... + + + + + + + Keep until: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + They expire + + + + + I exit the application + + + + + At most 90 days + + + + + + + + Cookies... + + + + + + + + + + Qt::Vertical + + + + 371 + 177 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Proxy + + + + + + Enable proxy + + + true + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Socks5 + + + + + Http + + + + + + + + Host: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 10000 + + + 1080 + + + + + + + Qt::Horizontal + + + + 293 + 20 + + + + + + + + User Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QLineEdit::Password + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + Advanced + + + + + + Style Sheet: + + + + + + + + + + Qt::Vertical + + + + 20 + 176 + + + + + + + + + + + + + + buttonBox + accepted() + Settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -r 9071511f7a5b -r b149ef2cb18b demos/browser/ui_downloaditem.d --- a/demos/browser/ui_downloaditem.d Wed May 20 21:06:33 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/******************************************************************************** -** Form generated from reading ui file 'downloaditem.ui' -** -** Created: Mon May 18 01:52:16 2009 -** by: Qt User Interface Compiler version 4.5.0 -** -** WARNING! All changes made in this file will be lost when recompiling ui file! -********************************************************************************/ - -import qt.core.QVariant; -import qt.gui.QAction; -import qt.gui.QApplication; -import qt.gui.QButtonGroup; -import qt.gui.QHBoxLayout; -import qt.gui.QHeaderView; -import qt.gui.QLabel; -import qt.gui.QProgressBar; -import qt.gui.QPushButton; -import qt.gui.QSpacerItem; -import qt.gui.QVBoxLayout; -import qt.gui.QWidget; -import squeezelabel; - - -class Ui_DownloadItem -{ -public: - QHBoxLayout horizontalLayout; - QLabel fileIcon; - QVBoxLayout verticalLayout_2; - SqueezeLabel fileNameLabel; - QProgressBar progressBar; - SqueezeLabel downloadInfoLabel; - QVBoxLayout verticalLayout; - QSpacerItem verticalSpacer; - QPushButton tryAgainButton; - QPushButton stopButton; - QPushButton openButton; - QSpacerItem verticalSpacer_2; - - void setupUi(QWidget DownloadItem) - { - if (DownloadItem.objectName().isEmpty()) - DownloadItem.setObjectName("DownloadItem"); - DownloadItem.resize(423, 110); - horizontalLayout = new QHBoxLayout(DownloadItem); - horizontalLayout.setMargin(0); - horizontalLayout.setObjectName("horizontalLayout"); - fileIcon = new QLabel(DownloadItem); - fileIcon.setObjectName("fileIcon"); - QSizePolicy sizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(fileIcon.sizePolicy().hasHeightForWidth()); - fileIcon.setSizePolicy(sizePolicy); - - horizontalLayout.addWidget(fileIcon); - - verticalLayout_2 = new QVBoxLayout(); - verticalLayout_2.setObjectName("verticalLayout_2")); - fileNameLabel = new SqueezeLabel(DownloadItem); - fileNameLabel.setObjectName("fileNameLabel")); - QSizePolicy sizePolicy1(QSizePolicy.Expanding, QSizePolicy.Preferred); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(fileNameLabel.sizePolicy().hasHeightForWidth()); - fileNameLabel.setSizePolicy(sizePolicy1); - - verticalLayout_2.addWidget(fileNameLabel); - - progressBar = new QProgressBar(DownloadItem); - progressBar.setObjectName("progressBar"); - progressBar.setValue(0); - - verticalLayout_2.addWidget(progressBar); - - downloadInfoLabel = new SqueezeLabel(DownloadItem); - downloadInfoLabel.setObjectName("downloadInfoLabel")); - QSizePolicy sizePolicy2(QSizePolicy.Minimum, QSizePolicy.Preferred); - sizePolicy2.setHorizontalStretch(0); - sizePolicy2.setVerticalStretch(0); - sizePolicy2.setHeightForWidth(downloadInfoLabel.sizePolicy().hasHeightForWidth()); - downloadInfoLabel.setSizePolicy(sizePolicy2); - - verticalLayout_2.addWidget(downloadInfoLabel); - - - horizontalLayout.addLayout(verticalLayout_2); - - verticalLayout = new QVBoxLayout(); - verticalLayout.setObjectName("verticalLayout")); - verticalSpacer = new QSpacerItem(17, 1, QSizePolicy.Minimum, QSizePolicy.Expanding); - - verticalLayout.addItem(verticalSpacer); - - tryAgainButton = new QPushButton(DownloadItem); - tryAgainButton.setObjectName("tryAgainButton"); - tryAgainButton.setEnabled(false); - - verticalLayout.addWidget(tryAgainButton); - - stopButton = new QPushButton(DownloadItem); - stopButton.setObjectName("stopButton"); - - verticalLayout.addWidget(stopButton); - - openButton = new QPushButton(DownloadItem); - openButton.setObjectName("openButton"); - - verticalLayout.addWidget(openButton); - - verticalSpacer_2 = new QSpacerItem(17, 5, QSizePolicy.Minimum, QSizePolicy.Expanding); - - verticalLayout.addItem(verticalSpacer_2); - - - horizontalLayout.addLayout(verticalLayout); - - - retranslateUi(DownloadItem); - - QMetaObject.connectSlotsByName(DownloadItem); - } // setupUi - - void retranslateUi(QWidget DownloadItem) - { - DownloadItem.setWindowTitle(QApplication.translate("DownloadItem", "Form", 0, QApplication.UnicodeUTF8)); - fileIcon.setText(QApplication.translate("DownloadItem", "Ico", 0, QApplication.UnicodeUTF8)); - fileNameLabel.setProperty("text", QVariant(QApplication.translate("DownloadItem", "Filename", 0, QApplication.UnicodeUTF8))); - downloadInfoLabel.setProperty("text", QVariant(QString())); - tryAgainButton.setText(QApplication.translate("DownloadItem", "Try Again", 0, QApplication.UnicodeUTF8)); - stopButton.setText(QApplication.translate("DownloadItem", "Stop", 0, QApplication.UnicodeUTF8)); - openButton.setText(QApplication.translate("DownloadItem", "Open", 0, QApplication.UnicodeUTF8)); - Q_UNUSED(DownloadItem); - } // retranslateUi - -} - - -class DownloadItem: public Ui_DownloadItem {}