1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5159

ezavod (1):
      refactor(chatform): Use QStringList instead of QVector<QString>
This commit is contained in:
sudden6 2018-05-31 22:09:36 +02:00
commit afe7914bb7
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
9 changed files with 19 additions and 21 deletions

View File

@ -49,7 +49,7 @@ public:
virtual QString getProfileName() const = 0; virtual QString getProfileName() const = 0;
virtual RenameResult renameProfile(const QString& name) = 0; virtual RenameResult renameProfile(const QString& name) = 0;
virtual SaveResult exportProfile(const QString& path) const = 0; virtual SaveResult exportProfile(const QString& path) const = 0;
virtual QVector<QString> removeProfile() = 0; virtual QStringList removeProfile() = 0;
virtual void logout() = 0; virtual void logout() = 0;
virtual void copyQr(const QImage& image) const = 0; virtual void copyQr(const QImage& image) const = 0;

View File

@ -213,10 +213,9 @@ IProfileInfo::SaveResult ProfileInfo::exportProfile(const QString &path) const
* @brief Remove profile. * @brief Remove profile.
* @return List of files, which couldn't be removed automaticaly. * @return List of files, which couldn't be removed automaticaly.
*/ */
// TODO: Use QStringList QStringList ProfileInfo::removeProfile()
QVector<QString> ProfileInfo::removeProfile()
{ {
QVector<QString> manualDeleteFiles = profile->remove(); QStringList manualDeleteFiles = profile->remove();
QMetaObject::invokeMethod(&Nexus::getInstance(), "showLogin"); QMetaObject::invokeMethod(&Nexus::getInstance(), "showLogin");
return manualDeleteFiles; return manualDeleteFiles;
} }

View File

@ -40,7 +40,7 @@ public:
QString getProfileName() const override; QString getProfileName() const override;
RenameResult renameProfile(const QString& name) override; RenameResult renameProfile(const QString& name) override;
SaveResult exportProfile(const QString& path) const override; SaveResult exportProfile(const QString& path) const override;
QVector<QString> removeProfile() override; QStringList removeProfile() override;
void logout() override; void logout() override;
void copyQr(const QImage& image) const override; void copyQr(const QImage& image) const override;

View File

