OSDN Git Service

cleanup code
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 15 Mar 2003 02:12:09 +0000 (02:12 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Sat, 15 Mar 2003 02:12:09 +0000 (02:12 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@81 56b19765-1e22-0410-a548-a0f45d66c51a

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

index f8f9947..ceddf44 100644 (file)
 
 Kita::Kita()
     : KDockMainWindow( 0, "Kita" ),
-///      m_view(new KitaView(this)),
-      m_printer(0)
+    ///      m_view(new KitaView(this)),
+    m_printer(0)
 {
-    // accept dnd
-    setAcceptDrops(true);
-
-    // setup view, dock
-    setupView();
-    
-    // then, setup our actions
-    setupActions();
-
-    // and a status bar
-    statusBar()->show();
-
-    // apply the saved mainwindow settings, if any, and ask the mainwindow
-    // to automatically save settings if changed: window size, toolbar
-    // position, icon size, etc.
-    setAutoSaveSettings();
-
-    // allow the view to change the statusbar and caption
-    connect(m_threadview, SIGNAL(signalChangeStatusbar(const QString&)),
-            this,   SLOT(changeStatusbar(const QString&)));
-    connect(m_boardView, SIGNAL(signalLoadBoard(const KURL&, const QString&)),
-    m_subjectView, SLOT(slotLoadBoard(const KURL&, const QString&)));
-    connect(m_subjectView, SIGNAL(signalShowThread(const KURL&, const KURL&, const QString&)),
-    m_threadview, SLOT(slotShowThread(const KURL&, const KURL&, const QString&)));
-//    connect(m_view, SIGNAL(signalChangeCaption(const QString&)),
-//            this,   SLOT(changeCaption(const QString&)));
+  // accept dnd
+  setAcceptDrops(true);
+
+  // setup view, dock
+  setupView();
+
+  // then, setup our actions
+  setupActions();
+
+  // and a status bar
+  statusBar()->show();
+
+  // apply the saved mainwindow settings, if any, and ask the mainwindow
+  // to automatically save settings if changed: window size, toolbar
+  // position, icon size, etc.
+  setAutoSaveSettings();
+
+  // allow the view to change the statusbar and caption
+  connect(m_threadview, SIGNAL(signalChangeStatusbar(const QString&)),
+          this,   SLOT(changeStatusbar(const QString&)));
+  connect(m_boardView, SIGNAL(signalLoadBoard(const KURL&, const QString&)),
+          m_subjectView, SLOT(slotLoadBoard(const KURL&, const QString&)));
+  connect(m_subjectView, SIGNAL(signalShowThread(const KURL&, const KURL&, const QString&)),
+          m_threadview, SLOT(slotShowThread(const KURL&, const KURL&, const QString&)));
+  //    connect(m_view, SIGNAL(signalChangeCaption(const QString&)),
+  //            this,   SLOT(changeCaption(const QString&)));
   m_boardView->loadBoardList();
 }
 
 Kita::~Kita()
-{
-}
+{}
 
 void Kita::load(const KURL& url)
 {
-    QString target;
-    // the below code is what you should normally do.  in this
-    // example case, we want the url to our own.  you probably
-    // want to use this code instead for your app
-
-    #if 0
-    // download the contents
-    if (KIO::NetAccess::download(url, target))
-    {
-        // set our caption
-        setCaption(url);
-
-        // load in the file (target is always local)
-        loadFile(target);
-
-        // and remove the temp file
-        KIO::NetAccess::removeTempFile(target);
-    }
-    #endif
-
-    setCaption(url.url());
-//    m_view->openURL(url);
+  QString target;
+  // the below code is what you should normally do.  in this
+  // example case, we want the url to our own.  you probably
+  // want to use this code instead for your app
+
+#if 0
+  // download the contents
+  if (KIO::NetAccess::download(url, target)) {
+    // set our caption
+    setCaption(url);
+
+    // load in the file (target is always local)
+    loadFile(target);
+
+    // and remove the temp file
+    KIO::NetAccess::removeTempFile(target);
+  }
+#endif
+
+  setCaption(url.url());
+  //    m_view->openURL(url);
 }
 
 void Kita::setupActions()
 {
-    KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
-    KStdAction::open(this, SLOT(fileOpen()), actionCollection());
-    KStdAction::save(this, SLOT(fileSave()), actionCollection());
-    KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
-    KStdAction::print(this, SLOT(filePrint()), actionCollection());
-    KStdAction::quit(kapp, SLOT(quit()), actionCollection());
-
-    m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
-    m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
-
-    KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
-    KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
-    KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
-
-    // this doesn't do anything useful.  it's just here to illustrate
-    // how to insert a custom menu and menu item
-/*    KAction *custom = new KAction(i18n("Cus&tom Menuitem"), 0,
-                                  this, SLOT(optionsPreferences()),
-                                  actionCollection(), "custom_action");*/
-    
-    KAction *loadBoardList = new KAction(i18n("Load BoardList"), 0,
-                                  m_boardView, SLOT(loadBoardList()),
-                                  actionCollection(), "load_board_list");
-    createGUI();
+  KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
+  KStdAction::open(this, SLOT(fileOpen()), actionCollection());
+  KStdAction::save(this, SLOT(fileSave()), actionCollection());
+  KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection());
+  KStdAction::print(this, SLOT(filePrint()), actionCollection());
+  KStdAction::quit(kapp, SLOT(quit()), actionCollection());
+
+  m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
+  m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
+
+  KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
+  KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
+  KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
+
+  // this doesn't do anything useful.  it's just here to illustrate
+  // how to insert a custom menu and menu item
+  /*    KAction *custom = new KAction(i18n("Cus&tom Menuitem"), 0,
+                                    this, SLOT(optionsPreferences()),
+                                    actionCollection(), "custom_action");*/
+
+  KAction *loadBoardList = new KAction(i18n("Load BoardList"), 0,
+                                       m_boardView, SLOT(loadBoardList()),
+                                       actionCollection(), "load_board_list");
+  createGUI();
 }
 
 void Kita::saveProperties(KConfig *config)
 {
-    // the 'config' object points to the session managed
-    // config file.  anything you write here will be available
-    // later when this app is restored
+  // the 'config' object points to the session managed
+  // config file.  anything you write here will be available
+  // later when this app is restored
 
-//    if (m_view->currentURL() != QString::null)
-//        config->writeEntry("lastURL", m_view->currentURL());
+  //    if (m_view->currentURL() != QString::null)
+  //        config->writeEntry("lastURL", m_view->currentURL());
 }
 
 void Kita::readProperties(KConfig *config)
 {
-    // the 'config' object points to the session managed
-    // config file.  this function is automatically called whenever
-    // the app is being restored.  read in here whatever you wrote
-    // in 'saveProperties'
+  // the 'config' object points to the session managed
+  // config file.  this function is automatically called whenever
+  // the app is being restored.  read in here whatever you wrote
+  // in 'saveProperties'
 
-//    QString url = config->readEntry("lastURL");
+  //    QString url = config->readEntry("lastURL");
 
-//    if (url != QString::null)
-//        m_view->openURL(KURL(url));
+  //    if (url != QString::null)
+  //        m_view->openURL(KURL(url));
 }
 
 void Kita::dragEnterEvent(QDragEnterEvent *event)
 {
-    // accept uri drops only
-    event->accept(QUriDrag::canDecode(event));
+  // accept uri drops only
+  event->accept(QUriDrag::canDecode(event));
 }
 
 void Kita::dropEvent(QDropEvent *event)
 {
-    // this is a very simplistic implementation of a drop event.  we
-    // will only accept a dropped URL.  the Qt dnd code can do *much*
-    // much more, so please read the docs there
-    QStrList uri;
-
-    // see if we can decode a URI.. if not, just ignore it
-    if (QUriDrag::decode(event, uri))
-    {
-        // okay, we have a URI.. process it
-        QString url, target;
-        url = uri.first();
-
-        // load in the file
-        load(KURL(url));
-    }
+  // this is a very simplistic implementation of a drop event.  we
+  // will only accept a dropped URL.  the Qt dnd code can do *much*
+  // much more, so please read the docs there
+  QStrList uri;
+
+  // see if we can decode a URI.. if not, just ignore it
+  if (QUriDrag::decode(event, uri)) {
+    // okay, we have a URI.. process it
+    QString url, target;
+    url = uri.first();
+
+    // load in the file
+    load(KURL(url));
+  }
 }
 
 void Kita::fileNew()
 {
-    // this slot is called whenever the File->New menu is selected,
-    // the New shortcut is pressed (usually CTRL+N) or the New toolbar
-    // button is clicked
+  // this slot is called whenever the File->New menu is selected,
+  // the New shortcut is pressed (usually CTRL+N) or the New toolbar
+  // button is clicked
 
-    // create a new window
-    (new Kita)->show();
+  // create a new window
+  (new Kita)->show();
 }
 
 void Kita::fileOpen()
 {
-    // this slot is called whenever the File->Open menu is selected,
-    // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
-    // button is clicked
-//    KURL url = KURLRequesterDlg::getURL(QString::null, this, i18n("Open Location") );
-//    if (!url.isEmpty())
-//        m_view->openURL(url);
+  // this slot is called whenever the File->Open menu is selected,
+  // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
+  // button is clicked
+  //    KURL url = KURLRequesterDlg::getURL(QString::null, this, i18n("Open Location") );
+  //    if (!url.isEmpty())
+  //        m_view->openURL(url);
 }
 
 void Kita::fileSave()
 {
-    // this slot is called whenever the File->Save menu is selected,
-    // the Save shortcut is pressed (usually CTRL+S) or the Save toolbar
-    // button is clicked
+  // this slot is called whenever the File->Save menu is selected,
+  // the Save shortcut is pressed (usually CTRL+S) or the Save toolbar
+  // button is clicked
 
-    // save the current file
+  // save the current file
 }
 
 void Kita::fileSaveAs()
 {
-    // this slot is called whenever the File->Save As menu is selected,
-    KURL file_url = KFileDialog::getSaveURL();
-    if (!file_url.isEmpty() && !file_url.isMalformed())
-    {
-        // save your info, here
-    }
+  // this slot is called whenever the File->Save As menu is selected,
+  KURL file_url = KFileDialog::getSaveURL();
+  if (!file_url.isEmpty() && !file_url.isMalformed()) {
+    // save your info, here
+  }
 }
 
 void Kita::filePrint()
 {
-    // this slot is called whenever the File->Print menu is selected,
-    // the Print shortcut is pressed (usually CTRL+P) or the Print toolbar
-    // button is clicked
-/*    if (!m_printer) m_printer = new KPrinter;
-    if (m_printer->setup(this))
-    {
-        // setup the printer.  with Qt, you always "print" to a
-        // QPainter.. whether the output medium is a pixmap, a screen,
-        // or paper
-        QPainter p;
-        p.begin(m_printer);
-
-        // we let our view do the actual printing
-        QPaintDeviceMetrics metrics(m_printer);
-        m_view->print(&p, metrics.height(), metrics.width());
-
-        // and send the result to the printer
-        p.end();
-    }*/
+  // this slot is called whenever the File->Print menu is selected,
+  // the Print shortcut is pressed (usually CTRL+P) or the Print toolbar
+  // button is clicked
+  /*    if (!m_printer) m_printer = new KPrinter;
+      if (m_printer->setup(this))
+      {
+          // setup the printer.  with Qt, you always "print" to a
+          // QPainter.. whether the output medium is a pixmap, a screen,
+          // or paper
+          QPainter p;
+          p.begin(m_printer);
+   
+          // we let our view do the actual printing
+          QPaintDeviceMetrics metrics(m_printer);
+          m_view->print(&p, metrics.height(), metrics.width());
+   
+          // and send the result to the printer
+          p.end();
+      }*/
 }
 
 void Kita::optionsShowToolbar()
 {
-    // this is all very cut and paste code for showing/hiding the
-    // toolbar
-    if (m_toolbarAction->isChecked())
-        toolBar()->show();
-    else
-        toolBar()->hide();
+  // this is all very cut and paste code for showing/hiding the
+  // toolbar
+  if (m_toolbarAction->isChecked())
+    toolBar()->show();
+  else
+    toolBar()->hide();
 }
 
 void Kita::optionsShowStatusbar()
 {
-    // this is all very cut and paste code for showing/hiding the
-    // statusbar
-    if (m_statusbarAction->isChecked())
-        statusBar()->show();
-    else
-        statusBar()->hide();
+  // this is all very cut and paste code for showing/hiding the
+  // statusbar
+  if (m_statusbarAction->isChecked())
+    statusBar()->show();
+  else
+    statusBar()->hide();
 }
 
 void Kita::optionsConfigureKeys()
 {
-    KKeyDialog::configureKeys(actionCollection(), "kitaui.rc");
+  KKeyDialog::configureKeys(actionCollection(), "kitaui.rc");
 }
 
 void Kita::optionsConfigureToolbars()
 {
-    // use the standard toolbar editor
-    saveMainWindowSettings( KGlobal::config(), autoSaveGroup() );
-    KEditToolbar dlg(actionCollection());
-    connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig()));
-    dlg.exec();
+  // use the standard toolbar editor
+  saveMainWindowSettings( KGlobal::config(), autoSaveGroup() );
+  KEditToolbar dlg(actionCollection());
+  connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig()));
+  dlg.exec();
 }
 
 void Kita::newToolbarConfig()
 {
-    // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
-    // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
-    createGUI();
-    applyMainWindowSettings( KGlobal::config(), autoSaveGroup() );
+  // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
+  // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
+  createGUI();
+  applyMainWindowSettings( KGlobal::config(), autoSaveGroup() );
 }
 
 void Kita::optionsPreferences()
 {
-    // popup some sort of preference dialog, here
-    KitaPreferences dlg;
-    if (dlg.exec())
-    {
-        // redo your settings
-    }
+  // popup some sort of preference dialog, here
+  KitaPreferences dlg;
+  if (dlg.exec()) {
+    // redo your settings
+  }
 }
 
 void Kita::changeStatusbar(const QString& text)
 {
-    // display the text on the statusbar
-    statusBar()->message(text);
+  // display the text on the statusbar
+  statusBar()->message(text);
 }
 
 void Kita::changeCaption(const QString& text)
 {
-    // display the text on the caption
-    setCaption(text);
+  // display the text on the caption
+  setCaption(text);
 }
