svnno****@sourc*****
svnno****@sourc*****
2009年 7月 14日 (火) 06:43:18 JST
Revision: 2406 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2406 Author: nogu Date: 2009-07-14 06:43:18 +0900 (Tue, 14 Jul 2009) Log Message: ----------- don't use K3ListView Modified Paths: -------------- kita/branches/KITA-KDE4/kita/src/bbsview.cpp kita/branches/KITA-KDE4/kita/src/bbsview.h kita/branches/KITA-KDE4/kita/src/boardview.cpp kita/branches/KITA-KDE4/kita/src/boardview.h kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp kita/branches/KITA-KDE4/kita/src/favoritelistview.h kita/branches/KITA-KDE4/kita/src/kitaui/CMakeLists.txt kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.cpp kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.h kita/branches/KITA-KDE4/kita/src/libkita/CMakeLists.txt kita/branches/KITA-KDE4/kita/src/threadlistview.cpp kita/branches/KITA-KDE4/kita/src/threadlistview.h kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui kita/branches/KITA-KDE4/kita/src/threadlistviewitem.cpp kita/branches/KITA-KDE4/kita/src/threadlistviewitem.h Modified: kita/branches/KITA-KDE4/kita/src/bbsview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/bbsview.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/bbsview.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -17,10 +17,12 @@ #include <QtGui/QApplication> #include <QtGui/QClipboard> #include <QtGui/QHBoxLayout> +#include <QtGui/QHeaderView> #include <QtGui/QMessageBox> +#include <QtGui/QMouseEvent> #include <QtGui/QSpacerItem> +#include <QtGui/QTreeWidget> #include <QtGui/QVBoxLayout> -#include <Qt3Support/Q3Header> #include <kaction.h> #include <kcombobox.h> @@ -30,7 +32,6 @@ #include <kmessagebox.h> #include <krun.h> #include <kstandarddirs.h> -#include <k3listview.h> #include <kio/netaccess.h> #include "viewmediator.h" @@ -76,32 +77,29 @@ layout10->addItem(spacer2); KitaBBSViewBaseLayout->addLayout(layout10); - m_boardList = new K3ListView(this); + m_boardList = new QTreeWidget(this); m_boardList->setRootIsDecorated(true); - m_boardList->setTreeStepSize(10); - m_boardList->setFullWidth(true); KitaBBSViewBaseLayout->addWidget(m_boardList); resize(QSize(600, 482).expandedTo(minimumSizeHint())); setAttribute(Qt::WA_WState_Polished); /* copy end */ - m_boardList->setSorting(-1); - m_boardList->addColumn(i18n("board name")); - m_boardList->header() ->setClickEnabled(false); + m_boardList->setHeaderLabel(i18n("board name")); + m_boardList->header()->setClickable(false); /* default colors */ QPalette palette = m_boardList->viewport() ->palette(); m_textColor = palette.text(); m_baseColor = palette.base(); m_backColor = m_boardList->viewport()->palette().color(QPalette::Background); - m_altColor = m_boardList->alternateBackground(); - connect(m_boardList, SIGNAL(mouseButtonClicked(int, Q3ListViewItem*, const QPoint&, int)), - SLOT(slotMouseButtonClicked(int, Q3ListViewItem*))); - connect(m_boardList, SIGNAL(returnPressed(Q3ListViewItem*)), SLOT(loadBoard(Q3ListViewItem*))); - connect(m_boardList, SIGNAL(contextMenuRequested(Q3ListViewItem*, const QPoint&, int)), - SLOT(slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int))); - connect(Kita::FavoriteBoards::getInstance(), SIGNAL(changed()), SLOT(refreshFavoriteBoards())); + connect(m_boardList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), + SLOT(loadBoard(QTreeWidgetItem*))); + connect(m_boardList, + SIGNAL(customContextMenuRequested(const QPoint&)), + SLOT(slotContextMenuRequested(const QPoint&))); + connect(Kita::FavoriteBoards::getInstance(), SIGNAL(changed()), + SLOT(refreshFavoriteBoards())); connect(SearchCombo, SIGNAL(textChanged(const QString&)), SLOT(filter(const QString&))); } @@ -159,14 +157,16 @@ QString boardURL = *it2; QString boardName = category.boardNameList[ count ]; QString oldURL; - int ret = Kita::BoardManager::enrollBoard(boardURL, boardName, oldURL, Kita::Board_Unknown, - true /* test only */ - ); + int ret = Kita::BoardManager::enrollBoard( + boardURL, boardName, oldURL, Kita::Board_Unknown, + true /* test only */); if (ret == Kita::Board_enrollNew) { - newBoards += boardName + " ( " + category.category_name + " ) " + boardURL + '\n'; + newBoards += boardName + " ( " + category.category_name + + " ) " + boardURL + '\n'; } if (ret == Kita::Board_enrollMoved) { - oldBoards += boardName + " ( " + category.category_name + " ) " + oldURL + " -> " + boardURL + '\n'; + oldBoards += boardName + " ( " + category.category_name + + " ) " + oldURL + " -> " + boardURL + '\n'; } count++; oldURLs += oldURL; @@ -190,26 +190,26 @@ QStringList boardList = oldBoards.split('\n'); KMessageBox::informationList(this, - i18n("These boards were moved:\n\n") - + i18n("\nPlease create the backup of those caches.\n"), - boardList, "Kita"); + i18n("These boards were moved:\n\n") + + i18n("\nPlease create the backup of those caches.\n"), + boardList, "Kita"); } if ((!newBoards.isEmpty() && newBoards.count("\n") < maxNewBoard) || !oldBoards.isEmpty()) { QMessageBox mb("kita", i18n("Do you really want to update board list?"), - QMessageBox::Information, - QMessageBox::Ok, - QMessageBox::Cancel | QMessageBox::Default | QMessageBox::Escape, - QMessageBox::No, this); + QMessageBox::Information, + QMessageBox::Ok, + QMessageBox::Cancel | QMessageBox::Default | QMessageBox::Escape, + QMessageBox::No, this); mb.setButtonText(QMessageBox::No, i18n("Copy")); int ret; while ((ret = mb.exec()) == QMessageBox::No) { QString str = i18n("New boards:\n\n") + newBoards + '\n' - + i18n("These boards were moved:\n\n") + oldBoards; + + i18n("These boards were moved:\n\n") + oldBoards; QApplication::clipboard() ->setText(str , QClipboard::Clipboard); QApplication::clipboard() ->setText(str , QClipboard::Selection); } @@ -305,7 +305,6 @@ QPalette palette; palette.setColor(widget->backgroundRole(), m_backColor); widget->setPalette(palette); - m_boardList->setAlternateBackground(m_altColor); // clear list m_boardList->clear(); @@ -321,7 +320,7 @@ QString category = (*it); KConfigGroup group = config.group(category); - Kita::ListViewItem* categoryItem = new Kita::ListViewItem(m_boardList, previous, category); + Kita::ListViewItem* categoryItem = new Kita::ListViewItem(m_boardList, previous, QStringList(category)); categoryItem->setColor(m_textColor.color(), m_baseColor.color()); Kita::ListViewItem* previousBoard = 0; @@ -342,7 +341,7 @@ QString oldURL; Kita::BoardManager::enrollBoard(boardURL, boardName, oldURL); Kita::BoardManager::loadBBSHistory(boardURL); - previousBoard = new Kita::ListViewItem(categoryItem, previousBoard, boardName, boardURL); + previousBoard = new Kita::ListViewItem(categoryItem, previousBoard, QStringList() << boardName << boardURL); previousBoard->setColor(m_textColor.color(), m_baseColor.color()); } previous = categoryItem; @@ -351,7 +350,8 @@ QString boardURL = "http://jbbs.livedoor.jp/computer/18420/" ; QString boardName = i18n("Kita Board"); QString oldURL; - new Kita::ListViewItem(m_boardList, 0, boardName, boardURL); + new Kita::ListViewItem(m_boardList, 0, + QStringList() << boardName << boardURL); Kita::BoardManager::enrollBoard(boardURL, boardName, oldURL); loadExtBoard(); @@ -372,7 +372,8 @@ QStringList list; QString str; - Kita::ListViewItem* categoryItem = new Kita::ListViewItem(m_boardList, "extboard"); + Kita::ListViewItem* categoryItem + = new Kita::ListViewItem(m_boardList, QStringList("extboard")); categoryItem->setColor(m_textColor.color(), m_baseColor.color()); while (!(str = stream.readLine()).isEmpty()) { @@ -383,12 +384,16 @@ QString board_title = list[ 0 ]; QString board_url = list[ 1 ]; - Kita::ListViewItem* tmpitem = new Kita::ListViewItem(categoryItem, board_title, board_url); - tmpitem->setColor(m_textColor.color(), m_baseColor.color()); + Kita::ListViewItem* tmpitem + = new Kita::ListViewItem(categoryItem, + QStringList() << board_title << board_url); + tmpitem->setColor( + m_textColor.color(), m_baseColor.color()); QString oldURL; int type = Kita::Board_Unknown; if (list.size() == 3) type = list[ 2 ].toInt(); - Kita::BoardManager::enrollBoard(board_url, board_title, oldURL, type); + Kita::BoardManager::enrollBoard( + board_url, board_title, oldURL, type); } } } @@ -422,7 +427,8 @@ if (regexp.indexIn((*it)) != -1) { QString url = regexp.cap(1); QString title = regexp.cap(2); - if (Kita::isBoardURL(url) && !current_category.category_name.isEmpty()) { + if (Kita::isBoardURL(url) + && !current_category.category_name.isEmpty()) { current_category.boardNameList.append(title); current_category.boardURLList.append(url); } @@ -435,13 +441,14 @@ void KitaBBSView::refreshFavoriteBoards() { if (! m_favorites) { - m_favorites = new Kita::ListViewItem(m_boardList, 0, i18n("Favorites")); + m_favorites = new Kita::ListViewItem(m_boardList, + QStringList(i18n("Favorites"))); } m_favorites->setColor(m_textColor.color(), m_baseColor.color()); // remove all items. do { - Q3ListViewItem* child = m_favorites->firstChild(); + QTreeWidgetItem* child = m_favorites->child(0); delete child; } while (m_favorites->childCount() != 0); @@ -453,12 +460,14 @@ QString boardURL = (*it).prettyUrl(); QString boardName = Kita::BoardManager::boardName(boardURL); - Kita::ListViewItem* item = new Kita::ListViewItem(m_favorites, 0, boardName, boardURL); + Kita::ListViewItem* item + = new Kita::ListViewItem(m_favorites, + QStringList() << boardName << boardURL); item->setColor(m_textColor.color(), m_baseColor.color()); } } -void KitaBBSView::loadBoard(Q3ListViewItem* item) +void KitaBBSView::loadBoard(QTreeWidgetItem* item) { if (! item) return ; @@ -486,33 +495,37 @@ void KitaBBSView::slotMenuOpenWithBrowser() { - Q3ListViewItem* item = m_boardList->currentItem(); + QTreeWidgetItem* item = m_boardList->currentItem(); QString boardName = item->text(0); KUrl boardURL = item->text(1); KRun::runUrl(boardURL, "text/html", 0); } -void KitaBBSView::slotContextMenuRequested(Q3ListViewItem* item, const QPoint& point, int) +void KitaBBSView::slotContextMenuRequested(const QPoint& point) { + QTreeWidgetItem* item = m_boardList->itemAt(point); if (item == 0) { - return ; + return; } KMenu popup(0); - KAction* openWithBrowserAct = new KAction(i18n("Open with Web Browser"), this); + KAction* openWithBrowserAct + = new KAction(i18n("Open with Web Browser"), this); popup.addAction(openWithBrowserAct); KAction* copyURLAct = new KAction(i18n("Copy URL"), this); popup.addAction(copyURLAct); - KAction* copyTitleAndURLAct = new KAction(i18n("Copy title and URL"), this); + KAction* copyTitleAndURLAct + = new KAction(i18n("Copy title and URL"), this); popup.addAction(copyTitleAndURLAct); KAction* removeFromFavoritesAct = 0; KAction* addToFavoritesAct = 0; if (item->parent() == m_favorites) { - removeFromFavoritesAct = new KAction(i18n("Remove from Favorites"), this); + removeFromFavoritesAct + = new KAction(i18n("Remove from Favorites"), this); popup.addAction(removeFromFavoritesAct); } else { addToFavoritesAct = new KAction(i18n("Add to Favorites"), this); @@ -534,8 +547,10 @@ clipboard->setText(boardURL_upToDate.prettyUrl(), QClipboard::Clipboard); clipboard->setText(boardURL_upToDate.prettyUrl(), QClipboard::Selection); } else if (action == copyTitleAndURLAct) { - clipboard->setText(boardName + '\n' + boardURL_upToDate.prettyUrl(), QClipboard::Clipboard); - clipboard->setText(boardName + '\n' + boardURL_upToDate.prettyUrl(), QClipboard::Selection); + clipboard->setText(boardName + '\n' + boardURL_upToDate.prettyUrl(), + QClipboard::Clipboard); + clipboard->setText(boardName + '\n' + boardURL_upToDate.prettyUrl(), + QClipboard::Selection); } else if (action == addToFavoritesAct) { Kita::FavoriteBoards::append(boardURL_upToDate); } else if (action == removeFromFavoritesAct) { @@ -543,39 +558,20 @@ } } -void KitaBBSView::slotMouseButtonClicked(int button, Q3ListViewItem* item) -{ - if (! item) return ; - - QString boardName = item->text(0); - QString boardURL = Kita::BoardManager::boardURL(item->text(1)); - if (boardURL.isEmpty()) { - m_boardList->setOpen(item, !item->isOpen()); - return ; - } - - switch (button) { - case Qt::MidButton: - ViewMediator::getInstance()->openBoard(boardURL); - break; - case Qt::LeftButton: - ViewMediator::getInstance()->openBoard(boardURL); - break; - } -} - void KitaBBSView::loadOpened() { - QString configPath = KStandardDirs::locateLocal("appdata", "board_state.conf"); + QString configPath + = KStandardDirs::locateLocal("appdata", "board_state.conf"); KConfig config(configPath); - QStringList openedList = config.group("").readEntry("Opened", QStringList()); + QStringList openedList + = config.group("").readEntry("Opened", QStringList()); - Q3ListViewItem* item; - for (item = m_boardList->firstChild(); item; item = item->nextSibling()) { + for (int i = 0, j = m_boardList->topLevelItemCount(); i < j; i++) { + QTreeWidgetItem* item = m_boardList->topLevelItem(0); QString categoryName = item->text(0); if (openedList.indexOf(categoryName) != -1) { - item->setOpen(true); + item->setExpanded(true); } } } @@ -583,16 +579,15 @@ void KitaBBSView::saveOpened() { QStringList openedList; - Q3ListViewItem* item; - - for (item = m_boardList->firstChild(); item; item = item->nextSibling()) { + for (int i = 0, j = m_boardList->topLevelItemCount(); i < j; i++) { + QTreeWidgetItem* item = m_boardList->topLevelItem(0); QString categoryName = item->text(0); - if (item->isOpen()) { + if (item->isExpanded()) { openedList << categoryName; } - } - - QString configPath = KStandardDirs::locateLocal("appdata", "board_state.conf"); + } + QString configPath + = KStandardDirs::locateLocal("appdata", "board_state.conf"); KConfig config(configPath); config.group("").writeEntry("Opened", openedList); @@ -605,22 +600,46 @@ */ void KitaBBSView::filter(const QString& str) { - Q3ListViewItem* categoryItem; - Q3ListViewItem* boardItem; - for (categoryItem = m_boardList->firstChild(); categoryItem; categoryItem = categoryItem->nextSibling()) { + for (int i = 0, j = m_boardList->topLevelItemCount(); i < j; i++) { bool matched = false; + QTreeWidgetItem* categoryItem = m_boardList->topLevelItem(i); - for (boardItem = categoryItem->firstChild(); boardItem; boardItem = boardItem->nextSibling()) { + for (int k = 0, l = categoryItem->childCount(); k < l; k++) { + QTreeWidgetItem* boardItem = categoryItem->child(k); QString boardName = boardItem->text(0); if (boardName.contains(str)) { - boardItem->setVisible(true); + boardItem->setHidden(false); matched = true; } else { - boardItem->setVisible(false); + boardItem->setHidden(true); } } + categoryItem->setHidden(!matched); + } +} - categoryItem->setVisible(matched); + +void KitaBBSView::mousePressEvent(QMouseEvent *e) +{ + QTreeWidgetItem* item = m_boardList->itemAt(e->pos()); + if (!item) return; + + QString boardName = item->text(0); + QString boardURL = Kita::BoardManager::boardURL(item->text(1)); + if (boardURL.isEmpty()) { + item->setExpanded(!item->isExpanded()); + return ; } + + switch (e->button()) { + case Qt::MidButton: + ViewMediator::getInstance()->openBoard(boardURL); + break; + case Qt::LeftButton: + ViewMediator::getInstance()->openBoard(boardURL); + break; + default: + return; + } } Modified: kita/branches/KITA-KDE4/kita/src/bbsview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/bbsview.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/bbsview.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -14,15 +14,15 @@ #include <QtCore/QList> #include <QtGui/QWidget> -class KComboBox; -class KUrl; -class K3ListView; -class QCp932Codec; -class Q3ListViewItem; +class QHBoxLayout; class QSpacerItem; +class QTreeWidget; +class QTreeWidgetItem; class QVBoxLayout; -class QHBoxLayout; +class KComboBox; +class KUrl; + namespace Kita { class Board; @@ -43,13 +43,12 @@ QBrush m_textColor; QBrush m_baseColor; QColor m_backColor; - QColor m_altColor; QList<Kita::Category> getCategoryList(const QString& html) const; void saveOpened(); KComboBox* SearchCombo; - K3ListView* m_boardList; + QTreeWidget* m_boardList; protected: QVBoxLayout* KitaBBSViewBaseLayout; @@ -57,9 +56,8 @@ QSpacerItem* spacer2; private slots: - void loadBoard(Q3ListViewItem* item); - void slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int); - void slotMouseButtonClicked(int, Q3ListViewItem*); + void loadBoard(QTreeWidgetItem* item); + void slotContextMenuRequested(const QPoint&); void refreshFavoriteBoards(); void filter(const QString& str); void slotMenuOpenWithBrowser(); @@ -79,6 +77,7 @@ private: void loadExtBoard(); bool downloadBoardList(); + void mousePressEvent(QMouseEvent *e); KitaBBSView(const KitaBBSView&); KitaBBSView& operator=(const KitaBBSView&); }; Modified: kita/branches/KITA-KDE4/kita/src/boardview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -43,21 +43,19 @@ m_parent = parent; closeButton->setEnabled(true); - connect(subjectList, SIGNAL(contextMenuRequested(Q3ListViewItem*, const QPoint&, int)), - SLOT(slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int))); - connect(subjectList, SIGNAL(returnPressed(Q3ListViewItem*)), - SLOT(loadThread(Q3ListViewItem*))); + connect(subjectList, SIGNAL(customContextMenuRequested(const QPoint&)), + SLOT(slotContextMenuRequested(const QPoint&))); + connect(subjectList, SIGNAL(returnPressed(QTableWidgetItem*)), + SLOT(loadThread(QTableWidgetItem*))); connect(ReloadButton, SIGNAL(clicked()), SLOT(reloadSubject())); connect(closeButton, SIGNAL(clicked()), SLOT(slotCloseButton())); - Q3Header* header = subjectList->header(); - connect(header, SIGNAL(sizeChange(int, int, int)), + connect(subjectList, SIGNAL(columnResized(int, int, int)), SLOT(slotSizeChange(int, int, int))); - header->installEventFilter(this); loadLayout(); loadHeaderOnOff(); } @@ -102,11 +100,11 @@ loadBoard(m_boardURL, false); } -void KitaBoardView::loadThread(Q3ListViewItem* item) +void KitaBoardView::loadThread(QTableWidgetItem* item) { if (! item) return ; - KUrl datURL = item->text(Col_DatURL); + KUrl datURL = item->text(); ViewMediator::getInstance()->openThread(datURL); } @@ -148,13 +146,16 @@ subjectList->clear(); QDateTime current = QDateTime::currentDateTime(); - unsigned int countNew = threadList.count(); - unsigned int countOld = oldLogList.count(); - for (unsigned i = 0; i < countNew + countOld; i++) { + int countNew = threadList.count(); + int countOld = oldLogList.count(); + int count = countNew + countOld; + subjectList->setRowCount(count); + for (int i = 0; i < count; i++) { Kita::Thread* thread = i < countNew ? threadList.at(i) : oldLogList.at(i - countNew); KUrl datURL = thread->datURL(); - Kita::ThreadListViewItem* item = new Kita::ThreadListViewItem(subjectList); + Kita::ThreadListViewItem* item = new Kita::ThreadListViewItem(); + subjectList->setItem(i, 0, item); int id = (i < countNew ? i + 1 : 0); int order = i + 1; updateListViewItem(item, datURL, current, id, order); @@ -167,19 +168,21 @@ switch (Kita::Config::listSortOrder()) { case Kita::Config::EnumListSortOrder::Mark: - subjectList->setSorting(Col_Mark); + subjectList->sortItems(Col_Mark); break; case Kita::Config::EnumListSortOrder::ID: - subjectList->setSorting(Col_ID); + subjectList->sortItems(Col_ID); break; default: // do nothing break; } - subjectList->setSelected(subjectList->firstChild(), true); + subjectList->setRangeSelected( + QTableWidgetSelectionRange(0, 0, 0, subjectList->columnCount()), + true); subjectList->setFocus(); - UpdateKindLabel(); + updateKindLabel(); /* restore column size */ loadLayout(); @@ -203,7 +206,7 @@ } } -void KitaBoardView::UpdateKindLabel() +void KitaBoardView::updateKindLabel() { QString fmtstr; fmtstr += QString("<font color=#C50000>%1</font>").arg(m_unreadNum); @@ -223,10 +226,10 @@ QDateTime current = QDateTime::currentDateTime(); KUrl datURL = Kita::getDatURL(url); - for (Q3ListViewItem * item = subjectList->firstChild(); item; item = item->nextSibling()) { - if (item->text(Col_DatURL) == datURL.prettyUrl()) { + for (int i = 0, j = subjectList->rowCount(); i < j; i++) { + if (subjectList->item(i, Col_DatURL)->text() == datURL.prettyUrl()) { - switch (item->text(Col_MarkOrder).toInt()) { + switch (subjectList->item(i, Col_MarkOrder)->text().toInt()) { case Thread_Readed : case Thread_Read : m_readNum--; break; case Thread_New : m_newNum--; break; @@ -235,11 +238,12 @@ Kita::Thread* thread = Kita::Thread::getByURLNew(datURL); if (thread == 0) return ; - int id = item->text(Col_ID).toInt(); - int order = item->text(Col_IDOrder).toInt(); - updateListViewItem(item, datURL, current, id, order); + int id = subjectList->item(i, Col_ID)->text().toInt(); + int order = subjectList->item(i, Col_IDOrder)->text().toInt(); + updateListViewItem(subjectList->item(i, 0), + datURL, current, id, order); - UpdateKindLabel(); + updateKindLabel(); return ; } @@ -250,8 +254,9 @@ /* if id == 0, this thread is old thread. */ /* private */ -void KitaBoardView::updateListViewItem(Q3ListViewItem* item, const KUrl& datURL, const QDateTime& current, int id, int order) +void KitaBoardView::updateListViewItem(QTableWidgetItem* item, const KUrl& datURL, const QDateTime& current, int id, int order) { + int row = item->row(); QDateTime since; since.setTime_t(Kita::datToSince(datURL)); QString threadName = Kita::DatManager::threadName(datURL); @@ -260,60 +265,68 @@ int viewPos = Kita::DatManager::getViewPos(datURL); double speed = resNum / (since.secsTo(current) / (60.0 * 60.0 * 24.0)); - if (id) item->setText(Col_ID, QString().setNum(id)); - item->setText(Col_IDOrder, QString().setNum(order)); - item->setText(Col_Subject, threadName); - item->setText(Col_ResNum, QString("%1").arg(resNum, 4)); - item->setText(Col_ReadNum, (viewPos > 0) ? QString("%1").arg(viewPos, 4) : QString("")); - item->setText(Col_Unread, (viewPos > 0 && resNum > viewPos) ? QString("%1").arg(resNum - viewPos, 4) : QString("")); - item->setText(Col_Since, since.toString("yy/MM/dd hh:mm")); - item->setText(Col_DatURL, datURL.prettyUrl()); - item->setText(Col_Speed, QString(" %1 ").arg(speed, 0, 'f', 2)); + if (id) subjectList->item(row, Col_ID)->setText(QString::number(id)); + subjectList->item(row, Col_IDOrder)->setText(QString::number(order)); + subjectList->item(row, Col_Subject)->setText(threadName); + subjectList->item(row, Col_ResNum)->setText(QString("%1").arg(resNum, 4)); + subjectList->item(row, Col_ReadNum) + ->setText((viewPos > 0) ? QString("%1").arg(viewPos, 4) : QString()); + subjectList->item(row, Col_Unread) + ->setText((viewPos > 0 && resNum > viewPos) + ? QString("%1").arg(resNum - viewPos, 4) : QString()); + subjectList->item(row, Col_Since) + ->setText(since.toString("yy/MM/dd hh:mm")); + subjectList->item(row, Col_DatURL)->setText(datURL.prettyUrl()); + subjectList->item(row, Col_Speed) + ->setText(QString(" %1 ").arg(speed, 0, 'f', 2)); /* set mark order */ if (!id) { /* old thread */ - - item->setText(Col_MarkOrder, QString::number(Thread_Old)); - } else if (readNum > 0 && (resNum > readNum || resNum > viewPos)) { /* There are new responses. */ - - item->setPixmap(Col_Mark, SmallIcon("unread")); + subjectList->item(row, Col_MarkOrder) + ->setText(QString::number(Thread_Old)); + } else if (readNum > 0 && (resNum > readNum || resNum > viewPos)) { + /* There are new responses. */ + subjectList->item(row, Col_Mark)->setIcon(QIcon(SmallIcon("unread"))); m_unreadNum++; - item->setText(Col_MarkOrder, QString::number(Thread_HasUnread)); - + subjectList->item(row, Col_MarkOrder) + ->setText(QString::number(Thread_HasUnread)); } else if (readNum > 0) { /* Cache exists */ - - item->setPixmap(Col_Mark, SmallIcon("read")); + subjectList->item(row, Col_Mark)->setIcon(QIcon(SmallIcon("read"))); m_readNum++; - item->setText(Col_MarkOrder, QString::number((viewPos > 1000) ? Thread_Readed : Thread_Read)); - - } else if (since.secsTo(current) < 3600 * Kita::Config::markTime()) { /* new thread */ - - item->setPixmap(Col_Mark, SmallIcon("newthread")); + subjectList->item(row, Col_MarkOrder) + ->setText(QString::number((viewPos > 1000) + ? Thread_Readed : Thread_Read)); + } else if (since.secsTo(current) < 3600 * Kita::Config::markTime()) { + /* new thread */ + subjectList->item(row, Col_Mark) + ->setIcon(QIcon(SmallIcon("newthread"))); m_newNum++; - item->setText(Col_MarkOrder, QString::number(Thread_New)); - + subjectList->item(row, Col_MarkOrder) + ->setText(QString::number(Thread_New)); } else { /* normal */ - - item->setText(Col_MarkOrder, QString::number(Thread_Normal)); - item->setPixmap(Col_Mark, 0); + subjectList->item(row, Col_MarkOrder) + ->setText(QString::number(Thread_Normal)); + subjectList->item(row, Col_Mark)->setIcon(QIcon()); } // no effect: m_unreadNum, m_readNum, m_newNum, markOrder - if (Kita::DatManager::isMainThreadOpened(datURL) && resNum == readNum) { /* opened */ - item->setPixmap(Col_Mark, SmallIcon("open")); + if (Kita::DatManager::isMainThreadOpened(datURL) && resNum == readNum) { + /* opened */ + subjectList->item(row, Col_Mark)->setIcon(QIcon(SmallIcon("open"))); } } -void KitaBoardView::slotContextMenuRequested(Q3ListViewItem* item, const QPoint& point, int) +void KitaBoardView::slotContextMenuRequested(const QPoint& point) { + QTableWidgetItem* item = subjectList->itemAt(point); if (item == 0) { - return ; + return; } - QString datURL = item->text(Col_DatURL); + QString datURL = subjectList->item(item->row(), Col_DatURL)->text(); QString threadURL = Kita::DatManager::threadURL(datURL); - bool isFavorites = FavoriteThreads::getInstance() ->contains(datURL); + bool isFavorites = FavoriteThreads::getInstance()->contains(datURL); // create popup menu. KMenu popup(0); @@ -409,8 +422,8 @@ if (autoResize()) return ; QString configPath = KStandardDirs::locateLocal("appdata", "subjectview.conf"); - KConfig config(configPath); - subjectList->saveLayout(&config, "Layout"); +// KConfig config(configPath); TODO +// subjectList->saveLayout(&config, "Layout"); TODO } void KitaBoardView::loadLayout() @@ -418,7 +431,7 @@ if (autoResize()) return ; QString configPath = KStandardDirs::locateLocal("appdata", "subjectview.conf"); KConfig config(configPath); - subjectList->restoreLayout(&config, "Layout"); + // subjectList->restoreLayout(&config, "Layout"); TODO } bool KitaBoardView::eventFilter(QObject* watched, QEvent* e) @@ -458,7 +471,7 @@ return false; } } else { - return subjectList->header() ->eventFilter(watched, e); + return false;//subjectList->header() ->eventFilter(watched, e);//TODO } } Modified: kita/branches/KITA-KDE4/kita/src/boardview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -15,7 +15,9 @@ #include "threadlistview.h" +class QTreeWidgetItem; class QWidget; + class KListViewItem; class KitaBoardTabWidget; @@ -50,10 +52,11 @@ bool m_showOldLogs; bool m_enableSizeChange; - void UpdateKindLabel(); + void updateKindLabel(); void deleteLog(const KUrl& url); void loadLayout(); - void updateListViewItem(Q3ListViewItem* item, const KUrl& datURL, const QDateTime& current, int id, int order); + void updateListViewItem(QTableWidgetItem* item, const KUrl& datURL, + const QDateTime& current, int id, int order); bool eventFilter(QObject* watched, QEvent* e); void saveHeaderOnOff(); void loadHeaderOnOff(); @@ -63,8 +66,8 @@ KitaBoardView& operator=(const KitaBoardView&); private slots: - void loadThread(Q3ListViewItem* item); - void slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int); + void loadThread(QTableWidgetItem* item); + void slotContextMenuRequested(const QPoint&); void slotCloseButton(); void slotSizeChange(int section, int oldSize, int newSize); Modified: kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -13,11 +13,11 @@ #include <QtCore/QDateTime> #include <QtGui/QApplication> #include <QtGui/QClipboard> +#include <QtGui/QTableWidgetItem> #include <kaction.h> #include <kmenu.h> #include <krun.h> -#include <k3listview.h> #include "threadlistviewitem.h" #include "viewmediator.h" @@ -35,10 +35,10 @@ { KindLabel->hide(); - connect(subjectList, SIGNAL(returnPressed(Q3ListViewItem*)), - SLOT(loadThread(Q3ListViewItem*))); - connect(subjectList, SIGNAL(contextMenuRequested(Q3ListViewItem*, const QPoint&, int)), - SLOT(slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int))); + connect(subjectList, SIGNAL(cellPressed(int, int)), + SLOT(loadThread(int, int))); + connect(subjectList, SIGNAL(customContextMenuRequested(const QPoint&)), + SLOT(slotContextMenuRequested(const QPoint&))); connect(ReloadButton, SIGNAL(clicked()), SLOT(reload())); @@ -73,30 +73,36 @@ int viewPos = Kita::DatManager::getViewPos(datURL); int resNum = Kita::DatManager::getResNum(datURL); - K3ListViewItem* item = new K3ListViewItem(subjectList); - item->setText(Col_Board, Kita::BoardManager::boardName(datURL)); - item->setText(Col_Subject, Kita::DatManager::threadName(datURL)); - item->setText(Col_ReadNum, QString("%1").arg(viewPos, 4)); + subjectList->setItem(i, Col_Board, + new QTableWidgetItem(Kita::BoardManager::boardName(datURL))); + subjectList->setItem(i, Col_Subject, + new QTableWidgetItem(Kita::DatManager::threadName(datURL))); + subjectList->setItem(i, Col_ReadNum, + new QTableWidgetItem(QString("%1").arg(viewPos, 4))); if (resNum > 0) { - item->setText(Col_ResNum, QString("%1").arg(resNum, 4)); + subjectList->setItem(i, Col_ResNum, + new QTableWidgetItem(QString("%1").arg(resNum, 4))); } if (resNum != 0 && resNum != viewPos) { - item->setText(Col_Unread, QString("%1").arg(resNum - viewPos, 4)); + subjectList->setItem(i, Col_Unread, new QTableWidgetItem( + QString("%1").arg(resNum - viewPos, 4))); } - item->setText(Col_Since, since.toString("yy/MM/dd hh:mm")); - item->setText(Col_DatURL, datURL); + subjectList->setItem(i, Col_Since, + new QTableWidgetItem(since.toString("yy/MM/dd hh:mm"))); + subjectList->setItem(i, Col_DatURL, new QTableWidgetItem(datURL)); } - subjectList->setSorting(Col_Board); + subjectList->sortItems(Col_Board); } /** * */ -void FavoriteListView::loadThread(Q3ListViewItem* item) +void FavoriteListView::loadThread(int row, int column) { + QTableWidgetItem* item = subjectList->item(row, column); if (! item) return ; - QString itemURL = item->text(Col_DatURL); + QString itemURL = subjectList->item(item->row(), Col_DatURL)->text(); for (int i = 0; FavoriteThreads::count() > i; i++) { QString datURL = FavoriteThreads::getDatURL(i); @@ -110,9 +116,10 @@ /** * show and exec popup menu. */ -void FavoriteListView::slotContextMenuRequested(Q3ListViewItem* item, const QPoint& point, int) +void FavoriteListView::slotContextMenuRequested(const QPoint& point) { - if (! item) { + QTableWidgetItem* item = subjectList->itemAt(point); + if (!item) { return; } @@ -130,7 +137,7 @@ KAction* removeFromFavoritesAct = new KAction(i18n("Remove from Favorites"), this); popup.addAction(removeFromFavoritesAct); - QString datURL = item->text(Col_DatURL); + QString datURL = subjectList->item(item->row(), Col_DatURL)->text(); QString threadURL = Kita::DatManager::threadURL(datURL); QClipboard* clipboard = QApplication::clipboard(); Modified: kita/branches/KITA-KDE4/kita/src/favoritelistview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/favoritelistview.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/favoritelistview.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -28,8 +28,8 @@ void refresh(); private slots: - void loadThread(Q3ListViewItem* item); - void slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int); + void loadThread(int row, int column); + void slotContextMenuRequested(const QPoint&); void reload(); }; Modified: kita/branches/KITA-KDE4/kita/src/kitaui/CMakeLists.txt =================================================================== --- kita/branches/KITA-KDE4/kita/src/kitaui/CMakeLists.txt 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/kitaui/CMakeLists.txt 2009-07-13 21:43:18 UTC (rev 2406) @@ -8,7 +8,7 @@ kde4_add_library(kitaui SHARED ${kitaui_LIB_SRCS}) -target_link_libraries(kitaui ${KDE4_KDECORE_LIBS} ${KDE4_KHTML_LIBS} ${QT_QT3SUPPORT_LIBRARY} ${KDE4_KDE3SUPPORT_LIBS}) +target_link_libraries(kitaui ${KDE4_KDECORE_LIBS} ${KDE4_KHTML_LIBS}) set_target_properties(kitaui PROPERTIES VERSION 1.0.0 SOVERSION 1) install(TARGETS kitaui ${INSTALL_TARGETS_DEFAULT_ARGS}) Modified: kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -12,64 +12,37 @@ using namespace Kita; -ListViewItem::ListViewItem(Q3ListView *parent, Q3ListViewItem *after, - const QString& label1, const QString& label2, const QString& label3, - const QString& label4, const QString& label5, const QString& label6, - const QString& label7, const QString& label8) - : K3ListViewItem(parent, after, label1, label2, label3, label4, label5, - label6, label7, label8) +ListViewItem::ListViewItem(QTreeWidget *parent, QTreeWidgetItem *preceding, + const QStringList& strings) + : QTreeWidgetItem(parent, preceding) { - init(); + for (int i = 0, j = strings.size(); i < j; i++) + setText(i, strings.at(i)); } -ListViewItem::ListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after, - const QString& label1, const QString& label2, const QString& label3, - const QString& label4, const QString& label5, const QString& label6, - const QString& label7, const QString& label8) - : K3ListViewItem(parent, after, label1, label2, label3, label4, label5, - label6, label7, label8) +ListViewItem::ListViewItem(QTreeWidget *parent, const QStringList& strings) + : QTreeWidgetItem(parent, strings) { - init(); } -ListViewItem::ListViewItem(Q3ListView* parent, - const QString& label1, const QString& label2) - : K3ListViewItem(parent, label1, label2) +ListViewItem::ListViewItem(QTreeWidgetItem* parent, QTreeWidgetItem *preceding, + const QStringList& strings) + : QTreeWidgetItem(parent, preceding) { - init(); + for (int i = 0, j = strings.size(); i < j; i++) + setText(i, strings.at(i)); } -ListViewItem::ListViewItem(Q3ListViewItem* parent, - const QString& label1, const QString& label2) - : K3ListViewItem(parent, label1, label2) +ListViewItem::ListViewItem(QTreeWidgetItem* parent, const QStringList& strings) + : QTreeWidgetItem(parent, strings) { - init(); } -ListViewItem::~ListViewItem() -{} - -/* private */ -void ListViewItem::init() -{ - QPalette palette = listView() ->viewport() ->palette(); - m_textPalette = palette.text(); - m_basePalette = palette.base(); -} - /* public */ void ListViewItem::setColor(const QColor& textColor, const QColor& baseColor) { - m_textPalette = textColor; - m_basePalette = baseColor; + for (int i = 0, j = columnCount(); i < j; i++) { + setForeground(i, QBrush(textColor)); + setBackground(i, QBrush(baseColor)); + } } - -/* public */ /* virtual */ -void ListViewItem::paintCell(QPainter *p, const QColorGroup &cg, - int column, int width, int align) -{ -/* QColorGroup colorGroup(cg); - colorGroup.setColor(QColorGroup::Text, m_textPalette); - colorGroup.setColor(QColorGroup::Base, m_basePalette);*/ // TODO - K3ListViewItem::paintCell(p, cg, column, width, align); -} Modified: kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/kitaui/listviewitem.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -11,39 +11,27 @@ #ifndef KITALISTVIEWITEM_H #define KITALISTVIEWITEM_H -#include <k3listview.h> +#include <QtGui/QTreeWidgetItem> +#include <kdemacros.h> + namespace Kita { - class KDE_EXPORT ListViewItem : public K3ListViewItem + class KDE_EXPORT ListViewItem : public QTreeWidgetItem { - QBrush m_textPalette; /* text palette */ - QBrush m_basePalette; /* background palette */ - public: - ListViewItem(Q3ListView *parent, Q3ListViewItem *after, - const QString&, const QString& = QString(), - const QString& = QString(), const QString& = QString(), - const QString& = QString(), const QString& = QString(), - const QString& = QString(), const QString& = QString()); + ListViewItem(QTreeWidget *parent, QTreeWidgetItem *preceding, + const QStringList& strings); - ListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after, - const QString&, const QString& = QString(), - const QString& = QString(), const QString& = QString(), - const QString& = QString(), const QString& = QString(), - const QString& = QString(), const QString& = QString()); + ListViewItem(QTreeWidget *parent, const QStringList& strings); - explicit ListViewItem(Q3ListView* parent, - const QString& = QString(), const QString& = QString()); + ListViewItem(QTreeWidgetItem *parent, QTreeWidgetItem *preceding, + const QStringList& strings); - explicit ListViewItem(Q3ListViewItem* parent, - const QString& = QString(), const QString& = QString()); + ListViewItem(QTreeWidgetItem *parent, const QStringList& strings); - ~ListViewItem(); - void setColor(const QColor& textColor, const QColor& baseColor); - virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align); private: void init(); Modified: kita/branches/KITA-KDE4/kita/src/libkita/CMakeLists.txt =================================================================== --- kita/branches/KITA-KDE4/kita/src/libkita/CMakeLists.txt 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/libkita/CMakeLists.txt 2009-07-13 21:43:18 UTC (rev 2406) @@ -30,7 +30,7 @@ kde4_add_library(kitautil SHARED ${kita_LIB_SRCS}) -target_link_libraries(kitautil ${KDE4_KDECORE_LIBS} ${QT_QT3SUPPORT_LIBRARY} ${KDE4_KIO_LIBS} ${KDE4_KDE3SUPPORT_LIBS}) +target_link_libraries(kitautil ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS}) set_target_properties(kitautil PROPERTIES VERSION 1.0.0 SOVERSION 1) install(TARGETS kitautil ${INSTALL_TARGETS_DEFAULT_ARGS}) Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -11,7 +11,6 @@ #include "threadlistview.h" #include <kurl.h> -#include <k3listview.h> #include "threadlistviewitem.h" #include "viewmediator.h" @@ -46,15 +45,18 @@ ReloadButton->setIcon(SmallIcon("view-refresh")); closeButton->setIcon(SmallIcon("tab-close")); - Q3Header* header = subjectList->header(); + //Q3Header* header = subjectList->header(); TODO for (int i = Col_Begin; i <= Col_End; i++) { - subjectList->addColumn(i18n(s_colAttr[ i ].labelName)); + int count = subjectList->columnCount() + 1; + subjectList->setColumnCount(count); + subjectList->setHorizontalHeaderItem(count, + new QTableWidgetItem(i18n(s_colAttr[i].labelName))); if (s_colAttr[ i ].showDefault != true) { hideColumn(i); } } - header->setStretchEnabled(true, Col_Subject); + //header->setStretchEnabled(true, Col_Subject); TODO connect(SearchCombo, SIGNAL(activated(int)), SLOT(slotSearchButton())); @@ -62,8 +64,8 @@ SLOT(slotSearchButton())); connect(HideButton, SIGNAL(toggled(bool)), SLOT(slotHideButton(bool))); - connect(subjectList, SIGNAL(mouseButtonClicked(int, Q3ListViewItem*, const QPoint&, int)), - SLOT(slotMouseButtonClicked(int, Q3ListViewItem*))); + connect(subjectList, SIGNAL(itemClicked(QTableWidgetItem*)), + SLOT(slotMouseButtonClicked(QTableWidgetItem*))); } ThreadListView::~ThreadListView() @@ -99,9 +101,11 @@ Q_ASSERT(query == m_prevquery); Q_ASSERT(m_nextHitIndex < static_cast<unsigned>(m_hitList.size())); - K3ListViewItem* item = m_hitList[ m_nextHitIndex ]; - subjectList->ensureItemVisible(item); - subjectList->setSelected(item, true); + QTableWidgetItem* item = m_hitList[m_nextHitIndex]; + subjectList->scrollToItem(item); + subjectList->setRangeSelected(QTableWidgetSelectionRange( + item->row(), 0, item->row(), subjectList->columnCount() - 1), + true); m_nextHitIndex++; if (m_nextHitIndex >= static_cast<unsigned>(m_hitList.size())) @@ -114,73 +118,56 @@ m_nextHitIndex = 0; m_prevquery = query; - Q3ListViewItemIterator listIt(subjectList); - while (listIt.current() != 0) { - K3ListViewItem * item = static_cast<K3ListViewItem*>(listIt.current()); - item->setPixmap(Col_Icon, 0); + for (int i = 0, j = subjectList->rowCount(); i < j; i++) { + subjectList->item(i, Col_Icon)->setIcon(QIcon()); QStringList::const_iterator queryIt = query.begin(); for (; queryIt != query.end(); ++queryIt) { - if (item->text(Col_Subject).contains(*queryIt, Qt::CaseInsensitive)) { - item->setPixmap(Col_Icon, SmallIcon("edit-find")); - m_hitList.append(item); + if (subjectList->item(i, Col_Subject) + ->text().contains(*queryIt, Qt::CaseInsensitive)) { + subjectList->item(i, Col_Icon) + ->setIcon(QIcon(SmallIcon("edit-find"))); + m_hitList.append(subjectList->item(i, 0)); break; } } - ++listIt; } } void ThreadListView::clearSearch() { - Q3ListViewItemIterator listIt(subjectList); - while (listIt.current() != 0) { - K3ListViewItem * item = static_cast<K3ListViewItem *>(listIt.current()); - item->setPixmap(Col_Icon, 0); - item->setVisible(true); - ++listIt; + for (int i = 0, j = subjectList->rowCount(); i < j; i++) { + subjectList->item(i, Col_Icon)->setIcon(QIcon()); + subjectList->showRow(i); } } void ThreadListView::slotHideButton(bool on) { - Q3ListViewItemIterator listIt(subjectList); - while (listIt.current() != 0) { - K3ListViewItem * item = static_cast<K3ListViewItem *>(listIt.current()); - if (on && ! item->pixmap(Col_Icon)) { - item->setVisible(false); + for (int i = 0, j = subjectList->rowCount(); i < j; i++) { + if (on && !subjectList->item(i, Col_Icon)->icon().isNull()) { + subjectList->hideRow(i); } else { - item->setVisible(true); + subjectList->showRow(i); } - ++listIt; } } -void ThreadListView::slotMouseButtonClicked(int button, Q3ListViewItem* item) +void ThreadListView::slotMouseButtonClicked(QTableWidgetItem* item) { - if (! item) return ; - - KUrl datURL = item->text(Col_DatURL); - - if (button == Qt::LeftButton) { - ViewMediator::getInstance()->openThread(datURL); - } + if (!item) return; + KUrl datURL = subjectList->item(item->row(), Col_DatURL)->text(); + ViewMediator::getInstance()->openThread(datURL); } void ThreadListView::hideColumn(int col) { - Q3Header* header = subjectList->header(); - subjectList->setColumnWidthMode(col, Q3ListView::Manual); - header->setResizeEnabled(false, col); - subjectList->setColumnWidth(col, 0); + subjectList->hideColumn(col); } void ThreadListView::showColumn(int col) { - Q3Header* header = subjectList->header(); - subjectList->setColumnWidthMode(col, Q3ListView::Maximum); - header->setResizeEnabled(true, col); - subjectList->adjustColumn(col); + subjectList->showColumn(col); } #include "threadlistview.moc" Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistview.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/threadlistview.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -14,8 +14,6 @@ #include "ui_threadlistviewbase.h" -class K3ListView; - struct Col_Attr { const char* labelName; /// for header's label @@ -43,7 +41,7 @@ static struct Col_Attr s_colAttr[]; QStringList m_prevquery; unsigned m_nextHitIndex; - QList<K3ListViewItem *> m_hitList; + QList<QTableWidgetItem *> m_hitList; void insertSearchCombo(); void searchNext(const QStringList& input); @@ -54,7 +52,7 @@ protected slots: void slotHideButton(bool on); - void slotMouseButtonClicked(int, Q3ListViewItem*); + void slotMouseButtonClicked(QTableWidgetItem*); private slots: void slotSearchButton(); Modified: kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-13 21:43:18 UTC (rev 2406) @@ -1,147 +1,132 @@ -<ui version="4.0" stdsetdef="1" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>Kita::ThreadListViewBase</class> - <widget class="QWidget" name="Kita::ThreadListViewBase" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>601</width> - <height>483</height> - </rect> - </property> - <property name="windowTitle" > - <string>Form2</string> - </property> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" > - <item> - <widget class="QComboBox" name="SearchCombo" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="editable" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="HideButton" > - <property name="text" > - <string>Hide</string> - </property> - <property name="checkable" > - <bool>true</bool> - </property> - <property name="toolTip" stdset="0" > - <string>filter thread</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="ReloadButton" > - <property name="text" > - <string>Reload</string> - </property> - <property name="checkable" > - <bool>false</bool> - </property> - <property name="toolTip" stdset="0" > - <string>reload board</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="KindLabel" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="alignment" > - <set>Qt::AlignVCenter|Qt::AlignLeft</set> - </property> - <property name="indent" > - <number>5</number> - </property> - <property name="toolTip" stdset="0" > - <string>unread/read/new threads</string> - </property> - <property name="wordWrap" > - <bool>false</bool> - </property> - </widget> - </item> - <item> - <spacer name="spacer1" > - <property name="sizeHint" > - <size> - <width>150</width> - <height>20</height> - </size> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="closeButton" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="text" > - <string>Close</string> - </property> - <property name="toolTip" stdset="0" > - <string>close tab</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="K3ListView" name="subjectList" > - <property name="allColumnsShowFocus" > - <bool>true</bool> - </property> - </widget> - </item> +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Kita::ThreadListViewBase</class> + <widget class="QWidget" name="Kita::ThreadListViewBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>601</width> + <height>483</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form2</string> + </property> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout"> + <item> + <widget class="QComboBox" name="SearchCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>200</width> + <height>0</height> + </size> + </property> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="HideButton"> + <property name="toolTip"> + <string>filter thread</string> + </property> + <property name="text"> + <string>Hide</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="ReloadButton"> + <property name="toolTip"> + <string>reload board</string> + </property> + <property name="text"> + <string>Reload</string> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="KindLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>unread/read/new threads</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>5</number> + </property> + </widget> + </item> + <item> + <spacer name="spacer1"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>150</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="closeButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip"> + <string>close tab</string> + </property> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <customwidgets> - <customwidget> - <class>K3ListView</class> - <extends>Q3ListView</extends> - <header location="global" >k3listview.h</header> - </customwidget> - </customwidgets> + </item> + <item> + <widget class="QTableWidget" name="subjectList"/> + </item> + </layout> + </widget> + <layoutdefault spacing="6" margin="11"/> + <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> + <resources/> + <connections/> </ui> Modified: kita/branches/KITA-KDE4/kita/src/threadlistviewitem.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistviewitem.cpp 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewitem.cpp 2009-07-13 21:43:18 UTC (rev 2406) @@ -12,16 +12,18 @@ using namespace Kita; -ThreadListViewItem::ThreadListViewItem(Q3ListView* parent) - : Kita::ListViewItem(parent) +ThreadListViewItem::ThreadListViewItem() {} ThreadListViewItem::~ThreadListViewItem() {} /* public */ /* virtual */ -int ThreadListViewItem::compare(Q3ListViewItem* i, int col, bool ascending) const +int ThreadListViewItem::compare(QTableWidgetItem* i, int col, bool ascending) const { + return 0; +// TODO +#if 0 switch (col) { case Col_ResNum: case Col_ReadNum: @@ -38,4 +40,5 @@ default: return QString::localeAwareCompare(key(col, ascending), i->key(col, ascending)); } +#endif } Modified: kita/branches/KITA-KDE4/kita/src/threadlistviewitem.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistviewitem.h 2009-07-13 11:11:47 UTC (rev 2405) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewitem.h 2009-07-13 21:43:18 UTC (rev 2406) @@ -11,7 +11,7 @@ #ifndef KITATHREADLISTVIEWITEM_H #define KITATHREADLISTVIEWITEM_H -#include "kitaui/listviewitem.h" +#include <QtGui/QTableWidgetItem> enum ThreadListCol { Col_Begin = 0, @@ -35,13 +35,13 @@ namespace Kita { /* for KitaBoardView */ - class ThreadListViewItem : public Kita::ListViewItem + class ThreadListViewItem : public QTableWidgetItem { public: - ThreadListViewItem(Q3ListView* parent); + ThreadListViewItem(); ~ThreadListViewItem(); - virtual int compare(Q3ListViewItem* i, int col, bool ascending) const; + virtual int compare(QTableWidgetItem* i, int col, bool ascending) const; }; }