Files
transmission/qt/Application.h
Charles Kerr d857a5821a refractor: simplify torrent model signal emissions (#1044)
refractor: simplify torrent model signal emissions

The Torrent->Application signal connections make up for about 5% of the
app's memory use. Move this to the TorrentModel so that there are only a
handful of signal connections.

Moving signals to TorrentModel means batch change signals can be emitted
instead of per-change-per-torrent emissions and can be handled that way.
2019-11-09 08:44:40 -06:00

73 lines
1.5 KiB
C++

/*
* This file Copyright (C) 2009-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#pragma once
#include <QApplication>
#include <QSet>
#include <QTimer>
#include <QTranslator>
#include "FaviconCache.h"
class AddData;
class Prefs;
class Session;
class TorrentModel;
class MainWindow;
class WatchDir;
class Application : public QApplication
{
Q_OBJECT
public:
Application(int& argc, char** argv);
virtual ~Application();
void raise();
bool notifyApp(QString const& title, QString const& body) const;
FaviconCache& faviconCache();
public slots:
void addTorrent(AddData const&);
private slots:
void consentGiven(int result);
void onSessionSourceChanged();
void refreshPref(int key);
void refreshTorrents();
void onTorrentsAdded(QSet<int> const& torrents);
void onTorrentsCompleted(QSet<int> const& torrents);
void onTorrentsNeedInfo(QSet<int> const& torrents);
private:
void maybeUpdateBlocklist();
void loadTranslations();
void quitLater();
QStringList getNames(QSet<int> const& ids) const;
private:
Prefs* myPrefs;
Session* mySession;
TorrentModel* myModel;
MainWindow* myWindow;
WatchDir* myWatchDir;
QTimer myModelTimer;
QTimer myStatsTimer;
QTimer mySessionTimer;
time_t myLastFullUpdateTime;
QTranslator myQtTranslator;
QTranslator myAppTranslator;
FaviconCache myFavicons;
};
#undef qApp
#define qApp static_cast<Application*>(Application::instance())