1 /***************************************************************************
2 * Copyright (C) 2003 by Hideki Ikemoto *
3 * ikemo@users.sourceforge.jp *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 #include "favoritelistview.h"
13 #include "libkita/favoritethreads.h"
14 #include "libkita/board.h"
20 enum FavoriteListViewRows {
31 FavoriteListView::FavoriteListView(QWidget* parent, const char *name)
32 : KListView(parent, name)
34 addColumn(i18n("Board"));
36 addColumn(i18n("Title"));
37 addColumn(i18n("ResNum"));
38 addColumn(i18n("Vested"));
39 addColumn(i18n("Unread"));
40 addColumn(i18n("Dat"));
42 setColumnWidth(Row_Subject, 400);
43 setColumnWidthMode(Row_Subject, QListView::Manual);
45 connect( this, SIGNAL( clicked(QListViewItem*) ),
46 SLOT( loadThread(QListViewItem*) ) );
49 FavoriteListView::~FavoriteListView()
53 void FavoriteListView::update()
55 const QDict<Kita::Thread>& threads = FavoriteThreads::getInstance()->threads();
56 // FavoriteThreads::const_iterator it;
60 QDictIterator<Kita::Thread> it( threads );
61 for(; it.current(); ++it) {
62 const Kita::Thread* thread = it.current();
63 const Kita::Board* board = thread->getBoard();
65 new KListViewItem( this,
69 QString("%1").arg(thread->resNum(), 4),
72 thread->datURL().fileName(),
73 thread->datURL().prettyURL() );
77 void FavoriteListView::loadThread( QListViewItem* item )
81 const QDict<Kita::Thread>& threads = FavoriteThreads::getInstance()->threads();
82 // FavoriteThreads::const_iterator it;
84 QDictIterator<Kita::Thread> it( threads );
85 for(; it.current(); ++it) {
86 const Kita::Thread* thread = it.current();
88 if( thread->datURL().prettyURL() == item->text( Row_DatURL ) ) {
89 emit signalShowThread( *thread );