Skip to content

Commit

Permalink
Adapt to orient v0.4 API
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxsucks committed Jan 27, 2023
1 parent b15f63b commit ef599e5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 127 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else(NOT SEEV_SYSTEM_ORIENT)
find_package(orie REQUIRED)
endif(NOT SEEV_SYSTEM_ORIENT)

project(seev VERSION 0.3.1)
project(seev VERSION 0.4.0)
set(seev_src
main.cc
widgets/homepagewidget.cpp widgets/homepagewidget.hpp widgets/homepagewidget.ui
Expand Down
9 changes: 6 additions & 3 deletions widgets/homepagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ HomePageWidget::HomePageWidget(Previewer *previewer, QWidget *parent)

// Always launch with default seev configuration path
setSeevConfPath(seevDefaultConfPath);
m_orieApp.read_db()
m_orieApp
.add_start_path(orie::str_t())
.start_auto_update(std::chrono::seconds(ui->updIntSpin->value()), false);
}

void HomePageWidget::fromJsonObj(const QJsonObject& obj) {
QString orieConfPath = obj["orieConfPath"].toString(orieDefaultConfPath);
// Write default configuration if the specified orie conf file does not exist
if (!m_orieApp.read_conf(orieConfPath.toStdString())) {
try {
m_orieApp.read_conf(orieConfPath.toStdString());
} catch (std::runtime_error& e) {
qDebug() << orieConfPath << " " << e.what();
qDebug() << tr("Initializing default configuation.");
m_orieApp = orie::app::os_default(m_pool);
// TODO: Auto update stops here!
m_orieApp.write_conf(orieConfPath.toStdString());
}

Expand Down
58 changes: 26 additions & 32 deletions widgets/orieconfwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,35 @@ void OrieConfWidget::writeConfFile() const {
static orie::fifo_thpool dummy_pool(0);
orie::app writer(dummy_pool);

for (int i = 0; i < ui->ssdRootPathLst->count(); ++i)
writer.add_root_path(ui->ssdRootPathLst->item(i)->text().toStdString(), true);
for (int i = 0; i < ui->hddRootPathLst->count(); ++i)
writer.add_root_path(ui->hddRootPathLst->item(i)->text().toStdString(), false);
for (int i = 0; i < ui->prunedPathLst->count(); ++i)
writer.add_ignored_path(ui->prunedPathLst->item(i)->text().toStdString());
writer.set_db_path(ui->dbPathEdit->text().toStdString())
.write_conf(m_confPath.toStdString());
// Hard-code indexing from root
try {
writer.set_db_path(ui->dbPathEdit->text().toStdString().c_str())
.set_root_path(orie::str_t(1, orie::separator));
for (int i = 0; i < ui->prunedPathLst->count(); ++i)
writer.add_ignored_path(ui->prunedPathLst->item(i)->text().toStdString());
writer.write_conf(m_confPath.toStdString());
} catch (std::runtime_error&) {
QMessageBox::warning(nullptr, tr("Bad database file"),
tr("No read permission to selected database file."));
}
}

void OrieConfWidget::readConfFile(const QString& path) {
static orie::fifo_thpool dummy_pool(0);
orie::app reader(dummy_pool);

reader.read_conf(path.toStdString());
ui->dbPathEdit->setText(QString::fromStdString(reader.db_path()));
for (const auto& [pathStr, isConcur] : reader.root_paths()) {
isConcur ? ui->ssdRootPathLst->addItem(QString::fromStdString(pathStr))
: ui->hddRootPathLst->addItem(QString::fromStdString(pathStr));
try {
reader.read_conf(path.toStdString());
} catch(const std::runtime_error& e) {
qDebug() << path << " " << e.what();
qDebug() << tr("Using an empty one in config GUI.");
return;
}
for (const auto& pathStr : reader.ignored_paths())

ui->dbPathEdit->setText(QString::fromStdString(reader.db_path()));
for (const orie::str_t& slowPathStr : reader.slow_paths())
ui->slowPathLst->addItem(QString::fromStdString(slowPathStr));
for (const orie::str_t& pathStr : reader.ignored_paths())
ui->prunedPathLst->addItem(QString::fromStdString(pathStr));
}

Expand All @@ -79,26 +87,12 @@ OrieConfWidget::OrieConfWidget(const QString &orieConfPath, QWidget *parent)
ui->setupUi(this);
readConfFile(orieConfPath);

// Two "Move To" buttons
connect(ui->moveToHddBut, &QPushButton::clicked, this, [this] () {
ui->hddRootPathLst->addItem(
ui->ssdRootPathLst->takeItem(ui->ssdRootPathLst->currentRow())
); });
connect(ui->moveToSsdBut, &QPushButton::clicked, this, [this] () {
ui->ssdRootPathLst->addItem(
ui->hddRootPathLst->takeItem(ui->hddRootPathLst->currentRow())
); });

connect(ui->hddRootAddBut, &QPushButton::clicked,
std::bind(__selAndAddPath, ui->hddRootPathLst));
connect(ui->ssdRootAddBut, &QPushButton::clicked,
std::bind(__selAndAddPath, ui->ssdRootPathLst));
connect(ui->addSlowBut, &QPushButton::clicked,
std::bind(__selAndAddPath, ui->slowPathLst));
connect(ui->addPrunedBut, &QPushButton::clicked,
std::bind(__selAndAddPath, ui->prunedPathLst));
connect(ui->hddRootEraseBut, &QPushButton::clicked,
std::bind(__delCurPath, ui->hddRootPathLst));
connect(ui->ssdRootEraseBut, &QPushButton::clicked,
std::bind(__delCurPath, ui->ssdRootPathLst));
connect(ui->eraseSlowBut, &QPushButton::clicked,
std::bind(__delCurPath, ui->slowPathLst));
connect(ui->erasePrunedBut, &QPushButton::clicked,
std::bind(__delCurPath, ui->prunedPathLst));
connect(ui->buttonBox, &QDialogButtonBox::accepted,
Expand Down
128 changes: 37 additions & 91 deletions widgets/orieconfwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,35 @@
<ui version="4.0">
<class>seev::OrieConfWidget</class>
<widget class="QWidget" name="seev::OrieConfWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>720</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuring `orient`</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QPushButton" name="ssdRootAddBut">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<widget class="QListWidget" name="hddRootPathLst"/>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="browseDbPath">
<property name="toolTip">
<string>Default one generally works.</string>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="13" column="1">
<item row="9" column="1">
<widget class="QPushButton" name="erasePrunedBut">
<property name="text">
<string>Erase</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<widget class="QListWidget" name="ssdRootPathLst"/>
<item row="7" column="0" colspan="4">
<widget class="QListWidget" name="prunedPathLst"/>
</item>
<item row="9" column="2" colspan="2">
<widget class="QPushButton" name="moveToSsdBut">
<item row="5" column="1">
<widget class="QPushButton" name="eraseSlowBut">
<property name="text">
<string>Move up, it is on SSD</string>
<string>Erase</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="hddRootEraseBut">
<property name="text">
<string>Erase</string>
<item row="10" column="0" colspan="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QLabel" name="z_1">
<property name="toolTip">
<string>Default one generally works.</string>
Expand All @@ -71,89 +43,63 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="z_0">
<property name="text">
<string>SSD Root Paths</string>
</property>
<property name="buddy">
<cstring>ssdRootPathLst</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="ssdRootEraseBut">
<property name="text">
<string>Erase</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="z_2">
<property name="text">
<string>HDD Root Paths</string>
</property>
<property name="buddy">
<cstring>hddRootPathLst</cstring>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="hddRootAddBut">
<widget class="QPushButton" name="addPrunedBut">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QPushButton" name="addPrunedBut">
<item row="0" column="3">
<widget class="QPushButton" name="browseDbPath">
<property name="toolTip">
<string>Default one generally works.</string>
</property>
<property name="text">
<string>Add</string>
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="z_4">
<item row="5" column="0">
<widget class="QPushButton" name="addSlowBut">
<property name="text">
<string>Please make sure the HDD root paths are actually mounted on HDD disks, and so for SSD Root Paths. Mismatches may cause severe performance drops. If unsure, place all root paths on SSD.
Root and ignored paths CAN overlap.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="dbPathEdit">
<property name="toolTip">
<string>Default one generally works.</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="4">
<widget class="QListWidget" name="prunedPathLst"/>
<item row="4" column="0" colspan="4">
<widget class="QListWidget" name="slowPathLst"/>
</item>
<item row="10" column="0">
<item row="6" column="0" colspan="4">
<widget class="QLabel" name="z_3">
<property name="text">
<string>Ignored Paths</string>
<string>Ignored Paths (Large, temporary or seldom used directories)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>prunedPathLst</cstring>
</property>
</widget>
</item>
<item row="6" column="2" colspan="2">
<widget class="QPushButton" name="moveToHddBut">
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="z_2">
<property name="text">
<string>Move down, it is on HDD</string>
<string>Slow Paths (Mount points of Spinning Disks (HDDs))</string>
</property>
</widget>
</item>
<item row="14" column="0" colspan="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>slowPathLst</cstring>
</property>
</widget>
</item>
Expand Down

0 comments on commit ef599e5

Please sign in to comment.