2004-01-19 Hideki Ikemoto <ikemo@users.sourceforge.jp>
* add 'reload board' button.
+ * ThreadListView.{cpp, h}: change sort order.
2004-01-17 Hideki Ikemoto <ikemo@users.sourceforge.jp>
int resNum = cache->resNum( thread->datURL() ); // TODO unused variables.
KListViewItem* item = new KListViewItem( subjectList );
- item->setText( Row_Board, thread->boardName() );
- item->setText( Row_Subject, thread->name() );
- item->setText( Row_Read, QString( "%1" ).arg( readNum, 4 ) );
- item->setText( Row_Since, since.toString( "yy/MM/dd hh:mm" ) );
- item->setText( Row_DatURL, thread->datURL() );
+ item->setText( Col_Board, thread->boardName() );
+ item->setText( Col_Subject, thread->name() );
+ item->setText( Col_Read, QString( "%1" ).arg( readNum, 4 ) );
+ item->setText( Col_Since, since.toString( "yy/MM/dd hh:mm" ) );
+ item->setText( Col_DatURL, thread->datURL() );
}
}
for ( ; it.current(); ++it ) {
const Kita::Thread* thread = it.current();
- if ( thread->datURL() == item->text( Row_DatURL ) ) {
+ if ( thread->datURL() == item->text( Col_DatURL ) ) {
emit signalShowThread( thread );
}
}
void FavoriteListView::updateThread( const Kita::Thread* updated_thread )
{
for ( QListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling() ) {
- if ( item->text( Row_DatURL ) == updated_thread->datURL() ) {
- item->setText( Row_ResNum, QString( "%1" ).arg( updated_thread->resNum(), 4 ) );
+ if ( item->text( Col_DatURL ) == updated_thread->datURL() ) {
+ item->setText( Col_ResNum, QString( "%1" ).arg( updated_thread->resNum(), 4 ) );
}
}
}
popup.insertItem( i18n( "Open with new tab" ), 1 );
popup.insertItem( i18n( "Copy title and URL" ), 2 );
- Kita::Thread* thread = Kita::Thread::getByURL( item->text( Row_DatURL ) );
+ Kita::Thread* thread = Kita::Thread::getByURL( item->text( Col_DatURL ) );
QClipboard* clipboard = QApplication::clipboard();
{
if ( ! item ) return ;
- KURL datURL = item->text( Row_DatURL );
+ KURL datURL = item->text( Col_DatURL );
Kita::Board::setName( Kita::datToBoard( datURL.url() ), m_board->name() );
- Kita::Thread::setName( datURL.url(), item->text( Row_Subject ) );
+ Kita::Thread::setName( datURL.url(), item->text( Col_Subject ) );
Kita::Thread* thread = Kita::Thread::getByURL( datURL.url() );
- KitaThreadInfo::setResNum( datURL.url(), item->text( Row_Read ).toInt() );
+ KitaThreadInfo::setResNum( datURL.url(), item->text( Col_Read ).toInt() );
emit signalShowThread( thread );
}
int readNum = cache->readNum( thread->datURL() );
int resNum = thread->resNum();
- KListViewItem* item = new KListViewItem( subjectList );
- item->setText( Row_ID, QString( "%1" ).arg( i + 1, 4 ) );
- item->setText( Row_Subject, thread->name() );
- item->setText( Row_ResNum, QString( "%1" ).arg( resNum, 4 ) );
- item->setText( Row_Read, ( readNum > 0 ) ? QString( "%1" ).arg( readNum, 4 ) : QString( "" ) );
- item->setText( Row_Unread, ( readNum > 0 && resNum != readNum ) ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
- item->setText( Row_Board, thread->boardName() );
- item->setText( Row_Since, since.toString( "yy/MM/dd hh:mm" ) );
- item->setText( Row_DatURL, thread->datURL() );
+ Kita::ThreadListViewItem* item = new Kita::ThreadListViewItem( subjectList );
+ item->setText( Col_ID, QString( "%1" ).arg( i + 1, 4 ) );
+ item->setText( Col_Subject, thread->name() );
+ item->setText( Col_ResNum, QString( "%1" ).arg( resNum, 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( "" ) );
+ item->setText( Col_Board, thread->boardName() );
+ item->setText( Col_Since, since.toString( "yy/MM/dd hh:mm" ) );
+ item->setText( Col_DatURL, thread->datURL() );
if ( readNum > 0 && resNum != readNum ) {
// ̤Æɤ¢¤ê
- item->setPixmap( Row_Mark, SmallIcon( "unread" ) );
+ item->setPixmap( Col_Mark, SmallIcon( "unread" ) );
} else if ( readNum > 0 ) {
// ´ûÆÉ
- item->setPixmap( Row_Mark, SmallIcon( "read" ) );
+ item->setPixmap( Col_Mark, SmallIcon( "read" ) );
}
}
void KitaSubjectView::updateThread( const Kita::Thread* updated_thread )
{
for ( QListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling() ) {
- if ( item->text( Row_DatURL ) == updated_thread->datURL() ) {
- int resNum = item->text( Row_ResNum ).toInt();
+ if ( item->text( Col_DatURL ) == updated_thread->datURL() ) {
+ int resNum = item->text( Col_ResNum ).toInt();
int readNum = updated_thread->resNum();
- item->setText( Row_Read, QString( "%1" ).arg( readNum, 4 ) );
- item->setText( Row_Unread, readNum > 0 && resNum != readNum ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
+ item->setText( Col_Read, QString( "%1" ).arg( readNum, 4 ) );
+ item->setText( Col_Unread, readNum > 0 && resNum != readNum ? QString( "%1" ).arg( resNum - readNum, 4 ) : QString( "" ) );
}
}
}
popup.insertItem( i18n( "Open with new tab" ), 1 );
popup.insertItem( i18n( "Copy title and URL" ), 2 );
- Kita::Thread* thread = Kita::Thread::getByURL( item->text( Row_DatURL ) );
+ Kita::Thread* thread = Kita::Thread::getByURL( item->text( Col_DatURL ) );
QClipboard* clipboard = QApplication::clipboard();
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qregexp.h>
+#include <qheader.h>
using namespace Kita;
subjectList->addColumn( i18n( "ResNum" ) );
subjectList->addColumn( i18n( "ReadNum" ) );
subjectList->addColumn( i18n( "Unread" ) );
- subjectList->addColumn( i18n( "Board" ) );
subjectList->addColumn( i18n( "Since" ) );
+ subjectList->addColumn( i18n( "Board" ) );
- subjectList->setColumnWidth( Row_Subject, 400 );
- subjectList->setColumnWidthMode( Row_Subject, QListView::Manual );
+ subjectList->setColumnWidth( Col_Subject, 400 );
+ subjectList->setColumnWidthMode( Col_Subject, QListView::Manual );
connect( SearchButton, SIGNAL( clicked() ),
SLOT( slotSearchButton() ) );
{
for ( int count = 0; count < SearchCombo->count(); ++count ) {
if ( SearchCombo->text( count ) == SearchCombo->currentText() ) {
- return;
+ return ;
}
}
SearchCombo->insertItem( SearchCombo->currentText() );
void ThreadListView::searchNext( const QStringList &query )
{
- if ( query.isEmpty() ) return;
+ if ( query.isEmpty() ) return ;
if ( query != m_prevquery ) {
searchAll( query );
slotHideButton( HideButton->isOn() );
m_nextHitIndex = 0; //A next jump-search target reset to '0'.
- return;
+ return ;
}
if ( m_nextHitIndex >= m_hitList.size() ) {
- return;
+ return ;
}
KListViewItem* item = m_hitList[ m_nextHitIndex ];
QListViewItemIterator listIt( subjectList );
while ( listIt.current() != 0 ) {
- KListViewItem* item = static_cast<KListViewItem*>( listIt.current() );
- item->setPixmap( Row_Icon, 0 );
+ KListViewItem * item = static_cast<KListViewItem*>( listIt.current() );
+ item->setPixmap( Col_Icon, 0 );
QStringList::const_iterator queryIt = query.begin();
for ( ; queryIt != query.end(); ++queryIt ) {
- if ( item->text( Row_Subject ).contains( *queryIt, false ) ) {
- item->setPixmap( Row_Icon, SmallIcon( "find" ) );
+ if ( item->text( Col_Subject ).contains( *queryIt, false ) ) {
+ item->setPixmap( Col_Icon, SmallIcon( "find" ) );
m_hitList.append( item );
break;
}
void ThreadListView::slotHideButton( bool on )
{
- if ( m_hitList.empty() ) return;
+ if ( m_hitList.empty() ) return ;
QListViewItemIterator listIt( subjectList );
while ( listIt.current() != 0 ) {
- KListViewItem* item = static_cast<KListViewItem *>( listIt.current() );
- if ( on && ! item->pixmap( Row_Icon ) ) {
+ KListViewItem * item = static_cast<KListViewItem *>( listIt.current() );
+ if ( on && ! item->pixmap( Col_Icon ) ) {
item->setVisible( false );
} else {
item->setVisible( true );
}
}
+int ThreadListViewItem::compare( QListViewItem* i, int col, bool ascending ) const
+{
+ switch ( col ) {
+ case Col_ResNum:
+ case Col_Read:
+ case Col_Unread:
+ return QString::localeAwareCompare( i->key( col, ascending ), key( col, ascending ) );
+ default:
+ return QString::localeAwareCompare( key( col, ascending ), i->key( col, ascending ) );
+ }
+}
+
#include "threadlistview.moc"
#include <klistview.h>
enum ThreadListViewRows {
- Row_Mark,
- Row_ID,
- Row_Icon,
- Row_Subject,
- Row_ResNum,
- Row_Read,
- Row_Unread,
- Row_Board,
- Row_Since,
- Row_DatURL
+ Col_Mark,
+ Col_ID,
+ Col_Icon,
+ Col_Subject,
+ Col_ResNum,
+ Col_Read,
+ Col_Unread,
+ Col_Since,
+ Col_Board,
+ Col_DatURL
};
namespace Kita
void slotSearchButton();
};
+ class ThreadListViewItem : public KListViewItem
+ {
+ public:
+ ThreadListViewItem( QListView* parent ) : KListViewItem( parent ) {};
+ virtual ~ThreadListViewItem() {};
+
+ virtual int compare( QListViewItem* i, int col, bool ascending ) const;
+ };
};
#endif