OSDN Git Service

b6fcdf5a2ce3df4017773fac4679acf4d6b3a357
[kita/kita.git] / kita / src / writeview.h
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10 #ifndef KITAWRITEVIEW_H
11 #define KITAWRITEVIEW_H
12
13 #include <QtCore/QByteArray>
14 #include <QtGui/QWidget>
15
16 #include <kio/job.h>
17
18 #include "ui_writedialogbase.h"
19
20 /* result code */
21 enum{
22     K2ch_Unknown,
23     K2ch_True,
24     K2ch_False,
25     K2ch_Error,
26     K2ch_Check,
27     K2ch_Cookie
28 };
29
30 namespace Kita {
31     class PreviewPart;
32     class WriteTabWidget;
33
34     /**
35      * 
36      * Hideki Ikemoto
37      **/
38     class WriteView : public QWidget, public ::Ui::WriteDialogBase
39     {
40         Q_OBJECT
41
42         WriteTabWidget* m_parent;
43
44         WriteView(const WriteView&);
45         WriteView& operator=(const WriteView&);
46
47     protected:
48
49         QByteArray m_array;
50         KUrl m_bbscgi;
51         int m_bbstype;
52         KUrl m_datUrl;
53         QString m_mailswap;
54
55         void initUI();
56         bool checkFields();
57         QString buildPostMessage();
58         int getWriteResNum();
59         void processPostFinished();
60         void logPostMessage();
61         int resultCode(const QString& response) const;
62         QString resultMessage(const QString& response) const;
63         QString resultTitle(const QString& response) const;
64
65     public:
66         WriteView(WriteTabWidget* parent, const KUrl& url);
67         virtual ~WriteView();
68         void setMessage(const QString& bodyStr);
69         void insertMessage(const QString& str);
70
71         const KUrl datUrl() const;
72         const QString threadName() const;
73         const QString boardName() const;
74         const QString boardId() const;
75         const QString name() const
76         {
77           return nameLine->text();
78         }
79
80         const QString mail() const
81         {
82           return mailLine->text();
83         }
84
85         const QString body() const
86         {
87           return bodyText->toPlainText();
88         }
89
90     public slots:
91
92         virtual void setFocus();
93         void slotPostMessage();
94         void slotCancel();
95         void slotEnableWriting(bool enable);
96         void sageBoxToggled(bool on)
97         {
98           if (on) {
99             m_mailswap = mailLine->text();
100             mailLine->setText("sage");
101             mailLine->setReadOnly(true);
102           } else {
103             mailLine->setReadOnly(false);
104             mailLine->setText(m_mailswap);
105           }
106         }
107
108     private slots:
109
110         void slotRecieveData(KIO::Job*, const QByteArray&);
111         void slotPostFinished(KJob*);
112
113     protected slots:
114         bool slotBodyTextChanged();
115
116     };
117 }
118 #endif