-#include "kita.moc"
 
 void Kita::setupView()
 {
-    KDockWidget* mainDock;
-    mainDock = createDockWidget("main", 0L, 0L, i18n("main"));
-    m_threadview = new KitaThreadView(mainDock);
-    mainDock->setWidget(m_threadview);
-    mainDock->setDockSite(KDockWidget::DockFullSite);
-    mainDock->setEnableDocking(KDockWidget::DockNone);
-    
-    KDockWidget* subjectDock;
-    subjectDock = createDockWidget("subject", 0L, 0L, i18n("subject"));
-    m_subjectView = new KitaSubjectView(subjectDock, this);
-    subjectDock->setWidget(m_subjectView);
-    subjectDock->setDockSite(KDockWidget::DockFullSite);
-    
-    KDockWidget* boardDock;
-    boardDock = createDockWidget("board", 0L, 0L, i18n("board"));
-    m_boardView = new KitaBoardView(boardDock, this);
-    boardDock->setWidget(m_boardView);
-    boardDock->setDockSite(KDockWidget::DockFullSite);
-    
-    setView(mainDock);
-    setMainDockWidget(mainDock);
-    
-    boardDock->manualDock(mainDock, KDockWidget::DockLeft, 20);
-    subjectDock->manualDock(mainDock, KDockWidget::DockTop);
+  KDockWidget* mainDock;
+  mainDock = createDockWidget("main", 0L, 0L, i18n("main"));
+  m_threadview = new KitaThreadView(mainDock);
+  mainDock->setWidget(m_threadview);
+  mainDock->setDockSite(KDockWidget::DockFullSite);
+  mainDock->setEnableDocking(KDockWidget::DockNone);
+
+  KDockWidget* subjectDock;
+  subjectDock = createDockWidget("subject", 0L, 0L, i18n("subject"));
+  m_subjectView = new KitaSubjectView(subjectDock);
+  subjectDock->setWidget(m_subjectView);
+  subjectDock->setDockSite(KDockWidget::DockFullSite);
+
+  KDockWidget* boardDock;
+  boardDock = createDockWidget("board", 0L, 0L, i18n("board"));
+  m_boardView = new KitaBoardView(boardDock);
+  boardDock->setWidget(m_boardView);
+  boardDock->setDockSite(KDockWidget::DockFullSite);
+
+  setView(mainDock);
+  setMainDockWidget(mainDock);
+
+  boardDock->manualDock(mainDock, KDockWidget::DockLeft, 20);
+  subjectDock->manualDock(mainDock, KDockWidget::DockTop);
 }
