cleaning\ncorrections of code
This commit is contained in:
+30
-24
@@ -1,6 +1,5 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QtGlobal>
|
||||
//#include <QComboBox>
|
||||
#include <QTextBlock>
|
||||
#include "ui_configuration.h"
|
||||
#include "version.h"
|
||||
@@ -8,8 +7,9 @@
|
||||
#include "password.h"
|
||||
#include <kcombobox.h>
|
||||
#include <signal.h>
|
||||
#include <QTextStream>
|
||||
#include <QHostInfo>
|
||||
#include <iostream>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -542,6 +542,7 @@ void MainWindow::listServices()
|
||||
|
||||
if (this->connexion.ipversion == 0)
|
||||
{
|
||||
info(DEBUGMACRO, "test version of ip address of " + this->connexion.server);
|
||||
this->connexion.ipversion = whatIpVersion(this->connexion.server);
|
||||
}
|
||||
|
||||
@@ -716,7 +717,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
|
||||
size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " ";
|
||||
}
|
||||
|
||||
if (line[0] == "d")
|
||||
if (line[0] == 'd')
|
||||
{
|
||||
isDir = true;
|
||||
}else
|
||||
@@ -843,7 +844,7 @@ uint MainWindow::validateServer(QString *server)
|
||||
{
|
||||
line = line.mid(answerFound, queryPos - answerFound);
|
||||
info(DEBUGMACRO, "line is:\n" + line);
|
||||
responseList = line.split(QRegExp("\\s+"));
|
||||
responseList = line.split(QRegularExpression("\\s+"));
|
||||
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
|
||||
if (serverAddress.setAddress(responseList.at(4)))
|
||||
{
|
||||
@@ -860,12 +861,12 @@ uint MainWindow::validateServer(QString *server)
|
||||
}
|
||||
}
|
||||
|
||||
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
|
||||
//ipversion = whatIpVersion(*server);
|
||||
|
||||
ipversion = serverAddress.protocol();
|
||||
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
|
||||
|
||||
return (ipversion==IPV4?4:6);
|
||||
return (ipversion == QAbstractSocket::IPv4Protocol?4:6);
|
||||
}
|
||||
|
||||
|
||||
@@ -897,7 +898,7 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q
|
||||
QFont font;
|
||||
QTreeWidgetItem *treeItem;
|
||||
|
||||
info(DEBUGMACRO, "addTreeItem() => adding item to treeview");
|
||||
//info(DEBUGMACRO, "addTreeItem() => adding item to treeview");
|
||||
|
||||
if (parent != nullptr)
|
||||
{
|
||||
@@ -965,7 +966,7 @@ void MainWindow::preparePopulateTree()
|
||||
this->rescan = true;
|
||||
this->connexion.user = nullptr;
|
||||
this->connexion.password = nullptr;
|
||||
str = "Folder/" + this->connexion.server + "/" + this->connexion.service;
|
||||
str = "Folder/" + this->connexion.server + ":" + QByteArray::number(this->connexion.port) + "/" + this->connexion.service;
|
||||
|
||||
// if service exists in settings for this server
|
||||
if (this->settings.contains(str))
|
||||
@@ -1083,7 +1084,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
if (item->text(1) != tr("Dir") or downloadDir == true)
|
||||
{
|
||||
// exists saving path in settings ?
|
||||
str = "Folder/" + this->connexion.server + "/" + this->connexion.service;
|
||||
str = "Folder/" + this->connexion.server + ":" + QByteArray::number(this->connexion.port) + "/" + this->connexion.service;
|
||||
if(!this->settings.contains(str))
|
||||
{
|
||||
info(DEBUGMACRO, "saving path do not exists, asking for it");
|
||||
@@ -1164,7 +1165,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
}
|
||||
info(DEBUGMACRO, "Downloading process exist, adding download to download list");
|
||||
// Adding download to download list
|
||||
str = path + " => " + this->connexion.server + "/" + this->connexion.service;
|
||||
str = path + " => " + this->connexion.server + ":" + QByteArray::number(this->connexion.port) + "/" + this->connexion.service;
|
||||
ui->listDownload->addItem(str);
|
||||
}else
|
||||
{
|
||||
@@ -1269,10 +1270,12 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
if (reply == QMessageBox::Yes)
|
||||
{
|
||||
retry = true;
|
||||
}else
|
||||
{
|
||||
this->stopDlAsked = false;
|
||||
this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information);
|
||||
}
|
||||
}
|
||||
this->stopDlAsked = false;
|
||||
this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information);
|
||||
|
||||
// disconnecting signals to slots
|
||||
disconnect(this->downloading.process, 0, 0, 0);
|
||||
@@ -1283,9 +1286,9 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
|
||||
if (retry == false)
|
||||
{
|
||||
QString filename = ui->listDownload->item(0)->text();
|
||||
pos = filename.contains(" => ");
|
||||
filename.resize(pos);
|
||||
//QString filename = ui->listDownload->item(0)->text();
|
||||
//pos = filename.contains(" => ");
|
||||
//filename.resize(pos);
|
||||
delete ui->listDownload->takeItem(0);
|
||||
}
|
||||
this->downloading.clear();
|
||||
@@ -1296,19 +1299,22 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
// initializing download
|
||||
path = ui->listDownload->item(0)->text();
|
||||
pos = path.lastIndexOf("/");
|
||||
this->downloading.service = path.midRef(pos+1).toString();
|
||||
this->downloading.service = path.mid(pos+1);
|
||||
path.resize(pos);
|
||||
pos = path.lastIndexOf(":");
|
||||
this->downloading.port = path.mid(pos+1).toUInt();
|
||||
path.resize(pos);
|
||||
pos = path.lastIndexOf(" => ");
|
||||
this->downloading.server = path.midRef(pos+4).toString();
|
||||
this->downloading.server = path.mid(pos+4);
|
||||
path.resize(pos);
|
||||
this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server + "/port").toInt();
|
||||
//this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server + "/port").toInt();
|
||||
this->downloading.path = path;
|
||||
|
||||
//getUserPassword(true);
|
||||
testServerPresence(this->downloading.service, true);
|
||||
|
||||
// savepath exists in settings ?
|
||||
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
|
||||
str = "Folder/" + this->downloading.server + ":" + QByteArray::number(this->downloading.port) + "/" + this->downloading.service;
|
||||
if (this->settings.contains(str))
|
||||
{
|
||||
// setting savepath from saved settings
|
||||
@@ -1461,7 +1467,7 @@ bool MainWindow::on_DefaultSaveFolder_triggered()
|
||||
}
|
||||
|
||||
// Asking for directory to save files
|
||||
folder = "Folder/" + this->connexion.server + "/" + this->connexion.service;
|
||||
folder = "Folder/" + this->connexion.server + ":" + QByteArray::number(this->connexion.port )+ "/" + this->connexion.service;
|
||||
path = this->settings.value(folder).toString();
|
||||
info(DEBUGMACRO, "Path = " + path);
|
||||
dir = dialog.getExistingDirectory(this, tr("Choose folder where to save file"), path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
@@ -1558,14 +1564,14 @@ void MainWindow::loadDownloadList()
|
||||
|
||||
path = ui->listDownload->item(0)->text();
|
||||
pos = path.lastIndexOf("/");
|
||||
this->downloading.service = path.midRef(pos+1).toString();
|
||||
this->downloading.service = path.mid(pos+1);
|
||||
path.resize(pos);
|
||||
pos = path.lastIndexOf(" => ");
|
||||
this->downloading.server = path.midRef(pos+4).toString();
|
||||
this->downloading.server = path.mid(pos+4);
|
||||
this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server+ "/port").toInt();
|
||||
path.resize(pos);
|
||||
this->downloading.path = path;
|
||||
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
|
||||
str = "Folder/" + this->downloading.server + ":" + QByteArray::number(this->downloading.port) + "/" + this->downloading.service;
|
||||
if (this->settings.contains(str))
|
||||
{
|
||||
this->downloading.savePath = this->settings.value(str).toString();
|
||||
|
||||
Reference in New Issue
Block a user