OSDN Git Service

>>846
authorikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Fri, 4 Jun 2004 14:45:51 +0000 (14:45 +0000)
committerikemo <ikemo@56b19765-1e22-0410-a548-a0f45d66c51a>
Fri, 4 Jun 2004 14:45:51 +0000 (14:45 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@1120 56b19765-1e22-0410-a548-a0f45d66c51a

kita/src/kitaboardview.cpp
kita/src/kitaboardview.h
kita/src/libkita/favoriteboards.cpp
kita/src/libkita/favoriteboards.h
kita/src/part/kitathreadview.cpp
kita/src/part/kitathreadview.h
kita/src/pref.cpp
kita/src/threadlistview.cpp

index 06cedb4..1ad4132 100644 (file)
@@ -20,6 +20,7 @@
 #include <krun.h>
 #include <kdebug.h>
 #include <qvaluelist.h>
+#include <qheader.h>
 
 #include "kitaboardview.h"
 #include "kita.h"
@@ -37,11 +38,13 @@ KitaBoardView::KitaBoardView( QWidget *parent, const char *name )
 {
     m_boardList->setSorting( -1 );
     m_boardList->addColumn( i18n( "board name" ) );
+    m_boardList->header()->setClickEnabled( FALSE );
     connect( m_boardList, SIGNAL( mouseButtonClicked( int, QListViewItem*, const QPoint&, int ) ),
              SLOT( slotMouseButtonClicked( int, QListViewItem* ) ) );
     connect( m_boardList, SIGNAL( returnPressed( QListViewItem* ) ), SLOT( loadBoard( QListViewItem* ) ) );
     connect( m_boardList, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ),
              SLOT( slotContextMenuRequested( QListViewItem*, const QPoint&, int ) ) );
+    connect( Kita::FavoriteBoards::getInstance(), SIGNAL( changed() ), SLOT( refreshFavoriteBoards() ) );
 }
 
 KitaBoardView::~KitaBoardView()
@@ -231,11 +234,9 @@ void KitaBoardView::slotContextMenuRequested( QListViewItem* item, const QPoint&
         break;
     case 2:
         Kita::FavoriteBoards::append( url );
-        refreshFavoriteBoards();
         break;
     case 3:
         Kita::FavoriteBoards::remove( url );
-        refreshFavoriteBoards();
         break;
     default:
         break;
index a65f475..555adf8 100644 (file)
@@ -37,12 +37,12 @@ class KitaBoardView : public KitaBoardViewBase
     QString getBoardURL( const QString& line ) const;
     bool isBoardURL( const QString& url ) const;
     QValueList<Kita::Category> getCategoryList( const QString& html ) const;
-    void refreshFavoriteBoards();
 
 private slots:
     void loadBoard( QListViewItem* item );
     void slotContextMenuRequested( QListViewItem*, const QPoint&, int );
     void slotMouseButtonClicked( int, QListViewItem* );
+    void refreshFavoriteBoards();
 
 public:
     KitaBoardView( QWidget *parent, const char *name = 0 );
index f82867e..11ab24c 100644 (file)
@@ -35,6 +35,7 @@ void FavoriteBoards::append( KURL& url )
 {
     if ( ! getInstance() ->m_list.contains( url ) ) {
         getInstance() ->m_list.append( url );
+        getInstance()->notifyChange();
     }
 }
 
@@ -42,6 +43,7 @@ void FavoriteBoards::remove( KURL& url )
 {
     if ( getInstance() ->m_list.contains( url ) ) {
         getInstance() ->m_list.remove( url );
+        getInstance()->notifyChange();
     }
 }
 
@@ -87,7 +89,9 @@ void FavoriteBoards::processChildNode( QDomNode& node )
     KURL url = KURL( urlText );
     if ( url.isValid() ) {
         Kita::Board::setName( urlText, nameText );
-        FavoriteBoards::append( url );
+        //FavoriteBoards::append( url );
+        if ( !getInstance()->m_list.contains( url ) )
+            getInstance()->m_list.append( url );
     }
 }
 
@@ -133,5 +137,12 @@ void FavoriteBoards::replace( QString fromURL, QString toURL )
             it = boardList.begin();
         }
     }
+    FavoriteBoards::getInstance()->notifyChange();
 }
 
+void FavoriteBoards::notifyChange()
+{
+    emit changed();
+}
+
+#include "favoriteboards.moc"
index 855b284..db148c3 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef KITAFAVORITEBOARDS_H
 #define KITAFAVORITEBOARDS_H
 
+#include <qobject.h>
 #include <kurl.h>
 
 class QDomNode;
@@ -19,14 +20,19 @@ namespace Kita
     /**
     @author Hideki Ikemoto
     */