+
+#include "kita.moc"
index e3d281f..615535f 100644 (file)
 #include "kita.h"
 
 
-KitaBoardView::KitaBoardView(QWidget *parent, Kita* _m, const char *name)
+KitaBoardView::KitaBoardView(QWidget *parent, const char *name)
     : KitaBoardViewBase(parent, name)
 {
   boardList->setSorting(-1);
   boardList->addColumn("name");
-  mainWindow = _m;
-  connect(boardList, SIGNAL(executed(QListViewItem*)), SLOT(loadBoard(QListViewItem*)));
+  connect(boardList, SIGNAL(executed(QListViewItem*)), SLOT(slotLoadBoard(QListViewItem*)));
 }
 
-
 KitaBoardView::~KitaBoardView()
 {}
 
@@ -46,7 +44,6 @@ void KitaBoardView::loadBoardList()
     if(file.open(IO_ReadOnly))
     {
       QString html = stream.read();
-      //      BoardList board(html);
 
       /* boardList*/
       QStringList lines = QStringList::split("\n", html);
@@ -62,11 +59,8 @@ void KitaBoardView::loadBoardList()
         if(category_r.search(*it) != -1)
         {
           QString category = category_r.cap(1);
-//          QString board_url = category_r.cap(2);
-//          QString board_title = category_r.cap(3);
-
+          
           current_category = new KListViewItem(boardList, current_category, category);
-//          current_board = new KListViewItem(current_category, board_title, board_url);
         }
         else if(board_r.search(*it) != -1)
         {
@@ -83,7 +77,7 @@ void KitaBoardView::loadBoardList()
   }
 }
 
