File: mainwindow.h

package info (click to toggle)
android-file-transfer 4.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,496 kB
  • sloc: cpp: 12,909; python: 140; lex: 47; xml: 26; sh: 13; makefile: 6
file content (137 lines) | stat: -rw-r--r-- 3,794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
    This file is part of Android File Transfer For Linux.
    Copyright (C) 2015-2020  Vladimir Menshakov

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License,
    or (at your option) any later version.

    This library is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this library; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef AFTL_QT_MAINWINDOW_H
#define AFTL_QT_MAINWINDOW_H

#include <QMainWindow>
#include <QModelIndex>
#include <QVector>
#include <QByteArray>
#include <mtp/ptp/ObjectId.h>
#include <mtp/ptp/ObjectFormat.h>
#include <mtp/types.h>

namespace Ui {
	class MainWindow;
}
namespace mtp {
	class Device;
	DECLARE_PTR(Device);
	class TrustedApp;
	DECLARE_PTR(TrustedApp);
	class Library;
	DECLARE_PTR(Library);
	class Session;
	DECLARE_PTR(Session);
}

class MtpObjectsModel;
class MtpStoragesModel;
class FileUploader;

class QSortFilterProxyModel;
class QClipboard;
class QNetworkAccessManager;
class QNetworkReply;

class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	explicit MainWindow(QWidget *parent = 0);
	~MainWindow();

	bool started() const
	{ return _device != 0; }

	void enableDeviceReset(bool enable)
	{ _resetDevice = enable; }

private:
	void showEvent(QShowEvent *e);
	void closeEvent(QCloseEvent *event);
	QModelIndex mapIndex(const QModelIndex &index);
	void saveGeometry(const QString &name, const QWidget &widget);
	void restoreGeometry(const QString &name, QWidget &widget);
	static QString getMtpzDataPath();
	void tryCreateLibrary();
	void importMusic(bool directoryMode);

private slots:
	bool reconnectToDevice();
	void back();
	void down();
	void onActivated ( const QModelIndex & index );
	void activate(const QModelIndex & index);
	void updateActionsState();
	void showContextMenu ( const QPoint & pos );
	void createDirectory();
	void refresh();
	void uploadFiles();
	void uploadDirectories();
	void uploadAlbum();
	void uploadAlbum(QString path);
	void importMusic();
	void importMusicFiles();
	void importMusic(QString path);
	void downloadFiles();
	void renameFile();
	void deleteFiles();
	void downloadFiles(const QVector<mtp::ObjectId> &objects);
	void uploadFiles(const QStringList &files, mtp::ObjectFormat format = mtp::ObjectFormat::Any);
	void onFilesDropped(const QStringList &files);
	void onStorageChanged(int idx);
	void validateClipboard();
	void pasteFromClipboard();
	bool confirmOverwrite(const QString &file);
	void showThumbnails(bool enable);
	void attachCover();
	void removeCover();
	void uploadFirmware();
	void rebootDevice();

public slots:
	void downloadFiles(const QString & path, const QVector<mtp::ObjectId> &objects);
	void replyReadyRead();
	void replyFinished(QNetworkReply*);

private:
	Ui::MainWindow *			_ui;
	QNetworkAccessManager *		_nam;
	QClipboard *				_clipboard;
	QSortFilterProxyModel *		_proxyModel;
	MtpStoragesModel *			_storageModel;
	MtpObjectsModel *			_objectModel;
	FileUploader *				_uploader;
	typedef QVector<QPair<QString, mtp::ObjectId>> History;
	History						_history;
	int							_uploadAnswer;

	mtp::DevicePtr				_device;
	mtp::SessionPtr				_session;
	mtp::TrustedAppPtr			_trustedApp;
	mtp::LibraryPtr				_mediaLibrary;
	bool						_resetDevice;
	QNetworkReply *				_networkReply;
	QByteArray					_networkReplyBody;
};

#endif // MAINWINDOW_H