add path setting via text box
This commit is contained in:
parent
7f2a730dd5
commit
83ba1bae08
|
@ -20,6 +20,8 @@ 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);
|
||||||
|
@ -30,28 +32,6 @@ 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;
|
||||||
|
@ -77,6 +57,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -94,8 +82,34 @@ bool Project::goUp() {
|
||||||
return m_model->goUp();
|
return m_model->goUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::goPath(std::string path) {
|
bool Project::goPath() {
|
||||||
return m_model->goPath(path);
|
auto newPath = dirName->text().toStdString();
|
||||||
|
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,6 +18,7 @@ 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:
|
||||||
|
@ -26,9 +27,9 @@ public slots:
|
||||||
bool goTop();
|
bool goTop();
|
||||||
bool goUp();
|
bool goUp();
|
||||||
|
|
||||||
bool goPath(std::string path);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
bool goPath();
|
||||||
|
|
||||||
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="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
@ -32,7 +32,8 @@
|
||||||
</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>
|
||||||
|
@ -48,7 +49,8 @@
|
||||||
</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>
|
||||||
|
@ -64,7 +66,8 @@
|
||||||
</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