Forgot to add untracked files.

This commit is contained in:
eelke 2017-03-05 21:25:37 +01:00
parent 73528ca965
commit a2f39692a2
5 changed files with 181 additions and 0 deletions

100
core/BackupFormatModel.cpp Normal file
View file

@ -0,0 +1,100 @@
#include "BackupFormatModel.h"
#include <vector>
namespace {
class BackupFormatItem {
public:
const QString shortFlag;
const QString longFlag;
const QString description;
BackupFormatItem(QString s, QString l, QString d)
: shortFlag(std::move(s))
, longFlag(std::move(l))
, description(std::move(d))
{}
};
using t_BackupFormatItemVector = std::vector<BackupFormatItem>;
t_BackupFormatItemVector g_BackupFormats = {
BackupFormatItem{ "p", "plain", "Output a plaintext SQL script, restore with psql" },
BackupFormatItem{ "c", "custom", "Postgresql's own format most flexible and compressed, restore with pg_restore" },
BackupFormatItem{ "d", "directory", "Generates a directory with a file for each table or blob" },
BackupFormatItem{ "t", "tar", "Similar to directory if untarred it results in a valid directory backup" }
};
} // end of unnamed namespace
BackupFormatModel::BackupFormatModel(QObject *parent)
: QAbstractListModel(parent)
{
}
//QVariant BackupFormatModel::headerData(int section, Qt::Orientation orientation, int role) const
//{
// QVariant result;
// if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
// switch (section) {
// case Column::Short:
// result = tr("Short");
// break;
// case Column::Long:
// result = tr("Long");
// break;
// case Column::Description:
// result = tr("Description");
// break;
// }
// }
// return result;
//}
int BackupFormatModel::rowCount(const QModelIndex &parent) const
{
int size = g_BackupFormats.size();
return size;
}
int BackupFormatModel::columnCount(const QModelIndex &parent) const
{
return 3;
}
QVariant BackupFormatModel::data(const QModelIndex &index, int role) const
{
QVariant result;
if (index.isValid()) {
const int row = index.row();
const int col = index.column();
if (role == Qt::DisplayRole) {
const auto &item = g_BackupFormats.at(row);
switch (col) {
case Column::Short:
result = item.shortFlag;
break;
case Column::Long:
result = item.longFlag;
break;
case Column::Description:
result = item.description;
break;
}
}
else if (role == Qt::ToolTipRole) {
const auto &item = g_BackupFormats.at(row);
result = item.description;
}
}
return result;
}

26
core/BackupFormatModel.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef BACKUPFORMATMODEL_H
#define BACKUPFORMATMODEL_H
#include <QAbstractListModel>
class BackupFormatModel : public QAbstractListModel
{
Q_OBJECT
public:
enum class Column { Short=1, Long=0, Description=2 };
explicit BackupFormatModel(QObject *parent);
// Header:
// QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
};
#endif // BACKUPFORMATMODEL_H

View file

@ -0,0 +1,14 @@
#include "ProcessStdioWidget.h"
#include "ui_ProcessStdioWidget.h"
ProcessStdioWidget::ProcessStdioWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ProcessStdioWidget)
{
ui->setupUi(this);
}
ProcessStdioWidget::~ProcessStdioWidget()
{
delete ui;
}

22
src/ProcessStdioWidget.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef PROCESSSTDIOWIDGET_H
#define PROCESSSTDIOWIDGET_H
#include <QWidget>
namespace Ui {
class ProcessStdioWidget;
}
class ProcessStdioWidget : public QWidget
{
Q_OBJECT
public:
explicit ProcessStdioWidget(QWidget *parent = 0);
~ProcessStdioWidget();
private:
Ui::ProcessStdioWidget *ui;
};
#endif // PROCESSSTDIOWIDGET_H

19
src/ProcessStdioWidget.ui Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProcessStdioWidget</class>
<widget class="QWidget" name="ProcessStdioWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>