#include "kitawritedialog.h"
#include "libkita/qcp932codec.h"
-#include "libkita/thread.h"
#include "libkita/kitaconfig.h"
#include "kita2ch.h"
-#include "kitathreadview.h"
-#include "kitadomtree.h"
-#include "libkita/access.h"
+#include "kitahtmlpart.h"
+#include "kitahtmlview.h"
#include "libkita/datmanager.h"
#include "libkita/parsemisc.h"
#include "libkita/signalcollection.h"
#include <kstandarddirs.h>
#include <klineedit.h>
+#include <qapplication.h>
#include <qtextedit.h>
#include <qpushbutton.h>
#include <qlabel.h>
KitaWriteDialogPrivate* KitaWriteDialog::s_private = 0;
-KitaWriteDialog::KitaWriteDialog( const Kita::Thread* thread, QWidget* parent, const char* name )
- : KitaWriteDialogBase( parent, name )
+KitaWriteDialog::KitaWriteDialog( const KURL& datURL, QWidget* parent, const char* name )
+ : KitaWriteDialogBase( parent, name, WStyle_Customize | WType_TopLevel | WStyle_DialogBorder | WStyle_Title | WStyle_SysMenu | WStyle_MinMax | Qt::WDestructiveClose )
{
QFont font = KitaConfig::font();
bodyText->setFont( font );
/*--------------------*/
/* init preview */
- m_thread = const_cast<Kita::Thread *>( thread );
+ m_datURL = datURL;
connect( qtw, SIGNAL( currentChanged ( QWidget * ) ),
this, SLOT( slotCurrentChanged ( QWidget * ) ) );
- m_preview = new KitaThreadView( qtw );
- qtw->addTab( m_preview, i18n( "preview" ) );
+ m_preview = new KitaHTMLPart( NULL );
+ qtw->addTab( m_preview->view(), i18n( "preview" ) );
- m_preview->setupEx( m_thread , 0, VIEWMODE_PREVIEW );
+ m_preview->setup( HTMLPART_MODE_KHTML, m_datURL );
+
+ /* move to center */
+ QWidget * desk = QApplication::desktop();
+ QPoint p = QPoint( (desk->width() - width() )/2, (desk->height()-height())/2 );
+ move(p);
}
KitaWriteDialog::~KitaWriteDialog()
// TODO: Thread¥¯¥é¥¹¤ò»È¤¦¤è¤¦¤Ë½ñ¤´¹¤¨¤ë
KitaWriteDialog* KitaWriteDialog::open( const Kita::PostInfo& info,
- const Kita::Thread* thread )
+ const KURL& datURL,
+ QWidget* parent )
{
if ( ! info.check() ) return 0;
if ( ! s_private ) {
if ( ! s_private ) return 0;
}
- KitaWriteDialog* new_dlg = new KitaWriteDialog( thread );
+ KitaWriteDialog* new_dlg = new KitaWriteDialog( datURL, parent );
if ( ! new_dlg ) return 0;
new_dlg->m_postInfo = info;
new_dlg->connect( new_dlg->buttonOk, SIGNAL( clicked() ),
new_dlg, SLOT( postMessage() ) );
+ new_dlg->connect( new_dlg->buttonCancel, SIGNAL( clicked() ),
+ new_dlg, SLOT( reject() ) );
+
// set fields
new_dlg->nameLine->setText( info.name );
new_dlg->mailLine->setText( info.mail );
}
new_dlg->bodyText->setText( info.body );
- new_dlg->boardNameLabel->setText( thread->boardName() );
- new_dlg->threadNameLabel->setText( thread->name() );
- new_dlg->threadURLLabel->setText( thread->url() );
+ new_dlg->boardNameLabel->setText( Kita::DatManager::thread_boardName( datURL ) );
+ new_dlg->threadNameLabel->setText( Kita::DatManager::thread_name( datURL ) );
+ new_dlg->threadURLLabel->setText( Kita::DatManager::thread_url( datURL ) );
KCompletion* comp = KitaConfig::nameCompletion();
new_dlg->nameLine->setCompletionObject( comp );
- new_dlg->setCaption( i18n( "Write in %1" ).arg( thread->name() ) );
+ new_dlg->setCaption( i18n( "Write in %1" ).arg( Kita::DatManager::thread_name( datURL ) ) );
return new_dlg;
}
m_array.resize( 0 );
int idx = s_private->m_heaplist.find( this );
- if ( idx != -1 )
- delete this;
+ if ( idx != -1 )
+ close( TRUE );
}
void KitaWriteDialog::reject()
"Do you want to close?" ),
QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default ) ) {
case QMessageBox::Ok:
- KitaWriteDialogBase::reject();
+ close( TRUE );
break;
case QMessageBox::Cancel:
// do nothing
{
if ( w == bodyText ) return ;
- int resnum = Kita::DatManager::getMaxResNumber( m_thread->datURL() ) + 1 ;
+ int resnum = Kita::DatManager::getMaxResNumber( m_datURL ) + 1 ;
QDateTime now = QDateTime::currentDateTime();
QString bodystr = body();
- bodystr.replace( ">", ">" ).replace( "\n", " <br> " );
+ bodystr.replace( "<", "<" ).replace( ">", ">" ).replace( "\n", " <br> " );
QString namestr = name();
if ( namestr == NULL || namestr.length() == 0 ) namestr = "(default name)";
QString rawData = namestr + "<>" + mail() + "<>"
+ "<> " + bodystr + " <>";
QString htmlstr = Kita::ParseMisc::DatToHtml(rawData,resnum,KitaConfig::showMailAddress());
- m_preview->domSetInnerHTML( htmlstr );
+ m_preview->setInnerHTML( htmlstr );
}
template <class type> class QPtrList;
class KitaWriteDialogPrivate;
class KitaWriteDialog;
-class KitaThreadView;
-class KitaDomTree;
+class KitaHTMLPart;
+
namespace Kita
{
class Access;
- class Thread;
}
/**
{
Q_OBJECT
public:
- KitaWriteDialog( const Kita::Thread* thread, QWidget* parent = 0, const char* name = 0 );
+ KitaWriteDialog( const KURL& datURL, QWidget* parent = 0, const char* name = 0 );
virtual ~KitaWriteDialog();
const QString name() const;
const QString mail() const;
virtual bool error() { return false; };
- static KitaWriteDialog* open( const Kita::PostInfo& info, const Kita::Thread* thread );
+ static KitaWriteDialog* open( const Kita::PostInfo& info, const KURL& datURL, QWidget* parent );
public slots:
void postMessage();
QCString m_array;
bool m_error;
static KitaWriteDialogPrivate* s_private;
- KitaThreadView *m_preview;
+ KitaHTMLPart *m_preview;
int m_resnum;
- Kita::Thread* m_thread;
+ KURL m_datURL;
private slots:
void slotRecieveData( KIO::Job*, const QByteArray& );