From: ikemo Date: Mon, 18 Aug 2003 15:22:09 +0000 (+0000) Subject: implements popup menu in FavoriteListView X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=18e556f1e62c3d5be851b5e2c2b2ca2d7110dfa2;p=kita%2Fkita.git implements popup menu in FavoriteListView git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@465 56b19765-1e22-0410-a548-a0f45d66c51a --- diff --git a/kita/src/favoritelistview.cpp b/kita/src/favoritelistview.cpp index 9a44315..577ad03 100644 --- a/kita/src/favoritelistview.cpp +++ b/kita/src/favoritelistview.cpp @@ -14,8 +14,12 @@ #include "libkita/board.h" #include +#include +#include #include +#include +#include enum FavoriteListViewRows { Row_Board, @@ -44,6 +48,8 @@ FavoriteListView::FavoriteListView(QWidget* parent, const char *name) connect( this, SIGNAL( clicked(QListViewItem*) ), SLOT( loadThread(QListViewItem*) ) ); + connect( this, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), + SLOT( slotContextMenuRequested( QListViewItem*, const QPoint&, int ) ) ); } FavoriteListView::~FavoriteListView() @@ -99,3 +105,43 @@ void FavoriteListView::updateThread( const Kita::Thread& updated_thread ) } } } + +// TODO: KitaSubjectView¥¯¥é¥¹¤ÎƱ¥á¥½¥Ã¥É¤È¤Û¤È¤ó¤ÉƱ¤¸ +void FavoriteListView::slotContextMenuRequested( QListViewItem* item, const QPoint& point, int ) +{ + if( item == 0 ) { + return; + } + + KPopupMenu popup( 0 ); + popup.insertItem( i18n("Open with Web Browser"), 0 ); + popup.insertItem( i18n("Open with new tab"), 1 ); + popup.insertItem( i18n("Copy title and URL"), 2 ); + + QString datName = item->text(Row_DatName); + KURL datURL = KURL( item->text(Row_DatURL) ); + + qDebug("datURL = %s", datURL.url().latin1()); + Kita::Board board = Kita::Board( KURL( datURL, ".." ) ); + qDebug("board.url = %s", board.url().url().latin1()); + Kita::Thread thread( board, datURL ); + qDebug("thread.url = %s", thread.url().url().latin1()); + thread.setName( item->text( Row_Subject ) ); + thread.setResNum( item->text( Row_Read ).toInt() ); + + QClipboard* clipboard = QApplication::clipboard(); + + switch( popup.exec( point ) ) { + case 0: + KRun::runURL( thread.url(), "text/html" ); + break; + case 1: + emit signalShowThreadWithNewTab( thread ); + break; + case 2: + clipboard->setText( thread.name() + "\n" + thread.url().url() ); + break; + default: + break; + } +} diff --git a/kita/src/favoritelistview.h b/kita/src/favoritelistview.h index 03bb319..a007543 100644 --- a/kita/src/favoritelistview.h +++ b/kita/src/favoritelistview.h @@ -45,13 +45,14 @@ public: public slots: void updateThread( const Kita::Thread& updated_thread ); - + private slots: /** * @param item clicked item. */ void loadThread( QListViewItem* item ); + void slotContextMenuRequested( QListViewItem*, const QPoint&, int ); signals: @@ -59,6 +60,7 @@ signals: * @param thread ɽ¼¨¤¹¤ë¥¹¥ì */ void signalShowThread( const Kita::Thread& thread ); + void signalShowThreadWithNewTab( const Kita::Thread& thread ); }; #endif diff --git a/kita/src/kitasubjecttabwidget.cpp b/kita/src/kitasubjecttabwidget.cpp index b692952..b659e22 100644 --- a/kita/src/kitasubjecttabwidget.cpp +++ b/kita/src/kitasubjecttabwidget.cpp @@ -54,8 +54,8 @@ void KitaSubjectTabWidget::connectSignals( FavoriteListView* view ) { connect( view, SIGNAL( signalShowThread( const Kita::Thread& ) ), this, SIGNAL( signalShowThread( const Kita::Thread& ) ) ); -// connect( view, SIGNAL( signalShowThreadWithNewTab( const Kita::Thread& ) ), -// this, SIGNAL( signalShowThreadWithNewTab( const Kita::Thread& ) ) ); + connect( view, SIGNAL( signalShowThreadWithNewTab( const Kita::Thread& ) ), + this, SIGNAL( signalShowThreadWithNewTab( const Kita::Thread& ) ) ); // connect( view, SIGNAL( loadBoardCompleted( const KURL& ) ), // this, SIGNAL( loadBoardCompleted( const KURL& ) ) ); }