OSDN Git Service

refactoring.
[kita/kita.git] / kita / src / mainwindow.cpp
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10
11 #include "mainwindow.h"
12
13 #include "prefs/prefs.h"
14
15 #include "threadview.h"
16 #include "threadtabwidget.h"
17 #include "boardview.h"
18 #include "boardtabwidget.h"
19 #include "bbsview.h"
20 #include "bbstabwidget.h"
21 #include "writetabwidget.h"
22 #include "viewmediator.h"
23
24 #include "libkita/threadinfo.h"
25 #include "libkita/favoriteboards.h"
26 #include "libkita/favoritethreads.h"
27 #include "libkita/kita_misc.h"
28 #include "libkita/kitaconfig.h"
29 #include "libkita/signalcollection.h"
30 #include "libkita/account.h"
31 #include "libkita/datmanager.h"
32 #include "libkita/boardmanager.h"
33 #include "libkita/config_xt.h"
34 #include "libkita/asciiart.h"
35 #include "libkita/abone.h"
36
37 #include <qdragobject.h>
38 #include <qtextcodec.h>
39 #include <qevent.h>
40 #include <qregexp.h>
41 #include <qmessagebox.h>
42 #include <qclipboard.h>
43
44 #include <klineedit.h>
45 #include <kglobal.h>
46 #include <klocale.h>
47 #include <kiconloader.h>
48 #include <kmenubar.h>
49 #include <kstatusbar.h>
50 #include <kkeydialog.h>
51 #include <kaccel.h>
52 #include <kio/netaccess.h>
53 #include <kuserprofile.h>
54 #include <kfiledialog.h>
55 #include <kconfig.h>
56 #include <kurl.h>
57 #include <krun.h>
58 #include <kstandarddirs.h>
59 #include <kdebug.h>
60 #include <ksimpleconfig.h>
61 #include <kedittoolbar.h>
62 #include <kstdaccel.h>
63 #include <kaction.h>
64 #include <kstdaction.h>
65 #include <kshortcut.h>
66 #include <kaboutdata.h>
67 #include <kparts/partmanager.h>
68 #include <kdeversion.h>
69 #include <kglobal.h>
70
71 KitaMainWindow::KitaMainWindow()
72         : KDockMainWindow( 0, "Kita" )
73 {
74     // FIXME: merge *.po
75     KGlobal::locale() ->insertCatalogue( "kitapart" );
76
77     // accept dnd
78     setAcceptDrops( true );
79
80     // setup view, dock
81     setupView();
82
83     // then, setup our actions
84     setupActions();
85
86     // load cache
87     loadCache();
88
89     // load style sheet
90     loadStyleSheet();
91
92     // load ascii art
93     Kita::AsciiArtConfig::self()->readConfig();
94     if ( Kita::AsciiArtConfig::self()->asciiArtList().empty() ) {
95         loadAsciiArt();
96     }
97
98     // load abone lists
99     Kita::AboneConfig::self()->readConfig();
100     if ( Kita::AboneConfig::self()->aboneIDList().empty() ) {
101         loadAboneIDList();
102     }
103
104     if ( Kita::AboneConfig::self()->aboneNameList().empty() ) {
105         loadAboneNameList();
106     }
107
108     if ( Kita::AboneConfig::self()->aboneWordList().empty() ) {
109         loadAboneWordList();
110     }
111
112     // and a status bar
113     statusBar() ->show();
114
115     // read dock status
116     m_bbsDock->loadSession();
117     m_boardDock->loadSession();
118     m_threadDock->loadSession();
119     m_writeDock->loadSession();
120     QString dockConfigPath = locateLocal( "appdata", "dock.conf" );
121     KConfig dockConfig( dockConfigPath );
122     readDockConfig( &dockConfig );
123
124     // show subject dock
125     m_boardDock->slotShowDock();
126
127     // show thread view
128     m_threadDock->slotShowDock();
129
130     // hide writedock
131     makeDockInvisible( m_writeDock );
132
133     // for compativility
134     loadCompletion();
135     KitaConfig::readConfig( KGlobal::config() );
136
137     Kita::Config::self()->readConfig();
138
139     // apply the saved mainwindow settings, if any, and ask the mainwindow
140     // to automatically save settings if changed: window size, toolbar
141     // position, icon size, etc.
142     setAutoSaveSettings();
143
144     // set list font
145     setFont( Kita::Config::font() );
146
147     // allow the view to change the statusbar and caption
148     Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
149
150     connect( signalCollection, SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
151              SLOT( slotOpenURLRequest( const KURL&, const KParts::URLArgs& ) ) );
152
153     connect( signalCollection, SIGNAL( openURLRequestExt( const KURL&, const QString ) ),
154              SLOT( slotOpenURLRequestExt( const KURL&, const QString ) ) );
155
156     connect( signalCollection, SIGNAL( setMainCaption( const QString& ) ),
157              SLOT( slotSetMainCaption( const QString& ) ) );
158
159     connect( signalCollection, SIGNAL( bookmarked( const QString&, bool ) ),
160              SLOT( bookmark( const QString&, bool ) ) );
161
162     connect( this, SIGNAL( favoritesUpdated() ),
163              signalCollection, SIGNAL( favoritesUpdated() ) );
164
165     connect( m_urlLine, SIGNAL( returnPressed() ),
166              SLOT( slotURLLine() ) );
167
168     QPopupMenu* settingsPopup = static_cast<QPopupMenu *>( factory() ->container( "settings", this ) );
169     connect( settingsPopup, SIGNAL( aboutToShow() ),
170              SLOT( settingsMenuAboutToShow() ) );
171
172     // load favorite boards;
173     loadFavoriteBoards();
174
175     // load boad list
176     {
177         QString configPath = locateLocal( "appdata", "board_list" );
178         if ( QFile::exists( configPath ) ) {
179             m_bbsTab->showBoardList();
180             m_bbsTab->loadOpened();
181         } else {
182             m_bbsTab->updateBoardList();
183         }
184     }
185
186     // load favorites
187     loadFavorites();
188
189     // show board dock
190     m_bbsDock->slotShowDock();
191
192     // update favorite list
193     emit favoritesUpdated();
194
195     if ( Kita::Config::autoLogin() ) {
196         login();
197     }
198 }
199
200 KitaMainWindow::~KitaMainWindow()
201 {
202     /* save dock status */
203     m_bbsDock->saveSession();
204     m_boardDock->saveSession();
205     m_threadDock->saveSession();
206     m_writeDock->saveSession();
207
208     Kita::AboneConfig::self()->writeConfig();
209
210     saveStyleSheet();
211
212     Kita::AsciiArtConfig::self()->writeConfig();
213
214     saveFavoriteBoards();
215
216     saveFavorites();
217
218     saveCache();
219
220     saveMainWindowSettings( KGlobal::config(), "MainWindow" );
221
222     KitaConfig::writeConfig( KGlobal::config() );
223     Kita::Config::self()->writeConfig();
224
225     QString dockConfigPath = locateLocal( "appdata", "dock.conf" );
226     KConfig dockConfig( dockConfigPath );
227     writeDockConfig( &dockConfig );
228
229     delete m_bbsDock;
230     delete m_threadDock;
231     delete m_writeDock;
232
233     Kita::DatManager::deleteAllDatInfo();
234 }
235
236 void KitaMainWindow::load( const KURL& url )
237 {
238     setCaption( url.url() );
239 }
240
241 void KitaMainWindow::bookmark( const QString& datURL, bool on )
242 {
243     FavoriteThreads * favorite = FavoriteThreads::getInstance();
244
245     if ( on ) {
246         favorite->insert( datURL );
247     } else {
248         favorite->remove( datURL );
249     }
250     saveFavorites();
251     emit favoritesUpdated();
252 }
253
254 void KitaMainWindow::closeSubjectView()
255 {
256     m_subjectListAction->setChecked( FALSE );
257 }
258
259 void KitaMainWindow::login()
260 {
261     if ( Kita::Account::login( Kita::Config::userID(), Kita::Config::password() ) ) {
262         slotSetMainStatusbar( i18n( "Login succeeded." ) );
263     } else {
264         slotSetMainStatusbar( i18n( "Login failed." ) );
265     }
266 }
267
268 void KitaMainWindow::newToolbarConfig()
269 {
270     // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
271     // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
272     applyMainWindowSettings( KGlobal::config(), "MainWindow" );
273 }
274
275 void KitaMainWindow::optionsShowToolbar()
276 {
277     // this is all very cut and paste code for showing/hiding the
278     // toolbar
279     if ( m_toolbarAction->isChecked() ) {
280         toolBar() ->show();
281     } else {
282         toolBar() ->hide();
283     }
284 }
285
286 void KitaMainWindow::optionsShowStatusbar()
287 {
288     // this is all very cut and paste code for showing/hiding the
289     // statusbar
290     if ( m_statusbarAction->isChecked() ) {
291         statusBar() ->show();
292     } else {
293         statusBar() ->hide();
294     }
295 }
296
297 void KitaMainWindow::optionsConfigureKeys()
298 {
299     KKeyDialog dlg( TRUE, this );
300     dlg.insert( actionCollection(), "Kita" );
301     dlg.configure();
302 }
303
304 void KitaMainWindow::optionsConfigureToolbars()
305 {
306     // use the standard toolbar editor
307     KEditToolbar dlg( factory() );
308     connect( &dlg, SIGNAL( newToolbarConfig() ),
309              SLOT( newToolbarConfig() ) );
310     dlg.exec();
311 }
312
313 void KitaMainWindow::optionsPreferences()
314 {
315     // popup some sort of preference dialog, here
316     if ( KConfigDialog::showDialog( "Kita Preferences" ) ) {
317         return;
318     }
319
320     KitaPreferences* dialog = new KitaPreferences( this );
321
322     connect( dialog, SIGNAL( fontChanged( const QFont& ) ),
323              SLOT( setFont( const QFont& ) ) );
324
325     dialog->show();
326 }
327
328 void KitaMainWindow::settingsMenuAboutToShow()
329 {
330     m_toolbarAction->setChecked( toolBar() ->isVisible() );
331     m_statusbarAction->setChecked( statusBar() ->isVisible() );
332 }
333
334 void KitaMainWindow::setFont( const QFont& font )
335 {
336     m_boardTab->setFont( font );
337     m_bbsTab->setFont( font );
338 }
339
340 void KitaMainWindow::setUrl( const KURL& url )
341 {
342     m_urlLine->setText( url.url() );
343 }
344
345 void KitaMainWindow::windowToggleView()
346 {
347     //FIXME: m_boardDock->dockSite() & KDockWidget::DockCenter != 0 igai no toki ha dousuru?
348     kdDebug() << "Do toggle" << endl;
349     if ( !m_boardDock->isVisible()
350             || !m_boardDock->isActiveWindow() ) m_boardDock->slotShowDock();
351     else {
352         m_threadDock->slotShowDock();
353     }
354 }
355
356 void KitaMainWindow::slotCheckBoardToggleAction( bool check )
357 {
358     if ( m_boardListAction ) m_boardListAction->setChecked( check );
359 }
360
361 void KitaMainWindow::slotCheckSubjectToggleAction( bool check )
362 {
363     if ( m_subjectListAction ) m_subjectListAction->setChecked( check );
364 }
365
366 void KitaMainWindow::slotCheckWriteToggleAction( bool check )
367 {
368     if ( m_showWriteDockAction ) m_showWriteDockAction->setChecked( check );
369 }
370
371 void KitaMainWindow::slotEditCopy()
372 {
373     QWidget * widget = kapp->focusWidget();
374
375     if ( widget ) {
376         QKeyEvent e( QEvent::KeyPress, Key_C, 'C', ControlButton );
377         QApplication::sendEvent( widget, &e );
378     }
379 }
380
381 /* open url */ /* public slot */ /* obsolete */
382 void KitaMainWindow::slotOpenURLRequest( const KURL& url, const KParts::URLArgs& args )
383 {
384     slotOpenURLRequestExt( url );
385 }
386
387 /* open url */
388 /*
389   If mimetype == "text/html", open url with web browser.
390   if mimetype == QString::null, use KIO::NetAccess::mimetype to decide mime type of url.
391  
392 */  /* public slot */
393 void KitaMainWindow::slotOpenURLRequestExt( const KURL& url, const QString mimetype )
394 {
395     // FIXME: support be.2ch.net
396     if ( url.host() == "be.2ch.net" && url.path().contains( "/test/p.php", true ) < 1 ) {
397         QMessageBox::warning( this,
398                               "Kita",
399                               i18n( "be.2ch.net is currently not supported." ) );
400         return ;
401     }
402
403     kdDebug() << QString( "Requested OpenURL: \"%1\"" ).arg( url.url() ) << endl;
404
405     /*  open url with web browser, etc. */
406     if ( mimetype != QString::null ) {
407         KRun::runURL( url, mimetype );
408         return ;
409     }
410
411     /* open thread with new thread tab */
412     if ( Kita::DatManager::isThreadEnrolled( url ) ) {
413         m_threadDock->slotShowThread( url );
414         return ;
415     }
416
417     if ( mimetype == QString::null ) {
418         QString url_mimetype = KIO::NetAccess::mimetype( url , this );
419         kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( url_mimetype ) << endl;
420         KRun::runURL( url, url_mimetype );
421     } else {
422         kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( mimetype ) << endl;
423         KRun::runURL( url, mimetype );
424     }
425 }
426
427 void KitaMainWindow::slotSetMainCaption( const QString& captionStr )
428 {
429     setCaption( captionStr );
430 }
431
432 void KitaMainWindow::slotSetMainStatusbar( const QString& statusStr )
433 {
434     // display the text on the statusbar
435     statusBar() ->message( statusStr );
436 }
437
438 void KitaMainWindow::slotURLLine()
439 {
440     KURL url = m_urlLine->text();
441     KURL datURL = Kita::getDatURL( url );
442     m_threadDock->slotShowThread( datURL );
443 }
444
445 //
446 // private method
447 //
448
449 void KitaMainWindow::setupActions()
450 {
451     KStdAction::quit( this, SLOT( close() ), actionCollection() );
452     KStdAction::copy( this, SLOT( slotEditCopy() ), actionCollection() );
453
454     m_toolbarAction = KStdAction::showToolbar( this,
455                       SLOT( optionsShowToolbar() ),
456                       actionCollection() );
457
458     m_statusbarAction = KStdAction::showStatusbar( this,
459                         SLOT( optionsShowStatusbar() ),
460                         actionCollection() );
461
462     m_boardListAction = new KToggleAction( i18n( "Show board list" ),
463                                            0,
464                                            m_bbsDock,
465                                            SLOT( slotToggleShowHide() ),
466                                            actionCollection(),
467                                            "window_show_board_list" );
468
469     m_subjectListAction = new KToggleAction( i18n( "Show subject list" ),
470                           0,
471                           m_boardDock,
472                           SLOT( slotToggleShowHide() ),
473                           actionCollection(),
474                           "window_show_subject_list" );
475
476     m_showWriteDockAction = new KToggleAction( i18n( "Show Write Dock" ),
477                             0,
478                             m_writeDock,
479                             SLOT( slotToggleShowHide() ),
480                             actionCollection(),
481                             "window_show_writedock" );
482
483     m_urlLine = new KLineEdit( "", 0 );
484
485     new KWidgetAction( m_urlLine,
486                        i18n( "URL Line" ),
487                        0,
488                        this,
489                        SLOT( slotURLLine() ),
490                        actionCollection(), "url_line_action" );
491
492     KStdAction::keyBindings( this, SLOT( optionsConfigureKeys() ), actionCollection() );
493     KStdAction::configureToolbars( this, SLOT( optionsConfigureToolbars() ), actionCollection() );
494     KStdAction::preferences( this, SLOT( optionsPreferences() ), actionCollection() );
495
496     new KAction( i18n( "Load board list" ),
497                  0,
498                  m_bbsTab,
499                  SLOT( updateBoardList() ),
500                  actionCollection(),
501                  "load_board_list" );
502
503     m_toggleViewAction = new KAction(
504                              i18n( "&Toggle subject view and thread view" ),
505                              KShortcut( Qt::Key_F7 ),
506                              this,
507                              SLOT( windowToggleView() ),
508                              actionCollection(),
509                              "window_toggle_view" );
510
511     new KAction( i18n( "Login" ),
512                  0,
513                  this,
514                  SLOT( login() ),
515                  actionCollection(),
516                  "login" );
517
518     setXMLFile( "kitaui.rc" );
519     KMainWindow::createGUI();
520     factory() ->addClient( m_bbsTab );
521     factory() ->addClient( m_boardTab );
522     factory() ->addClient( m_threadTab );
523     factory() ->addClient( m_writeTab );
524 }
525
526 void KitaMainWindow::setupView()
527 {
528     ViewMediator::getInstance()->setMainWindow( this );
529
530     /* dummy Main Dock Widget */
531     m_dummyDock = createDockWidget( "dummy", 0L, 0L, "dummy", "dummy" );
532     m_dummyDock->setDockSite( KDockWidget::DockFullSite );
533     m_dummyDock->setEnableDocking( KDockWidget::DockNone );
534     setView( m_dummyDock );
535     setMainDockWidget( m_dummyDock );
536
537     /* Subject View */
538     m_boardDock = new KitaBoardDock( manager(), "subject", 0L, 0L, i18n( "subject" ), i18n( "subject" ) );
539     m_boardTab = new KitaBoardTabWidget( this, "Subject" );
540     m_boardDock->setWidget( m_boardTab );
541     ViewMediator::getInstance()->setBoardTabWidget( m_boardTab );
542     connect( m_boardDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckSubjectToggleAction( bool ) ) );
543
544     /* Board View */
545     m_bbsDock = new KitaBBSDock( manager(), "board", 0L, 0L, i18n( "board" ), i18n( "board" ) );
546     m_bbsTab = m_bbsDock->setup();
547     connect( m_bbsDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckBoardToggleAction( bool ) ) );
548
549     /* Thread View */
550     m_threadDock = new KitaThreadDock( manager(), "Thread", 0L, 0L, i18n( "Thread" ), i18n( "Thread" ) );
551     m_threadTab = m_threadDock->setupAsMainView();
552     ViewMediator::getInstance()->setThreadDock( m_threadDock );
553     ViewMediator::getInstance()->setThreadTabWidget( m_threadTab );
554     m_threadDock->setDockSite( KDockWidget::DockFullSite );
555
556     /* write dock */
557     m_writeDock = new KitaWriteDock( manager(), "Write", 0L, 0L, i18n( "Write" ), i18n( "Write" ) );
558     m_writeTab = new KitaWriteTabWidget( m_writeDock, "Write View" );
559     m_writeDock->setWidget( m_writeTab );
560     m_writeDock->setWriteTabWidget( m_writeTab );
561     m_writeDock->setup();
562     ViewMediator::getInstance()->setWriteDock( m_writeDock );
563     connect( m_writeDock, SIGNAL( checkToggleAction( bool ) ), SLOT( slotCheckWriteToggleAction( bool ) ) );
564
565     /* reset dock status */
566     m_boardListAction = NULL;
567     m_subjectListAction = NULL;
568     m_showWriteDockAction = NULL;
569 }
570
571 void KitaMainWindow::loadCache()
572 {
573     KitaThreadInfo * cache = KitaThreadInfo::getInstance();
574     QString cacheConfigPath = locateLocal( "appdata", "cache" );
575     QFile file( cacheConfigPath );
576     if ( file.open( IO_ReadOnly ) ) {
577         QDataStream stream( &file );
578         stream >> *cache;
579     }
580 }
581
582 void KitaMainWindow::saveCache()
583 {
584     KitaThreadInfo * cache = KitaThreadInfo::getInstance();
585     QString cacheConfigPath = locateLocal( "appdata", "cache" );
586     QFile file( cacheConfigPath );
587     if ( file.open( IO_WriteOnly ) ) {
588         QDataStream stream( &file );
589         stream << *cache;
590     }
591 }
592
593 void KitaMainWindow::loadFavorites()
594 {
595     QString favoritesConfigPath = locateLocal( "appdata", "favorites.xml" );
596     QFile file( favoritesConfigPath );
597     if ( file.open( IO_ReadOnly ) ) {
598         QTextStream stream( &file );
599         stream.setEncoding( QTextStream::UnicodeUTF8 );
600
601         QString xml = stream.read();
602         FavoriteThreads::readFromXML( xml );
603     }
604 }
605
606 void KitaMainWindow::saveFavorites()
607 {
608     QString favoritesConfigPath = locateLocal( "appdata", "favorites.xml" );
609     QFile file( favoritesConfigPath );
610     if ( file.open( IO_WriteOnly ) ) {
611         QTextStream stream( &file );
612         stream.setEncoding( QTextStream::UnicodeUTF8 );
613         stream << FavoriteThreads::getInstance() ->toXML();
614     }
615 }
616
617 void KitaMainWindow::loadFavoriteBoards()
618 {
619     QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
620     QFile file( configPath );
621     if ( file.open( IO_ReadOnly ) ) {
622         QTextStream stream( &file );
623         stream.setEncoding( QTextStream::UnicodeUTF8 );
624
625         QString xml = stream.read();
626         Kita::FavoriteBoards::readFromXML( xml );
627     }
628 }
629
630 void KitaMainWindow::saveFavoriteBoards()
631 {
632     QString configPath = locateLocal( "appdata", "favorite_boards.xml" );
633     QFile file( configPath );
634     if ( file.open( IO_WriteOnly ) ) {
635         QTextStream stream( &file );
636         stream.setEncoding( QTextStream::UnicodeUTF8 );
637         stream << Kita::FavoriteBoards::toXML();
638     }
639 }
640
641 void KitaMainWindow::loadCompletion()
642 {
643     QString configPath = locateLocal( "appdata", "completion" );
644     KSimpleConfig config( configPath );
645
646     Kita::Config::setNameCompletionList( config.readListEntry( "name" ) );
647 }
648
649 void KitaMainWindow::loadStyleSheet()
650 {
651     QString configPath = locateLocal( "appdata", "stylesheet" );
652     QFile file( configPath );
653     if ( file.open( IO_ReadOnly ) ) {
654         QTextStream stream( &file );
655         stream.setEncoding( QTextStream::UnicodeUTF8 );
656
657         QStringList list;
658         QString str;
659
660         while ( ( str = stream.readLine() ) != QString::null ) {
661             if ( ! str.isEmpty() ) {
662                 list << str;
663             }
664         }
665         KitaConfig::setStyleSheetText( list.join( "\n" ) );
666     }
667 }
668
669 void KitaMainWindow::saveStyleSheet()
670 {
671     QString configPath = locateLocal( "appdata", "stylesheet" );
672     QFile file( configPath );
673     if ( file.open( IO_WriteOnly ) ) {
674         QTextStream stream( &file ) ;
675         stream.setEncoding( QTextStream::UnicodeUTF8 );
676
677         stream << KitaConfig::styleSheetText();
678     }
679 }
680
681 void KitaMainWindow::loadAsciiArt()
682 {
683     QString configPath = locateLocal( "appdata", "asciiart" );
684     QFile file( configPath );
685     if ( file.open( IO_ReadOnly ) ) {
686         QTextStream stream( &file );
687         stream.setEncoding( QTextStream::UnicodeUTF8 );
688
689         QStringList list;
690         QString str;
691
692         while ( ( str = stream.readLine() ) != QString::null ) {
693             if ( ! str.isEmpty() ) {
694                 list << str;
695             }
696         }
697         Kita::AsciiArtConfig::setAsciiArtList( list );
698     }
699 }
700
701 void KitaMainWindow::loadAboneIDList()
702 {
703     QString configPath = locateLocal( "appdata", "abone_id" );
704     QFile file( configPath );
705     if ( file.open( IO_ReadOnly ) ) {
706         QTextStream stream( &file );
707         stream.setEncoding( QTextStream::UnicodeUTF8 );
708
709         QStringList list;
710         QString str;
711
712         while ( ( str = stream.readLine() ) != QString::null ) {
713             if ( ! str.isEmpty() ) {
714                 list << str;
715             }
716         }
717         Kita::AboneConfig::setAboneIDList( list );
718     }
719 }
720
721 void KitaMainWindow::loadAboneNameList()
722 {
723     QString configPath = locateLocal( "appdata", "abone_name" );
724     QFile file( configPath );
725     if ( file.open( IO_ReadOnly ) ) {
726         QTextStream stream( &file );
727         stream.setEncoding( QTextStream::UnicodeUTF8 );
728
729         QStringList list;
730         QString str;
731
732         while ( ( str = stream.readLine() ) != QString::null ) {
733             if ( ! str.isEmpty() ) {
734                 list << str;
735             }
736         }
737         Kita::AboneConfig::setAboneNameList( list );
738     }
739 }
740
741 void KitaMainWindow::loadAboneWordList()
742 {
743     QString configPath = locateLocal( "appdata", "abone_word" );
744     QFile file( configPath );
745     if ( file.open( IO_ReadOnly ) ) {
746         QTextStream stream( &file );
747         stream.setEncoding( QTextStream::UnicodeUTF8 );
748
749         QStringList list;
750         QString str;
751
752         while ( ( str = stream.readLine() ) != QString::null ) {
753             if ( ! str.isEmpty() ) {
754                 list << str;
755             }
756         }
757         Kita::AboneConfig::setAboneWordList( list );
758     }
759 }
760
761 #include "mainwindow.moc"