00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "newcommentform.h"
00021
00022 #include <attica/provider.h>
00023
00024 #include <KTextEdit>
00025 #include <KLineEdit>
00026 #include <Plasma/PushButton>
00027 #include <Plasma/LineEdit>
00028 #include <Plasma/TextEdit>
00029
00030 #include <QGraphicsLinearLayout>
00031
00032 NewCommentForm::NewCommentForm( QGraphicsItem* parent, Qt::WindowFlags wFlags )
00033 : QGraphicsWidget( parent, wFlags )
00034 {
00035 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout( Qt::Vertical, this );
00036 QGraphicsLinearLayout* layout2 = new QGraphicsLinearLayout( Qt::Horizontal, layout );
00037 layout2->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
00038
00039 m_titleEdit = new Plasma::LineEdit( this );
00040 m_titleEdit->nativeWidget()->setClickMessage( i18n( "Subject" ) );
00041
00042 m_bodyEdit = new Plasma::TextEdit( this );
00043 m_bodyEdit->nativeWidget()->setClickMessage( i18n( "Message" ) );
00044
00045 m_okButton = new Plasma::PushButton( this );
00046 m_okButton->setText( i18n( "OK" ) );
00047 connect( m_okButton, SIGNAL( clicked() ), SLOT( validateAndSubmit() ) );
00048
00049 m_cancelButton = new Plasma::PushButton( this );
00050 m_cancelButton->setText( i18n( "Cancel" ) );
00051 connect( m_cancelButton, SIGNAL( clicked() ), SIGNAL( canceled() ) );
00052
00053 layout->addItem( m_titleEdit );
00054 layout->addItem( m_bodyEdit );
00055 layout2->addItem( m_cancelButton );
00056 layout2->addItem( m_okButton );
00057 layout->addItem( layout2 );
00058
00059 setLayout( layout );
00060 }
00061
00062 NewCommentForm::~NewCommentForm()
00063 {
00064 }
00065
00066 void NewCommentForm::setParentIndex( QModelIndex parentIndex )
00067 {
00068 m_parentIndex = parentIndex;
00069 }
00070
00071 void NewCommentForm::validateAndSubmit()
00072 {
00073 if( m_titleEdit->text().isEmpty())
00074 {
00075 qDebug() << "Empty title";
00076 }
00077 if(m_bodyEdit->text().isEmpty() )
00078 {
00079 qDebug() << "Empty body";
00080 return;
00081 }
00082 emit accepted( m_parentIndex, m_titleEdit->text(), m_bodyEdit->nativeWidget()->toPlainText() );
00083 }
00084
00085 #include "newcommentform.moc"