| 1 |
#ifndef MAINWINDOWIMPL_H |
| 2 |
#define MAINWINDOWIMPL_H |
| 3 |
// |
| 4 |
#include <QtCore> |
| 5 |
#include <QtNetwork> |
| 6 |
#include <QtGui> |
| 7 |
#include <QtXml> |
| 8 |
#include "ui_mainwindow.h" |
| 9 |
#include "src/globals.h" |
| 10 |
#include "src/kimo2chtimerdialog.h" |
| 11 |
#include "src/kimo2chprefsdialog.h" |
| 12 |
#include "src/tabwidgetimpl.h" |
| 13 |
#include "src/browsewidgetimpl.h" |
| 14 |
#include "src/xmlprefshandler.h" |
| 15 |
#include "src/kimo2chtextbrowser.h" |
| 16 |
#include "src/abonedialog.h" |
| 17 |
#include "src/authproxydialog.h" |
| 18 |
#include "src/filteredit.h" |
| 19 |
#include "src/kimo2chfavoriteshandler.h" |
| 20 |
#include "src/rescountitem.h" |
| 21 |
#include "src/cp932codec.h" |
| 22 |
#include "src/newthreaddialog.h" |
| 23 |
// |
| 24 |
|
| 25 |
// Preference items |
| 26 |
const QString INITIALBOARDURL = "http://www.2ch.net/bbsmenu.html"; |
| 27 |
|
| 28 |
class MainWindowImpl : public QMainWindow, public Ui::MainWindow |
| 29 |
{ |
| 30 |
Q_OBJECT |
| 31 |
public: |
| 32 |
MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 ); |
| 33 |
|
| 34 |
virtual ~MainWindowImpl(); |
| 35 |
|
| 36 |
QList<Favorite> *getFavoriteList() { return &favoriteList; } |
| 37 |
QNetworkProxy *getProxy() { return &globalProxy; } |
| 38 |
bool isAutoReloading() { return autoReloading; } |
| 39 |
|
| 40 |
signals: |
| 41 |
void windowOpened(); |
| 42 |
void restoreLastSession(); |
| 43 |
|
| 44 |
public slots: |
| 45 |
void downReloadButton(); |
| 46 |
void upReloadButton(); |
| 47 |
void openLink(const QUrl &url); |
| 48 |
void startAutoReload(bool state = true); |
| 49 |
|
| 50 |
private slots: |
| 51 |
void restoreSession(); |
| 52 |
// View control |
| 53 |
void showBoardList(); |
| 54 |
void showThreadList(); |
| 55 |
void showResEditTab(); |
| 56 |
void hideAllPanes(); |
| 57 |
void hidePopups(); |
| 58 |
void filterLabelChange(); |
| 59 |
void filterLabelRevert(); |
| 60 |
void searchLabelChange(); |
| 61 |
void searchLabelRevert(); |
| 62 |
// New thread post dialog |
| 63 |
void showNewThreadDialog(); |
| 64 |
void newThreadPost(); |
| 65 |
// Preferences dialog |
| 66 |
void showPrefsDialog(); |
| 67 |
void prefsChange(); |
| 68 |
// Reload timer dialog |
| 69 |
void showTimerDialog(); |
| 70 |
void timerChange(); |
| 71 |
// Favorite list update dialog |
| 72 |
void showUpdateDialog(); |
| 73 |
void startAutoUpdate(bool state = true); |
| 74 |
// Search dialog |
| 75 |
void doSearch(QString searchText = 0); |
| 76 |
void doSearchBackward(); |
| 77 |
void doFilter(QString filterText); |
| 78 |
// Abone dialog |
| 79 |
void showAboneDialog(); |
| 80 |
void aboneChange(); |
| 81 |
void closeAboneDialog(); |
| 82 |
// Buttons |
| 83 |
void reject(); |
| 84 |
void post(); |
| 85 |
void reload(); |
| 86 |
void closeTab(int index); |
| 87 |
void loadSubject(); |
| 88 |
void toggleAddFavoriteButton(); |
| 89 |
// Networking |
| 90 |
void networkStartup(); |
| 91 |
void buildBoardList(); |
| 92 |
void boardDownloaded(); |
| 93 |
void boardSelected(const QModelIndex index); |
| 94 |
void subjectUpdate(); |
| 95 |
void favoritesUpdate(); |
| 96 |
void favoritesUpdateError(QNetworkReply::NetworkError code); |
| 97 |
void findNextThreads(); |
| 98 |
void threadTabChanged(int index); |
| 99 |
|
| 100 |
void updateTimeouted(); |
| 101 |
// Proxy authentication dialog |
| 102 |
void authProxy(const QNetworkProxy &proxy, QAuthenticator *authenticator); |
| 103 |
|
| 104 |
void readThread(const QModelIndex index); |
| 105 |
void openTab(QString url); |
| 106 |
void clearCache(); |
| 107 |
|
| 108 |
void messagePosted(); |
| 109 |
|
| 110 |
void updateFavoriteList(); |
| 111 |
private: |
| 112 |
// Prefs |
| 113 |
void readPrefs(); |
| 114 |
void writePrefs(); |
| 115 |
void readFavorites(); |
| 116 |
void writeFavorites(); |
| 117 |
|
| 118 |
void setupProxy(); |
| 119 |
// Session |
| 120 |
void readSession(); |
| 121 |
void writeSession(); |
| 122 |
// New editor tab |
| 123 |
QWidget* createNewEditorTab(QWidget *parent); |
| 124 |
|
| 125 |
// Thread view column width restore |
| 126 |
void rememberColumnWidth(); |
| 127 |
void restoreColumnWidth(); |
| 128 |
|
| 129 |
// Networks |
| 130 |
QList<QNetworkCookie> loadCookie(QString server); |
| 131 |
|
| 132 |
public: |
| 133 |
// Utilities |
| 134 |
QString urlToDat(QString url); |
| 135 |
QString datToUrl(QString dat); |
| 136 |
|
| 137 |
// Data members |
| 138 |
private: |
| 139 |
// Menus |
| 140 |
QMenu *reloadMenu; |
| 141 |
QMenu *updateMenu; |
| 142 |
|
| 143 |
// Dialogs |
| 144 |
NewThreadDialog *newThreadDialog; // New thread post dialog |
| 145 |
Kimo2chPrefsDialog *prefsDialog; // Preferences dialog |
| 146 |
Kimo2chTimerDialog *timerDialog; // Auto reload timer dialog |
| 147 |
QAction *reloadStart; |
| 148 |
QAction *updateStart; |
| 149 |
AboneDialog *aboneDialog; // Name, mail or ID abone dialog |
| 150 |
|
| 151 |
// Prefs data |
| 152 |
Kimo2chPrefs *prefs; // Preferences data |
| 153 |
struct aboneData *aboneData; // A-bone data |
| 154 |
QStringList *aboneKeywordList; // A-bone keyword for hiding |
| 155 |
QDir cacheRootDir; |
| 156 |
|
| 157 |
// Timer |
| 158 |
QTimer reloadTimer; |
| 159 |
QTimer updateTimer; |
| 160 |
QTimer postReloadTimer; |
| 161 |
QTimer updateTimeoutTimer; |
| 162 |
int timerSec; |
| 163 |
|
| 164 |
// Networking |
| 165 |
QNetworkAccessManager *network; |
| 166 |
QNetworkProxy globalProxy; |
| 167 |
QFile *boardFile; |
| 168 |
bool isFavoritesUpdating; |
| 169 |
|
| 170 |
QNetworkReply *boardReply; |
| 171 |
QNetworkReply *subjectReply; |
| 172 |
QNetworkReply *favoriteReply; |
| 173 |
QNetworkReply *postReply; |
| 174 |
|
| 175 |
int boardListGetID; |
| 176 |
int subjectGetID; |
| 177 |
int favoriteUpdateID; |
| 178 |
|
| 179 |
QString postServer; |
| 180 |
int postReqId; |
| 181 |
|
| 182 |
QString currentBoard; |
| 183 |
QString currentBoardName; |
| 184 |
|
| 185 |
QString currentLoadingBoard; |
| 186 |
// Containers |
| 187 |
QStandardItemModel *boardModel; |
| 188 |
QStandardItemModel *threadModel; |
| 189 |
QStandardItemModel *oldThreadModel; |
| 190 |
QStandardItemModel *filteredModel; |
| 191 |
QList<Favorite> favoriteList; |
| 192 |
|
| 193 |
// Temporary containers |
| 194 |
QList<QList<Favorite>* > targetBoardList; |
| 195 |
|
| 196 |
// Favorite status |
| 197 |
int unreadThreadNum; |
| 198 |
int unreadResNum; |
| 199 |
|
| 200 |
// Others |
| 201 |
bool isReadOnNewTab; |
| 202 |
bool initialTab; |
| 203 |
|
| 204 |
// Auto update flags |
| 205 |
bool autoReloading; |
| 206 |
bool isAutoUpdating; |
| 207 |
|
| 208 |
// URLs |
| 209 |
QString boardURL; |
| 210 |
}; |
| 211 |
|
| 212 |
#endif |