73a8c03fa1
and added some options to the menu that changes the behaviour of the app. such as turning on/off the auto playing of files and the directory and volume control. this is all kept persistent using an IDM formated file in the app's config directory. still having issues with it not calculating the durations properly but i now know why. it's because QMediaPlayer can't calculate the durations of VBR files (variable bit- rate) properly. other than that, everything seems to be working perfectly. i'll add more feasures such as a next/previous file button and a stop button.
93 lines
2.5 KiB
C++
93 lines
2.5 KiB
C++
#ifndef IDM_H
|
|
#define IDM_H
|
|
|
|
#include <QObject>
|
|
#include <QByteArray>
|
|
#include <QMutex>
|
|
|
|
#include "int.h"
|
|
|
|
class Idm : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum Flags
|
|
{
|
|
FIXED_KEY_LEN = 1
|
|
};
|
|
|
|
static const QByteArray TAG;
|
|
static const int MAX_MAJOR;
|
|
static const int MAX_MINOR;
|
|
static int CURRENT_MAJOR;
|
|
static int CURRENT_MINOR;
|
|
static int DEFAULT_INT_SIZE;
|
|
static int DEFAULT_FLAGS;
|
|
static int DEFAULT_KEY_LEN;
|
|
|
|
static bool verifyExHeader(const QByteArray &data, int major, int minor);
|
|
static bool rdExHeader(const QByteArray &data, int &major, int &minor, int &intSz, int &flgs, int &keyLen);
|
|
static QByteArray buildHeader(int major, int minor, int intSz, int flgs, int keyLen);
|
|
|
|
explicit Idm(const QByteArray &data, QObject *parent = 0);
|
|
explicit Idm(QObject *parent = 0);
|
|
|
|
void setVersion(int major, int minor);
|
|
void setFlags(int flgs);
|
|
void setIntSize(int bytes);
|
|
void wrHeader();
|
|
void setKeyLen(int len);
|
|
void loadData(const QByteArray &data);
|
|
bool insert(const QByteArray &key, const QByteArray &data);
|
|
bool insert(quint64 key, quint64 num);
|
|
bool insert(quint64 key, const QByteArray &data);
|
|
bool remove(const QByteArray &key);
|
|
bool remove(quint64 key);
|
|
bool rdHeader();
|
|
bool rdExHeader(const QByteArray &data);
|
|
quint64 intValue(quint64 key);
|
|
quint64 intValue(const QByteArray &key);
|
|
QByteArray value(const QByteArray &key);
|
|
QByteArray value(quint64 key);
|
|
QByteArray &getBuff();
|
|
|
|
private:
|
|
|
|
enum Operation
|
|
{
|
|
RELOAD,
|
|
GET_BUFF,
|
|
RD_HEADER,
|
|
WR_HEADER,
|
|
SET_KEY_LEN,
|
|
SET_FLAGS,
|
|
SET_INT_SIZE,
|
|
SET_VERSION,
|
|
RD_VALUE,
|
|
WR_VALUE,
|
|
RM_VALUE
|
|
};
|
|
|
|
QByteArray buffPtr;
|
|
int header;
|
|
int intSize;
|
|
int keyLen;
|
|
int flags;
|
|
|
|
void op(Operation opr,
|
|
const QByteArray &inA = QByteArray(),
|
|
const QByteArray &inB = QByteArray(),
|
|
QByteArray *out = 0,
|
|
int intA = 0,
|
|
int intB = 0,
|
|
bool *ok = 0);
|
|
|
|
void init();
|
|
bool findKey(int &addr, int &dataLen, const QByteArray &key);
|
|
QByteArray rdData(int, int, bool *ok = 0);
|
|
};
|
|
|
|
#endif // IDM_H
|