OSDN Git Service

implements popup menu in FavoriteListView
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 18 Aug 2003 15:22:09 +0000 (15:22 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Mon, 18 Aug 2003 15:22:09 +0000 (15:22 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@465 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/favoritelistview.cpp
kita/src/favoritelistview.h
kita/src/kitasubjecttabwidget.cpp

index 9a44315..577ad03 100644 (file)
 #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,
@@ -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;
+  }
+}
index 03bb319..a007543 100644 (file)
@@ -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
index b692952..b659e22 100644 (file)
@@ -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& ) ) );
 }