svnno****@sourc*****
svnno****@sourc*****
2009年 7月 15日 (水) 22:47:04 JST
Revision: 2411 http://sourceforge.jp/projects/kita/svn/view?view=rev&revision=2411 Author: nogu Date: 2009-07-15 22:47:04 +0900 (Wed, 15 Jul 2009) Log Message: ----------- - enable sorting in subjectList - hide the vertical header of subjectList - set horizontal header labels of subjectList - don't show grid in subjectList - select all the items in the same row - don't use QTableWidget::clear() because it also removes header labels - set the height of a item in subjectList - remove unneeded destructors - add `explicit' - don't capitalize the first letter of a member variable - change the definition of operator< - remove useless tags from a UI file Modified Paths: -------------- 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/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 Modified: kita/branches/KITA-KDE4/kita/src/boardview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/boardview.cpp 2009-07-15 13:47:04 UTC (rev 2411) @@ -60,9 +60,6 @@ loadHeaderOnOff(); } -KitaBoardView::~KitaBoardView() -{} - /* public */ void KitaBoardView::init() { @@ -143,7 +140,11 @@ Kita::BoardManager::getThreadList(m_boardURL, m_showOldLogs, online, threadList, oldLogList); // reset list - subjectList->clear(); + 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); + } + } QDateTime current = QDateTime::currentDateTime(); int countNew = threadList.count(); @@ -151,7 +152,8 @@ int count = countNew + countOld; subjectList->setRowCount(count); for (int i = 0; i < count; i++) { - + subjectList->setRowHeight(i, qMax(QFontMetrics(QFont()).height(), + SmallIcon("unread").height())); // TODO Kita::Thread* thread = i < countNew ? threadList.at(i) : oldLogList.at(i - countNew); KUrl datURL = thread->datURL(); for (int j = 0, k = subjectList->columnCount(); j < k; j++) { @@ -214,7 +216,7 @@ fmtstr += QString("<font color=#C50000>%1</font>").arg(m_unreadNum); fmtstr += QString("/<font color=#00C200>%1</font>").arg(m_readNum); fmtstr += QString("/<font color=#5AAAFF>%1</font>").arg(m_newNum); - KindLabel->setText(fmtstr); + kindLabel->setText(fmtstr); } void KitaBoardView::setFont(const QFont& font) Modified: kita/branches/KITA-KDE4/kita/src/boardview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/boardview.h 2009-07-15 13:47:04 UTC (rev 2411) @@ -32,8 +32,7 @@ KitaBoardTabWidget* m_parent; public: - KitaBoardView(KitaBoardTabWidget* parent); - ~KitaBoardView(); + explicit KitaBoardView(KitaBoardTabWidget* parent); void init(); const KUrl boardURL(); void toggleShowOldLogs(); Modified: kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/favoritelistview.cpp 2009-07-15 13:47:04 UTC (rev 2411) @@ -33,7 +33,7 @@ FavoriteListView::FavoriteListView(QWidget* parent) : Kita::ThreadListView(parent) { - KindLabel->hide(); + kindLabel->hide(); connect(subjectList, SIGNAL(cellPressed(int, int)), SLOT(loadThread(int, int))); @@ -48,12 +48,6 @@ /** * */ -FavoriteListView::~FavoriteListView() -{} - -/** - * - */ void FavoriteListView::refresh() { // clear @@ -61,7 +55,11 @@ m_nextHitIndex = 0; m_prevquery = QStringList(""); - subjectList->clear(); + 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); + } + } // insert item. for (int i = 0; FavoriteThreads::count() > i; i++) { Modified: kita/branches/KITA-KDE4/kita/src/favoritelistview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/favoritelistview.h 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/favoritelistview.h 2009-07-15 13:47:04 UTC (rev 2411) @@ -22,8 +22,7 @@ Q_OBJECT public: - FavoriteListView(QWidget* parent = 0); - ~FavoriteListView(); + explicit FavoriteListView(QWidget* parent = 0); void refresh(); Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.cpp =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/threadlistview.cpp 2009-07-15 13:47:04 UTC (rev 2411) @@ -45,19 +45,21 @@ ReloadButton->setIcon(SmallIcon("view-refresh")); closeButton->setIcon(SmallIcon("tab-close")); + subjectList->setColumnCount(Col_End - Col_Begin + 1); subjectList->setContextMenuPolicy(Qt::CustomContextMenu); - //Q3Header* header = subjectList->header(); TODO + subjectList->setShowGrid(false); + subjectList->setSortingEnabled(true); + subjectList->verticalHeader()->setVisible(false); + //QHeaderView* header = subjectList->horizontalHeader(); TODO + QStringList labels; for (int i = Col_Begin; i <= Col_End; i++) { - int count = subjectList->columnCount() + 1; - subjectList->setColumnCount(count); - subjectList->setHorizontalHeaderItem(count, - new QTableWidgetItem(i18n(s_colAttr[i].labelName))); - - if (s_colAttr[ i ].showDefault != true) { + labels << i18n(s_colAttr[i].labelName); + if (!s_colAttr[i].showDefault) { hideColumn(i); } } - //header->setStretchEnabled(true, Col_Subject); TODO + //header->setStretchLastSection(true); + subjectList->setHorizontalHeaderLabels(labels); connect(SearchCombo, SIGNAL(activated(int)), SLOT(slotSearchButton())); @@ -69,9 +71,6 @@ SLOT(slotMouseButtonClicked(QTableWidgetItem*))); } -ThreadListView::~ThreadListView() -{} - void ThreadListView::slotSearchButton() { insertSearchCombo(); @@ -157,6 +156,8 @@ void ThreadListView::slotMouseButtonClicked(QTableWidgetItem* item) { if (!item) return; + for (int i = 0, j = subjectList->columnCount(); i < j; i++) + subjectList->item(item->row(), i)->setSelected(true); KUrl datURL = subjectList->item(item->row(), Col_DatURL)->text(); ViewMediator::getInstance()->openThread(datURL); } Modified: kita/branches/KITA-KDE4/kita/src/threadlistview.h =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistview.h 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/threadlistview.h 2009-07-15 13:47:04 UTC (rev 2411) @@ -34,8 +34,7 @@ Q_OBJECT public: - ThreadListView(QWidget* parent = 0); - ~ThreadListView(); + explicit ThreadListView(QWidget* parent = 0); protected: static struct Col_Attr s_colAttr[]; Modified: kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui =================================================================== --- kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewbase.ui 2009-07-15 13:47:04 UTC (rev 2411) @@ -68,7 +68,7 @@ </widget> </item> <item> - <widget class="QLabel" name="KindLabel"> + <widget class="QLabel" name="kindLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -125,8 +125,4 @@ </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-14 14:58:43 UTC (rev 2410) +++ kita/branches/KITA-KDE4/kita/src/threadlistviewitem.cpp 2009-07-15 13:47:04 UTC (rev 2411) @@ -25,16 +25,16 @@ case Col_ResNum: case Col_ReadNum: case Col_Unread: - return thisText.toInt() < otherText.toInt(); + return thisText.toInt() > otherText.toInt(); case Col_ID: - return thisText.toInt() < otherText.toInt(); + return thisText.toInt() > otherText.toInt(); case Col_Mark: - return QString::localeAwareCompare(thisText, otherText); + return QString::localeAwareCompare(thisText, otherText) > 0; case Col_Since: - return QString::localeAwareCompare(thisText, otherText); + return QString::localeAwareCompare(thisText, otherText) > 0; case Col_Speed: - return thisText.toDouble() * 1000 < otherText.toDouble() * 1000; + return thisText.toDouble() * 1000 > otherText.toDouble() * 1000; default: - return QString::localeAwareCompare(thisText, otherText); + return QString::localeAwareCompare(thisText, otherText) > 0; } }