Implemented progress model.
This commit is contained in:
parent
7a79c476a3
commit
2114a3dbf0
@ -350,6 +350,10 @@
|
||||
RelativePath=".\src\Model_MetaInfo.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_Progress.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_Settings.cpp"
|
||||
>
|
||||
@ -706,6 +710,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_Progress.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model_Settings.h"
|
||||
>
|
||||
|
@ -22,11 +22,13 @@
|
||||
<file>icons/compress.png</file>
|
||||
<file>icons/computer.png</file>
|
||||
<file>icons/controller.png</file>
|
||||
<file>icons/control_pause_blue.png</file>
|
||||
<file>icons/cross.png</file>
|
||||
<file>icons/date.png</file>
|
||||
<file>icons/delete.png</file>
|
||||
<file>icons/door_out.png</file>
|
||||
<file>icons/drive_cd.png</file>
|
||||
<file>icons/exclamation.png</file>
|
||||
<file>icons/feed.png</file>
|
||||
<file>icons/folder_add.png</file>
|
||||
<file>icons/folder_go.png</file>
|
||||
@ -40,6 +42,7 @@
|
||||
<file>icons/page_white_add.png</file>
|
||||
<file>icons/page_white_cd.png</file>
|
||||
<file>icons/play.png</file>
|
||||
<file>icons/resultset_next.png</file>
|
||||
<file>icons/script_edit.png</file>
|
||||
<file>icons/sound.png</file>
|
||||
<file>icons/star.png</file>
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 33
|
||||
#define VER_LAMEXP_BUILD 34
|
||||
#define VER_LAMEXP_SUFFIX TechPreview
|
||||
|
||||
/*
|
||||
|
142
src/Model_Progress.cpp
Normal file
142
src/Model_Progress.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Model_Progress.h"
|
||||
|
||||
ProgressModel::ProgressModel(void) :
|
||||
m_iconRunning(":/icons/resultset_next.png"),
|
||||
m_iconPaused(":/icons/control_pause_blue.png"),
|
||||
m_iconComplete(":/icons/accept.png"),
|
||||
m_iconFailed(":/icons/exclamation.png")
|
||||
{
|
||||
}
|
||||
|
||||
ProgressModel::~ProgressModel(void)
|
||||
{
|
||||
}
|
||||
|
||||
int ProgressModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int ProgressModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return m_jobList.count();
|
||||
}
|
||||
|
||||
QVariant ProgressModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(index.row() >= 0 && index.row() < m_jobList.count())
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case 0:
|
||||
return m_jobName.value(m_jobList.at(index.row()));
|
||||
break;
|
||||
case 1:
|
||||
return m_jobStatus.value(m_jobList.at(index.row()));
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(role == Qt::DecorationRole && index.column() == 0)
|
||||
{
|
||||
switch(m_jobState.value(m_jobList.at(index.row())))
|
||||
{
|
||||
case JobRunning:
|
||||
break;
|
||||
case JobPaused:
|
||||
break;
|
||||
case JobComplete:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant ProgressModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
{
|
||||
if(orientation == Qt::Horizontal)
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
return "Job";
|
||||
break;
|
||||
case 1:
|
||||
return "Status";
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(orientation == Qt::Vertical)
|
||||
{
|
||||
return QString::number(section + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ProgressModel::addJob(const QString &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState)
|
||||
{
|
||||
if(m_jobList.contains(jobId, Qt::CaseInsensitive))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString id = jobId.toLower();
|
||||
|
||||
beginResetModel();
|
||||
m_jobList.append(id);
|
||||
m_jobName.insert(id, jobName);
|
||||
m_jobStatus.insert(id, jobInitialStatus);
|
||||
m_jobState.insert(id, jobInitialState);
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ProgressModel::updateJob(const QString &jobId, const QString &newStatus, int newState)
|
||||
{
|
||||
if(!m_jobList.contains(jobId, Qt::CaseInsensitive))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString id = jobId.toLower();
|
||||
|
||||
beginResetModel();
|
||||
if(!newStatus.isEmpty()) m_jobStatus.insert(id, newStatus);
|
||||
if(newState >= 0) m_jobState.insert(id, newState);
|
||||
endResetModel();
|
||||
}
|
66
src/Model_Progress.h
Normal file
66
src/Model_Progress.h
Normal file
@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// LameXP - Audio Encoder Front-End
|
||||
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QIcon>
|
||||
|
||||
class ProgressModel : public QAbstractTableModel
|
||||
{
|
||||
public:
|
||||
ProgressModel(void);
|
||||
~ProgressModel(void);
|
||||
|
||||
//Enums
|
||||
enum JobState
|
||||
{
|
||||
JobRunning = 0,
|
||||
JobPaused = 1,
|
||||
JobComplete = 2,
|
||||
JobFailed = 3
|
||||
};
|
||||
|
||||
//Model functions
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
public slots:
|
||||
void addJob(const QString &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning);
|
||||
void updateJob(const QString &jobId, const QString &newStatus, int newState);
|
||||
|
||||
private:
|
||||
QStringList m_jobList;
|
||||
QMap<QString, QString> m_jobName;
|
||||
QMap<QString, QString> m_jobStatus;
|
||||
QMap<QString, int> m_jobState;
|
||||
|
||||
const QIcon m_iconRunning;
|
||||
const QIcon m_iconPaused;
|
||||
const QIcon m_iconComplete;
|
||||
const QIcon m_iconFailed;
|
||||
};
|
Loading…
Reference in New Issue
Block a user