Skip to content

Commit

Permalink
新增文件管理功能(重命名、上传文件、下载文件、删除文件)
Browse files Browse the repository at this point in the history
  • Loading branch information
yz-java committed May 26, 2021
1 parent 33a1e27 commit d5d7467
Show file tree
Hide file tree
Showing 24 changed files with 884 additions and 433 deletions.
16 changes: 13 additions & 3 deletions components/confirmdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
#include <QLineEdit>
#include <QPushButton>

ConfirmDialog::ConfirmDialog(QWidget *parent,QString title):QDialog(parent)
ConfirmDialog::ConfirmDialog(QWidget *parent,QString title):ConfirmDialog(parent,title,"修改","取消")
{

}

ConfirmDialog::ConfirmDialog(QWidget *parent,QString title,QString okButtonName):ConfirmDialog(parent,title,okButtonName,"取消")
{

}

ConfirmDialog::ConfirmDialog(QWidget *parent,QString title,QString okButtonName,QString cancelButtonName):QDialog(parent)
{
if(!title.isEmpty()){
setWindowTitle(title);
Expand All @@ -18,12 +28,12 @@ ConfirmDialog::ConfirmDialog(QWidget *parent,QString title):QDialog(parent)
QLineEdit* inputEdit=new QLineEdit();
rootlayout->addWidget(inputEdit);
QHBoxLayout* hlayout=new QHBoxLayout();
QPushButton* cancelButton=new QPushButton("取消");
QPushButton* cancelButton=new QPushButton(cancelButtonName);
cancelButton->setAutoDefault(false);
connect(cancelButton,&QPushButton::clicked,[=](){
this->close();
});
QPushButton* okButton=new QPushButton("修改");
QPushButton* okButton=new QPushButton(okButtonName);
okButton->setAutoDefault(true);
connect(okButton,&QPushButton::clicked,[=](){
emit successEdit(inputEdit->text());
Expand Down
6 changes: 6 additions & 0 deletions components/confirmdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ class ConfirmDialog:public QDialog
{
Q_OBJECT
public:

ConfirmDialog(QWidget *parent = nullptr,QString title="");

ConfirmDialog(QWidget *parent,QString title,QString okButtonName);

ConfirmDialog(QWidget *parent,QString title,QString okButtonName,QString cancelButtonName);


signals:
void successEdit(QString input);
};
Expand Down
9 changes: 8 additions & 1 deletion connectmanagerui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QMenu>
#include <QHeaderView>
#include "db/connectdao.h"
#include "sftpdialog.h"


ConnectManagerUI::ConnectManagerUI(QWidget *parent) :
Expand Down Expand Up @@ -139,14 +140,20 @@ void ConnectManagerUI::popMenu(const QPoint& p){
menu.addAction(addconnect);
}
QAction* connectWell;

QAction* sftpWell;
if(info.parentId!=0){
connectWell=new QAction("连接",this);//连接
connect(connectWell, &QAction::triggered,[&](){
emit openSSHConnect(info);
});
menu.addAction(connectWell);

sftpWell=new QAction("文件管理",this);
connect(sftpWell, &QAction::triggered,[&](){
SftpDialog* sftpDialog=new SftpDialog(this,&info);
sftpDialog->show();
});
menu.addAction(sftpWell);

}
QAction* editWell=new QAction("编辑",this);
Expand Down
27 changes: 27 additions & 0 deletions fileinfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "fileinfo.h"


FileInfo_S parseBySftpData(QString data){
FileInfo_S info;
QList<QString> array;
for(auto d:data.split(" ")){
if(!d.isEmpty()){
array.append(d);
}
}
info.permission=array[0];
info.fileNum=array[1];
QString type=array[0].at(0);
if(type=="d"){
info.fileType=1;
}else if(type=="-"){
info.fileType=2;
}else if(type=="l"){
info.fileType=3;
}
info.userOrGroup=array[2]+"/"+array[3];
info.fileSize=array[4];
info.fileName=array[8];

return info;
}
30 changes: 30 additions & 0 deletions fileinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef FILEINFO_H
#define FILEINFO_H
#include <QString>
#include <QStringList>
#include <QObjectUserData>

struct FileInfo_S {

QString filePath;

QString fileName;

QString fileSize;
//1=文件夹 2=文件
int fileType;

QString permission;

QString userOrGroup;

QString fileNum;

};
Q_DECLARE_METATYPE(FileInfo_S)

FileInfo_S parseBySftpData(QString data);



#endif // FILEINFO_H
Binary file added filemanager-gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icon.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<file>icons/welcome.png</file>
<file>icons/cancel.png</file>
<file>icons/refresh.png</file>
<file>icons/file.png</file>
</qresource>
</RCC>
Binary file added icons/file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion ishell.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui websockets webchannel webenginewidgets sql
QT += core concurrent gui websockets webchannel webenginewidgets sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

Expand All @@ -17,9 +17,12 @@ SOURCES += \
console.cpp \
db/connectdao.cpp \
db/dbutil.cpp \
fileinfo.cpp \
main.cpp \
mainwindow.cpp \
mylabel.cpp \
sftpclient.cpp \
sftpdialog.cpp \
sshclient.cpp \
webconsole.cpp \
websocketserver.cpp \
Expand All @@ -34,8 +37,11 @@ HEADERS += \
console.h \
db/connectdao.h \
db/dbutil.h \
fileinfo.h \
mainwindow.h \
mylabel.h \
sftpclient.h \
sftpdialog.h \
sshclient.h \
webconsole.h \
websocketserver.h \
Expand All @@ -46,6 +52,7 @@ FORMS += \
connectmanagerui.ui \
console.ui \
mainwindow.ui \
sftpdialog.ui \
webconsole.ui \
welcome.ui

Expand Down
Loading

0 comments on commit d5d7467

Please sign in to comment.