Permalink
Browse files

Settings complete.

  • Loading branch information...
1 parent 0acb75d commit aff58d64927475d1e67e56c952e337d5b13e190f Gav Wood committed Sep 5, 2012
Showing with 68 additions and 26 deletions.
  1. +9 −0 Paranoia.cpp
  2. +1 −0 Paranoia.h
  3. +24 −7 Settings.cpp
  4. +2 −1 Settings.h
  5. +32 −18 Settings.ui
View
@@ -19,6 +19,15 @@ Paranoia::~Paranoia()
close();
}
+std::map<int, std::string> Paranoia::flags()
+{
+ return {
+ { PARANOIA_MODE_VERIFY, "Verify data integrety in overlap area" },
+ { PARANOIA_MODE_OVERLAP, "Perform overlapped reads" },
+ { PARANOIA_MODE_NEVERSKIP, "Do not skip failed reads (retry)" }
+ };
+}
+
int Paranoia::defaultFlags()
{
return PARANOIA_MODE_FULL ^ PARANOIA_MODE_NEVERSKIP;
View
@@ -24,6 +24,7 @@ class Paranoia
static int defaultFlags();
static std::map<std::string, std::string> devices();
+ static std::map<int, std::string> flags();
private:
cdrom_drive_s* m_cdrom;
View
@@ -1,4 +1,5 @@
#include <QFileDialog>
+#include <QStringList>
#include "Paranoia.h"
#include "RIP.h"
#include "ui_Settings.h"
@@ -15,6 +16,13 @@ Settings::Settings(RIP* _parent):
// populate devices before m_rip is set.
for (auto d: Paranoia::devices())
ui->device->addItem(QString::fromUtf8(d.second.c_str()), QString::fromUtf8(d.first.c_str()));
+ for (auto f: Paranoia::flags())
+ {
+ auto it = new QTreeWidgetItem(ui->paranoia, QStringList(QString::fromUtf8(f.second.c_str())));
+ it->setData(0, Qt::UserRole, f.first);
+ it->setCheckState(0, Qt::Unchecked);
+ }
+
m_rip = _parent;
populate();
@@ -44,10 +52,16 @@ void Settings::on_device_currentIndexChanged(int _i)
m_rip->setDevice(ui->device->itemData(_i).toString());
}
-void Settings::on_paranoia_clicked()
+void Settings::on_paranoia_itemChanged()
{
- if (m_rip){}
- // m_rip->setParanoia(/*compiled flags*/);
+ if (m_rip)
+ {
+ int f = 0;
+ for (int i = 0; i < ui->paranoia->topLevelItemCount(); ++i)
+ if (ui->paranoia->topLevelItem(i)->checkState(0) == Qt::Checked)
+ f |= ui->paranoia->topLevelItem(i)->data(0, Qt::UserRole).toInt();
+ m_rip->setParanoia(f);
+ }
}
void Settings::on_filename_textChanged()
@@ -60,8 +74,11 @@ void Settings::populate()
{
ui->directory->setText(m_rip->directory());
ui->filename->setPlainText(m_rip->filename());
- QString d = m_rip->device();
- int i = ui->device->findData(d);
- ui->device->setCurrentIndex(i);
-// ui->paranoia-> /*set each flag from*/ m_rip->paranoia();
+ ui->device->setCurrentIndex(ui->device->findData(m_rip->device()));
+ int fs = m_rip->paranoia();
+ for (int i = 0; i < ui->paranoia->topLevelItemCount(); ++i)
+ {
+ int f = ui->paranoia->topLevelItem(i)->data(0, Qt::UserRole).toInt();
+ ui->paranoia->topLevelItem(i)->setCheckState(0, (f & fs) ? Qt::Checked : Qt::Unchecked);
+ }
}
View
@@ -7,6 +7,7 @@ class Settings;
}
class RIP;
+class QTreeWidgetItem;
class Settings: public QDialog
{
@@ -21,7 +22,7 @@ public slots:
void on_openDirectory_clicked();
void populate();
void on_device_currentIndexChanged(int _i);
- void on_paranoia_clicked();
+ void on_paranoia_itemChanged();
void on_filename_textChanged();
private:
View
@@ -20,6 +20,37 @@
<string>Input</string>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="1" rowspan="3">
+ <widget class="QTreeWidget" name="paranoia">
+ <property name="indentation">
+ <number>10</number>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>false</bool>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="device"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>&amp;Device</string>
+ </property>
+ <property name="buddy">
+ <cstring>device</cstring>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -30,13 +61,7 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="device"/>
- </item>
- <item row="1" column="1" rowspan="2">
- <widget class="QListWidget" name="paranoia"/>
- </item>
- <item row="2" column="0">
+ <item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -49,16 +74,6 @@
</property>
</spacer>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&amp;Device</string>
- </property>
- <property name="buddy">
- <cstring>device</cstring>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
@@ -141,7 +156,6 @@
</widget>
<tabstops>
<tabstop>device</tabstop>
- <tabstop>paranoia</tabstop>
<tabstop>directory</tabstop>
<tabstop>openDirectory</tabstop>
<tabstop>filename</tabstop>

0 comments on commit aff58d6

Please sign in to comment.