Compare commits
No commits in common. "8975d156831900dc121e9997aaa3f8401698281b" and "7f2a730dd58d6addfc9a46aedf50071e4517dc7c" have entirely different histories.
8975d15683
...
7f2a730dd5
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLocale>
|
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -24,9 +23,6 @@
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
||||||
using LitInt = unsigned long long int;
|
|
||||||
using LitFlt = long double;
|
|
||||||
|
|
||||||
inline constexpr std::nullopt_t None{std::nullopt};
|
inline constexpr std::nullopt_t None{std::nullopt};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -76,39 +72,6 @@ struct IMemoryStream : public virtual MemoryStreamBuf, public std::istream {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define siPrefixDivT(T, name, value) \
|
|
||||||
constexpr T operator "" name(T n) {return n / T(value);}
|
|
||||||
|
|
||||||
#define siPrefixMulT(T, name, value) \
|
|
||||||
constexpr T operator "" name(T n) {return n * T(value);}
|
|
||||||
|
|
||||||
#define siPrefixDiv(name, value) \
|
|
||||||
siPrefixDivT(LitInt, name, value) \
|
|
||||||
siPrefixDivT(LitFlt, name, value)
|
|
||||||
|
|
||||||
#define siPrefixMul(name, value) \
|
|
||||||
siPrefixMulT(LitInt, name, value) \
|
|
||||||
siPrefixMulT(LitFlt, name, value)
|
|
||||||
|
|
||||||
#define siPrefixDivMul(divName, mulName, value) \
|
|
||||||
siPrefixDiv(divName, value) \
|
|
||||||
siPrefixMul(mulName, value)
|
|
||||||
|
|
||||||
siPrefixDivMul(_d, _da, 10)
|
|
||||||
siPrefixDivMul(_c, _h, 100)
|
|
||||||
siPrefixDivMul(_m, _k, 1'000)
|
|
||||||
siPrefixDivMul(_mc, _M, 1'000'000)
|
|
||||||
siPrefixDivMul(_n, _G, 1'000'000'000)
|
|
||||||
siPrefixDivMul(_p, _T, 1'000'000'000'000)
|
|
||||||
siPrefixDivMul(_f, _P, 1'000'000'000'000'000)
|
|
||||||
siPrefixDivMul(_a, _E, 1'000'000'000'000'000'000)
|
|
||||||
siPrefixMul(_Ki, 1'024)
|
|
||||||
siPrefixMul(_Mi, 1'048'576)
|
|
||||||
siPrefixMul(_Gi, 1'073'741'824)
|
|
||||||
siPrefixMul(_Ti, 1'099'511'627'776)
|
|
||||||
siPrefixMul(_Pi, 1'125'899'906'842'624)
|
|
||||||
siPrefixMul(_Ei, 1'152'921'504'606'846'976)
|
|
||||||
|
|
||||||
static inline QString trMain(char const *sourceText,
|
static inline QString trMain(char const *sourceText,
|
||||||
char const *disambiguation = nullptr,
|
char const *disambiguation = nullptr,
|
||||||
int n = -1) {
|
int n = -1) {
|
||||||
|
@ -173,10 +136,6 @@ static inline T orThrow(Option<T> opt, Error err) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QString toBinSize(qint64 bytes) {
|
|
||||||
return QLocale().formattedDataSize(bytes, 2, QLocale::DataSizeSIFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline QDebug operator<<(QDebug debug, std::string const &t) {
|
static inline QDebug operator<<(QDebug debug, std::string const &t) {
|
||||||
debug << QString::fromStdString(t);
|
debug << QString::fromStdString(t);
|
||||||
return debug;
|
return debug;
|
||||||
|
|
|
@ -195,7 +195,7 @@ namespace Arc {
|
||||||
switch(col) {
|
switch(col) {
|
||||||
case Column::Size:
|
case Column::Size:
|
||||||
if(auto file = node->getFile()) {
|
if(auto file = node->getFile()) {
|
||||||
return QVariant{toBinSize(file->size())};
|
return QVariant{QString::number(file->size())};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Column::Type:
|
case Column::Type:
|
||||||
|
|
|
@ -20,8 +20,6 @@ Project::Project(std::istream &st, QErrorMessage *errors, QWidget *parent) :
|
||||||
this, &Project::dirChanged);
|
this, &Project::dirChanged);
|
||||||
connect(tableView, &QAbstractItemView::doubleClicked,
|
connect(tableView, &QAbstractItemView::doubleClicked,
|
||||||
m_model, &Arc::Model::setDirToIndex);
|
m_model, &Arc::Model::setDirToIndex);
|
||||||
connect(dirName, &QLineEdit::returnPressed,
|
|
||||||
this, &Project::goPath);
|
|
||||||
|
|
||||||
dirName->setValidator(m_arc->validator);
|
dirName->setValidator(m_arc->validator);
|
||||||
m_sorter->setSourceModel(m_model);
|
m_sorter->setSourceModel(m_model);
|
||||||
|
@ -32,6 +30,28 @@ Project::Project(std::istream &st, QErrorMessage *errors, QWidget *parent) :
|
||||||
Project::~Project() {
|
Project::~Project() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Project::dirChanged(Arc::Dir *from, Arc::Dir *to) {
|
||||||
|
if(!m_seekingDir) {
|
||||||
|
if(std::ptrdiff_t(m_histPos) < std::ptrdiff_t(m_hist.size()) - 1) {
|
||||||
|
auto beg = m_hist.begin();
|
||||||
|
std::advance(beg, m_histPos + 1);
|
||||||
|
m_hist.erase(beg, m_hist.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hist.push_back(to->getPath());
|
||||||
|
m_histPos = m_hist.size() - 1;
|
||||||
|
} else {
|
||||||
|
m_seekingDir = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tableView->sortByColumn(int(Arc::Column::Type), Qt::AscendingOrder);
|
||||||
|
tableView->resizeColumnsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::seekTop() {
|
||||||
|
m_model->setDir(&m_arc->root);
|
||||||
|
}
|
||||||
|
|
||||||
bool Project::seekHistory(std::ptrdiff_t newPos) {
|
bool Project::seekHistory(std::ptrdiff_t newPos) {
|
||||||
if(newPos < 0 || newPos >= m_hist.size()) {
|
if(newPos < 0 || newPos >= m_hist.size()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -57,14 +77,6 @@ bool Project::seekHistory(std::ptrdiff_t newPos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::seekPath(std::string path) {
|
|
||||||
return m_model->goPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::seekTop() {
|
|
||||||
m_model->setDir(&m_arc->root);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Project::goBack() {
|
bool Project::goBack() {
|
||||||
return seekHistory(std::ptrdiff_t(m_histPos) - 1);
|
return seekHistory(std::ptrdiff_t(m_histPos) - 1);
|
||||||
}
|
}
|
||||||
|
@ -82,34 +94,8 @@ bool Project::goUp() {
|
||||||
return m_model->goUp();
|
return m_model->goUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::goPath() {
|
bool Project::goPath(std::string path) {
|
||||||
auto newPath = dirName->text().toStdString();
|
return m_model->goPath(path);
|
||||||
if(!m_model->goPath(newPath)) {
|
|
||||||
m_errors->showMessage(tr("could not find directory") +
|
|
||||||
QString::fromStdString(" '"s + newPath + "'"));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::dirChanged(Arc::Dir *from, Arc::Dir *to) {
|
|
||||||
if(!m_seekingDir) {
|
|
||||||
if(std::ptrdiff_t(m_histPos) < std::ptrdiff_t(m_hist.size()) - 1) {
|
|
||||||
auto beg = m_hist.begin();
|
|
||||||
std::advance(beg, m_histPos + 1);
|
|
||||||
m_hist.erase(beg, m_hist.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hist.push_back(to->getPath());
|
|
||||||
m_histPos = m_hist.size() - 1;
|
|
||||||
} else {
|
|
||||||
m_seekingDir = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dirName->setText(QString::fromStdString(to->getPath()));
|
|
||||||
tableView->sortByColumn(int(Arc::Column::Type), Qt::AscendingOrder);
|
|
||||||
tableView->resizeColumnsToContents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -18,7 +18,6 @@ public:
|
||||||
virtual ~Project();
|
virtual ~Project();
|
||||||
|
|
||||||
bool seekHistory(std::ptrdiff_t newPos);
|
bool seekHistory(std::ptrdiff_t newPos);
|
||||||
bool seekPath(std::string path);
|
|
||||||
void seekTop();
|
void seekTop();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -27,9 +26,9 @@ public slots:
|
||||||
bool goTop();
|
bool goTop();
|
||||||
bool goUp();
|
bool goUp();
|
||||||
|
|
||||||
private slots:
|
bool goPath(std::string path);
|
||||||
bool goPath();
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
void dirChanged(Arc::Dir *from, Arc::Dir *to);
|
void dirChanged(Arc::Dir *from, Arc::Dir *to);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
@ -32,8 +32,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-previous">
|
<iconset theme="go-previous"/>
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -49,8 +48,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-next">
|
<iconset theme="go-next"/>
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -66,8 +64,7 @@
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-up">
|
<iconset theme="go-up"/>
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user