-    class FavoriteBoards
+    class FavoriteBoards : public QObject
     {
+
+        Q_OBJECT
+
         static FavoriteBoards* instance;
         QValueList<KURL> m_list;
         FavoriteBoards();
         ~FavoriteBoards();
 
         static void processChildNode( QDomNode& node );
+    private:
+        void notifyChange();
     public:
         static FavoriteBoards* getInstance();
         static void append( KURL& url );
@@ -35,6 +41,8 @@ namespace Kita
         static bool readFromXML( QString& xml );
         static QString toXML();
         static void replace( QString fromURL, QString toURL );
+    signals:
+        void changed();
     };
 }
 
index 54edeb3..ff8e9e8 100644 (file)
@@ -40,6 +40,7 @@
 #include <qdatetime.h>
 #include <qeucjpcodec.h>
 #include <qsimplerichtext.h>
+#include <qpopupmenu.h>
 
 #include <kxmlguifactory.h>
 #include <kaction.h>
 #include "libkita/threadinfo.h"
 #include "libkita/qcp932codec.h"
 #include "libkita/favoritethreads.h"
+#include "libkita/favoriteboards.h"
 #include "libkita/datmanager.h"
 #include "libkita/parsemisc.h"
+#include "libkita/board.h"
 
 #define MAX_LABEL_LENGTH 60
 
@@ -86,6 +89,8 @@ KitaThreadView::KitaThreadView( QWidget* parent, const char* name )
         LBox->addWidget( subjectLabel );
         connect( subjectLabel, SIGNAL( urlClick( const QString& ) ),
                  SLOT( subjectlinkClicked( const QString& ) ) );
+        connect( subjectLabel, SIGNAL( urlMClick( const QString& ) ),
+                 SLOT( subjectlinkMClicked( const QString& ) ) );
     }
 
     {
@@ -247,6 +252,12 @@ void KitaThreadView::subjectlinkClicked(const QString& URL )
     emit openBoardRequested( URL, KitaConfig::alwaysUseTab() );
 }
 
+void KitaThreadView::subjectlinkMClicked( const QString &URL )
+{
+    kdDebug() << QString("Jump board as new tab: \"%1\"").arg(URL) << endl;
+    emit openBoardRequested( URL, TRUE );
+}
+
 void KitaThreadView::updateButton()
 {
     writeButton->setEnabled( true );
@@ -470,6 +481,70 @@ namespace Kita
     {
         return minimumSizeHint();
     }
+    void KitaSubjectLabel::contentsMousePressEvent ( QMouseEvent * e )
+    {
+        KTextBrowser::contentsMousePressEvent( e );
+        kdDebug() << "Press Button:" << QString::number( e->button() ) << endl;
+        if ( e->button() == Qt::MidButton )
+        {
+            QString t = text();
+            QSimpleRichText rt( t, font() );
+            m_popupURL = rt.anchorAt( e->pos() );
+        }
+    }
+
+    void KitaSubjectLabel::contentsMouseReleaseEvent ( QMouseEvent * e )
+    {
+        KTextBrowser::contentsMouseReleaseEvent( e );
+        if ( !m_popupURL.isEmpty() && e->button() == Qt::MidButton )
+            emit urlMClick( m_popupURL );
+    }
+
+    QPopupMenu * KitaSubjectLabel::createPopupMenu ( const QPoint & pos )
+    {
+        QString t = text();
+        QSimpleRichText rt( t, font() );
+        m_popupURL = rt.anchorAt( pos );
+        kdDebug() << QString( "popupMenu for \"%1\"").arg( m_popupURL ) << endl
+;
+        if ( !m_popupURL.isEmpty() )
+        {
+            QPopupMenu *popup = new QPopupMenu;
+            popup->insertItem( i18n( "Open with new tab" ), this, SLOT( popupOpenAsNewTab() ) );
+            popup->insertItem( i18n( "Copy title and URL" ), this, SLOT( popupCopyToClipboard() ) );
+            QString ft = Kita::FavoriteBoards::boards().contains( KURL( m_popupURL ) ) ?
+              i18n( "Remove from Favorites" ) : i18n( "Add to Favorites") ;
+                popup->insertItem( ft, this, SLOT( popupFavorites() ) );
+            return popup;
+        }
+        else return NULL;
+    }
+
+    void KitaSubjectLabel::popupOpenAsNewTab()
+    {
+        if ( !m_popupURL.isEmpty() )
+            emit urlMClick( m_popupURL );
+    }
+
+    void KitaSubjectLabel::popupCopyToClipboard()
+    {
+        QClipboard * clipboard = QApplication::clipboard();
+        QString text = QString("%1\n%2").arg( Kita::Board::getName( m_popupURL ) ).arg( m_popupURL );
+        kdDebug() << "popupCopytoClipboard :" << endl << text << endl;
+        clipboard->setText( text , QClipboard::Clipboard );
+        clipboard->setText( text , QClipboard::Selection );
+    }
+
+    void KitaSubjectLabel::popupFavorites()
+    {
+        if ( !m_popupURL.isEmpty() ) {
+            KURL u = KURL( m_popupURL );
+            if ( Kita::FavoriteBoards::boards().contains( u ) )
+                Kita::FavoriteBoards::remove( u );
+            else
+                Kita::FavoriteBoards::append( u );
+        }
+    }
 
     PopupTextBrowser::PopupTextBrowser( QFrame* frame )
             : QTextBrowser( frame )
index d2a2377..35b1639 100644 (file)
@@ -84,6 +84,7 @@ public:
 
 public slots:
     void subjectlinkClicked(const QString& URL );
+    void subjectlinkMClicked( const QString &URL );
     void showThread( const Kita::Thread* thread );
     void setFont( const QFont& font );
     void slotReloadButton();
@@ -184,6 +185,17 @@ namespace Kita
         QSize sizeHint() const;
     private slots:
         void paletteChanged();
+        void popupOpenAsNewTab();
+        void popupCopyToClipboard();
+        void popupFavorites();
+    protected:
+        virtual QPopupMenu * createPopupMenu ( const QPoint & pos );
+        virtual void contentsMousePressEvent ( QMouseEvent * e );
+        virtual void contentsMouseReleaseEvent ( QMouseEvent * e );
+    signals:
+        void urlMClick( const QString& url );
+    private:
+        QString m_popupURL;
     };
 
     class PopupTextBrowser : public QTextBrowser
