OSDN Git Service

refactoring...
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 17 May 2003 17:05:28 +0000 (17:05 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 17 May 2003 17:05:28 +0000 (17:05 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@233 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/kitaboardview.cpp
kita/src/kitaboardview.h

index ea4e5a4..e0f170a 100644 (file)
@@ -33,6 +33,16 @@ KitaBoardView::KitaBoardView(QWidget *parent, const char *name)
 KitaBoardView::~KitaBoardView()
 {}
 
+QString KitaBoardView::getCategory(QString line)
+{
+  QRegExp regexp("<BR><BR><B>(.*)</B><BR>", false);
+  if(regexp.search(line) != -1) {
+    return regexp.cap(1);
+  } else {
+    return QString::null;
+  }
+}
+
 void KitaBoardView::loadBoardList()
 {
   QString tmpFile;
@@ -57,18 +67,16 @@ void KitaBoardView::loadBoardList()
       QRegExp url_2ch("http://.*\\.2ch\\.net/.*");
       QRegExp url_bbspink("http://.*\\.bbspink\\.com/.*");
       QRegExp url_www_2ch("http://www\\.2ch\\.net/.*");
-      
+
       KListViewItem* current_category = 0;
       KListViewItem* current_board = 0;
       for(it = lines.begin(); it != lines.end(); ++it)
       {
-        if(category_r.search(*it) != -1)
-        {
-          QString category = category_r.cap(1);
-          
+        QString category = getCategory(*it);
+        if( category != QString::null ) {
           KListViewItem* old_category = current_category;
           current_category = new KListViewItem(boardList, old_category, category);
-          
+
           if( old_category != 0 && old_category->childCount() == 0 ) {
             // useless category. remove it!
             delete old_category;
index e25967c..6922523 100644 (file)
@@ -30,6 +30,7 @@ class KitaBoardView : public KitaBoardViewBase
 {
   Q_OBJECT
 
+  QString getCategory(QString line);
 public:
   KitaBoardView(QWidget *parent, const char *name=0);
   ~KitaBoardView();