¡¦¤ªµ¤¤ËÆþ¤ê¤ò¥Ä¥ê¡¼¤Ëɽ¼¨
¥Ð¥°
+¡¦¤´¤ßÈ¢¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¥¦¥£¥ó¥É¥¦¤¬ÊĤ¸¤é¤ì¤ë¤¬¡¢¥¿¥¤¥È¥ë¤¬ÊѤï¤é¤Ê¤¤
¡¦¤ªµ¤¤ËÆþ¤ê¤ò¥¯¥ê¥Ã¥¯¤·¤¿¤È¤¤Ë¾ðÊ󤬹¹¿·¤µ¤ì¤ë¤¬¡¢
ÁªÂò¾ðÊó¤Þ¤Ç¾Ã¤¨¤ë¤Î¤¬µ¤»ý¤Á°¤¤¡£
¡¦NetAccess::download¤È¤«¤¬deprecated¤Ë¤Ê¤Ã¤Æ¤ë¡£
#include "libkita/kita_misc.h"
#include "libkita/threadinfo.h"
#include "libkita/signalcollection.h"
+#include "libkita/parsemisc.h"
#include <qmap.h>
#include <qapplication.h>
signalCollection, SIGNAL( openBoardRequested( const QString&, bool ) ) );
connect( signalCollection, SIGNAL( favoritesUpdated() ),
SLOT( update() ) );
+
+ connect( signalCollection, SIGNAL( updateSubjectTab( const KURL& ) ),
+ SLOT( slotUpdateSubject( const KURL& ) ) );
}
FavoriteListView::~FavoriteListView()
}
}
-void FavoriteListView::updateThread( const Kita::Thread* updated_thread )
+void FavoriteListView::slotUpdateSubject( const KURL& url )
{
+ KURL datURL = Kita::ParseMisc::parseURLonly( url );
+ Kita::Thread* updated_thread = Kita::Thread::getByURLNew( datURL );
for ( QListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling() ) {
- if ( item->text( Col_DatURL ) == updated_thread->datURL() ) {
+ if ( item->text( Col_DatURL ) == datURL.prettyURL() ) {
int resNum = updated_thread->resNum();
int readNum = KitaThreadInfo::readNum( updated_thread->datURL() );
item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 4 ) );
~FavoriteListView();
public slots:
- void updateThread( const Kita::Thread* updated_thread );
+ void slotUpdateSubject( const KURL& url );
/**
*
SLOT( deleteView( KitaSubjectView* ) ) );
connect( signalCollection, SIGNAL( openBoardRequested( const QString&, bool ) ),
SLOT( loadBoard( const QString&, bool ) ) );
- connect( signalCollection, SIGNAL( updateSubjectTab( const KURL& ) ),
- SLOT( slotUpdateSubjectTab( const KURL& ) ) );
}
KitaSubjectTabWidget::~KitaSubjectTabWidget()
showPage( m_latestView );
}
-void KitaSubjectTabWidget::slotUpdateSubjectTab( const KURL& datURL )
-{
- Kita::Thread* thread = Kita::Thread::getByURL( datURL.prettyURL() );
- for ( int i = 0; i < count(); i++ )
- {
- QWidget* widget = page( i );
- // TODO: class¤ÇȽÄꤷ¤è¤¦¡£
- if ( QString::compare( widget->name(), "favoriteTab" ) == 0 )
- {
- static_cast<FavoriteListView*>( widget ) ->updateThread( thread );
- }
- else
- {
- static_cast<KitaSubjectView*>( widget ) ->updateThread( thread );
- }
- }
-}
-
void KitaSubjectTabWidget::connectSignals( Kita::ThreadListView* view )
{
connect( view, SIGNAL( showThreadRequested( const QString&, bool ) ),
public slots:
void loadBoard( const QString&, bool withNewTab = false );
- void slotUpdateSubjectTab( const KURL& datURL );
void reloadSubjectList();
private:
#include "libkita/kitaconfig.h"
#include "libkita/favoritethreads.h"
#include "libkita/datmanager.h"
+#include "libkita/parsemisc.h"
+#include "libkita/signalcollection.h"
#include "part/kita2ch.h"
KitaSubjectView::KitaSubjectView( QWidget* parent, const char* name )
SLOT( loadThread( QListViewItem* ) ) );
connect( ReloadButton, SIGNAL( clicked() ),
SLOT( reloadSubject() ) );
+
+ Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
+ connect( signalCollection, SIGNAL( updateSubjectTab( const KURL& ) ),
+ SLOT( slotUpdateSubject( const KURL& ) ) );
+ connect( this, SIGNAL( closeThreadTab( const KURL& ) ),
+ signalCollection, SIGNAL( closeThreadTab( const KURL& ) ));
}
KitaSubjectView::~KitaSubjectView()
subjectList->setFont( font );
}
-void KitaSubjectView::updateThread( const Kita::Thread* updated_thread )
+void KitaSubjectView::slotUpdateSubject( const KURL& url )
{
+ KURL datURL = Kita::ParseMisc::parseURLonly( url );
+ Kita::Thread* updated_thread = Kita::Thread::getByURLNew( datURL );
for ( QListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling() ) {
- if ( item->text( Col_DatURL ) == updated_thread->datURL() ) {
+ if ( item->text( Col_DatURL ) == datURL.prettyURL() ) {
int resNum = updated_thread->resNum();
int readNum = KitaThreadInfo::readNum( updated_thread->datURL() );
item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 4 ) );
- item->setText( Col_Read, QString( "%1" ).arg( readNum, 4 ) );
+ item->setText( Col_Read, ( readNum > 0 ) ? QString( "%1" ).arg( readNum, 4 ) : QString( "" ) );
item->setText( Col_Unread, readNum > 0 && resNum != readNum ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
switch ( item->text( Col_MarkOrder ).toInt() ) {
m_readNum++;
item->setText( Col_MarkOrder, QString::number( ts_read ) );
} else {
+ item->setPixmap( Col_Mark, NULL );
item->setText( Col_MarkOrder, QString::number( ts_normal ) );
}
UpdateKindLabel();
== QMessageBox::Ok )
{
Kita::DatManager::deleteCache( url, this );
+ emit closeThreadTab( url );
+ slotUpdateSubject( url );
}
}
void reloadSubject();
void loadBoard( const QString& boardURL );
void setFont( const QFont& font );
- void updateThread( const Kita::Thread* thread );
+ void slotUpdateSubject( const KURL& url );
private:
QString m_boardURL;
signals:
void loadBoardCompleted( const KURL& );
+ void closeThreadTab( const KURL& );
};
#endif
if ( view ) {
m_viewList.append( view );
addTab( view, "thread" );
- connectSignals( view );
}
- connect( this, SIGNAL( currentChanged ( QWidget * ) ),
- SLOT( slotCurrentChanged ( QWidget * ) ) );
+ connectSignals();
}
KitaThreadTabWidget::~KitaThreadTabWidget()
if ( newView ) {
addTab( newView, getTabLabel( threadName ) );
- connectSignals( newView );
newView->showThread( datURL, num );
showPage( newView );
m_viewList.append( newView );
}
}
-void KitaThreadTabWidget::connectSignals( KitaThreadView* )
+void KitaThreadTabWidget::connectSignals()
{
+ connect( this, SIGNAL( currentChanged ( QWidget * ) ),
+ SLOT( slotCurrentChanged ( QWidget * ) ) );
+
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
connect( this, SIGNAL( setMainStatusbar( const QString& ) ),
signalCollection, SIGNAL( setMainStatusbar( const QString& ) ) );
signalCollection, SIGNAL( setMainCaption( const QString& ) ) );
connect( signalCollection, SIGNAL( updateThreadTab( const KURL& ) ),
this, SLOT( slotUpdateThreadTab( const KURL& ) ) );
+ connect( signalCollection, SIGNAL( closeCurrentThreadTab() ),
+ SLOT( closeCurrentTab() ));
+ connect( signalCollection, SIGNAL( closeThreadTab( const KURL& ) ),
+ SLOT( slotCloseThreadTab( const KURL& )));
}
KitaThreadView* KitaThreadTabWidget::findView( const QString& threadURL )
if ( view ) {
m_viewList.append( view );
addTab( view, "thread" );
- connectSignals( view );
showPage( view );
emit setMainStatusbar( "" );
void KitaThreadTabWidget::closeCurrentTab()
{
- deleteView( static_cast<KitaThreadView *>( currentPage() ) );
+ QWidget * view = currentPage();
+ CloseCurrentThreadTabEvent* e = new CloseCurrentThreadTabEvent( indexOf( view ) );
+ QApplication::postEvent( this, e ); // Qt will delete it when done
+}
+
+/* public slot */
+void KitaThreadTabWidget::slotCloseThreadTab( const KURL& url )
+{
+ KURL datURL = Kita::ParseMisc::parseURLonly( url );
+ QWidget * view = findView( Kita::DatManager::threadURL( datURL ) );
+ if( view ){
+ CloseCurrentThreadTabEvent* e = new CloseCurrentThreadTabEvent( indexOf( view ) );
+ QApplication::postEvent( this, e ); // Qt will delete it when done
+ }
+}
+
+/* Calling deleteView from KitaThreadView will be the
+ cause of crash. So you need to call deleteView
+ via custom event. */ /* protected */
+void KitaThreadTabWidget::customEvent( QCustomEvent * e )
+{
+ if ( e->type() == EVENT_CloseCurrentThreadTab ) {
+ deleteView ( page( static_cast< CloseCurrentThreadTabEvent* >(e)->getIndex() ) );
+ }
}
KitaThreadTabBar::KitaThreadTabBar( QWidget* parent, const char* name )
return title;
}
-void KitaThreadTabWidget::slotUpdateThreadTab( const KURL& datURL )
+void KitaThreadTabWidget::slotUpdateThreadTab( const KURL& url )
{
+ KURL datURL = Kita::ParseMisc::parseURLonly( url );
Kita::Thread* thread = Kita::Thread::getByURL( datURL.prettyURL() );
KitaThreadView * view = findView( thread->url() );
if ( view )
void focusSearchCombo();
void slotCurrentChanged( QWidget* );
void closeCurrentTab();
+ void slotCloseThreadTab( const KURL& url );
void showAlternativeView( const KURL&, const QString&, const QString& );
private:
- void connectSignals( KitaThreadView* );
+ void connectSignals();
KitaThreadView* createView();
QPtrList<KitaThreadView> m_viewList;
KitaThreadView* findView( const QString& threadURL );
const QString getTabLabel( const QString &name );
private slots:
- void slotUpdateThreadTab( const KURL& datURL );
+ void slotUpdateThreadTab( const KURL& url );
+protected:
+ virtual void customEvent( QCustomEvent * e );
+
signals:
void setMainStatusbar( const QString& );
void setMainCaption( const QString& );
void deleteMenuSelected( QWidget* );
};
+
+/*------------------------------------------------------------------*/
+#include <qevent.h>
+
+#define EVENT_CloseCurrentThreadTab ( QEvent::User + 100 )
+
+
+class CloseCurrentThreadTabEvent : public QCustomEvent
+{
+ int pageindex;
+
+ public:
+
+ CloseCurrentThreadTabEvent( int idx )
+ : QCustomEvent( EVENT_CloseCurrentThreadTab ), pageindex( idx ){}
+
+ const int getIndex() const { return pageindex; }
+};
+
+
#endif
void openBoardRequested( const QString& boardURL, bool withNewTab );
void favoritesUpdated();
- /* to : KitaSubjectTabWidget */
- void updateSubjectTab( const KURL& datURL );
+ /* to : KitaSubjectView, FavoriteListView */
+ void updateSubjectTab( const KURL& url );
/* to : KitaThreadTabWidget */
- void updateThreadTab( const KURL& datURL );
+ void updateThreadTab( const KURL& url );
+ void closeThreadTab( const KURL& url );
+ void closeCurrentThreadTab();
/* to : KitaMainWindow */
void setMainURLLine( const KURL& url );
signalCollection, SIGNAL( openBoardRequested( const QString&, bool ) ) );
connect( this, SIGNAL( setMainCaption( const QString& ) ),
signalCollection, SIGNAL( setMainCaption( const QString& ) ) );
+ connect( this, SIGNAL( closeThreadTab( const KURL& ) ),
+ signalCollection, SIGNAL( closeThreadTab( const KURL& ) ));
m_viewmode = VIEWMODE_PARENT;
m_rescode = 200;
void KitaThreadView::slotDeleteButtonClicked()
{
- if ( QMessageBox::warning( this,
+ if ( !m_datURL.isEmpty()
+ && QMessageBox::warning( this,
"Kita",
"Do you want to delete Log ?",
QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
== QMessageBox::Ok )
{
Kita::DatManager::deleteCache( threadURL(), this );
+ emit closeThreadTab( m_datURL );
+ emit updateSubjectTab( m_datURL );
}
}
void bookmarked( const QString& datURL, bool on );
void openBoardRequested( const QString& URL, bool useTab );
void showThreadCompleted(); /* to KitaThreadPart */
+ void closeThreadTab( const KURL& url );
};
namespace Kita