index b8c010a..08b742c 100644 (file)
@@ -25,6 +25,7 @@
 #include <qcheckbox.h>
 #include <qspinbox.h>
 #include <qbuttongroup.h>
+#include <qvbox.h>
 
 #include "libkita/kitaconfig.h"
 #include "kitafontprefbase.h"
@@ -42,7 +43,7 @@ KitaPreferences::KitaPreferences()
     // this is the base class for your preferences dialog.  it is now
     // a Treelist dialog.. but there are a number of other
     // possibilities (including Tab, Swallow, and just Plain)
-    QFrame * fontFrame = addPage( i18n( "Font" ), i18n( "Font" ) );
+    QVBox * fontFrame = addVBoxPage( i18n( "Font" ), i18n( "Font" ) );
     m_fontPage = new KitaFontPrefPage( fontFrame );
 
     connect( m_fontPage, SIGNAL( fontChanged( const QFont& ) ),
@@ -51,19 +52,19 @@ KitaPreferences::KitaPreferences()
     connect( m_fontPage, SIGNAL( threadFontChanged( const QFont& ) ),
              SIGNAL( threadFontChanged( const QFont& ) ) );
 
-    QFrame * colorFrame = addPage( i18n( "Color" ), i18n( "Color" ) );
+    QVBox * colorFrame = addVBoxPage( i18n( "Color" ), i18n( "Color" ) );
     m_colorPage = new KitaColorPrefPage( colorFrame );
 
-    QFrame * asciiArtFrame = addPage( i18n( "AsciiArt" ), i18n( "AsciiArt" ) );
+    QVBox * asciiArtFrame = addVBoxPage( i18n( "AsciiArt" ), i18n( "AsciiArt" ) );
     m_asciiArtPage = new Kita::AsciiArtPrefPage( asciiArtFrame );
 
-    QFrame * uiFrame = addPage( i18n( "User Interface" ), i18n( "User Interface" ) );
+    QVBox * uiFrame = addVBoxPage( i18n( "User Interface" ), i18n( "User Interface" ) );
     m_uiPage = new Kita::UIPrefPage( uiFrame );
     
-    QFrame * aboneFrame = addPage( i18n( "Abone" ), i18n( "Abone" ) );
+    QVBox * aboneFrame = addVBoxPage( i18n( "Abone" ), i18n( "Abone" ) );
     m_abonePage = new Kita::AbonePrefPage( aboneFrame );
 
-    QFrame * debugFrame = addPage( i18n( "Debug" ), i18n( "Debug" ) );
+    QVBox * debugFrame = addVBoxPage( i18n( "Debug" ), i18n( "Debug" ) );
     m_debugPage = new DebugPrefPage( debugFrame );
 
     connect( m_fontPage, SIGNAL( changed() ), SLOT( slotChanged() ) );
index d6a9520..0a1560c 100644 (file)
@@ -41,7 +41,12 @@ ThreadListView::ThreadListView( QWidget* parent, const char* name )
     subjectList->addColumn( i18n( "Unread" ) );
     subjectList->addColumn( i18n( "Since" ) );
 
-    subjectList->setColumnWidth( Col_Subject, 400 );
+    QHeader *h = subjectList->header();
+    h->setResizeEnabled( FALSE, Col_Mark );
+    h->setResizeEnabled( FALSE, Col_Icon );
+    h->setStretchEnabled( TRUE, Col_Subject );
+
+    //subjectList->setColumnWidth( Col_Subject, 400 );
     subjectList->setColumnWidthMode( Col_Subject, QListView::Manual );
 
     connect( SearchButton, SIGNAL( clicked() ),