-void KitaBoardView::loadBoard(QListViewItem* item)
+void KitaBoardView::slotLoadBoard(QListViewItem* item)
 {
   QString boardName = item->text(0);
   KURL url = item->text(1);
index 8480138..6ef2b78 100644 (file)
@@ -27,13 +27,11 @@ class KitaBoardView : public KitaBoardViewBase
   Q_OBJECT
 
 public:
-  KitaBoardView(QWidget *parent, Kita* _m, const char *name=0);
+  KitaBoardView(QWidget *parent, const char *name=0);
   ~KitaBoardView();
 public slots:
   void loadBoardList();
-  void loadBoard(QListViewItem* item);
-private: // Private attributes
-  Kita* mainWindow;
+  void slotLoadBoard(QListViewItem* item);
 signals:
   void signalLoadBoard(const KURL& url, const QString& boardName);
 };
index 6433795..b76df54 100644 (file)
 #include "kitasubjectview.h"
 #include "kita.h"
 
-KitaSubjectView::KitaSubjectView(QWidget *parent, Kita* _mainWindow, const char *name)
+KitaSubjectView::KitaSubjectView(QWidget *parent, const char *name)
   : KitaSubjectViewBase(parent, name)
 {
   subjectList->addColumn("No");
   subjectList->addColumn("Title");
   subjectList->addColumn("ResNum");
   subjectList->addColumn("Dat");
-  mainWindow = _mainWindow;
   connect(subjectList, SIGNAL(clicked(QListViewItem*)), SLOT(loadThread(QListViewItem*)));
 }
 
