From 1388bed0effca69e1fee0fb080eb035a3653f4c1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 24 Feb 2009 11:50:03 +0100 Subject: Documented API bookmarks && download classes. Fixed load on startup --- src/application.cpp | 18 ++++------- src/bookmarks.cpp | 4 ++- src/bookmarks.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/download.h | 17 ++++++++++- 4 files changed, 104 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index c4b4b38f..315c5cf1 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -65,6 +65,9 @@ Application::Application() m_mainWindow = new MainWindow(); m_mainWindow->setObjectName("MainWindow"); setWindowIcon( KIcon("rekonq") ); + newTab(); + mainWindow()->slotHome(); + m_mainWindow->show(); QTimer::singleShot(0, this, SLOT( postLaunch() ) ); @@ -75,7 +78,6 @@ Application::~Application() { delete s_networkAccessManager; delete s_historyManager; - delete m_mainWindow; } @@ -83,7 +85,7 @@ int Application::newInstance() { KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - static bool first = true; + if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) @@ -92,17 +94,9 @@ int Application::newInstance() newTab(); mainWindow()->loadUrl( url ); } + args->clear(); } - else - { - if( !first || !isSessionRestored()) - { - newTab(); - mainWindow()->slotHome(); - } - } - first = false; - args->clear(); + return 0; } diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 584b2689..a2ebf08a 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -37,8 +37,10 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) } -void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers ) +void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) { + Q_UNUSED(mb); + Q_UNUSED(km); emit openUrl( b.url() ); } diff --git a/src/bookmarks.h b/src/bookmarks.h index aa18834c..825c0d3a 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -31,40 +31,112 @@ class MainWindow; -/* +/** + * Inherited from KBookmarkOwner, this class allows to manage + * bookmarks as actions * + * @author Andrea Diamantini + * @since 4.x */ class OwnBookMarks : public QObject , public KBookmarkOwner { Q_OBJECT + public: - OwnBookMarks(KMainWindow *); - virtual void openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ); + /** + * The class ctor. + * + * @param parent the pointer to the browser mainwindow. We need it + * to link bookmarks actions with the right window + * where load url in + */ + OwnBookMarks(KMainWindow *parent); + + /** + * This function is called when a bookmark is selected and belongs to + * the ancestor class. + * This method actually emits signal to load bookmark's url without + * considering mousebuttons or keyboard modifiers. + * + * @param b the bookmark to open + * @param mb the mouse buttons clicked to select the bookmark + * @param km the keyboard modifiers pushed when the bookmark was selected + */ + virtual void openBookmark (const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); - // KBookmarkOwner interface: + + /** + * this method, from KBookmarkOwner interface, allows to add the current page + * to the bookmark list, returning the URL page as QString. + * + * @return the current page's URL + */ virtual QString currentUrl() const; + + /** + * this method, from KBookmarkOwner interface, allows to add the current page + * to the bookmark list, returning the title's page as QString. + * + * @return the current page's title + */ virtual QString currentTitle() const; signals: + /** + * This signal is emitted when an url has to be loaded + * + * @param url the URL to load + * + */ void openUrl(const KUrl &); private: + // the MainWindow pointer MainWindow *m_parent; }; + // ------------------------------------------------------------------------------ -/* + +/** + * This class represent the interface to rekonq bookmarks system. + * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided + * from this class. + * So it implements code to have each one + * + * @author Andrea Diamantini + * @since 4.x * */ class BookmarksProvider : public QObject { Q_OBJECT + public: - BookmarksProvider(KMainWindow*); + /** + * Class constructor. Connect BookmarksProvider with bookmarks source + * (actually konqueror's bookmarks) + * + * @param parent The MainWindow to provide bookmarks objects + * + */ + BookmarksProvider(KMainWindow* parent); + + /** + * Customize bookmarks toolbar + * + * @param toolbar the toolbar to customize + */ + void provideBmToolbar(KToolBar* toolbar); - void provideBmToolbar(KToolBar*); + /** + * Generate the Bookmarks Menu + * + * @return the Bookmarks Menu + * + */ KMenu *bookmarksMenu(); private: diff --git a/src/download.h b/src/download.h index cd363d00..a3ce9d23 100644 --- a/src/download.h +++ b/src/download.h @@ -29,16 +29,31 @@ #include #include -/* +/** * This class lets rekonq to download an object from the network. * Creating a new object, you can continue downloading a file also * when rekonq is closed. + * */ class Download : public QObject { Q_OBJECT public: + /** + * Class constructor. This is the unique method we need to + * use this class. In fact Download class needs to know just + * "where" catch the file to download and where it has to put it + * + * @param srcUrl the source url + * + * @param destUrl the destination url + * + */ Download(const KUrl &srcUrl, const KUrl &destUrl); + + /** + * class destructor + */ ~Download(); private slots: -- cgit v1.2.1