diff options
Diffstat (limited to 'konq-plugins/sidebar/delicious')
-rw-r--r-- | konq-plugins/sidebar/delicious/Makefile.am | 22 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/bookmarkListItem.cpp | 72 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/bookmarkListItem.h | 51 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/delicious_add.desktop | 57 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/mainWidget.cpp | 354 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/mainWidget.h | 175 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/pics/Makefile.am | 1 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png | bin | 0 -> 128 bytes | |||
-rw-r--r-- | konq-plugins/sidebar/delicious/plugin.cpp | 108 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/plugin.h | 85 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/tagListItem.cpp | 78 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/tagListItem.h | 50 | ||||
-rw-r--r-- | konq-plugins/sidebar/delicious/widget.ui | 165 |
13 files changed, 1218 insertions, 0 deletions
diff --git a/konq-plugins/sidebar/delicious/Makefile.am b/konq-plugins/sidebar/delicious/Makefile.am new file mode 100644 index 0000000..cb8eb48 --- /dev/null +++ b/konq-plugins/sidebar/delicious/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = . pics + +METASOURCES = AUTO +INCLUDES = -I$(kde_includes)/kio $(all_includes) + +################################ +# these are the headers for your project +noinst_HEADERS = plugin.h mainWidget.h tagListItem.h bookmarkListItem.h + +kde_module_LTLIBRARIES = konqsidebar_delicious.la + +# the Part's source, library search path, and link libraries +konqsidebar_delicious_la_SOURCES = plugin.cpp widget.ui mainWidget.cpp plugin.skel tagListItem.cpp \ + bookmarkListItem.cpp +konqsidebar_delicious_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +konqsidebar_delicious_la_LIBADD = $(LIB_KPARTS) $(LIB_KIO) -lkonqsidebarplugin + +globaladddir = $(kde_datadir)/konqsidebartng/add +globaladd_DATA = delicious_add.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/konqsidebar_delicious.pot diff --git a/konq-plugins/sidebar/delicious/bookmarkListItem.cpp b/konq-plugins/sidebar/delicious/bookmarkListItem.cpp new file mode 100644 index 0000000..f4bd8f5 --- /dev/null +++ b/konq-plugins/sidebar/delicious/bookmarkListItem.cpp @@ -0,0 +1,72 @@ +////////////////////////////////////////////////////////////////////////// +// bookmarkListItem.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "bookmarkListItem.h" + +#include <kglobal.h> +#include <klocale.h> + +BookmarkListItem::BookmarkListItem( QListView *parent, const QString & url, const QString & desc, time_t time ) + : KListViewItem( parent ), m_desc( desc ) +{ + m_url = KURL::fromPathOrURL( url ); + m_dateTime.setTime_t( time ); +} + +int BookmarkListItem::compare( QListViewItem * i, int col, bool ascending ) const +{ + if ( col == 1 ) + { + QDateTime them = static_cast<BookmarkListItem *>( i )->date(); + if ( m_dateTime < them ) + return -1; + else if ( m_dateTime > them ) + return 1; + else + return 0; + } + return QListViewItem::compare( i, col, ascending ); +} + +QString BookmarkListItem::text( int column ) const +{ + if ( column == 0 ) + return m_desc; + else if ( column == 1 ) + return KGlobal::locale()->formatDateTime( m_dateTime ); + + return QString::null; +} + +KURL BookmarkListItem::url() const +{ + return m_url; +} + +QDateTime BookmarkListItem::date() const +{ + return m_dateTime; +} + +QString BookmarkListItem::desc() const +{ + return m_desc; +} diff --git a/konq-plugins/sidebar/delicious/bookmarkListItem.h b/konq-plugins/sidebar/delicious/bookmarkListItem.h new file mode 100644 index 0000000..9188fcd --- /dev/null +++ b/konq-plugins/sidebar/delicious/bookmarkListItem.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// bookmarkListItem.h // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _BOOKMARKLISTITEM_H_ +#define _BOOKMARKLISTITEM_H_ + +#include <qdatetime.h> + +#include <klistview.h> +#include <kurl.h> + +#include <time.h> + +class QString; + +class BookmarkListItem: public KListViewItem +{ +public: + BookmarkListItem( QListView *parent, const QString & url, const QString & desc, time_t time ); + KURL url() const; + QDateTime date() const; + QString desc() const; + +protected: + virtual int compare( QListViewItem * i, int col, bool ascending ) const; + virtual QString text( int column ) const; + + KURL m_url; + QString m_desc; + QDateTime m_dateTime; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/delicious_add.desktop b/konq-plugins/sidebar/delicious/delicious_add.desktop new file mode 100644 index 0000000..b2e3e07 --- /dev/null +++ b/konq-plugins/sidebar/delicious/delicious_add.desktop @@ -0,0 +1,57 @@ +[Desktop Entry] +Type=Link +URL= +Icon=konqsidebar_delicious +Name=del.icio.us Bookmarks +Name[bg]=Отметки del.icio.us +Name[br]=Sinedoù del.icio.us +Name[ca]=Punts del.icio.us +Name[cs]=del.icio.us záložky +Name[da]=del.icio.us Bogmærker +Name[de]=Lesezeichen von del.icio.us +Name[el]=Σελιδοδείκτες del.icio.us +Name[eo]=del.icio.us legosignoj +Name[es]=Marcadores del.icio.us +Name[et]=del.icio.us järjehoidjad +Name[eu]=del.icio.us laster-markak +Name[fa]=چوب الفهای del.icio.us +Name[fi]=del.icio.us kirjanmerkit +Name[fr]=Signets del.icio.us +Name[fy]=del.icio.us-blêdwizers +Name[ga]=Leabharmharcanna del.icio.us +Name[gl]=Favoritos del.icio.us +Name[he]=סימניות של del.icio.us +Name[hr]=del.icio.us oznake +Name[hu]=Del.icio.us könyvjelzők +Name[is]=del.icio.us bókamerki +Name[it]=Segnalibri di del.icio.us +Name[ja]=del.icio.us ブックマーク +Name[ka]=del.icio.us სანიშნეები +Name[kk]=del.icio.us бетбелгілері +Name[km]=ចំណាំ del.icio.us +Name[lt]=del.icio.us žymelės +Name[mk]=Обележувачи за del.icio.us +Name[nb]=del.icio.us bokmerker +Name[nds]="del.icio.us"-Leestekens +Name[ne]=del.icio.us पुस्तकचिनोहरू +Name[nl]=del.icio.us-bladwijzers +Name[nn]=del.icio.us-bokmerke +Name[pa]=del.icio.us ਬੁੱਕਮਾਰਕ +Name[pl]=Zakładki del.icio.us +Name[pt]=Favoritos del.icio.us +Name[pt_BR]=Favorito do del.icio.us +Name[ru]=Закладки del.icio.us +Name[sk]=del.icio.us záložky +Name[sl]=Zaznamki del.icio.us +Name[sr]=ук.ус.ни маркери +Name[sr@Latn]=uk.us.ni markeri +Name[sv]=del.icio.us bokmärken +Name[tr]=del.icio.us Yer İmleri +Name[uk]=Закладки del.icio.us +Name[uz]=del.icio.us xatchoʻplari +Name[uz@cyrillic]=del.icio.us хатчўплари +Name[vi]=Dấu nhớ del.icio.us +Name[zh_CN]=del.icio.us 书签 +Open=false +X-KDE-KonqSidebarAddModule=konqsidebar_delicious +X-KDE-KonqSidebarUniversal=true diff --git a/konq-plugins/sidebar/delicious/mainWidget.cpp b/konq-plugins/sidebar/delicious/mainWidget.cpp new file mode 100644 index 0000000..759e348 --- /dev/null +++ b/konq-plugins/sidebar/delicious/mainWidget.cpp @@ -0,0 +1,354 @@ +// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +////////////////////////////////////////////////////////////////////////// +// mainWidget.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "mainWidget.h" +#include "tagListItem.h" +#include "bookmarkListItem.h" + +#include <qlistview.h> +#include <qdom.h> +#include <qpopupmenu.h> +#include <qpushbutton.h> +#include <qtimer.h> +#include <qdatetime.h> + +#include <kdebug.h> +#include <kio/job.h> +#include <krfcdate.h> +#include <klistview.h> +#include <klocale.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kconfig.h> +#include <kinputdialog.h> + +MainWidget::MainWidget( KConfig * config, QWidget * parent ) + : MainWidget_base( parent ), m_config( config ) +{ + loadTags(); + + KIconLoader * il = KGlobal::iconLoader(); + + btnRefreshTags->setIconSet( il->loadIconSet( "reload", KIcon::Small ) ); + btnRefreshBookmarks->setIconSet( il->loadIconSet( "reload", KIcon::Small ) ); + btnNew->setIconSet( il->loadIconSet( "bookmark_add", KIcon::Small ) ); + + connect( ( QWidget * ) btnRefreshTags, SIGNAL( clicked() ), + this, SLOT( slotGetTags() ) ); + + connect( ( QWidget * ) btnRefreshBookmarks, SIGNAL( clicked() ), + this, SLOT( slotGetBookmarks() ) ); + + connect( ( QWidget * ) btnNew, SIGNAL( clicked() ), + this, SLOT( slotNewBookmark() ) ); + + connect( lvBookmarks, SIGNAL( executed( QListViewItem * ) ), + this, SLOT( slotBookmarkExecuted( QListViewItem * ) ) ); + connect( lvBookmarks, SIGNAL( mouseButtonClicked ( int, QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotBookmarkClicked( int, QListViewItem *, const QPoint &, int ) ) ); + + connect( lvTags, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotTagsContextMenu( QListViewItem *, const QPoint &, int ) ) ); + + connect( lvBookmarks, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotBookmarksContextMenu( QListViewItem *, const QPoint &, int ) ) ); + + m_updateTimer = new QTimer( this ); + connect( m_updateTimer, SIGNAL( timeout() ), SLOT( slotGetBookmarks() ) ); + + slotGetTags(); +} + +MainWidget::~MainWidget() +{ + saveTags(); +} + +void MainWidget::setCurrentURL( const KURL & url ) +{ + m_currentURL = url; +} + +void MainWidget::slotGetTags() +{ + kdDebug() << k_funcinfo << endl; + + KIO::StoredTransferJob * job = KIO::storedGet( "http://del.icio.us/api/tags/get" ); + connect( job, SIGNAL( result( KIO::Job * ) ), + this, SLOT( slotFillTags( KIO::Job * ) ) ); +} + +void MainWidget::slotFillTags( KIO::Job * job ) +{ + kdDebug() << k_funcinfo << endl; + + if ( job->error() ) + { + job->showErrorDialog( this ); + return; + } + + lvTags->clear(); + m_tags.clear(); + + // fill lvTags with job->data() + QDomDocument doc; + doc.setContent( static_cast<KIO::StoredTransferJob *>( job )->data() ); + QDomNodeList tags = doc.elementsByTagName( "tag" ); + for ( uint i = 0; i < tags.length(); ++i ) + { + QDomElement tag = tags.item( i ).toElement(); + if ( !tag.isNull() ) + { + TagListItem *item = new TagListItem( lvTags, tag.attribute( "tag" ), tag.attribute( "count" ).toInt() ); + m_tags.append( tag.attribute( "tag" ) ); + connect( item, SIGNAL( signalItemChecked( TagListItem * ) ), SLOT( itemToggled() ) ); + } + } +} + +void MainWidget::slotGetBookmarks() +{ + KURL url( "http://del.icio.us/api/posts/recent" ); + url.setQuery( "tag=" + checkedTags().join( " " ) ); + + kdDebug() << k_funcinfo << url.url() << endl; + + KIO::StoredTransferJob * job = KIO::storedGet( url ); + connect( job, SIGNAL( result( KIO::Job * ) ), + this, SLOT( slotFillBookmarks( KIO::Job * ) ) ); +} + +void MainWidget::slotFillBookmarks( KIO::Job * job ) +{ + kdDebug() << k_funcinfo << endl; + + if ( job->error() ) + { + job->showErrorDialog( this ); + return; + } + + lvBookmarks->clear(); + + // fill lvBookmarks with job->data() + QDomDocument doc; + doc.setContent( static_cast<KIO::StoredTransferJob *>( job )->data() ); + QDomNodeList posts = doc.elementsByTagName( "post" ); + + for ( uint i = 0; i < posts.length(); ++i ) + { + QDomElement post = posts.item( i ).toElement(); + if ( !post.isNull() ) + { + new BookmarkListItem( lvBookmarks, post.attribute( "href" ), post.attribute( "description" ), + KRFCDate::parseDateISO8601( post.attribute( "time" ) ) ); + } + } +} + +QStringList MainWidget::checkedTags() const +{ + QListViewItemIterator it( lvTags, QListViewItemIterator::Visible | QListViewItemIterator::Checked ); + + QStringList tmp; + + while ( it.current() ) + { + tmp.append( it.current()->text( 0 ) ); + ++it; + } + + return tmp; +} + +void MainWidget::slotBookmarkExecuted( QListViewItem * item ) +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( item ); + if ( bookmark ) + { + kdDebug() << k_funcinfo << "Clicked bookmark URL: " << bookmark->url() << endl; + emit signalURLClicked( bookmark->url() ); + } +} + +void MainWidget::slotBookmarkClicked( int button, QListViewItem * item, const QPoint &, int ) +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( item ); + if ( bookmark && button == Qt::MidButton ) // handle middle click + { + kdDebug() << k_funcinfo << "Middle clicked bookmark URL: " << bookmark->url() << endl; + emit signalURLMidClicked( bookmark->url() ); + } +} + +QStringList MainWidget::tags() const +{ + return m_tags; +} + +QStringList MainWidget::bookmarks() const +{ + QListViewItemIterator it( lvBookmarks ); + + QStringList tmp; + + while ( it.current() ) + { + tmp.append( static_cast<BookmarkListItem *>( it.current() )->url().url() ); + ++it; + } + + return tmp; +} + +void MainWidget::slotTagsContextMenu( QListViewItem *, const QPoint & pos, int ) +{ + if ( lvTags->childCount() == 0 ) + return; + + QPopupMenu * tagMenu = new QPopupMenu( this ); + Q_CHECK_PTR( tagMenu ); + + tagMenu->insertItem( i18n( "Check All" ), this, SLOT( slotCheckAllTags() ) ); + tagMenu->insertItem( i18n( "Uncheck All" ), this, SLOT( slotUncheckAllTags() ) ); + tagMenu->insertItem( i18n( "Toggle All" ), this, SLOT( slotToggleTags() ) ); + tagMenu->insertSeparator(); + tagMenu->insertItem( KGlobal::iconLoader()->loadIconSet( "edit", KIcon::Small ), + i18n( "Rename Tag..." ), this, SLOT( slotRenameTag() ) ); + + tagMenu->exec( pos ); +} + +void MainWidget::slotCheckAllTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( true ); + ++it; + } +} + +void MainWidget::slotUncheckAllTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( false ); + ++it; + } +} + +void MainWidget::slotToggleTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( !item->isOn() ); + ++it; + } +} + +void MainWidget::itemToggled() +{ + m_updateTimer->start( 2000, true ); +} + +void MainWidget::slotNewBookmark() +{ + emit signalURLClicked( "http://del.icio.us/post/?url=" + m_currentURL.url() ); +} + +void MainWidget::saveTags() +{ + m_config->writeEntry( "Tags", m_tags ); +} + +void MainWidget::loadTags() +{ + m_tags = m_config->readListEntry( "Tags" ); +} + +void MainWidget::slotRenameTag() +{ + TagListItem * tag = static_cast<TagListItem *>( lvTags->currentItem() ); + if ( tag ) + { + QString oldName = tag->name(); + QString newName = KInputDialog::getText( i18n( "Rename Tag" ), i18n( "Provide a new name for tag '%1':" ).arg( oldName ) ); + if ( !newName.isEmpty() ) + { + KURL url( "http://del.icio.us/api/tags/rename" ); + url.addQueryItem( "old", oldName ); + url.addQueryItem( "new", newName ); + KIO::get( url ); // rename the tag + + tag->setName( newName ); + } + } +} + +void MainWidget::slotBookmarksContextMenu( QListViewItem *, const QPoint & pos, int ) +{ + if ( lvBookmarks->childCount() == 0 ) + return; + + QPopupMenu * menu = new QPopupMenu( this ); + Q_CHECK_PTR( menu ); + + menu->insertItem( KGlobal::iconLoader()->loadIconSet( "editdelete", KIcon::Small ), + i18n( "Delete Bookmark" ), this, SLOT( slotDeleteBookmark() ) ); + + menu->exec( pos ); +} + +void MainWidget::slotDeleteBookmark() +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( lvBookmarks->currentItem() ); + if ( bookmark ) + { + int result = KMessageBox::warningContinueCancel( this, i18n( "Do you really want to remove the bookmark\n%1?" ).arg( bookmark->desc() ), + i18n( "Delete Bookmark" ), KStdGuiItem::del() ); + + if ( result == KMessageBox::Continue ) + { + KURL url( "http://del.icio.us/api/posts/delete" ); + url.addQueryItem( "url", bookmark->url().url() ); + kdDebug() << k_funcinfo << url << endl; + KIO::get( url ); + + delete bookmark; + + slotGetTags(); // re-read the tags + } + } +} + +#include "mainWidget.moc" diff --git a/konq-plugins/sidebar/delicious/mainWidget.h b/konq-plugins/sidebar/delicious/mainWidget.h new file mode 100644 index 0000000..5970524 --- /dev/null +++ b/konq-plugins/sidebar/delicious/mainWidget.h @@ -0,0 +1,175 @@ +// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +////////////////////////////////////////////////////////////////////////// +// mainWidget.h // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _MAINWIDGET_H_ +#define _MAINWIDGET_H_ + +#include "widget.h" + +#include <kio/jobclasses.h> +#include <kparts/browserextension.h> + +class QStringList; +class KURL; +class KConfig; + +/** + * Main widget of the del.icio.us bookmarks panel + */ +class MainWidget: public MainWidget_base +{ + Q_OBJECT +public: + MainWidget( KConfig * config, QWidget * parent ); + ~MainWidget(); + + /** + * @return all the tags user has + * (used in the DCOP iface) + */ + QStringList tags() const; + + /** + * @return all the (currently visible) bookmark (URLs) + * (used in the DCOP iface) + */ + QStringList bookmarks() const; + + /** + * Set the internal URL to @p url + */ + void setCurrentURL( const KURL & url ); + +public slots: + /** + * Show a dialog for adding a new bookmark + */ + void slotNewBookmark(); + +private slots: + /** + * Start the job to get the list of tags + */ + void slotGetTags(); + + /** + * Fill the Tags listview with job->data() + * (parses the XML returned by the server) + */ + void slotFillTags( KIO::Job * job ); + + /** + * Start the job to get the list of bookmarks + * for checked tags + */ + void slotGetBookmarks(); + + /** + * Fill the Bookmarks listview with job->data() + * (parses the XML returned by the server) + */ + void slotFillBookmarks( KIO::Job * job ); + + /** + * Handle clicking on a bookmark (KDE mode) + */ + void slotBookmarkExecuted( QListViewItem * item ); + + /** + * Handle middle clicking a bookmark + */ + void slotBookmarkClicked( int button, QListViewItem * item, const QPoint & pnt, int col ); + + /** + * Popup a tag context menu over @p item and position @pos + */ + void slotTagsContextMenu( QListViewItem * item, const QPoint & pos, int col ); + + /** + * Popup a bookmark context menu over @p item and position @pos + */ + void slotBookmarksContextMenu( QListViewItem * item, const QPoint & pos, int col ); + + /** + * Put a checkmark before all tags + */ + void slotCheckAllTags(); + + /** + * Cancel the checkmark before all tags + */ + void slotUncheckAllTags(); + + /** + * Toggle the checkmark before all tags + */ + void slotToggleTags(); + + /** + * Starts a singleshot timer once an item (tag) has been toggled. Timer will update bookmarks. + */ + void itemToggled(); + + /** + * Display a dialog box that allows renaming of tags + */ + void slotRenameTag(); + + /** + * Delete the selected bookmark + */ + void slotDeleteBookmark(); + +signals: + /** + * Emit a signal to the plugin interface that a @p url has been left-clicked + */ + void signalURLClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + + /** + * Emit a signal to the plugin interface that a @p url has been mid-clicked + */ + void signalURLMidClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + +private: + /** + * @return list of checked tags + */ + QStringList checkedTags() const; + + /** + * Save the tag list to the config file + */ + void saveTags(); + + /** + * Load the tag list from the config file + */ + void loadTags(); + + QTimer *m_updateTimer; + KURL m_currentURL; + QStringList m_tags; + KConfig * m_config; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/pics/Makefile.am b/konq-plugins/sidebar/delicious/pics/Makefile.am new file mode 100644 index 0000000..e5515a8 --- /dev/null +++ b/konq-plugins/sidebar/delicious/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = AUTO diff --git a/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png b/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png Binary files differnew file mode 100644 index 0000000..f28df92 --- /dev/null +++ b/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png diff --git a/konq-plugins/sidebar/delicious/plugin.cpp b/konq-plugins/sidebar/delicious/plugin.cpp new file mode 100644 index 0000000..cd400aa --- /dev/null +++ b/konq-plugins/sidebar/delicious/plugin.cpp @@ -0,0 +1,108 @@ +////////////////////////////////////////////////////////////////////////// +// plugin.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "plugin.h" + +#include <qstring.h> + +#include <kapplication.h> +#include <klocale.h> +#include <kglobal.h> + +KonqSidebarDelicious::KonqSidebarDelicious( KInstance *instance, QObject *parent, + QWidget *widgetParent, QString &desktopName_, + const char* name ) + : KonqSidebarPlugin( instance, parent, widgetParent, desktopName_, name ), + DCOPObject( "sidebar-delicious" ) + +{ + m_widget = new MainWidget( instance->config(), widgetParent ); + connect( m_widget, SIGNAL( signalURLClicked( const KURL &, const KParts::URLArgs & ) ), + this, SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ) ); + connect( m_widget, SIGNAL( signalURLMidClicked( const KURL &, const KParts::URLArgs & ) ), + this, SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs & ) ) ); +} + +KonqSidebarDelicious::~KonqSidebarDelicious() +{ + +} + +void * KonqSidebarDelicious::provides( const QString & ) +{ + return 0; +} + +QWidget * KonqSidebarDelicious::getWidget() +{ + return m_widget; +} + +void KonqSidebarDelicious::handleURL( const KURL & url ) +{ + m_widget->setCurrentURL( url ); +} + +bool KonqSidebarDelicious::universalMode() +{ + return true; +} + +extern "C" +{ + KDE_EXPORT void* create_konqsidebar_delicious( KInstance *instance, QObject *par, QWidget *widp, + QString &desktopname, const char *name ) + { + KGlobal::locale()->insertCatalogue( "konqsidebar_delicious" ); + return new KonqSidebarDelicious( instance, par, widp, desktopname, name ); + } +} + +extern "C" +{ + KDE_EXPORT bool add_konqsidebar_delicious( QString* fn, QString* /*param*/, QMap<QString,QString> *map ) + { + map->insert("Type", "Link"); + map->insert("Icon", "konqsidebar_delicious"); + map->insert("Name", i18n( "del.icio.us Bookmarks" ) ); + map->insert("Open", "false"); + map->insert("X-KDE-KonqSidebarModule", "konqsidebar_delicious"); + fn->setLatin1("delicious%1.desktop"); + return true; + } +} + +QStringList KonqSidebarDelicious::tags() const +{ + return m_widget->tags(); +} + +QStringList KonqSidebarDelicious::bookmarks() const +{ + return m_widget->bookmarks(); +} + +void KonqSidebarDelicious::newBookmark() +{ + m_widget->slotNewBookmark(); +} + +#include "plugin.moc" diff --git a/konq-plugins/sidebar/delicious/plugin.h b/konq-plugins/sidebar/delicious/plugin.h new file mode 100644 index 0000000..96f7082 --- /dev/null +++ b/konq-plugins/sidebar/delicious/plugin.h @@ -0,0 +1,85 @@ +////////////////////////////////////////////////////////////////////////// +// plugin.h // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#include "mainWidget.h" + +#include <konqsidebarplugin.h> +#include <kparts/part.h> +#include <kparts/factory.h> +#include <kparts/browserextension.h> +#include <kinstance.h> +#include <dcopobject.h> + +class QString; + +/** + * @brief del.icio.us bookmarks plugin + * @author Lukas Tinkl <lukas@kde.org> + */ +class KonqSidebarDelicious: public KonqSidebarPlugin, DCOPObject +{ + Q_OBJECT + K_DCOP +public: + KonqSidebarDelicious( KInstance * instance, QObject * parent, QWidget * widgetParent, + QString & desktopName_, const char * name = 0 ); + ~KonqSidebarDelicious(); + virtual void * provides( const QString & ); + /** + * @return the main widget + */ + virtual QWidget * getWidget(); + +k_dcop: + QStringList tags() const; + QStringList bookmarks() const; + void newBookmark(); + +protected: + /** + * Called when the shell's @p url changes + */ + virtual void handleURL( const KURL & url ); + + /** + * @return true if we are in universal (e.g. desktop) mode + */ + bool universalMode(); + +signals: + /** + * Emitted in order to open @p url in the shell app + */ + void openURLRequest( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + + /** + * Emitted in order to open @p url in the shell app's new window + */ + void createNewWindow( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + +private: + MainWidget * m_widget; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/tagListItem.cpp b/konq-plugins/sidebar/delicious/tagListItem.cpp new file mode 100644 index 0000000..866cc09 --- /dev/null +++ b/konq-plugins/sidebar/delicious/tagListItem.cpp @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////// +// tagListItem.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "tagListItem.h" + +TagListItem::TagListItem( QListView * parent, const QString & tagName, int count ) + : QCheckListItem( parent, tagName, QCheckListItem::CheckBox ), m_name( tagName ), m_count( count ) +{ +} + +// virtual +void TagListItem::stateChange( bool state ) +{ + QCheckListItem::stateChange( state ); + emit signalItemChecked( this ); +} + +// virtual +int TagListItem::compare( QListViewItem * i, int col, bool ascending ) const +{ + if ( col == 1 ) + { + int them = static_cast<TagListItem *>( i )->count(); + if ( m_count < them ) + return -1; + else if ( m_count > them ) + return 1; + else + return 0; + } + return QCheckListItem::compare( i, col, ascending ); +} + +int TagListItem::count() const +{ + return m_count; +} + +// virtual +QString TagListItem::text( int column ) const +{ + if ( column == 0 ) + return m_name; + else if ( column == 1 ) + return QString::number( m_count ); + else + return QString::null; +} + +QString TagListItem::name() const +{ + return m_name; +} + +void TagListItem::setName( const QString & name ) +{ + m_name = name; +} + +#include "tagListItem.moc" diff --git a/konq-plugins/sidebar/delicious/tagListItem.h b/konq-plugins/sidebar/delicious/tagListItem.h new file mode 100644 index 0000000..0bc293e --- /dev/null +++ b/konq-plugins/sidebar/delicious/tagListItem.h @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////// +// tagListItem.h // +// // +// Copyright (C) 2005 Lukas Tinkl <lukas@kde.org> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _TAGLISTITEM_H_ +#define _TAGLISTITEM_H_ + +#include <qobject.h> +#include <qlistview.h> + +class TagListItem: public QObject, public QCheckListItem +{ + Q_OBJECT +public: + TagListItem( QListView * parent, const QString & tagName, int count = 1 ); + int count() const; + QString name() const; + void setName( const QString & name ); + +protected: + virtual void stateChange( bool state ); + virtual int compare( QListViewItem * i, int col, bool ascending ) const; + virtual QString text( int column ) const; + +signals: + void signalItemChecked( TagListItem * ); + +private: + QString m_name; + int m_count; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/widget.ui b/konq-plugins/sidebar/delicious/widget.ui new file mode 100644 index 0000000..daccbe9 --- /dev/null +++ b/konq-plugins/sidebar/delicious/widget.ui @@ -0,0 +1,165 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MainWidget_base</class> +<author>Lukáš Tinkl <lukas@kde.org></author> +<widget class="QWidget"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>411</width> + <height>595</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSplitter"> + <property name="name"> + <cstring>splitter3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox2</cstring> + </property> + <property name="title"> + <string>Tags</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnRefreshTags</cstring> + </property> + <property name="text"> + <string>&Refresh Tags</string> + </property> + <property name="toolTip" stdset="0"> + <string>Refresh the list of tags</string> + </property> + </widget> + <widget class="QListView"> + <column> + <property name="text"> + <string>Tag</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Count</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>lvTags</cstring> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>AllColumns</enum> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Bookmarks</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="0"> + <property name="name"> + <cstring>btnRefreshBookmarks</cstring> + </property> + <property name="text"> + <string>Refresh &Bookmarks</string> + </property> + <property name="toolTip" stdset="0"> + <string>Refresh the list of bookmarks according to the selected tags</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>btnNew</cstring> + </property> + <property name="text"> + <string>Post &New...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Post a new bookmark</string> + </property> + </widget> + <widget class="KListView" row="0" column="0" rowspan="1" colspan="2"> + <column> + <property name="text"> + <string>Description</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Date</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>lvBookmarks</cstring> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>AllColumns</enum> + </property> + <property name="itemsMovable"> + <bool>false</bool> + </property> + </widget> + </grid> + </widget> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> |