wadseekerinterface.h
1 //------------------------------------------------------------------------------
2 // wadseekerinterface.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __WADSEEKERINTERFACE_H_
24 #define __WADSEEKERINTERFACE_H_
25 
26 #include "serverapi/serverptr.h"
27 #include "wadseeker/wadseeker.h"
28 #include "dptr.h"
29 #include <QDialog>
30 #include <QStringList>
31 #include <QTimer>
32 
33 class QModelIndex;
34 
41 class WadseekerInterface : public QDialog
42 {
43  Q_OBJECT
44 
45  public:
46  static bool isInstantiated();
47 
48  static WadseekerInterface *create(QWidget* parent = NULL);
49  static WadseekerInterface *create(ServerPtr server, QWidget* parent = NULL);
50  static WadseekerInterface *createAutoNoGame(QWidget* parent = NULL);
52 
53  bool isAutomatic() { return bAutomatic; }
54 
55  void setCustomSite(const QString& site)
56  {
57  this->customSite = site;
58  }
59 
68  void setWads(const QStringList& wads);
69 
70  Wadseeker& wadseekerRef() { return wadseeker; }
71 
72  private:
73  enum States
74  {
75  Downloading = 0,
76  Waiting = 1
77  };
78 
80 
81  static const int UPDATE_INTERVAL_MS;
82  static WadseekerInterface *currentInstance;
83 
84  bool bAutomatic;
85  bool bFirstShown;
86 
87  // Setup for customization in the future.
88  QString colorHtmlMessageFatalError;
89  QString colorHtmlMessageError;
90  QString colorHtmlMessageNotice;
91 
92  QString customSite;
93 
97  QStringList seekedWads;
98 
99  States state;
100 
105  QStringList successfulWads;
106 
107  QTimer updateTimer;
108  Wadseeker wadseeker;
109 
110  WadseekerInterface(QWidget* parent = NULL);
111  WadseekerInterface(ServerPtr server, QWidget* parent = NULL);
112 
113  void connectWadseekerObject();
114  void construct();
115  void displayMessage(const QString& message, WadseekerLib::MessageType type, bool bPrependErrorsWithMessageType);
116  void initMessageColors();
117 
121  void resetTitleToDefault();
122 
123  void setStateDownloading();
124  void setStateWaiting();
125  void setupAutomatic();
126  void setupIdgames();
127  void showEvent(QShowEvent* event);
128  void startSeeking(const QStringList& seekedFilesList);
129  void updateProgressBar();
130  void updateTitle();
131 
136  QStringList unsuccessfulWads() const;
137 
138  private slots:
139  void abortService(const QString &service);
140  void abortSite(const QUrl &url);
141  void accept();
142  void allDone(bool bSuccess);
143  void fileDownloadSuccessful(const QString& filename);
144  void reject();
145  void message(const QString& message, WadseekerLib::MessageType type);
146  void registerUpdateRequest();
147  void seekStarted(const QStringList& filenames);
148  void serviceStarted(const QString &service);
149  void serviceFinished(const QString &service);
150  void siteFinished(const QUrl& site);
151  void siteProgress(const QUrl& site, qint64 bytes, qint64 total);
152  void siteRedirect(const QUrl& oldUrl, const QUrl& newUrl);
153  void siteStarted(const QUrl& site);
154  void wadsTableRightClicked(const QModelIndex& index, const QPoint& cursorPosition);
155 };
156 
157 #endif
void setWads(const QStringList &wads)
Sets WADs to seek.
Wadseeker dialog box, only one instance is allowed.