#include "kitasubjecttabwidget.h"
+#include <kpopupmenu.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <krun.h>
+
+#include <qapplication.h>
+#include <qclipboard.h>
+
KitaSubjectTabWidget::KitaSubjectTabWidget( QWidget* parent, const char* name, WFlags f )
: QTabWidget( parent, name, f )
{
+ setTabBar( new Kita::SubjectTabBar( this ) );
KitaSubjectView * view = new KitaSubjectView( this );
addTab( view, " " );
m_latestView = view;
connect( this, SIGNAL( currentChanged( QWidget* ) ),
SLOT( slotCurrentChanged( QWidget* ) ) );
+ connect( tabBar(), SIGNAL( deleteMenuSelected( KitaSubjectView* ) ),
+ SLOT( deleteView( KitaSubjectView* ) ) );
}
KitaSubjectTabWidget::~KitaSubjectTabWidget()
m_latestView = static_cast<KitaSubjectView*>( widget );
}
}
+
+void KitaSubjectTabWidget::deleteView( KitaSubjectView* view )
+{
+ if ( count() <= 2 ) {
+ return ;
+ // favorite¤È¤³¤ì¤À¤±¤Î¤È¤¤Ï²¿¤â¤·¤Ê¤¤
+ }
+ removePage( view );
+ delete view;
+
+ // FIXME: favorite¤Ï°ìÈÖº¸¤Ë¤³¤Ê¤¤¤³¤È¤ò²¾Äê
+ setCurrentPage( 0 );
+ m_latestView = static_cast<KitaSubjectView *>( currentPage() );
+}
+
+Kita::SubjectTabBar::SubjectTabBar( QWidget* parent, const char* name )
+ : QTabBar( parent, name )
+{}
+
+Kita::SubjectTabBar::~SubjectTabBar()
+{}
+
+// FIXME: KitaThreadTabWidget¤«¤é¥³¥Ô¡¼
+void Kita::SubjectTabBar::contextMenuEvent( QContextMenuEvent* e )
+{
+ KPopupMenu popup( 0 );
+ popup.insertItem( i18n( "Open with Web Browser" ), 0 );
+ popup.insertItem( i18n( "Copy title and URL" ), 1 );
+ popup.insertItem( i18n( "Close this tab" ), 2 );
+
+ QTabWidget* parent = static_cast<QTabWidget *>( parentWidget() );
+ // FIXME: ¤Þ¤È¤â¤ÊȽÄê¤ò»È¤¦¤³¤È
+ if ( QString::compare( parent->currentPage() ->name(), "favoriteTab" ) == 0 ) {
+ return ;
+ }
+ KitaSubjectView* subjectView = static_cast<KitaSubjectView *>( parent->currentPage() );
+ QClipboard* clipboard = QApplication::clipboard();
+
+ switch ( popup.exec( e->globalPos() ) ) {
+ case 0:
+ KRun::runURL( subjectView->boardURL(), "text/html" );
+ break;
+ case 1:
+ clipboard->setText( subjectView->boardName() + "\n" + subjectView->boardURL() );
+ break;
+ case 2:
+ emit deleteMenuSelected( subjectView );
+ break;
+ default:
+ break;
+ }
+
+ kdDebug() << "currentPage = " << tab( currentTab() ) ->text() << endl;
+}
#define KITASUBJECTTABWIDGET_H
#include <qtabwidget.h>
+#include <qtabbar.h>
#include "favoritelistview.h"
#include "kitasubjectview.h"
private slots:
void slotCurrentChanged( QWidget* widget );
+ void deleteView( KitaSubjectView* view );
signals:
void signalShowThread( const Kita::Thread* );
void loadBoardCompleted( const KURL& );
};
+namespace Kita
+{
+ class SubjectTabBar : public QTabBar
+ {
+ Q_OBJECT
+
+ public:
+ SubjectTabBar( QWidget* parent = 0, const char* name = 0 );
+ ~SubjectTabBar();
+
+ protected:
+ virtual void contextMenuEvent( QContextMenuEvent* e );
+
+ signals:
+ void deleteMenuSelected( KitaSubjectView* );
+ };
+};
+
#endif
KitaSubjectView::KitaSubjectView( QWidget* parent, const char* name )
: Kita::ThreadListView( parent, name )
+ , m_board( 0 )
{
connect( subjectList, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ),
SLOT( slotContextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
void KitaSubjectView::reloadSubject()
{}
+const QString KitaSubjectView::boardURL()
+{
+ if ( m_board ) {
+ return m_board->url();
+ }
+ return "";
+}
+
+const QString KitaSubjectView::boardName()
+{
+ if ( m_board ) {
+ return m_board->name();
+ }
+ return "";
+}
+
void KitaSubjectView::loadThread( QListViewItem* item )
{
if ( ! item ) return ;