mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
generic: replace QUuid with QString and qRandomUuid()
implement new FileSystem::createUUID() method to de-duplicated code while at it Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
90b1789d62
commit
fc3ff6c252
6 changed files with 31 additions and 13 deletions
|
@ -14,7 +14,6 @@
|
|||
#include <QtCore/QSet>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include <QtXml/qdom.h>
|
||||
|
@ -65,6 +64,15 @@ static void deleteObjectRects( QList< ObjectRect * >& rects, const QSet<ObjectRe
|
|||
++it;
|
||||
}
|
||||
|
||||
static inline QString createAnnotationID()
|
||||
{
|
||||
#if QT_VERSION >= 0x041200
|
||||
return QString::fromLatin1(qRandomUuid());
|
||||
#else
|
||||
return QString::number(qrand());
|
||||
#endif
|
||||
}
|
||||
|
||||
PagePrivate::PagePrivate( Page *page, uint n, double w, double h, Rotation o )
|
||||
: m_page( page ), m_number( n ), m_orientation( o ),
|
||||
m_width( w ), m_height( h ), m_doc( 0 ), m_boundingBox( 0, 0, 1, 1 ),
|
||||
|
@ -631,10 +639,10 @@ QColor Page::textSelectionColor() const
|
|||
|
||||
void Page::addAnnotation( Annotation * annotation )
|
||||
{
|
||||
// Generate uniqueName: okular-{UUID}
|
||||
// Generate uniqueName: okular-UUID
|
||||
if(annotation->uniqueName().isEmpty())
|
||||
{
|
||||
QString uniqueName = "okular-" + QUuid::createUuid().toString();
|
||||
QString uniqueName = "okular-" + createAnnotationID();
|
||||
annotation->setUniqueName( uniqueName );
|
||||
}
|
||||
annotation->d_ptr->m_page = d;
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#if QT_VERSION < 0x041200
|
||||
# include <QUuid>
|
||||
#endif
|
||||
|
||||
/** Creates a new FileSystem object
|
||||
@param firstsector the first sector used by this FileSystem on the Device
|
||||
@param lastsector the last sector used by this FileSystem on the Device
|
||||
|
@ -388,6 +392,18 @@ bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, i
|
|||
return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@return UUID in the form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
*/
|
||||
QString FileSystem::createUUID()
|
||||
{
|
||||
#if QT_VERSION >= 0x041200
|
||||
return QString::fromLatin1(qRandomUuid());
|
||||
#else
|
||||
return QUuid::createUuid().toString().remove(QRegExp("\\{|\\}"));
|
||||
#endif
|
||||
}
|
||||
|
||||
FileSystem::Type FileSystem::defaultFileSystem()
|
||||
{
|
||||
return static_cast<FileSystem::Type>(Config::defaultFileSystem());
|
||||
|
|
|
@ -173,6 +173,7 @@ class FileSystem
|
|||
|
||||
protected:
|
||||
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
||||
static QString createUUID();
|
||||
|
||||
protected:
|
||||
FileSystem::Type m_Type;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "util/externalcommand.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
#include <KLocale>
|
||||
|
||||
|
@ -135,9 +134,7 @@ namespace FS
|
|||
|
||||
bool luks::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
|
||||
ExternalCommand cmd(report, "cryptsetup", QStringList() << "luksUUID" << deviceNode << "--uuid" << uuid.toString());
|
||||
ExternalCommand cmd(report, "cryptsetup", QStringList() << "luksUUID" << deviceNode << "--uuid" << createUUID());
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
#include <KLocale>
|
||||
#include <KTempDir>
|
||||
|
@ -177,8 +176,7 @@ namespace FS
|
|||
|
||||
bool nilfs2::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
ExternalCommand cmd(report, "nilfs-tune", QStringList() << "-U" << uuid.toString() << deviceNode);
|
||||
ExternalCommand cmd(report, "nilfs-tune", QStringList() << "-U" << createUUID() << deviceNode);
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QRegExp>
|
||||
#include <QUuid>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -165,8 +164,7 @@ namespace FS
|
|||
|
||||
bool reiserfs::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
const QString uuid = QUuid::createUuid().toString().remove(QRegExp("\\{|\\}"));
|
||||
ExternalCommand cmd(report, "reiserfstune", QStringList() << "-u" << uuid << deviceNode);
|
||||
ExternalCommand cmd(report, "reiserfstune", QStringList() << "-u" << createUUID() << deviceNode);
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue