I use md5 to check image stream or to stop connection param if the same as last..
{
QCryptographicHash formats( QCryptographicHash::Md5 );
formats.addData(xml.toUtf8());
return formats.result();
}
{
QCryptographicHash formats( QCryptographicHash::Md5 );
formats.addData(xml);
return formats.result();
}
static inline QByteArray fastmd5( const QString xml )
{
QCryptographicHash formats( QCryptographicHash::Md5 );
formats.addData(xml.toUtf8());
return formats.result();
}
static inline QByteArray fastmd5( const QByteArray xml )
{
QCryptographicHash formats( QCryptographicHash::Md5 );
formats.addData(xml);
return formats.result();
}
To copy to clipboard, switch view to plain text mode
/* fill params */
/* take qmenu from other layer edit or same as last? */
void PageWindow::PlayOn()
{
TextLayer *iter = CurrentView->LayerModel();
const int LayID = iter->data(ObjectNameEditor).toInt();
const QString editable
= LayID
== 0 ?
"no" : "yes";
bool canedit = LayID == 0 ? false : true;
const QString Pmyhash
= QString("%1-%2-%3-%4-%5").
arg(editable
) /* can edit area */ .arg(Clang) /* language */
.arg(wdoc->ID()) /* document nr .*/
.arg(LayID) /* layer nummer*/
.arg(iter->textCursor().position()); /* cursor position */
emit menupage(canedit,fastmd5(Pmyhash));
}
void Gui_Main
::editor( bool e ,
const QByteArray hashpage
) {
if (LastHash == hashpage) {
/* not make job ist the same edit status as last! */
return;
} else {
LastHash = hashpage;
}
/* continue ok*/
/* fill params */
/* take qmenu from other layer edit or same as last? */
void PageWindow::PlayOn()
{
TextLayer *iter = CurrentView->LayerModel();
const int LayID = iter->data(ObjectNameEditor).toInt();
const QString editable = LayID == 0 ? "no" : "yes";
bool canedit = LayID == 0 ? false : true;
const QString Pmyhash = QString("%1-%2-%3-%4-%5").arg(editable) /* can edit area */
.arg(Clang) /* language */
.arg(wdoc->ID()) /* document nr .*/
.arg(LayID) /* layer nummer*/
.arg(iter->textCursor().position()); /* cursor position */
emit menupage(canedit,fastmd5(Pmyhash));
}
void Gui_Main::editor( bool e , const QByteArray hashpage )
{
if (LastHash == hashpage) {
/* not make job ist the same edit status as last! */
return;
} else {
LastHash = hashpage;
}
/* continue ok*/
To copy to clipboard, switch view to plain text mode
My QImage cache work in this way to compose Multiple Animated Portable Network Graphics APNG... and all frame is unique...
http://www.qt-apps.org/content/show....?content=82221
class StreamFile
{
public:
StreamFile()
{
start();
}
~StreamFile()
{
d->close();
}
bool clear()
{
return d->bytesAvailable() == 0 ? true : false;
}
void start() {
d->seek(0);
}
bool LoadFile
( const QString file ) { if (clear()) {
if (f.exists()) {
if (f.
open(QFile::ReadOnly)) { d->write(f.readAll());
f.close();
start();
return true;
}
}
}
return false;
}
bool PutOnFile
( const QString file ) { if (f.
open(QFile::WriteOnly)) { uint bi = f.write(d->readAll());
start();
return bi > 0 ? true : false;
}
return false;
}
bool isValid() { return img.loadFromData(stream()); }
};
class StreamFile
{
public:
StreamFile()
:d(new QBuffer())
{
d->open(QIODevice::ReadWrite);
start();
}
~StreamFile()
{
d->close();
}
bool clear()
{
d->write(QByteArray());
return d->bytesAvailable() == 0 ? true : false;
}
void start() {
d->seek(0);
}
bool LoadFile( const QString file ) {
if (clear()) {
QFile f(file);
if (f.exists()) {
if (f.open(QFile::ReadOnly)) {
d->write(f.readAll());
f.close();
start();
return true;
}
}
}
return false;
}
bool PutOnFile( const QString file ) {
QFile f(file);
if (f.open(QFile::WriteOnly)) {
uint bi = f.write(d->readAll());
start();
return bi > 0 ? true : false;
}
return false;
}
QBuffer *device() { return d; }
bool isValid() { return img.loadFromData(stream()); }
QByteArray stream() { return d->data(); }
QImage img;
QBuffer *d;
};
To copy to clipboard, switch view to plain text mode
Bookmarks