#include "libkita/board.h"
#include <qmap.h>
+#include <qapplication.h>
+#include <qclipboard.h>
#include <klocale.h>
+#include <kpopupmenu.h>
+#include <krun.h>
enum FavoriteListViewRows {
Row_Board,
connect( this, SIGNAL( clicked(QListViewItem*) ),
SLOT( loadThread(QListViewItem*) ) );
+ connect( this, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ),
+ SLOT( slotContextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
}
FavoriteListView::~FavoriteListView()
}
}
}
+
+// 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;
+ }
+}
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:
* @param thread ɽ¼¨¤¹¤ë¥¹¥ì
*/
void signalShowThread( const Kita::Thread& thread );
+ void signalShowThreadWithNewTab( const Kita::Thread& thread );
};
#endif
{
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& ) ) );
}