@ -49,7 +49,7 @@
* @brief True if the profile has been removed by remove(). * @brief True if the profile has been removed by remove().
*/ */
QVector<QString> Profile::profiles; QStringList Profile::profiles;
Profile::Profile(QString name, const QString& password, bool isNewProfile, const QByteArray& toxsave) Profile::Profile(QString name, const QString& password, bool isNewProfile, const QByteArray& toxsave)
: name{name} : name{name}
@ -236,10 +236,10 @@ Profile::~Profile()
* @param extension Raw extension, e.g. "jpeg" not ".jpeg". * @param extension Raw extension, e.g. "jpeg" not ".jpeg".
* @return Vector of filenames. * @return Vector of filenames.
*/ */
QVector<QString> Profile::getFilesByExt(QString extension) QStringList Profile::getFilesByExt(QString extension)
{ {
QDir dir(Settings::getInstance().getSettingsDirPath()); QDir dir(Settings::getInstance().getSettingsDirPath());
QVector<QString> out; QStringList out;
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
dir.setNameFilters(QStringList("*." + extension)); dir.setNameFilters(QStringList("*." + extension));
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
@ -258,7 +258,7 @@ QVector<QString> Profile::getFilesByExt(QString extension)
void Profile::scanProfiles() void Profile::scanProfiles()
{ {
profiles.clear(); profiles.clear();
QVector<QString> toxfiles = getFilesByExt("tox"), inifiles = getFilesByExt("ini"); QStringList toxfiles = getFilesByExt("tox"), inifiles = getFilesByExt("ini");
for (QString toxfile : toxfiles) { for (QString toxfile : toxfiles) {
if (!inifiles.contains(toxfile)) { if (!inifiles.contains(toxfile)) {
Settings::getInstance().createPersonal(toxfile); Settings::getInstance().createPersonal(toxfile);
@ -268,7 +268,7 @@ void Profile::scanProfiles()
} }
} }
QVector<QString> Profile::getProfiles() QStringList Profile::getProfiles()
{ {
return profiles; return profiles;
} }
@ -630,7 +630,7 @@ bool Profile::isEncrypted(QString name)
* @return Vector of filenames that could not be removed. * @return Vector of filenames that could not be removed.
* @warning It is invalid to call loadToxSave or saveToxSave on a deleted profile. * @warning It is invalid to call loadToxSave or saveToxSave on a deleted profile.
*/ */
QVector<QString> Profile::remove() QStringList Profile::remove()
{ {
if (isRemoved) { if (isRemoved) {
qWarning() << "Profile " << name << " is already removed!"; qWarning() << "Profile " << name << " is already removed!";
@ -651,7 +651,7 @@ QVector<QString> Profile::remove()
QFile profileMain{path + ".tox"}; QFile profileMain{path + ".tox"};
QFile profileConfig{path + ".ini"}; QFile profileConfig{path + ".ini"};
QVector<QString> ret; QStringList ret;
if (!profileMain.remove() && profileMain.exists()) { if (!profileMain.remove() && profileMain.exists()) {
ret.push_back(profileMain.fileName()); ret.push_back(profileMain.fileName());

View File

@ -70,12 +70,12 @@ public:
bool isHistoryEnabled(); bool isHistoryEnabled();
History* getHistory(); History* getHistory();
QVector<QString> remove(); QStringList remove();
bool rename(QString newName); bool rename(QString newName);
static void scanProfiles(); static void scanProfiles();
static QVector<QString> getProfiles(); static QStringList getProfiles();
static bool exists(QString name); static bool exists(QString name);
static bool isEncrypted(QString name); static bool isEncrypted(QString name);
@ -92,7 +92,7 @@ private slots:
private: private:
Profile(QString name, const QString& password, bool newProfile, const QByteArray& toxsave); Profile(QString name, const QString& password, bool newProfile, const QByteArray& toxsave);
static QVector<QString> getFilesByExt(QString extension); static QStringList getFilesByExt(QString extension);
QString avatarPath(const ToxPk& owner, bool forceUnencrypted = false); QString avatarPath(const ToxPk& owner, bool forceUnencrypted = false);
private: private:
@ -105,7 +105,7 @@ private:
bool newProfile; bool newProfile;
bool isRemoved; bool isRemoved;
bool encrypted = false; bool encrypted = false;
static QVector<QString> profiles; static QStringList profiles;
}; };
#endif // PROFILE_H #endif // PROFILE_H

View File

@ -106,7 +106,7 @@ private:
QString path; QString path;
const ToxEncrypt* passKey; const ToxEncrypt* passKey;
int group, array, arrayIndex; int group, array, arrayIndex;
QVector<QString> groups; QStringList groups;
QVector<Array> arrays; QVector<Array> arrays;
QVector<Value> values; QVector<Value> values;
static const char magic[]; static const char magic[];

View File

@ -171,7 +171,7 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
QVector<QPair<QString, QString>> v4l2::getDeviceList() QVector<QPair<QString, QString>> v4l2::getDeviceList()
{ {
QVector<QPair<QString, QString>> devices; QVector<QPair<QString, QString>> devices;
QVector<QString> deviceFiles; QStringList deviceFiles;
DIR* dir = opendir("/dev"); DIR* dir = opendir("/dev");
if (!dir) if (!dir)

View File

@ -373,8 +373,7 @@ void ProfileForm::onDeleteClicked()
return; return;
} }
// TODO: Use QStringList const QStringList manualDeleteFiles = profileInfo->removeProfile();
const QVector<QString> manualDeleteFiles = profileInfo->removeProfile();
if (manualDeleteFiles.empty()) { if (manualDeleteFiles.empty()) {
return; return;
} }

View File

@ -87,7 +87,7 @@ void LoginScreen::reset(QString initialProfile)
if (initialProfile.isEmpty()) { if (initialProfile.isEmpty()) {
initialProfile = Settings::getInstance().getCurrentProfile(); initialProfile = Settings::getInstance().getCurrentProfile();
} }
QVector<QString> profiles = Profile::getProfiles(); QStringList profiles = Profile::getProfiles();
for (QString profile : profiles) { for (QString profile : profiles) {
ui->loginUsernames->addItem(profile); ui->loginUsernames->addItem(profile);
if (profile == initialProfile) { if (profile == initialProfile) {