KitaSubjectView * view = new KitaSubjectView( this );
addTab( view, " " );
m_latestView = view;
+ m_viewList.append( view );
m_favoriteList = new FavoriteListView( this, "favoriteTab" );
addTab( m_favoriteList, "Favorite" );
void KitaSubjectTabWidget::loadBoard( const Kita::Board* board, bool withNewTab )
{
- if ( withNewTab ) {
- KitaSubjectView * view = new KitaSubjectView( this );
- connectSignals( view );
- connect( view, SIGNAL( loadBoardCompleted( const KURL& ) ),
- this, SIGNAL( loadBoardCompleted( const KURL& ) ) );
- insertTab( view, board->name(), count() - 1 );
+ KitaSubjectView * view = findView( board->url() );
+ if ( view ) {
m_latestView = view;
+ setTabLabel( m_latestView, board->name() );
+ } else if ( withNewTab ) {
+ KitaSubjectView * newView = new KitaSubjectView( this );
+ connectSignals( newView );
+ connect( newView, SIGNAL( loadBoardCompleted( const KURL& ) ),
+ this, SIGNAL( loadBoardCompleted( const KURL& ) ) );
+ insertTab( newView, board->name(), count() - 1 );
+ m_latestView = newView;
+ m_viewList.append( newView );
} else {
setTabLabel( m_latestView, board->name() );
}
void KitaSubjectTabWidget::loadBoard( const QString& boardURL, bool withNewTab )
{
- Kita::Board* board = Kita::Board::getByURL( boardURL );
+ Kita::Board * board = Kita::Board::getByURL( boardURL );
loadBoard( board, withNewTab );
}
this, SIGNAL( showThreadRequested( const Kita::Thread*, bool ) ) );
}
+KitaSubjectView* KitaSubjectTabWidget::findView( const QString& boardURL )
+{
+ KitaSubjectView * view;
+ for ( view = m_viewList.first(); view; view = m_viewList.next() ) {
+ if ( view->boardURL() == boardURL ) {
+ return view;
+ }
+ }
+ return 0;
+}
+
void KitaSubjectTabWidget::slotCurrentChanged( QWidget* widget )
{
if ( QString::compare( widget->name(), "favoriteTab" ) == 0 ) {
return ;
// favorite¤È¤³¤ì¤À¤±¤Î¤È¤¤Ï²¿¤â¤·¤Ê¤¤
}
+ m_viewList.remove( view );
removePage( view );
delete view;
KitaThreadView* view = createView();
if ( view ) {
+ m_viewList.append( view );
addTab( view, "thread" );
connectSignals( view );
}
void KitaThreadTabWidget::showThread( const Kita::Thread* thread )
{
- // TODO: ¥¹¥ì¤¬¤É¤³¤«¤Î¥¿¥Ö¤Ë¤¹¤Ç¤Ë¤¢¤ë¤È¤¤Ï¤½¤ì¤ò»È¤¦
- static_cast<KitaThreadView *>( currentPage() ) ->showThread( thread );
+ KitaThreadView * view = findView( thread->url() );
+ if ( view ) {
+ setCurrentPage( indexOf( view ) );
+ view->showThread( thread );
+ } else {
+ static_cast<KitaThreadView *>( currentPage() ) ->showThread( thread );
+ }
// FIXME: showThreadWithNewTab()¤Ø¥³¥Ô¡¼
setTabLabel( currentPage(), Kita::unescape( thread->name().left( MAX_TABLABEL_LEN ) ) );
void KitaThreadTabWidget::showThread( const QString& datURL, bool withNewTab )
{
- Kita::Thread* thread = Kita::Thread::getByURL( datURL );
+ Kita::Thread * thread = Kita::Thread::getByURL( datURL );
if ( withNewTab ) {
showThreadWithNewTab( thread );
} else {
void KitaThreadTabWidget::showThreadWithNewTab( const Kita::Thread* thread )
{
- KitaThreadView * view = createView();
-
+ KitaThreadView * view = findView( thread->url() );
if ( view ) {
- addTab( view, Kita::unescape( thread->name().left( MAX_TABLABEL_LEN ) ) );
- setTabToolTip( view, thread->name() );
+ setCurrentPage( indexOf( view ) );
+ showThread( thread );
+ } else {
+ KitaThreadView * newView = createView();
- connectSignals( view );
- view->showThread( thread );
- showPage( view );
+ if ( newView ) {
+ addTab( newView, Kita::unescape( thread->name().left( MAX_TABLABEL_LEN ) ) );
+ setTabToolTip( newView, thread->name() );
+
+ connectSignals( newView );
+ newView->showThread( thread );
+ showPage( newView );
+ m_viewList.append( newView );
- QString threadName = view->threadName();
+ QString threadName = newView->threadName();
- // FIXME: showThread()¤«¤é¥³¥Ô¡¼
- setTabLabel( currentPage(), Kita::unescape( threadName.left( MAX_TABLABEL_LEN ) ) );
- setTabToolTip( currentPage(), threadName );
+ // FIXME: showThread()¤«¤é¥³¥Ô¡¼
+ setTabLabel( currentPage(), Kita::unescape( threadName.left( MAX_TABLABEL_LEN ) ) );
+ setTabToolTip( currentPage(), threadName );
+ }
}
}
this, SIGNAL( showThreadCompleted( const KURL& ) ) );
}
+KitaThreadView* KitaThreadTabWidget::findView( const QString& threadURL )
+{
+ KitaThreadView * view;
+ for ( view = m_viewList.first(); view; view = m_viewList.next() ) {
+ if ( view->threadURL().url() == threadURL ) {
+ return view;
+ }
+ }
+ return 0;
+}
+
void KitaThreadTabWidget::deleteView( KitaThreadView* view )
{
kdDebug() << "deleteView(" << static_cast<void*>( view ) << ")" << endl;
removePage( view );
+ m_viewList.remove( view );
delete view;
if ( count() == 0 ) {
KitaThreadView * view = createView();
if ( view ) {
+ m_viewList.append( view );
addTab( view, "thread" );
connectSignals( view );