命名规范
This commit is contained in:
@@ -26,9 +26,9 @@
|
||||
|
||||
|
||||
|
||||
// class CustomStyle : public QProxyStyle {
|
||||
// class Custom_Style : public QProxyStyle {
|
||||
// public:
|
||||
// explicit CustomStyle(QStyle *baseStyle = nullptr) : QProxyStyle(baseStyle) {}
|
||||
// explicit Custom_Style(QStyle *baseStyle = nullptr) : QProxyStyle(baseStyle) {}
|
||||
//
|
||||
// void drawPrimitive(QStyle::PrimitiveElement element,
|
||||
// const QStyleOption *option,
|
||||
@@ -66,25 +66,25 @@
|
||||
//
|
||||
|
||||
|
||||
class CustomFileDelegate;
|
||||
class FileExplorer : public QWidget {
|
||||
class Custom_File_Delegate;
|
||||
class file_explorer : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QTreeView *treeView;
|
||||
QTreeView *tree_view;
|
||||
QFileSystemModel *model;
|
||||
QVBoxLayout *layout;
|
||||
QLineEdit* showRootDir;
|
||||
QLineEdit* show_root_dir;
|
||||
QFileInfo focus;
|
||||
QLabel *showFocusFile;
|
||||
QPushButton *confirmButton, *cancelButton;
|
||||
int height = 60;
|
||||
CustomFileDelegate *it;
|
||||
void showCenter() {
|
||||
Custom_File_Delegate *it;
|
||||
void show_center() {
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
QRect screenRect = screen->availableGeometry();
|
||||
QRect windowRect = frameGeometry();
|
||||
int x = (screenRect.width() - windowRect.width()) / 2;
|
||||
int y = (screenRect.height() - windowRect.height()) / 2;
|
||||
QRect screen_rect = screen->availableGeometry();
|
||||
QRect window_rect = frameGeometry();
|
||||
int x = (screen_rect.width() - window_rect.width()) / 2;
|
||||
int y = (screen_rect.height() - window_rect.height()) / 2;
|
||||
move(x, y);
|
||||
show();
|
||||
}
|
||||
@@ -98,35 +98,35 @@ protected:
|
||||
painter.end();
|
||||
}
|
||||
public:
|
||||
void changeRoot(QString dir_path) {
|
||||
void change_root(QString dir_path) {
|
||||
dir_path.replace("\\", "/");
|
||||
QFileInfo fileInfo(dir_path); // 用 QFileInfo 检测路径
|
||||
if (fileInfo.isDir()) {
|
||||
QFileInfo file_info(dir_path); // 用 QFileInfo 检测路径
|
||||
if (file_info.isDir()) {
|
||||
//qDebug() << "dir " << dir_path;
|
||||
} else if (fileInfo.isFile()) {
|
||||
} else if (file_info.isFile()) {
|
||||
//qDebug() << "file " << dir_path;
|
||||
focus = fileInfo;
|
||||
focus = file_info;
|
||||
showFocusFile->setText(focus.absolutePath());
|
||||
dir_path = fileInfo.dir().absolutePath();
|
||||
dir_path = file_info.dir().absolutePath();
|
||||
} else {
|
||||
//qDebug() << "error " << dir_path;
|
||||
showRootDir->setText(model->rootPath());
|
||||
show_root_dir->setText(model->rootPath());
|
||||
return;
|
||||
}
|
||||
if (!dir_path.endsWith("/")) {
|
||||
dir_path.append("/");
|
||||
}
|
||||
showRootDir->setText(dir_path);
|
||||
show_root_dir->setText(dir_path);
|
||||
model->setRootPath(dir_path);
|
||||
treeView->setRootIndex(model->index(dir_path));
|
||||
tree_view->setRootIndex(model->index(dir_path));
|
||||
|
||||
model->setHeaderData(0,Qt::Horizontal,"文件名称");
|
||||
model->setHeaderData(1,Qt::Horizontal,"文件大小");
|
||||
|
||||
treeView->setColumnWidth(0, 500);
|
||||
tree_view->setColumnWidth(0, 500);
|
||||
}
|
||||
|
||||
FileExplorer();
|
||||
file_explorer();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user