diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyzer/networkanalyzer.cpp | 4 | ||||
| -rw-r--r-- | src/application.cpp | 59 | ||||
| -rw-r--r-- | src/application.h | 37 | ||||
| -rw-r--r-- | src/bookmarks/bookmarkspanel.cpp | 5 | ||||
| -rw-r--r-- | src/history/historymanager.cpp | 99 | ||||
| -rw-r--r-- | src/history/historymanager.h | 33 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 3 | ||||
| -rw-r--r-- | src/newtabpage.cpp | 2 | ||||
| -rw-r--r-- | src/webpage.cpp | 4 | 
9 files changed, 120 insertions, 126 deletions
diff --git a/src/analyzer/networkanalyzer.cpp b/src/analyzer/networkanalyzer.cpp index 47713557..1cf45e66 100644 --- a/src/analyzer/networkanalyzer.cpp +++ b/src/analyzer/networkanalyzer.cpp @@ -168,7 +168,7 @@ void NetworkAnalyzer::showItemDetails( QTreeWidgetItem *item )      QString details;      QNetworkRequest req = _itemRequestMap[item]; -    details += QL1S("<h3>Request Details</h3>"); +    details += i18n("<h3>Request Details</h3>");      details += QL1S("<ul>");      foreach(const QByteArray &header, req.rawHeaderList() )       { @@ -181,7 +181,7 @@ void NetworkAnalyzer::showItemDetails( QTreeWidgetItem *item )      details += QL1S("</ul>");      QPair< QList<QByteArray>, QList<QByteArray> > replyHeaders = _itemReplyMap[item]; -    details += QL1S("<h3>Response Details</h3>"); +    details += i18n("<h3>Response Details</h3>");      details += QL1S("<ul>");      for ( int i = 0; i < replyHeaders.first.count(); i++ )       { diff --git a/src/application.cpp b/src/application.cpp index 5b98fafa..07a3067b 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -548,3 +548,62 @@ void Application::updateConfiguration()      defaultSettings = 0;  } + + + + +void Application::addDownload(const QString &srcUrl, const QString &destUrl) +{ +    QWebSettings *globalSettings = QWebSettings::globalSettings(); +    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) +        return; +    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); +    QFile downloadFile(downloadFilePath); +    if (!downloadFile.open(QFile::WriteOnly | QFile::Append)) +    { +        kDebug() << "Unable to open download file (WRITE mode).."; +        return; +    } +    QDataStream out(&downloadFile); +    out << srcUrl; +    out << destUrl; +    out << QDateTime::currentDateTime(); +    downloadFile.close(); +} + + +DownloadList Application::downloads() +{ +    DownloadList list; + +    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); +    QFile downloadFile(downloadFilePath); +    if (!downloadFile.open(QFile::ReadOnly)) +    { +        kDebug() << "Unable to open download file (READ mode).."; +        return list; +    } + +    QDataStream in(&downloadFile); +    while (!in.atEnd()) +    { +        QString srcUrl; +        in >> srcUrl; +        QString destUrl; +        in >> destUrl; +        QDateTime dt; +        in >> dt; +        DownloadItem item(srcUrl, destUrl, dt); +        list << item; +    } +    return list; +} + + +bool Application::clearDownloadsHistory() +{ +    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); +    QFile downloadFile(downloadFilePath); +    return downloadFile.remove(); +} + diff --git a/src/application.h b/src/application.h index 7b58ab18..18c99afb 100644 --- a/src/application.h +++ b/src/application.h @@ -56,6 +56,38 @@ class WebView;  typedef QList< QWeakPointer<MainWindow> > MainWindowList; +// --------------------------------------------------------------------------------------------------------------- + + +#include <QDateTime> + + +class DownloadItem +{ +public: +    DownloadItem() {} +    explicit DownloadItem(const QString &srcUrl, +                          const QString &destUrl, +                          const QDateTime &d +                         ) +            : srcUrlString(srcUrl) +            , destUrlString(destUrl) +            , dateTime(d) +    {} + +    QString srcUrlString; +    QString destUrlString; +    QDateTime dateTime; +}; + + +typedef QList<DownloadItem> DownloadList; + + +// --------------------------------------------------------------------------------------------------------------- + + +  /**    *    */ @@ -80,6 +112,11 @@ public:      static SessionManager *sessionManager();      static AdBlockManager *adblockManager(); +    // DOWNLOADS MANAGEMENT METHODS +    void addDownload(const QString &srcUrl, const QString &destUrl); +    DownloadList downloads(); +    bool clearDownloadsHistory(); +  public slots:      /**       * Save application's configuration diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 25aab516..19db148b 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -218,6 +218,7 @@ void BookmarksPanel::deleteBookmark()          return;      KBookmark bm = bookmarkForIndex(index); +    KBookmarkGroup bmg = bm.parentGroup();      bool folder = bm.isGroup();      if (KMessageBox::warningContinueCancel( @@ -232,6 +233,6 @@ void BookmarksPanel::deleteBookmark()          return; -    bm.parentGroup().deleteBookmark(bm); -    Application::instance()->bookmarkProvider()->bookmarkManager()->emitChanged(); +    bmg.deleteBookmark(bm); +    Application::instance()->bookmarkProvider()->bookmarkManager()->emitChanged(bmg);  } diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp index 99862205..966487a9 100644 --- a/src/history/historymanager.cpp +++ b/src/history/historymanager.cpp @@ -115,6 +115,10 @@ bool HistoryManager::historyContains(const QString &url) const  void HistoryManager::addHistoryEntry(const QString &url)  { +    QWebSettings *globalSettings = QWebSettings::globalSettings(); +    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) +        return; +          QUrl cleanUrl(url);      // don't store about: urls (home page related) @@ -124,7 +128,13 @@ void HistoryManager::addHistoryEntry(const QString &url)      cleanUrl.setPassword(QString());      cleanUrl.setHost(cleanUrl.host().toLower());      HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime()); -    addHistoryEntry(item); + +    m_history.prepend(item); +    addHistoryHashEntry(item); +    emit entryAdded(item); + +    if (m_history.count() == 1) +        checkForExpired();  } @@ -210,20 +220,6 @@ void HistoryManager::checkForExpired()  } -void HistoryManager::addHistoryEntry(const HistoryItem &item) -{ -    QWebSettings *globalSettings = QWebSettings::globalSettings(); -    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) -        return; - -    m_history.prepend(item); -    addHistoryHashEntry(item); -    emit entryAdded(item); - -    if (m_history.count() == 1) -        checkForExpired(); -} -  void HistoryManager::addHistoryHashEntry(const HistoryItem &item)  {      if (m_hash.contains(item.url)) @@ -265,18 +261,6 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)  } -void HistoryManager::removeHistoryEntry(const HistoryItem &item) -{ -    m_lastSavedUrl.clear(); -    m_history.removeOne(item); -    if (m_hash.contains(item.url) && m_hash[item.url].savedCount>0) -    { -        m_hash[item.url].savedCount--; //this counter is used for expired urls -    } -    emit entryRemoved(item); -} - -  void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)  {      HistoryItem item; @@ -286,7 +270,9 @@ void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)                  && (title.isEmpty() || title == m_history.at(i).title))          {              item = m_history.at(i); -            removeHistoryEntry(item); +            m_lastSavedUrl.clear(); +            m_history.removeOne(item); +            emit entryRemoved(item);              break;          }      } @@ -494,60 +480,3 @@ void HistoryManager::save()      }      m_lastSavedUrl = m_history.value(0).url;  } - - -void HistoryManager::addDownload(const QString &srcUrl, const QString &destUrl) -{ -    QWebSettings *globalSettings = QWebSettings::globalSettings(); -    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) -        return; -    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); -    QFile downloadFile(downloadFilePath); -    if (!downloadFile.open(QFile::WriteOnly | QFile::Append)) -    { -        kDebug() << "Unable to open download file (WRITE mode).."; -        return; -    } -    QDataStream out(&downloadFile); -    out << srcUrl; -    out << destUrl; -    out << QDateTime::currentDateTime(); -    downloadFile.close(); -} - - -DownloadList HistoryManager::downloads() -{ -    DownloadList list; - -    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); -    QFile downloadFile(downloadFilePath); -    if (!downloadFile.open(QFile::ReadOnly)) -    { -        kDebug() << "Unable to open download file (READ mode).."; -        return list; -    } - -    QDataStream in(&downloadFile); -    while (!in.atEnd()) -    { -        QString srcUrl; -        in >> srcUrl; -        QString destUrl; -        in >> destUrl; -        QDateTime dt; -        in >> dt; -        DownloadItem item(srcUrl, destUrl, dt); -        list << item; -    } -    return list; -} - - -bool HistoryManager::clearDownloadsHistory() -{ -    QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); -    QFile downloadFile(downloadFilePath); -    return downloadFile.remove(); -} - diff --git a/src/history/historymanager.h b/src/history/historymanager.h index c1627530..85702b84 100644 --- a/src/history/historymanager.h +++ b/src/history/historymanager.h @@ -106,29 +106,6 @@ public:      int savedCount;  }; -// --------------------------------------------------------------------------------------------------------------- - - -class DownloadItem -{ -public: -    DownloadItem() {} -    explicit DownloadItem(const QString &srcUrl, -                          const QString &destUrl, -                          const QDateTime &d -                         ) -            : srcUrlString(srcUrl) -            , destUrlString(destUrl) -            , dateTime(d) -    {} - -    QString srcUrlString; -    QString destUrlString; -    QDateTime dateTime; -}; - - -typedef QList<DownloadItem> DownloadList;  // --------------------------------------------------------------------------------------------------------------- @@ -178,10 +155,6 @@ public:      HistoryFilterModel *historyFilterModel() const;      HistoryTreeModel *historyTreeModel() const; -    void addDownload(const QString &srcUrl, const QString &destUrl); -    DownloadList downloads(); -    bool clearDownloadsHistory(); -  public slots:      void clear();      void loadSettings(); @@ -190,12 +163,8 @@ private slots:      void save();      void checkForExpired(); -protected: -    void addHistoryEntry(const HistoryItem &item); -    void removeHistoryEntry(const HistoryItem &item); -    void addHistoryHashEntry(const HistoryItem &item); -  private: +    void addHistoryHashEntry(const HistoryItem &item);      void load();      AutoSaver *m_saveTimer; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 81eff496..55cc7a69 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -223,7 +223,6 @@ void MainWindow::setupToolbars()          m_bmBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);          m_bmBar->setIconDimensions(16); -        m_bmBar->hide();          KToolBar::setToolBarsEditable(false);          KToolBar::setToolBarsLocked(true); @@ -1207,7 +1206,7 @@ void MainWindow::clearPrivateData()          if (clearWidget.clearDownloads->isChecked())          { -            Application::historyManager()->clearDownloadsHistory(); +            Application::instance()->clearDownloadsHistory();          }          if (clearWidget.clearCookies->isChecked()) diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index cbdbe306..bbf6714e 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -549,7 +549,7 @@ void NewTabPage::downloadsPage()      clearData.findFirst("span").appendInside(i18n("Clear Private Data"));      m_root.document().findFirst("#actions").appendInside(clearData); -    DownloadList list = Application::historyManager()->downloads(); +    DownloadList list = Application::instance()->downloads();      if (list.isEmpty())      { diff --git a/src/webpage.cpp b/src/webpage.cpp index 939d7128..a63940b0 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -136,8 +136,8 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData      }       while (result == KIO::R_CANCEL && destUrl.isValid()); -    // Save download on history manager -    Application::historyManager()->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl()); +    // Save download history +    Application::instance()->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl());      if (ReKonfig::kgetDownload())      {  | 