@@ -49,15 +48,14 @@ void KitaSubjectView::reloadSubject()
 void KitaSubjectView::loadThread(QListViewItem* item)
 {
   QString datName = item->text(3);
-  QString tmpFile;
-  KURL url = boardURL;
-  url.addPath("/dat/" + datName);
-  emit signalShowThread(url, boardURL, m_boardName);
+  KURL datURL = m_boardURL;
+  datURL.addPath("/dat/" + datName);
+  emit signalShowThread(datURL, m_boardURL, m_boardName);
 }
 
 void KitaSubjectView::slotLoadBoard(const KURL& url, const QString& boardName)
 {
-  boardURL = url;
+  m_boardURL = url;
   m_boardName = boardName;
   
   KIO::SlaveConfig::self()->setConfigData("http", url.host() , "UserAgent", "Monazilla/1.00 (test)");
index aa3ffc8..cc57eaa 100644 (file)
@@ -26,15 +26,14 @@ class KitaSubjectView : public KitaSubjectViewBase
   Q_OBJECT
 
 public:
-  KitaSubjectView(QWidget *parent, Kita* _mainWindow, const char *name=0);
+  KitaSubjectView(QWidget *parent, const char *name=0);
   ~KitaSubjectView();
 public slots:
   void reloadSubject();
   void loadThread(QListViewItem* item);
   void slotLoadBoard(const KURL& url, const QString& boardName);
 private: // Private attributes
-  Kita* mainWindow;
-  KURL boardURL;
+  KURL m_boardURL;
   QString m_boardName;
 signals:
   void signalShowThread(const KURL& datURL, const KURL& boardURL, const QString& boardName);