now double-clickable
This commit is contained in:
parent
6b8a509f96
commit
eab16d6ea2
|
@ -4,7 +4,9 @@
|
|||
#include "statusbarwidget.h"
|
||||
#include "verticalpreviewwidget.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QFileSystemModel>
|
||||
#include <QUrl>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
@ -39,9 +41,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->stackedWidget->setCurrentIndex(mode);
|
||||
});
|
||||
|
||||
connect(ui->listView, &QAbstractItemView::doubleClicked, this, &MainWindow::viewGotoModelIndex);
|
||||
connect(ui->treeTable, &QAbstractItemView::doubleClicked, this, &MainWindow::viewGotoModelIndex);
|
||||
connect(ui->listView, &QAbstractItemView::doubleClicked, this, &MainWindow::gotoModelIndexOrOpenFile);
|
||||
connect(ui->treeTable, &QAbstractItemView::doubleClicked, this, &MainWindow::gotoModelIndexOrOpenFile);
|
||||
connect(ui->columnView, &QAbstractItemView::clicked, this, &MainWindow::viewGotoModelIndex);
|
||||
connect(ui->columnView, &QAbstractItemView::doubleClicked, this, &MainWindow::gotoModelIndexOrOpenFile);
|
||||
connect(ui->columnView, &QColumnView::updatePreviewWidget, m_previewWidget, &VerticalPreviewWidget::updatePreviewContent);
|
||||
}
|
||||
|
||||
|
@ -63,6 +66,32 @@ void MainWindow::viewGotoModelIndex(const QModelIndex &index)
|
|||
// if (columnClicked->selectionModel()->isSelected(index))
|
||||
// flags |= QItemSelectionModel::Select;
|
||||
ui->columnView->selectionModel()->setCurrentIndex(index, flags);
|
||||
|
||||
ui->addressEdit->setText(m_fsmodel->filePath(index));
|
||||
}
|
||||
|
||||
void MainWindow::gotoModelIndexOrOpenFile(const QModelIndex &index)
|
||||
{
|
||||
if (!m_fsmodel->isDir(index)) {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_fsmodel->filePath(index)));
|
||||
} else {
|
||||
viewGotoModelIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::gotoUrl(const QString &path)
|
||||
{
|
||||
if (!QFileInfo::exists(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QModelIndex &idx = m_fsmodel->index(path);
|
||||
if (idx.isValid()) {
|
||||
viewGotoModelIndex(idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::on_treeView_clicked(const QModelIndex &index)
|
||||
|
@ -84,3 +113,8 @@ void MainWindow::on_cdUpButton_clicked()
|
|||
|
||||
viewGotoModelIndex(idx.parent());
|
||||
}
|
||||
|
||||
void MainWindow::on_addressEdit_returnPressed()
|
||||
{
|
||||
gotoUrl(ui->addressEdit->text());
|
||||
}
|
||||
|
|
|
@ -18,12 +18,16 @@ public:
|
|||
~MainWindow();
|
||||
|
||||
void viewGotoModelIndex(const QModelIndex &index);
|
||||
void gotoModelIndexOrOpenFile(const QModelIndex &index);
|
||||
bool gotoUrl(const QString & path);
|
||||
|
||||
private slots:
|
||||
void on_treeView_clicked(const QModelIndex &index);
|
||||
|
||||
void on_cdUpButton_clicked();
|
||||
|
||||
void on_addressEdit_returnPressed();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="addressEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -145,7 +148,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1153</width>
|
||||
<height>25</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
|
@ -2,6 +2,7 @@ QT += core gui
|
|||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = pfile
|
||||
CONFIG += c++11
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
#include <QDebug>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
VerticalPreviewWidget::VerticalPreviewWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -29,9 +30,15 @@ void VerticalPreviewWidget::updatePreviewContent(const QModelIndex &index)
|
|||
ui->filenameLabel->setText(m_fsmodel->fileName(index));
|
||||
|
||||
const QFileInfo & info = m_fsmodel->fileInfo(index);
|
||||
static QMimeDatabase mimetypeDatabase;
|
||||
QMimeType mimeType = mimetypeDatabase.mimeTypeForFile(info);
|
||||
QString mimeTypeDisplayName = mimeType.comment();
|
||||
|
||||
ui->createdAtLabel->setText(info.birthTime().toString());
|
||||
ui->lastUpdateLabel->setText(info.lastModified().toString());
|
||||
ui->typeAndSizeLabel->setText(QString("%1 - %2").arg(mimeTypeDisplayName, this->locale().formattedDataSize(info.size())));
|
||||
|
||||
ui->createdAtLabel->setText(info.birthTime().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
||||
ui->lastUpdateLabel->setText(info.lastModified().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
||||
ui->lastAccessLabel->setText(info.lastRead().toString(tr("yyyy/MM/dd hh:mm:ss", "Qt string format")));
|
||||
|
||||
// ui->formLayout->addRow("Created at:", new QLabel(info.birthTime().toString()));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="typeAndSizeLabel">
|
||||
<property name="text">
|
||||
<string>Placeholder</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
|
@ -38,6 +51,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
|
@ -52,12 +72,8 @@
|
|||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lastUpdateLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -68,6 +84,33 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lastUpdateLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Last access:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lastAccessLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user