diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-05-27 12:00:28 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-05-27 23:34:32 +0200 |
commit | a33b32930451d479108fce701267f6c8bdc19319 (patch) | |
tree | dd45422752326580e8596e0aac3e047b976faca7 /src | |
parent | Fancy bookmarking on rekonq :) (diff) | |
download | rekonq-a33b32930451d479108fce701267f6c8bdc19319.tar.xz |
Let nepomuk dependencies being optional
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 53 | ||||
-rw-r--r-- | src/bookmarks/bookmarkowner.cpp | 39 | ||||
-rw-r--r-- | src/bookmarks/bookmarkowner.h | 7 | ||||
-rw-r--r-- | src/bookmarks/bookmarkscontextmenu.cpp | 5 | ||||
-rw-r--r-- | src/urlbar/bookmarkwidget.cpp | 159 | ||||
-rw-r--r-- | src/urlbar/bookmarkwidget.h | 42 |
6 files changed, 183 insertions, 122 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afdb9ec9..5aa70dbf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,8 +84,6 @@ SET( rekonq_KDEINIT_SRCS urlbar/bookmarkwidget.cpp urlbar/webshortcutwidget.cpp urlbar/favoritewidget.cpp - urlbar/resourcelinkdialog.cpp - urlbar/newresourcedialog.cpp #---------------------------------------- analyzer/analyzerpanel.cpp analyzer/networkanalyzer.cpp @@ -114,6 +112,13 @@ SET( rekonq_KDEINIT_SRCS sync/syncgooglesettingswidget.cpp ) +IF(HAVE_NEPOMUK) + SET( rekonq_KDEINIT_SRCS + ${rekonq_KDEINIT_SRCS} + urlbar/resourcelinkdialog.cpp + urlbar/newresourcedialog.cpp + ) +ENDIF(HAVE_NEPOMUK) KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS settings/settings_general.ui @@ -140,10 +145,10 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS ) KDE4_ADD_KCFG_FILES( rekonq_KDEINIT_SRCS rekonq.kcfgc ) -find_package(KDE4 REQUIRED) -find_package(Nepomuk REQUIRED) -include(SopranoAddOntology) -include (KDE4Defaults) + +IF(HAVE_NEPOMUK) + INCLUDE(SopranoAddOntology) +ENDIF(HAVE_NEPOMUK) ### ------------- INCLUDING DIRECTORIES... @@ -160,11 +165,13 @@ INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${QT4_INCLUDES} - ${SOPRANO_INCLUDE_DIR} - ${CMAKE_SOURCE_DIR} - ${NEPOMUK_INCLUDE_DIR} ) +IF(HAVE_NEPOMUK) + INCLUDE_DIRECTORIES(${SOPRANO_INCLUDE_DIR} + ${NEPOMUK_INCLUDE_DIR} + ) +ENDIF(HAVE_NEPOMUK) ### -------------- ADDING DEFINITIONS... @@ -181,20 +188,24 @@ KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp ) ### --------------- TARGETTING LINK LIBRARIES... -TARGET_LINK_LIBRARIES ( kdeinit_rekonq - ${QT_LIBRARIES} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} - ${KDE4_KDEWEBKIT_LIBS} - ${KDE4_KUTILS_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KIO_LIBS} - ${KDE4_KPARTS_LIBS} - ${NEPOMUK_LIBRARIES} - ${NEPOMUK_QUERY_LIBRARIES} - ${SOPRANO_LIBRARIES} +TARGET_LINK_LIBRARIES ( kdeinit_rekonq + ${QT_LIBRARIES} + ${QT_QTSCRIPT_LIBRARY} + ${QT_QTWEBKIT_LIBRARY} + ${KDE4_KDEWEBKIT_LIBS} + ${KDE4_KUTILS_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KPARTS_LIBS} ) +IF(HAVE_NEPOMUK) + TARGET_LINK_LIBRARIES( kdeinit_rekonq + ${NEPOMUK_LIBRARIES} + ${NEPOMUK_QUERY_LIBRARIES} + ${SOPRANO_LIBRARIES} + ) +ENDIF(HAVE_NEPOMUK) ### ------------ INSTALL FILES... diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp index 74683874..6cea5e9c 100644 --- a/src/bookmarks/bookmarkowner.cpp +++ b/src/bookmarks/bookmarkowner.cpp @@ -37,19 +37,27 @@ #include "mainview.h" #include "mainwindow.h" #include "webtab.h" -#include "resourcelinkdialog.h" // KDE Includes #include <KBookmarkDialog> #include <KLocalizedString> #include <KMessageBox> -#include <Nepomuk/Resource> -#include <Nepomuk/Vocabulary/NFO> - // Qt Includes #include <QClipboard> +// Nepomuk config include +#include "../config-nepomuk.h" + +#ifdef HAVE_NEPOMUK + // Local Nepomuk Includes + #include "resourcelinkdialog.h" + + // Nepomuk Includes + #include <Nepomuk/Resource> + #include <Nepomuk/Vocabulary/NFO> +#endif + BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent) : QObject(parent) @@ -90,9 +98,11 @@ KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAc case EDIT: return createAction(i18n("Edit"), "configure", i18n("Edit the bookmark"), SLOT(editBookmark(KBookmark)), bookmark); +#ifdef HAVE_NEPOMUK case FANCYBOOKMARK: return createAction(i18n("Fancy Bookmark"), "nepomuk", i18n("Link Nepomuk resources"), SLOT(fancyBookmark(KBookmark)), bookmark); +#endif case DELETE: return createAction(i18n("Delete"), "edit-delete", i18n("Delete the bookmark"), SLOT(deleteBookmark(KBookmark)), bookmark); @@ -212,12 +222,12 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark) else { parent = rApp->bookmarkManager()->rootGroup(); +#ifdef HAVE_NEPOMUK Nepomuk::Resource nfoResource; nfoResource = ((QUrl)currentUrl()); nfoResource.addType( Nepomuk::Vocabulary::NFO::Website() ); nfoResource.setLabel( currentTitle() ); - qDebug()<<nfoResource.uri(); - +#endif } KBookmark newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl())); @@ -310,13 +320,16 @@ void BookmarkOwner::editBookmark(KBookmark bookmark) delete dialog; } -void BookmarkOwner::fancyBookmark(KBookmark bookmark) -{ - Nepomuk::Resource nfoResource = (KUrl)bookmark.url(); - Nepomuk::ResourceLinkDialog r( nfoResource ); - r.exec(); -} +#ifdef HAVE_NEPOMUK + void BookmarkOwner::fancyBookmark(KBookmark bookmark) + { + Nepomuk::Resource nfoResource = (KUrl)bookmark.url(); + Nepomuk::ResourceLinkDialog r( nfoResource ); + r.exec(); + + } +#endif bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) { @@ -354,8 +367,10 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark) return false; bmg.deleteBookmark(bookmark); +#ifdef HAVE_NEPOMUK Nepomuk::Resource nfoResource(bookmark.url()); nfoResource.remove(); +#endif m_manager->emitChanged(bmg); return true; } diff --git a/src/bookmarks/bookmarkowner.h b/src/bookmarks/bookmarkowner.h index a9712d55..01a5c480 100644 --- a/src/bookmarks/bookmarkowner.h +++ b/src/bookmarks/bookmarkowner.h @@ -34,6 +34,9 @@ // Rekonq Includes #include "rekonq_defines.h" +// Nepomuk config include +#include "../config-nepomuk.h" + // KDE Includes #include <KAction> #include <KBookmarkOwner> @@ -60,7 +63,9 @@ public: NEW_SEPARATOR, COPY, EDIT, +#ifdef HAVE_NEPOMUK FANCYBOOKMARK, +#endif DELETE, NUM_ACTIONS, SET_TOOLBAR_FOLDER, @@ -108,7 +113,9 @@ public Q_SLOTS: void copyLink(const KBookmark &bookmark); void editBookmark(KBookmark bookmark); +#ifdef HAVE_NEPOMUK void fancyBookmark(KBookmark bookmark); +#endif bool deleteBookmark(const KBookmark &bookmark); void setToolBarFolder(KBookmark bookmark = KBookmark()); void unsetToolBarFolder(); diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp index bc8f0e3a..b49f6883 100644 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ b/src/bookmarks/bookmarkscontextmenu.cpp @@ -27,6 +27,9 @@ // Self Includes #include "bookmarkscontextmenu.h" +// Nepomuk config include +#include "../config-nepomuk.h" + // Local Includes #include "bookmarkowner.h" #include "bookmarkmanager.h" @@ -67,7 +70,9 @@ void BookmarksContextMenu::addBookmarkActions() addSeparator(); addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT)); +#ifdef HAVE_NEPOMUK addAction(m_bmOwner->createAction(bookmark(),BookmarkOwner::FANCYBOOKMARK)); +#endif addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE)); } diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index ea278218..f73e5eb4 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -33,7 +33,6 @@ #include "application.h" #include "bookmarkmanager.h" #include "bookmarkowner.h" -#include "resourcelinkdialog.h" // KDE Includes #include <KComboBox> @@ -50,8 +49,16 @@ #include <QCompleter> #include <QTextCursor> -//Nepomuk Includes -#include <Soprano/Vocabulary/NAO> +// Nepomuk config include +#include "../config-nepomuk.h" + +#ifdef HAVE_NEPOMUK + // Local Nepomuk Includes + #include "resourcelinkdialog.h" + + //Nepomuk Includes + #include <Soprano/Vocabulary/NAO> +#endif @@ -62,13 +69,12 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(320); +#ifdef HAVE_NEPOMUK m_nfoResource = (QUrl)m_bookmark->url(); - +#endif + QFormLayout *layout = new QFormLayout(this); layout->setHorizontalSpacing(20); - // Bookmark icon -// QLabel *bookmarkIcon = new QLabel(this); -// bookmarkIcon->setPixmap(KIcon("bookmarks").pixmap(32, 32)); // Title QHBoxLayout *hLayout = new QHBoxLayout; @@ -78,7 +84,6 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) f.setBold(true); bookmarkInfo->setFont(f); - // Remove button QLabel *removeLabel = new QLabel( this ); removeLabel->setText( i18n( "<a href='Remove'>Remove</a>" ) ); @@ -89,14 +94,6 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) connect(removeLabel, SIGNAL( linkActivated(QString) ), this, SLOT( removeBookmark() )); - /* - QPushButton *removeButton = new QPushButton(this); - removeButton->setText(i18n("Remove this Bookmark")); - connect(removeButton, SIGNAL(clicked()), this, SLOT(removeBookmark())); - vLayout->addWidget(removeButton); -*/ - //layout->addRow(bookmarkIcon, vLayout); - //Bookmark Folder QLabel *folderLabel = new QLabel(this); folderLabel->setText(i18n("Folder:")); @@ -120,6 +117,7 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) } layout->addRow(nameLabel, m_name); +#ifdef HAVE_NEPOMUK QLabel* rateLabel = new QLabel(this); rateLabel->setText( i18n( "Rate:" ) ); KRatingWidget *ratingWidget = new KRatingWidget( this ); @@ -141,14 +139,13 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) connect( m_commentEdit, SIGNAL(textChanged()), this, SLOT(addCommentSlot()) ); layout->addRow( commentLabel, m_commentEdit ); - //Create tags + // Create tags QLabel *tagLabel = new QLabel( this ); tagLabel->setText( i18n( "Tags:" ) ); tagLabel->setAlignment( Qt::AlignLeft ); m_tagLine = new KLineEdit( this ); m_tagLine->setPlaceholderText( i18n( "add tags(comma separated)" ) ); - //m_tagList = new QGridLayout( this ); QList<Nepomuk::Tag> tagList = Nepomuk::Tag::allTags(); Q_FOREACH(Nepomuk::Tag t,tagList) { @@ -159,14 +156,14 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) m_tagLine->setCompleter(completeTag); loadTags(); - // connect( m_tagLine,SIGNAL( textEdited(QString) ),this,SLOT( tagListSlot() ) ); layout->addRow(tagLabel,m_tagLine); -// layout->addRow(m_tagList); QPushButton *linkToResource = new QPushButton( this ); linkToResource->setText( i18n( "Link Resources" ) ); connect(linkToResource, SIGNAL(clicked()), this, SLOT( linkToResourceSlot() ) ); layout->addWidget(linkToResource); +#endif + // Ok & Cancel buttons QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); @@ -205,8 +202,11 @@ void BookmarkWidget::accept() parent.deleteBookmark(*m_bookmark); a.addBookmark(*m_bookmark); rApp->bookmarkManager()->manager()->emitChanged(a); - parseTags(); +#ifdef HAVE_NEPOMUK + parseTags(); +#endif + close(); } @@ -263,67 +263,78 @@ void BookmarkWidget::removeBookmark() } - -void BookmarkWidget::addTags(QList<Nepomuk::Tag> tagList) -{ - foreach( const Nepomuk::Tag &tag,tagList) { - if(!m_nfoResource.tags().contains(tag)) { - m_nfoResource.addTag(tag); +#ifdef HAVE_NEPOMUK + void BookmarkWidget::addTags(QList<Nepomuk::Tag> tagList) + { + foreach ( const Nepomuk::Tag &tag,tagList) + { + if (!m_nfoResource.tags().contains(tag)) + { + m_nfoResource.addTag(tag); + } + } + foreach ( Nepomuk::Tag tag,m_nfoResource.tags()) + { + if (!tagList.contains(tag)) + { + tag.remove(); + } } } - foreach( Nepomuk::Tag tag,m_nfoResource.tags()) { - if(!tagList.contains(tag)) { - tag.remove(); + + void BookmarkWidget::parseTags() + { + QList<Nepomuk::Tag> tagList; + if(m_tagLine->text().contains(',')) + { + QString text = m_tagLine->text(); + QStringList tagStringList = text.split( QChar::fromAscii(',') ); + + foreach( const QString &tag, tagStringList ) + { + QString trimmedTag = tag.trimmed(); + if (!trimmedTag.isEmpty()) + tagList << trimmedTag; + } + } + else + { + tagList << m_tagLine->text().trimmed(); } + addTags(tagList); } -} -void BookmarkWidget::parseTags() -{ - QList<Nepomuk::Tag> tagList; - if(m_tagLine->text().contains(',')) { - QString text = m_tagLine->text(); - QStringList tagStringList = text.split( QChar::fromAscii(',') ); - - foreach( const QString &tag, tagStringList ) { - QString trimmedTag = tag.trimmed(); - if( !trimmedTag.isEmpty() ) - tagList << trimmedTag; + + void BookmarkWidget::loadTags() + { + QString list; + if(!m_nfoResource.tags().isEmpty()) + { + foreach( const Nepomuk::Tag &tag, m_nfoResource.tags() ) + { + list.append(tag.genericLabel()); + list.append(","); } - } - else { - tagList<<m_tagLine->text().trimmed(); + m_tagLine->setText(list); + } } - addTags(tagList); -} - -void BookmarkWidget::loadTags() { - - QString list; - if(!m_nfoResource.tags().isEmpty()) { - foreach( const Nepomuk::Tag &tag, m_nfoResource.tags() ) { - list.append(tag.genericLabel()); - list.append(","); - } - m_tagLine->setText(list); - } - -} - -void BookmarkWidget::setRatingSlot( int rate ) -{ - m_nfoResource.setRating(rate); -} -void BookmarkWidget::addCommentSlot() -{ - m_nfoResource.setDescription(m_commentEdit->toPlainText()); -} + + void BookmarkWidget::setRatingSlot( int rate ) + { + m_nfoResource.setRating(rate); + } -void BookmarkWidget::linkToResourceSlot() -{ - Nepomuk::ResourceLinkDialog r( m_nfoResource ); - r.exec(); -} + + void BookmarkWidget::addCommentSlot() + { + m_nfoResource.setDescription(m_commentEdit->toPlainText()); + } + void BookmarkWidget::linkToResourceSlot() + { + Nepomuk::ResourceLinkDialog r( m_nfoResource ); + r.exec(); + } +#endif diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h index 01f672e9..7d5636a1 100644 --- a/src/urlbar/bookmarkwidget.h +++ b/src/urlbar/bookmarkwidget.h @@ -29,13 +29,19 @@ #define BOOKMARKWIDGET_H // Qt Includes -#include <QtGui/QMenu> -#include <QtGui/QGridLayout> -#include <QtGui/QPlainTextEdit> - -#include <Nepomuk/Resource> -#include <Nepomuk/Tag> -#include <Nepomuk/Vocabulary/NFO> +#include <QMenu> +#include <QGridLayout> +#include <QPlainTextEdit> + +// Nepomuk config include +#include "../config-nepomuk.h" + +#ifdef HAVE_NEPOMUK + // Nepomuk Includes + #include <Nepomuk/Resource> + #include <Nepomuk/Tag> + #include <Nepomuk/Vocabulary/NFO> +#endif // Forward Declarations class KBookmark; @@ -52,34 +58,40 @@ public: virtual ~BookmarkWidget(); void showAt(const QPoint &pos); + +#ifdef HAVE_NEPOMUK void addTags(QList<Nepomuk::Tag>); void parseTags(); void loadTags(); - +#endif + Q_SIGNALS: void updateIcon(); - +private: + void setupFolderComboBox(); + private Q_SLOTS: void accept(); void removeBookmark(); + +#ifdef HAVE_NEPOMUK void setRatingSlot( int rate ); void addCommentSlot(); void linkToResourceSlot(); - //void tagListSlot(); - +#endif + private: KBookmark *m_bookmark; KLineEdit *m_name; KComboBox *m_folder; KLineEdit *m_tagLine; QPlainTextEdit *m_commentEdit; - //QGridLayout* m_tagList; - Nepomuk::Resource m_nfoResource; QStringList m_tList; - - void setupFolderComboBox(); +#ifdef HAVE_NEPOMUK + Nepomuk::Resource m_nfoResource; +#endif }; #endif |