svnno****@sourc*****
svnno****@sourc*****
2009年 7月 19日 (日) 06:07:43 JST
Revision: 2432 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2432 Author: nogu Date: 2009-07-19 06:07:43 +0900 (Sun, 19 Jul 2009) Log Message: ----------- - HideButton -> hideButton - ReloadButton -> reloadButton - SearchCombo -> searchCombo - fix a bug on searching threads - fix a bug on favorite threads - use KMessageBox instead of QMessageBox - remove BoardView::loadThread() Modified Paths: -------------- kita/branches/KITA-KDE4/kita/src/bbsview.cpp 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/mainwindow.cpp kita/branches/KITA-KDE4/kita/src/threadlistview.cpp kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui Modified: kita/branches/KITA-KDE4/kita/src/bbsview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/bbsview.cpp 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/bbsview.cpp 2009-07-18 21:07:43 UTC (rev 2432) @@ -18,7 +18,6 @@ #include <QtGui/QClipboard> #include <QtGui/QHBoxLayout> #include <QtGui/QHeaderView> -#include <QtGui/QMessageBox> #include <QtGui/QMouseEvent> #include <QtGui/QSpacerItem> #include <QtGui/QTreeWidget> @@ -191,26 +190,21 @@ 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); - - mb.setButtonText(QMessageBox::No, i18n("Copy")); - - int ret; - while ((ret = mb.exec()) == QMessageBox::No) { + int ret = KMessageBox::warningYesNoCancel(this, + i18n("Do you really want to update board list?"), "kita", + KStandardGuiItem::yes(), KGuiItem(i18n("Copy")), + KStandardGuiItem::cancel(), + QString(), KMessageBox::Dangerous); + if (ret == KMessageBox::No) { QString str = i18n("New boards:\n\n") + newBoards + '\n' + i18n("These boards were moved:\n\n") + oldBoards; QApplication::clipboard() ->setText(str , QClipboard::Clipboard); QApplication::clipboard() ->setText(str , QClipboard::Selection); - } - - if (ret == QMessageBox::Cancel) return false; + } else if (ret == KMessageBox::Cancel) + return false; } else if (newBoards.isEmpty() && oldBoards.isEmpty()) { - QMessageBox::information(this, "Kita", i18n("no new boards")); + KMessageBox::information(this, i18n("no new boards"), "Kita"); return false; } Modified: kita/branches/KITA-KDE4/kita/src/boardview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-18 21:07:43 UTC (rev 2432) @@ -36,9 +36,7 @@ m_parent = parent; closeButton->setEnabled(true); - connect(subjectList, SIGNAL(returnPressed(QTableWidgetItem*)), - SLOT(loadThread(QTableWidgetItem*))); - connect(ReloadButton, SIGNAL(clicked()), + connect(reloadButton, SIGNAL(clicked()), SLOT(reloadSubject())); connect(closeButton, SIGNAL(clicked()), @@ -88,15 +86,6 @@ loadBoard(m_boardURL, false); } -void BoardView::loadThread(QTableWidgetItem* item) -{ - if (!item) return ; - - KUrl datURL = item->text(); - - ViewMediator::getInstance()->openThread(datURL); -} - enum { Thread_Old, Thread_Readed, @@ -154,8 +143,8 @@ } subjectList->setSortingEnabled(true); - if (HideButton->isChecked()) { - HideButton->toggle(); + if (hideButton->isChecked()) { + hideButton->toggle(); } ViewMediator::getInstance()->setMainURLLine(m_boardURL); @@ -198,7 +187,7 @@ /* public slot */ void BoardView::slotFocusSearchCombo() { - SearchCombo->hasFocus() ? setFocus() : SearchCombo->setFocus(); + searchCombo->hasFocus() ? setFocus() : searchCombo->setFocus(); } void BoardView::updateKindLabel() @@ -213,7 +202,7 @@ void BoardView::setFont(const QFont& font) { subjectList->setFont(font); - SearchCombo->setFont(font); + searchCombo->setFont(font); } void BoardView::slotUpdateSubject(const KUrl& url) Modified: kita/branches/KITA-KDE4/kita/src/boardview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-18 21:07:43 UTC (rev 2432) @@ -65,7 +65,6 @@ BoardView& operator=(const BoardView&); private slots: - void loadThread(QTableWidgetItem* item); 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-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp 2009-07-18 21:07:43 UTC (rev 2432) @@ -38,7 +38,7 @@ connect(subjectList, SIGNAL(cellPressed(int, int)), SLOT(loadThread(int, int))); - connect(ReloadButton, SIGNAL(clicked()), + connect(reloadButton, SIGNAL(clicked()), SLOT(reload())); showColumn(ColumnBoard); @@ -54,14 +54,20 @@ m_nextHitIndex = 0; m_prevquery = QStringList(); - for (int i = 0, j = subjectList->rowCount(); i < j; i++) { - for (int k = 0, l = subjectList->columnCount(); k < l; k++) { - delete subjectList->takeItem(i, k); + subjectList->clearContents(); + + subjectList->setSortingEnabled(false); + int count = FavoriteThreads::count(); + subjectList->setRowCount(count); + for (int i = 0; i < count; i++) { + for (int j = 0, k = subjectList->columnCount(); j < k; j++) { + ThreadListViewItem* item = new ThreadListViewItem(j); + subjectList->setItem(i, j, item); } } - + subjectList->setSortingEnabled(true); // insert item. - for (int i = 0; FavoriteThreads::count() > i; i++) { + for (int i = 0; i < count; i++) { QString datURL = FavoriteThreads::getDatURL(i); QDateTime since; @@ -70,23 +76,23 @@ int viewPos = DatManager::getViewPos(datURL); int resNum = DatManager::getResNum(datURL); - subjectList->setItem(i, ColumnBoard, - new QTableWidgetItem(BoardManager::boardName(datURL))); - subjectList->setItem(i, ColumnSubject, - new QTableWidgetItem(DatManager::threadName(datURL))); - subjectList->setItem(i, ColumnReadNum, - new QTableWidgetItem(QString("%1").arg(viewPos, 4))); + subjectList->item(i, ColumnBoard) + ->setText(BoardManager::boardName(datURL)); + subjectList->item(i, ColumnSubject) + ->setText(DatManager::threadName(datURL)); + subjectList->item(i, ColumnReadNum) + ->setText(QString("%1").arg(viewPos, 4)); if (resNum > 0) { - subjectList->setItem(i, ColumnResNum, - new QTableWidgetItem(QString("%1").arg(resNum, 4))); + subjectList->item(i, ColumnResNum) + ->setText(QString("%1").arg(resNum, 4)); } if (resNum != 0 && resNum != viewPos) { - subjectList->setItem(i, ColumnUnread, new QTableWidgetItem( - QString("%1").arg(resNum - viewPos, 4))); + subjectList->item(i, ColumnUnread) + ->setText(QString("%1").arg(resNum - viewPos, 4)); } - subjectList->setItem(i, ColumnSince, - new QTableWidgetItem(since.toString("yy/MM/dd hh:mm"))); - subjectList->setItem(i, ColumnDatUrl, new QTableWidgetItem(datURL)); + subjectList->item(i, ColumnSince) + ->setText(since.toString("yy/MM/dd hh:mm")); + subjectList->item(i, ColumnDatUrl)->setText(datURL); } subjectList->sortItems(ColumnBoard); for (int i = 0, j = subjectList->columnCount(); i < j; i++) { Modified: kita/branches/KITA-KDE4/kita/src/mainwindow.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/mainwindow.cpp 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/mainwindow.cpp 2009-07-18 21:07:43 UTC (rev 2432) @@ -163,11 +163,7 @@ { FavoriteThreads * favorite = FavoriteThreads::getInstance(); - if (on) { - favorite->insert(datURL); - } else { - favorite->remove(datURL); - } + on ? favorite->insert(datURL) : favorite->remove(datURL); saveFavorites(); ViewMediator::getInstance()->updateFavoriteListView(); } @@ -317,7 +313,7 @@ connect(load_board_action, SIGNAL(triggered()), m_bbsTab, SLOT(updateBoardList())); KAction* login_action = actionCollection()->addAction("login"); - load_board_action->setText(i18n("Login")); + login_action->setText(i18n("Login")); connect(login_action, SIGNAL(triggered()), m_bbsTab, SLOT(login())); setXMLFile("kitaui.rc"); @@ -395,12 +391,13 @@ void MainWindow::saveFavorites() { - QString favoritesConfigPath = KStandardDirs::locateLocal("appdata", "favorites.xml"); + QString favoritesConfigPath + = KStandardDirs::locateLocal("appdata", "favorites.xml"); QFile file(favoritesConfigPath); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream.setCodec("UTF-8"); - stream << FavoriteThreads::getInstance() ->toXML(); + stream << FavoriteThreads::getInstance()->toXML(); } } Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-18 21:07:43 UTC (rev 2432) @@ -54,8 +54,8 @@ : QWidget(parent) { setupUi(this); - HideButton->setIcon(SmallIcon("view-filter")); - ReloadButton->setIcon(SmallIcon("view-refresh")); + hideButton->setIcon(SmallIcon("view-filter")); + reloadButton->setIcon(SmallIcon("view-refresh")); closeButton->setIcon(SmallIcon("tab-close")); ThreadListHeaderView* header = new ThreadListHeaderView; @@ -74,11 +74,11 @@ } subjectList->setHorizontalHeaderLabels(labels); - connect(SearchCombo, SIGNAL(activated(int)), + connect(searchCombo, SIGNAL(activated(int)), SLOT(slotSearchButton())); - connect(SearchCombo, SIGNAL(textChanged(const QString&)), + connect(searchCombo, SIGNAL(textChanged(const QString&)), SLOT(slotSearchButton())); - connect(HideButton, SIGNAL(toggled(bool)), + connect(hideButton, SIGNAL(toggled(bool)), SLOT(slotHideButton(bool))); connect(subjectList, SIGNAL(itemClicked(QTableWidgetItem*)), SLOT(slotItemClicked(QTableWidgetItem*))); @@ -89,13 +89,14 @@ void ThreadListView::slotSearchButton() { insertSearchCombo(); - QStringList list = parseSearchQuery(SearchCombo->currentText()); + QStringList list = parseSearchQuery(searchCombo->currentText()); if (list.isEmpty()) { clearSearch(); } else if (list != m_prevquery) { searchNew(list); - HideButton->setDown(true); + hideButton->setDown(true); + slotHideButton(true); } else { searchNext(list); } @@ -103,12 +104,12 @@ void ThreadListView::insertSearchCombo() { - for (int count = 0; count < SearchCombo->count(); ++count) { - if (SearchCombo->itemText(count) == SearchCombo->currentText()) { + for (int count = 0; count < searchCombo->count(); ++count) { + if (searchCombo->itemText(count) == searchCombo->currentText()) { return; } } - SearchCombo->addItem(SearchCombo->currentText()); + searchCombo->addItem(searchCombo->currentText()); } void ThreadListView::searchNext(const QStringList &query) @@ -160,7 +161,7 @@ void ThreadListView::slotHideButton(bool on) { for (int i = 0, j = subjectList->rowCount(); i < j; i++) { - if (on && !subjectList->item(i, ColumnIcon)->icon().isNull()) { + if (on && subjectList->item(i, ColumnIcon)->icon().isNull()) { subjectList->hideRow(i); } else { subjectList->showRow(i); @@ -198,12 +199,12 @@ QString datURL = subjectList->item(item->row(), ColumnDatUrl)->text(); QString threadURL = DatManager::threadURL(datURL); - bool isFavorites = FavoriteThreads::getInstance()->contains(datURL); // create popup menu. 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); @@ -212,12 +213,10 @@ KAction* copyTitleAndURLAct = new KAction(i18n("Copy title and URL"), this); popup.addAction(copyTitleAndURLAct); - KAction* favoritesAct; - if (isFavorites) { - favoritesAct = new KAction(i18n("Remove from Favorites"), this); - } else { - favoritesAct = new KAction(i18n("Add to Favorites"), this); - } + bool isFavorites = FavoriteThreads::getInstance()->contains(datURL); + KAction* favoritesAct = isFavorites + ? new KAction(i18n("Remove from Favorites"), this) + : new KAction(i18n("Add to Favorites"), this); popup.addAction(favoritesAct); KAction* deleteLogAct = 0; Modified: kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-18 15:09:16 UTC (rev 2431) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-18 21:07:43 UTC (rev 2432) @@ -23,7 +23,7 @@ <item> <layout class="QHBoxLayout"> <item> - <widget class="QComboBox" name="SearchCombo"> + <widget class="QComboBox" name="searchCombo"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <horstretch>0</horstretch> @@ -42,7 +42,7 @@ </widget> </item> <item> - <widget class="QToolButton" name="HideButton"> + <widget class="QToolButton" name="hideButton"> <property name="toolTip"> <string>filter thread</string> </property> @@ -55,7 +55,7 @@ </widget> </item> <item> - <widget class="QToolButton" name="ReloadButton"> + <widget class="QToolButton" name="reloadButton"> <property name="toolTip"> <string>reload board</string> </property>