#include <krun.h>
#include <kdebug.h>
#include <qvaluelist.h>
+#include <qheader.h>
#include "kitaboardview.h"
#include "kita.h"
{
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()
break;
case 2:
Kita::FavoriteBoards::append( url );
- refreshFavoriteBoards();
break;
case 3:
Kita::FavoriteBoards::remove( url );
- refreshFavoriteBoards();
break;
default:
break;
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 );
{
if ( ! getInstance() ->m_list.contains( url ) ) {
getInstance() ->m_list.append( url );
+ getInstance()->notifyChange();
}
}
{
if ( getInstance() ->m_list.contains( url ) ) {
getInstance() ->m_list.remove( url );
+ getInstance()->notifyChange();
}
}
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 );
}
}
it = boardList.begin();
}
}
+ FavoriteBoards::getInstance()->notifyChange();
}
+void FavoriteBoards::notifyChange()
+{
+ emit changed();
+}
+
+#include "favoriteboards.moc"
#ifndef KITAFAVORITEBOARDS_H
#define KITAFAVORITEBOARDS_H
+#include <qobject.h>
#include <kurl.h>
class QDomNode;
/**
@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 );
static bool readFromXML( QString& xml );
static QString toXML();
static void replace( QString fromURL, QString toURL );
+ signals:
+ void changed();
};
}
#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
LBox->addWidget( subjectLabel );
connect( subjectLabel, SIGNAL( urlClick( const QString& ) ),
SLOT( subjectlinkClicked( const QString& ) ) );
+ connect( subjectLabel, SIGNAL( urlMClick( const QString& ) ),
+ SLOT( subjectlinkMClicked( const QString& ) ) );
}
{
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 );
{
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 )
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();
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
#include <qcheckbox.h>
#include <qspinbox.h>
#include <qbuttongroup.h>
+#include <qvbox.h>
#include "libkita/kitaconfig.h"
#include "kitafontprefbase.h"
// 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& ) ),
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() ) );
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() ),