OSDN Git Service

now refactoring...
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 21 May 2003 15:02:58 +0000 (15:02 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Wed, 21 May 2003 15:02:58 +0000 (15:02 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@250 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/kitaboardview.cpp
kita/src/libkita/Makefile.am
kita/src/libkita/category.cpp [new file with mode: 0644]
kita/src/libkita/category.h [new file with mode: 0644]

index 6082e1d..1cfb063 100644 (file)
@@ -22,6 +22,7 @@
 #include "kitaboardview.h"
 #include "kita.h"
 #include "libkita/board.h"
+#include "libkita/category.h"
 
 
 KitaBoardView::KitaBoardView(QWidget *parent, const char *name)
@@ -92,32 +93,37 @@ void KitaBoardView::loadBoardList()
       QStringList lines = QStringList::split("\n", html);
       QStringList::iterator it;
 
-      /*
-      QValueList< QPair<QString, Kita::Board> > board_list;
+
+      /*QPtrList<Kita::Category> categoryList;
       {
-        QString current_category;
+        Kita::Category* current_category = 0;
         for(it = lines.begin(); it != lines.end(); ++it) {
-          QString category = getCategory(*it);
-          if( category != QString::null ) {
-            current_category = category;
+          QString category_name = getCategory(*it);
+          if( category_name != QString::null ) {
+            current_category = new Kita::Category(category_name);
+            categoryList.append(current_category);
           } else {
             Kita::Board board = getBoard(*it);
 
             if( isBoardUrl(board.url()) ) {
-              board_list.append(QPair<QString, Kita::Board>(current_category, board));
+              current_category->append(board);
             }
           }
         }
       }
 
       {
-        QValueListIterator< QPair<QString, Kita::Board> > iterator;
-        for(iterator = board_list.begin(); iterator != board_list.end(); ++iterator) {
-          if((*iterator).first == QString::null) continue;
-
-          qDebug("category:%s name:%s url:%s", (const char *)(*iterator).first.local8Bit(),
-          (const char*)(*iterator).second.name().local8Bit(),
-          (*iterator).second.url().prettyURL().latin1());
+        Kita::Category* category;
+        for(category = categoryList.first(); category; category = categoryList.next()) {
+          if(category->name() == QString::null) continue;
+
+          QValueList<Kita::Board> board_list = category->getBoardList();
+          QValueListIterator<Kita::Board> it2;
+          for(it2 = board_list.begin(); it2 != board_list.end(); ++it2) {
+            qDebug("category:%s name:%s url:%s", (const char *)category->name().local8Bit(),
+            (const char*)(*it2).name().local8Bit(),
+            (*it2).url().prettyURL().latin1());
+          }
         }
       }*/
 
index 7c2f78d..a244b7a 100644 (file)
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes)
 
 lib_LTLIBRARIES = libkita.la
 
-libkita_la_SOURCES = comment.cpp comment.h thread.h thread.cpp qcp932codec.cpp qcp932codec.h board.h board.cpp bbs.h bbs.cpp
+libkita_la_SOURCES = comment.cpp comment.h thread.h thread.cpp qcp932codec.cpp qcp932codec.h board.h board.cpp bbs.h bbs.cpp category.h category.cpp
diff --git a/kita/src/libkita/category.cpp b/kita/src/libkita/category.cpp
new file mode 100644 (file)
index 0000000..8ebd350
--- /dev/null
@@ -0,0 +1,21 @@
+/***************************************************************************
+ *   Copyright (C) 2003 by Hideki Ikemoto                                  *
+ *   ikemo@users.sourceforge.jp                                            *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#include "category.h"
+
+using namespace Kita;
+
+Category::Category(QString& name) : m_name(name)
+{
+}
+
+Category::~Category()
+{
+}
diff --git a/kita/src/libkita/category.h b/kita/src/libkita/category.h
new file mode 100644 (file)
index 0000000..8865104
--- /dev/null
@@ -0,0 +1,36 @@
+/***************************************************************************
+ *   Copyright (C) 2003 by Hideki Ikemoto                                  *
+ *   ikemo@users.sourceforge.jp                                            *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#ifndef KITACATEGORY_H
+#define KITACATEGORY_H
+
+#include <qptrlist.h>
+
+#include "board.h"
+
+namespace Kita {
+
+/**
+@author Hideki Ikemoto
+*/
+class Category{
+  QString m_name;
+  QValueList<Board> m_boardList;
+public:
+  Category(QString& name);
+  ~Category();
+  void append(Board& board) { m_boardList.append(board); }
+  QValueList<Board>& getBoardList() { return m_boardList; }
+  QString name() { return m_name; }
+};
+
+};
+
+#endif