Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/browser/browsermainwindow.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8282    , m_reload(0)
    8383{
     84    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    8485    setAttribute(Qt::WA_DeleteOnClose, true);
    8586    statusBar()->setSizeGripEnabled(true);
     
    9091    BookmarksModel *boomarksModel = BrowserApplication::bookmarksManager()->bookmarksModel();
    9192    m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this);
    92     connect(m_bookmarksToolbar, SIGNAL(openUrl(const QUrl&)),
    93             m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
     93    connect(m_bookmarksToolbar, SIGNAL(openUrl(QUrl)),
     94            m_tabWidget, SLOT(loadUrlInCurrentTab(QUrl)));
    9495    connect(m_bookmarksToolbar->toggleViewAction(), SIGNAL(toggled(bool)),
    9596            this, SLOT(updateBookmarksToolbarActionText(bool)));
     
    109110        setCentralWidget(centralWidget);
    110111
    111     connect(m_tabWidget, SIGNAL(loadPage(const QString &)),
    112         this, SLOT(loadPage(const QString &)));
    113     connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)),
    114         this, SLOT(slotUpdateWindowTitle(const QString &)));
    115     connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)),
    116             statusBar(), SLOT(showMessage(const QString&)));
    117     connect(m_tabWidget, SIGNAL(linkHovered(const QString&)),
    118             statusBar(), SLOT(showMessage(const QString&)));
     112    connect(m_tabWidget, SIGNAL(loadPage(QString)),
     113        this, SLOT(loadPage(QString)));
     114    connect(m_tabWidget, SIGNAL(setCurrentTitle(QString)),
     115        this, SLOT(slotUpdateWindowTitle(QString)));
     116    connect(m_tabWidget, SIGNAL(showStatusBarMessage(QString)),
     117            statusBar(), SLOT(showMessage(QString)));
     118    connect(m_tabWidget, SIGNAL(linkHovered(QString)),
     119            statusBar(), SLOT(showMessage(QString)));
    119120    connect(m_tabWidget, SIGNAL(loadProgress(int)),
    120121            this, SLOT(slotLoadProgress(int)));
    121122    connect(m_tabWidget, SIGNAL(tabsChanged()),
    122123            m_autoSaver, SLOT(changeOccurred()));
    123     connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)),
    124             this, SLOT(geometryChangeRequested(const QRect &)));
    125     connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)),
    126             this, SLOT(printRequested(QWebFrame *)));
     124    connect(m_tabWidget, SIGNAL(geometryChangeRequested(QRect)),
     125            this, SLOT(geometryChangeRequested(QRect)));
     126    connect(m_tabWidget, SIGNAL(printRequested(QWebFrame*)),
     127            this, SLOT(printRequested(QWebFrame*)));
    127128    connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)),
    128129            menuBar(), SLOT(setVisible(bool)));
     
    369370    // History
    370371    HistoryMenu *historyMenu = new HistoryMenu(this);
    371     connect(historyMenu, SIGNAL(openUrl(const QUrl&)),
    372             m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
    373     connect(historyMenu, SIGNAL(hovered(const QString&)), this,
    374             SLOT(slotUpdateStatusbar(const QString&)));
     372    connect(historyMenu, SIGNAL(openUrl(QUrl)),
     373            m_tabWidget, SLOT(loadUrlInCurrentTab(QUrl)));
     374    connect(historyMenu, SIGNAL(hovered(QString)), this,
     375            SLOT(slotUpdateStatusbar(QString)));
    375376    historyMenu->setTitle(tr("Hi&story"));
    376377    menuBar()->addMenu(historyMenu);
     
    404405    // Bookmarks
    405406    BookmarksMenu *bookmarksMenu = new BookmarksMenu(this);
    406     connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)),
    407             m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
    408     connect(bookmarksMenu, SIGNAL(hovered(const QString&)),
    409             this, SLOT(slotUpdateStatusbar(const QString&)));
     407    connect(bookmarksMenu, SIGNAL(openUrl(QUrl)),
     408            m_tabWidget, SLOT(loadUrlInCurrentTab(QUrl)));
     409    connect(bookmarksMenu, SIGNAL(hovered(QString)),
     410            this, SLOT(slotUpdateStatusbar(QString)));
    410411    bookmarksMenu->setTitle(tr("&Bookmarks"));
    411412    menuBar()->addMenu(bookmarksMenu);
     
    455456    connect(m_historyBackMenu, SIGNAL(aboutToShow()),
    456457            this, SLOT(slotAboutToShowBackMenu()));
    457     connect(m_historyBackMenu, SIGNAL(triggered(QAction *)),
    458             this, SLOT(slotOpenActionUrl(QAction *)));
     458    connect(m_historyBackMenu, SIGNAL(triggered(QAction*)),
     459            this, SLOT(slotOpenActionUrl(QAction*)));
    459460    m_navigationBar->addAction(m_historyBack);
    460461
     
    463464    connect(m_historyForwardMenu, SIGNAL(aboutToShow()),
    464465            this, SLOT(slotAboutToShowForwardMenu()));
    465     connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)),
    466             this, SLOT(slotOpenActionUrl(QAction *)));
     466    connect(m_historyForwardMenu, SIGNAL(triggered(QAction*)),
     467            this, SLOT(slotOpenActionUrl(QAction*)));
    467468    m_historyForward->setMenu(m_historyForwardMenu);
    468469    m_navigationBar->addAction(m_historyForward);
     
    478479    m_toolbarSearch = new ToolbarSearch(m_navigationBar);
    479480    m_navigationBar->addWidget(m_toolbarSearch);
    480     connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&)));
     481    connect(m_toolbarSearch, SIGNAL(search(QUrl)), SLOT(loadUrl(QUrl)));
    481482
    482483    m_chaseWidget = new ChaseWidget(this);
     
    487488{
    488489    BookmarksDialog *dialog = new BookmarksDialog(this);
    489     connect(dialog, SIGNAL(openUrl(const QUrl&)),
    490             m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&)));
     490    connect(dialog, SIGNAL(openUrl(QUrl)),
     491            m_tabWidget, SLOT(loadUrlInCurrentTab(QUrl)));
    491492    dialog->show();
    492493}
     
    550551    }
    551552    m_autoSaver->changeOccurred();
    552 }
    553 
    554 QUrl BrowserMainWindow::guessUrlFromString(const QString &string)
    555 {
    556     QString urlStr = string.trimmed();
    557     QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*"));
    558 
    559     // Check if it looks like a qualified URL. Try parsing it and see.
    560     bool hasSchema = test.exactMatch(urlStr);
    561     if (hasSchema) {
    562         QUrl url = QUrl::fromEncoded(urlStr.toUtf8(), QUrl::TolerantMode);
    563         if (url.isValid())
    564             return url;
    565     }
    566 
    567     // Might be a file.
    568     if (QFile::exists(urlStr)) {
    569         QFileInfo info(urlStr);
    570         return QUrl::fromLocalFile(info.absoluteFilePath());
    571     }
    572 
    573     // Might be a shorturl - try to detect the schema.
    574     if (!hasSchema) {
    575         int dotIndex = urlStr.indexOf(QLatin1Char('.'));
    576         if (dotIndex != -1) {
    577             QString prefix = urlStr.left(dotIndex).toLower();
    578             QByteArray schema = (prefix == QLatin1String("ftp")) ? prefix.toLatin1() : "http";
    579             QUrl url =
    580                 QUrl::fromEncoded(schema + "://" + urlStr.toUtf8(), QUrl::TolerantMode);
    581             if (url.isValid())
    582                 return url;
    583         }
    584     }
    585 
    586     // Fall back to QUrl's own tolerant parser.
    587     QUrl url = QUrl::fromEncoded(string.toUtf8(), QUrl::TolerantMode);
    588 
    589     // finally for cases where the user just types in a hostname add http
    590     if (url.scheme().isEmpty())
    591         url = QUrl::fromEncoded("http://" + string.toUtf8(), QUrl::TolerantMode);
    592     return url;
    593553}
    594554
     
    677637        return;
    678638    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this);
    679     connect(dialog, SIGNAL(paintRequested(QPrinter *)),
    680             currentTab(), SLOT(print(QPrinter *)));
     639    connect(dialog, SIGNAL(paintRequested(QPrinter*)),
     640            currentTab(), SLOT(print(QPrinter*)));
    681641    dialog->exec();
    682642#endif
     
    740700        int ret = QMessageBox::warning(this, QString(),
    741701                           tr("Are you sure you want to close the window?"
    742                               "  There are %1 tab open").arg(m_tabWidget->count()),
     702                              "  There are %1 tabs open").arg(m_tabWidget->count()),
    743703                           QMessageBox::Yes | QMessageBox::No,
    744704                           QMessageBox::No);
     
    839799    QSettings settings;
    840800    settings.beginGroup(QLatin1String("MainWindow"));
    841     QString home = settings.value(QLatin1String("home"), QLatin1String("http://qtsoftware.com/")).toString();
     801    QString home = settings.value(QLatin1String("home"), QLatin1String("http://qt.nokia.com/")).toString();
    842802    loadPage(home);
    843803}
     
    873833void BrowserMainWindow::loadPage(const QString &page)
    874834{
    875     QUrl url = guessUrlFromString(page);
     835    QUrl url = QUrl::fromUserInput(page);
    876836    loadUrl(url);
    877837}
Note: See TracChangeset for help on using the changeset viewer.