Forgot to add the backup manager in the previous commit...
This commit is contained in:
		
							
								
								
									
										87
									
								
								backupitem.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								backupitem.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,87 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "backupitem.h"
 | 
			
		||||
#include "ui_backupitem.h"
 | 
			
		||||
#include "utils.h"
 | 
			
		||||
 | 
			
		||||
#include <QDesktopServices>
 | 
			
		||||
#include <QUrl>
 | 
			
		||||
 | 
			
		||||
const QString BackupItem::nameTemplate = "<html><head/><body>"
 | 
			
		||||
"<p><span style=\" font-size:12pt; font-weight:600;\">%1</span></p>"
 | 
			
		||||
"<p><span style=\" font-size:10pt;\">%2</span></p>"
 | 
			
		||||
"</body></html>";
 | 
			
		||||
 | 
			
		||||
BackupItem::BackupItem(QWidget *parent) :
 | 
			
		||||
    QWidget(parent),
 | 
			
		||||
    ui(new Ui::BackupItem)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    // connect the buttons
 | 
			
		||||
    connect(ui->openButton, SIGNAL(clicked()), this, SLOT(openDirectory()));
 | 
			
		||||
    connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeEntry()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BackupItem::~BackupItem()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::openDirectory()
 | 
			
		||||
{
 | 
			
		||||
    QDesktopServices::openUrl(QUrl("file:///" + path));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::removeEntry()
 | 
			
		||||
{
 | 
			
		||||
    emit deleteEntry(this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const QPixmap *BackupItem::getIconPixmap()
 | 
			
		||||
{
 | 
			
		||||
    return ui->itemPicture->pixmap();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setDirectory(const QString path)
 | 
			
		||||
{
 | 
			
		||||
    this->path = path;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setItemInfo(const QString name, const QString size)
 | 
			
		||||
{
 | 
			
		||||
    ui->itemName->setText(nameTemplate.arg(name, size));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int BackupItem::getIconWidth()
 | 
			
		||||
{
 | 
			
		||||
    return ui->itemPicture->width();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupItem::setItemIcon(const QString path, int width)
 | 
			
		||||
{
 | 
			
		||||
    ui->itemPicture->setMinimumWidth(width);
 | 
			
		||||
    ui->itemPicture->setPixmap(QPixmap(path));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool BackupItem::lessThan(const BackupItem *s1, const BackupItem *s2)
 | 
			
		||||
{
 | 
			
		||||
    return s1->title.compare(s2->title) < 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										62
									
								
								backupitem.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								backupitem.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef BACKUPITEM_H
 | 
			
		||||
#define BACKUPITEM_H
 | 
			
		||||
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class BackupItem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class BackupItem : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
    
 | 
			
		||||
public:
 | 
			
		||||
    explicit BackupItem(QWidget *parent = 0);
 | 
			
		||||
    ~BackupItem();
 | 
			
		||||
 | 
			
		||||
    void setItemInfo(const QString name, const QString size);
 | 
			
		||||
    void setItemIcon(const QString path, int width = 48);
 | 
			
		||||
    void setDirectory(const QString path);
 | 
			
		||||
    const QPixmap *getIconPixmap();
 | 
			
		||||
    int getIconWidth();
 | 
			
		||||
 | 
			
		||||
    static bool lessThan(const BackupItem *s1, const BackupItem *s2);
 | 
			
		||||
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    int row;
 | 
			
		||||
    QString title;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QString path;
 | 
			
		||||
    Ui::BackupItem *ui;
 | 
			
		||||
    static const QString nameTemplate;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void deleteEntry(BackupItem *entry);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void openDirectory();
 | 
			
		||||
    void removeEntry();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // BACKUPITEM_H
 | 
			
		||||
							
								
								
									
										102
									
								
								backupitem.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								backupitem.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,102 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>BackupItem</class>
 | 
			
		||||
 <widget class="QWidget" name="BackupItem">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>634</width>
 | 
			
		||||
    <height>86</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Form</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="itemPicture">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>48</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="maximumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string/>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="scaledContents">
 | 
			
		||||
        <bool>true</bool>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="alignment">
 | 
			
		||||
        <set>Qt::AlignCenter</set>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="itemName">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p><p><span style=" font-size:10pt;">0.00 GiB</span></p></body></html></string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>40</width>
 | 
			
		||||
         <height>20</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="deleteButton">
 | 
			
		||||
       <property name="sizePolicy">
 | 
			
		||||
        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
 | 
			
		||||
         <horstretch>0</horstretch>
 | 
			
		||||
         <verstretch>0</verstretch>
 | 
			
		||||
        </sizepolicy>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>32</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Delete entry</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QPushButton" name="openButton">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>32</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Open folder</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										195
									
								
								backupmanagerform.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								backupmanagerform.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,195 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "backupmanagerform.h"
 | 
			
		||||
#include "ui_backupmanagerform.h"
 | 
			
		||||
#include "cmaobject.h"
 | 
			
		||||
#include "sforeader.h"
 | 
			
		||||
#include "confirmdialog.h"
 | 
			
		||||
#include "utils.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QDialogButtonBox>
 | 
			
		||||
#include <QDir>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
 | 
			
		||||
BackupManagerForm::BackupManagerForm(QWidget *parent) :
 | 
			
		||||
    QWidget(parent),
 | 
			
		||||
    ui(new Ui::BackupManagerForm)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    setupForm();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BackupManagerForm::~BackupManagerForm()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::setupForm()
 | 
			
		||||
{
 | 
			
		||||
    this->resize(800, 480);
 | 
			
		||||
    connect(ui->backupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadBackupListing(int)));    
 | 
			
		||||
    ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
 | 
			
		||||
    ui->tableWidget->horizontalHeader()->hide();
 | 
			
		||||
    // the the account name when vitamtp returns this value
 | 
			
		||||
    ui->accountBox->addItem(QSettings().value("lastAccountId", tr("Default account")).toString());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::removeEntry(BackupItem *item)
 | 
			
		||||
{
 | 
			
		||||
    ConfirmDialog msgBox;
 | 
			
		||||
 | 
			
		||||
    msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
 | 
			
		||||
    msgBox.setMessagePixmap(*item->getIconPixmap(), item->getIconWidth());
 | 
			
		||||
 | 
			
		||||
    switch(msgBox.exec()) {
 | 
			
		||||
    case QDialogButtonBox::Ok:
 | 
			
		||||
        break;
 | 
			
		||||
    case QDialogButtonBox::Cancel:
 | 
			
		||||
        return;
 | 
			
		||||
    default:
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QMutexLocker locker(&db->mutex);
 | 
			
		||||
 | 
			
		||||
    CMAObject *obj = db->ohfiToObject(item->ohfi);
 | 
			
		||||
    if(obj) {
 | 
			
		||||
        obj->removeReferencedObject();
 | 
			
		||||
        db->remove(obj);
 | 
			
		||||
    }
 | 
			
		||||
    ui->tableWidget->removeRow(item->row);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BackupManagerForm::loadBackupListing(int index)
 | 
			
		||||
{
 | 
			
		||||
    int ohfi;
 | 
			
		||||
    bool sys_dir;
 | 
			
		||||
    int img_width;
 | 
			
		||||
 | 
			
		||||
    ui->tableWidget->clear();
 | 
			
		||||
 | 
			
		||||
    switch(index) {
 | 
			
		||||
    case 0:
 | 
			
		||||
        ohfi = VITA_OHFI_VITAAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 1:
 | 
			
		||||
        ohfi = VITA_OHFI_PSPAPP;
 | 
			
		||||
        img_width = 80;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 2:
 | 
			
		||||
        ohfi = VITA_OHFI_PSMAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 3:
 | 
			
		||||
        ohfi = VITA_OHFI_PSXAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
        break;
 | 
			
		||||
    case 4:
 | 
			
		||||
        ohfi = VITA_OHFI_PSPSAVE;
 | 
			
		||||
        img_width = 80;
 | 
			
		||||
        sys_dir = false;
 | 
			
		||||
        break;
 | 
			
		||||
    case 5:
 | 
			
		||||
        ohfi = VITA_OHFI_BACKUP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = false;
 | 
			
		||||
        break;
 | 
			
		||||
    default:
 | 
			
		||||
        ohfi = VITA_OHFI_VITAAPP;
 | 
			
		||||
        img_width = 48;
 | 
			
		||||
        sys_dir = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    db->mutex.lock();
 | 
			
		||||
 | 
			
		||||
    // get the item list
 | 
			
		||||
    metadata_t *meta;
 | 
			
		||||
    int row_count = db->filterObjects(ohfi, &meta);    
 | 
			
		||||
    ui->tableWidget->setRowCount(row_count);
 | 
			
		||||
 | 
			
		||||
    // adjust the table item width to fill all the widget
 | 
			
		||||
    QHeaderView *vert_header = ui->tableWidget->verticalHeader();
 | 
			
		||||
    QHeaderView *horiz_header = ui->tableWidget->horizontalHeader();
 | 
			
		||||
    horiz_header->setResizeMode(QHeaderView::Stretch);
 | 
			
		||||
 | 
			
		||||
    CMAObject *obj = db->ohfiToObject(ohfi);
 | 
			
		||||
    ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(obj->metadata.size, true)));
 | 
			
		||||
 | 
			
		||||
    QList<BackupItem *> item_list;
 | 
			
		||||
 | 
			
		||||
    while(meta) {
 | 
			
		||||
        QString base_path = obj->path + QDir::separator() + meta->name;
 | 
			
		||||
        QString parent_path = sys_dir ? base_path + QDir::separator() + "sce_sys" : base_path;
 | 
			
		||||
        SfoReader reader;
 | 
			
		||||
        QString game_name;
 | 
			
		||||
 | 
			
		||||
        // retrieve the game name from the SFO
 | 
			
		||||
        if(reader.load(QDir(parent_path).absoluteFilePath(sys_dir ? "param.sfo" : "PARAM.SFO"))) {
 | 
			
		||||
            game_name = QString::fromUtf8(reader.value("TITLE", meta->name));
 | 
			
		||||
        } else {
 | 
			
		||||
            game_name = QString(meta->name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        BackupItem *item = new BackupItem();
 | 
			
		||||
        // save the game title and ohfi for sorting/deleting
 | 
			
		||||
        item->ohfi = meta->ohfi;
 | 
			
		||||
        item->title = game_name;
 | 
			
		||||
 | 
			
		||||
        connect(item, SIGNAL(deleteEntry(BackupItem*)), this, SLOT(removeEntry(BackupItem*)));
 | 
			
		||||
        QString size = readable_size(meta->size);
 | 
			
		||||
 | 
			
		||||
        // check if the game data is present, else is just a LiveArea launcher
 | 
			
		||||
        if(sys_dir && !(QDir(base_path + QDir::separator() + "app").exists() || QDir(base_path + QDir::separator() + "game").exists())) {
 | 
			
		||||
            size.append(tr(" - (Launcher only)"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        item->setItemInfo(game_name, size);
 | 
			
		||||
        item->setItemIcon(QDir(parent_path).absoluteFilePath(sys_dir ? "icon0.png" : "ICON0.PNG"), img_width);
 | 
			
		||||
        item->setDirectory(obj->path + QDir::separator() + meta->name);
 | 
			
		||||
        item->resize(646, 60);
 | 
			
		||||
 | 
			
		||||
        item_list << item;
 | 
			
		||||
        meta = meta->next_metadata;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    qSort(item_list.begin(), item_list.end(), BackupItem::lessThan);
 | 
			
		||||
 | 
			
		||||
    int row;
 | 
			
		||||
    QList<BackupItem *>::iterator it;
 | 
			
		||||
    vert_header->setUpdatesEnabled(false);
 | 
			
		||||
 | 
			
		||||
    // insert the sorted items into the table
 | 
			
		||||
    for(it = item_list.begin(), row = 0; it != item_list.end(); ++it, ++row) {
 | 
			
		||||
        (*it)->row = row;
 | 
			
		||||
        ui->tableWidget->setCellWidget(row, 0, *it);
 | 
			
		||||
        vert_header->resizeSection(row, 60);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    vert_header->setUpdatesEnabled(true);
 | 
			
		||||
    db->mutex.unlock();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										52
									
								
								backupmanagerform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								backupmanagerform.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef BACKUPMANAGERFORM_H
 | 
			
		||||
#define BACKUPMANAGERFORM_H
 | 
			
		||||
 | 
			
		||||
#include "database.h"
 | 
			
		||||
#include "backupitem.h"
 | 
			
		||||
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class BackupManagerForm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class BackupManagerForm : public QWidget
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit BackupManagerForm(QWidget *parent = 0);
 | 
			
		||||
    ~BackupManagerForm();
 | 
			
		||||
 | 
			
		||||
    Database *db;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void setupForm();
 | 
			
		||||
 | 
			
		||||
    Ui::BackupManagerForm *ui;
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
    void loadBackupListing(int index);
 | 
			
		||||
    void removeEntry(BackupItem *item);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // BACKUPMANAGERFORM_H
 | 
			
		||||
							
								
								
									
										109
									
								
								backupmanagerform.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								backupmanagerform.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,109 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>BackupManagerForm</class>
 | 
			
		||||
 <widget class="QWidget" name="BackupManagerForm">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>857</width>
 | 
			
		||||
    <height>478</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Backup Manager</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="1" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout_2">
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QFormLayout" name="formLayout">
 | 
			
		||||
       <item row="0" column="0">
 | 
			
		||||
        <widget class="QLabel" name="label">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Account ID / Username</string>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="0" column="1">
 | 
			
		||||
        <widget class="QComboBox" name="accountBox"/>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <layout class="QFormLayout" name="formLayout_2">
 | 
			
		||||
       <property name="fieldGrowthPolicy">
 | 
			
		||||
        <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <item row="0" column="0">
 | 
			
		||||
        <widget class="QLabel" name="label_2">
 | 
			
		||||
         <property name="text">
 | 
			
		||||
          <string>Backup Type</string>
 | 
			
		||||
         </property>
 | 
			
		||||
         <property name="margin">
 | 
			
		||||
          <number>2</number>
 | 
			
		||||
         </property>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
       <item row="0" column="1">
 | 
			
		||||
        <widget class="QComboBox" name="backupComboBox">
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PS Vita Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSP Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSM Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSOne Games</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PSP Savedatas</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
         <item>
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>Backups</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </item>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
      </layout>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item row="2" column="0">
 | 
			
		||||
    <widget class="QTableWidget" name="tableWidget">
 | 
			
		||||
     <property name="columnCount">
 | 
			
		||||
      <number>1</number>
 | 
			
		||||
     </property>
 | 
			
		||||
     <column/>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item row="3" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="usageLabel">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Backup disk usage</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections/>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										50
									
								
								confirmdialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								confirmdialog.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "confirmdialog.h"
 | 
			
		||||
#include "ui_confirmdialog.h"
 | 
			
		||||
 | 
			
		||||
const QString ConfirmDialog::messageTemplate = "<html><head/><body>"
 | 
			
		||||
"<p><span style=\"font-size:10pt;\">%1</span></p>"
 | 
			
		||||
"<p><span style=\"font-size:12pt; font-weight:600;\">%2</span></p>"
 | 
			
		||||
"</body></html>";
 | 
			
		||||
 | 
			
		||||
ConfirmDialog::ConfirmDialog(QWidget *parent) :
 | 
			
		||||
    QDialog(parent),
 | 
			
		||||
    ui(new Ui::ConfirmDialog)
 | 
			
		||||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    this->layout()->setSizeConstraint(QLayout::SetFixedSize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfirmDialog::setMessageText(const QString message, const QString game_title)
 | 
			
		||||
{
 | 
			
		||||
    ui->confirmText->setText(messageTemplate.arg(message, game_title));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ConfirmDialog::setMessagePixmap(const QPixmap &pixmap, int width)
 | 
			
		||||
{
 | 
			
		||||
    ui->itemPicture->setPixmap(pixmap);
 | 
			
		||||
    ui->itemPicture->setMinimumWidth(width);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ConfirmDialog::~ConfirmDialog()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								confirmdialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								confirmdialog.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  QCMA: Cross-platform content manager assistant for the PS Vita
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (C) 2013  Codestation
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 *  it under the terms of the GNU General Public License as published by
 | 
			
		||||
 *  the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 *  (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 *  This program is distributed in the hope that it will be useful,
 | 
			
		||||
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 *  GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef CONFIRMDIALOG_H
 | 
			
		||||
#define CONFIRMDIALOG_H
 | 
			
		||||
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class ConfirmDialog;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ConfirmDialog : public QDialog
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit ConfirmDialog(QWidget *parent = 0);
 | 
			
		||||
    ~ConfirmDialog();
 | 
			
		||||
 | 
			
		||||
    void setMessageText(const QString message, const QString game_title);
 | 
			
		||||
    void setMessagePixmap(const QPixmap &pixmap, int width);
 | 
			
		||||
 | 
			
		||||
    static const QString messageTemplate;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Ui::ConfirmDialog *ui;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // CONFIRMDIALOG_H
 | 
			
		||||
							
								
								
									
										120
									
								
								confirmdialog.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								confirmdialog.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,120 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>ConfirmDialog</class>
 | 
			
		||||
 <widget class="QDialog" name="ConfirmDialog">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>519</width>
 | 
			
		||||
    <height>106</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Confirmation Message</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="modal">
 | 
			
		||||
   <bool>true</bool>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <item row="0" column="0">
 | 
			
		||||
    <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="itemPicture">
 | 
			
		||||
       <property name="minimumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>48</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="maximumSize">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>0</width>
 | 
			
		||||
         <height>48</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string/>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="scaledContents">
 | 
			
		||||
        <bool>true</bool>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <spacer name="horizontalSpacer">
 | 
			
		||||
       <property name="orientation">
 | 
			
		||||
        <enum>Qt::Horizontal</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeType">
 | 
			
		||||
        <enum>QSizePolicy::Fixed</enum>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="sizeHint" stdset="0">
 | 
			
		||||
        <size>
 | 
			
		||||
         <width>10</width>
 | 
			
		||||
         <height>0</height>
 | 
			
		||||
        </size>
 | 
			
		||||
       </property>
 | 
			
		||||
      </spacer>
 | 
			
		||||
     </item>
 | 
			
		||||
     <item>
 | 
			
		||||
      <widget class="QLabel" name="confirmText">
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string><html><head/><body><p><span style=" font-size:10pt;">Are you sure to delete the backup of the following game?</span></p><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p></body></html>
 | 
			
		||||
</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="margin">
 | 
			
		||||
        <number>0</number>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item row="1" column="0">
 | 
			
		||||
    <widget class="QDialogButtonBox" name="buttonBox">
 | 
			
		||||
     <property name="orientation">
 | 
			
		||||
      <enum>Qt::Horizontal</enum>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="standardButtons">
 | 
			
		||||
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>accepted()</signal>
 | 
			
		||||
   <receiver>ConfirmDialog</receiver>
 | 
			
		||||
   <slot>accept()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>248</x>
 | 
			
		||||
     <y>254</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>157</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>rejected()</signal>
 | 
			
		||||
   <receiver>ConfirmDialog</receiver>
 | 
			
		||||
   <slot>reject()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>316</x>
 | 
			
		||||
     <y>260</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>286</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
 </connections>
 | 
			
		||||
</ui>
 | 
			
		||||
		Reference in New Issue
	
	Block a user