rename log class to Log to avoid clashes with the C math lib function of the

same name

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1080742
This commit is contained in:
Volker Lanz 2010-01-26 21:12:42 +00:00
parent e66958e40b
commit a6427ee3ce
13 changed files with 49 additions and 49 deletions

View File

@ -59,7 +59,7 @@
static PedExceptionOption pedExceptionHandler(PedException* e) static PedExceptionOption pedExceptionHandler(PedException* e)
{ {
/** @todo These messages should end up in the Report, not in the GlobalLog. */ /** @todo These messages should end up in the Report, not in the GlobalLog. */
log(log::error) << i18nc("@info/plain", "LibParted Exception: %1", QString::fromLocal8Bit(e->message)); Log(Log::error) << i18nc("@info/plain", "LibParted Exception: %1", QString::fromLocal8Bit(e->message));
return PED_EXCEPTION_UNHANDLED; return PED_EXCEPTION_UNHANDLED;
} }
@ -233,7 +233,7 @@ void LibParted::scanDevices(OperationStack& ostack)
const Solid::Block* solidBlock = solidDevice.as<Solid::Block>(); const Solid::Block* solidBlock = solidDevice.as<Solid::Block>();
PedDevice* pedDevice = ped_device_get(solidBlock->device().toLocal8Bit()); PedDevice* pedDevice = ped_device_get(solidBlock->device().toLocal8Bit());
log(log::information) << i18nc("@info/plain", "Device found: %1", pedDevice->model); Log(Log::information) << i18nc("@info/plain", "Device found: %1", pedDevice->model);
Device* d = new Device(pedDevice->model, pedDevice->path, pedDevice->bios_geom.heads, pedDevice->bios_geom.sectors, pedDevice->bios_geom.cylinders, pedDevice->sector_size, solidDevice.icon()); Device* d = new Device(pedDevice->model, pedDevice->path, pedDevice->bios_geom.heads, pedDevice->bios_geom.sectors, pedDevice->bios_geom.cylinders, pedDevice->sector_size, solidDevice.icon());

View File

@ -97,7 +97,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
// -- 1 -- // -- 1 --
if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition()) if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition())
{ {
log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition."); Log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = NULL;
@ -111,7 +111,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
// -- 2 -- // -- 2 --
if (pushedResizeOp && &newOp->newPartition() == &pushedResizeOp->partition()) if (pushedResizeOp && &newOp->newPartition() == &pushedResizeOp->partition())
{ {
log() << i18nc("@info/plain", "Resizing a partition just created: Updating start and end in existing operation."); Log() << i18nc("@info/plain", "Resizing a partition just created: Updating start and end in existing operation.");
Partition* newPartition = new Partition(newOp->newPartition()); Partition* newPartition = new Partition(newOp->newPartition());
newPartition->setFirstSector(pushedResizeOp->newFirstSector()); newPartition->setFirstSector(pushedResizeOp->newFirstSector());
@ -132,7 +132,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
// -- 3 -- // -- 3 --
if (pushedCopyOp && &newOp->newPartition() == &pushedCopyOp->sourcePartition()) if (pushedCopyOp && &newOp->newPartition() == &pushedCopyOp->sourcePartition())
{ {
log() << i18nc("@info/plain", "Copying a new partition: Creating a new partition instead."); Log() << i18nc("@info/plain", "Copying a new partition: Creating a new partition instead.");
Partition* newPartition = new Partition(newOp->newPartition()); Partition* newPartition = new Partition(newOp->newPartition());
newPartition->setFirstSector(pushedCopyOp->copiedPartition().firstSector()); newPartition->setFirstSector(pushedCopyOp->copiedPartition().firstSector());
@ -150,7 +150,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
// -- 4 -- // -- 4 --
if (pushedLabelOp && &newOp->newPartition() == &pushedLabelOp->labeledPartition()) if (pushedLabelOp && &newOp->newPartition() == &pushedLabelOp->labeledPartition())
{ {
log() << i18nc("@info/plain", "Changing label for a new partition: No new operation required."); Log() << i18nc("@info/plain", "Changing label for a new partition: No new operation required.");
newOp->setLabelJob()->setLabel(pushedLabelOp->newLabel()); newOp->setLabelJob()->setLabel(pushedLabelOp->newLabel());
newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel()); newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel());
@ -164,7 +164,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
// -- 5 -- // -- 5 --
if (pushedCreateFileSystemOp && &newOp->newPartition() == &pushedCreateFileSystemOp->partition()) if (pushedCreateFileSystemOp && &newOp->newPartition() == &pushedCreateFileSystemOp->partition())
{ {
log() << i18nc("@info/plain", "Changing file system for a new partition: No new operation required."); Log() << i18nc("@info/plain", "Changing file system for a new partition: No new operation required.");
FileSystem* oldFs = &newOp->newPartition().fileSystem(); FileSystem* oldFs = &newOp->newPartition().fileSystem();
@ -220,14 +220,14 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
// copy operation, forget the delete and be done. // copy operation, forget the delete and be done.
if (copyOp->overwrittenPartition() == NULL) if (copyOp->overwrittenPartition() == NULL)
{ {
log() << i18nc("@info/plain", "Deleting a partition just copied: Removing the copy."); Log() << i18nc("@info/plain", "Deleting a partition just copied: Removing the copy.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = NULL;
} }
else else
{ {
log() << i18nc("@info/plain", "Deleting a partition just copied over an existing partition: Removing the copy and deleting the existing partition."); Log() << i18nc("@info/plain", "Deleting a partition just copied over an existing partition: Removing the copy and deleting the existing partition.");
pushedDeleteOp->setDeletedPartition(copyOp->overwrittenPartition()); pushedDeleteOp->setDeletedPartition(copyOp->overwrittenPartition());
} }
@ -241,7 +241,7 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
// -- 2 -- // -- 2 --
if (pushedCopyOp && &copyOp->copiedPartition() == &pushedCopyOp->sourcePartition()) if (pushedCopyOp && &copyOp->copiedPartition() == &pushedCopyOp->sourcePartition())
{ {
log() << i18nc("@info/plain", "Copying a partition that is itself a copy: Copying the original source partition instead."); Log() << i18nc("@info/plain", "Copying a partition that is itself a copy: Copying the original source partition instead.");
pushedCopyOp->setSourcePartition(&copyOp->sourcePartition()); pushedCopyOp->setSourcePartition(&copyOp->sourcePartition());
} }
@ -272,14 +272,14 @@ bool OperationStack::mergeRestoreOperation(Operation*& currentOp, Operation*& pu
{ {
if (restoreOp->overwrittenPartition() == NULL) if (restoreOp->overwrittenPartition() == NULL)
{ {
log() << i18nc("@info/plain", "Deleting a partition just restored: Removing the restore operation."); Log() << i18nc("@info/plain", "Deleting a partition just restored: Removing the restore operation.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = NULL;
} }
else else
{ {
log() << i18nc("@info/plain", "Deleting a partition just restored to an existing partition: Removing the restore operation and deleting the existing partition."); Log() << i18nc("@info/plain", "Deleting a partition just restored to an existing partition: Removing the restore operation and deleting the existing partition.");
pushedDeleteOp->setDeletedPartition(restoreOp->overwrittenPartition()); pushedDeleteOp->setDeletedPartition(restoreOp->overwrittenPartition());
} }
@ -313,7 +313,7 @@ bool OperationStack::mergePartFlagsOperation(Operation*& currentOp, Operation*&
if (pushedFlagsOp && &partFlagsOp->flagPartition() == &pushedFlagsOp->flagPartition()) if (pushedFlagsOp && &partFlagsOp->flagPartition() == &pushedFlagsOp->flagPartition())
{ {
log() << i18nc("@info/plain", "Changing flags again for the same partition: Removing old operation."); Log() << i18nc("@info/plain", "Changing flags again for the same partition: Removing old operation.");
pushedFlagsOp->setOldFlags(partFlagsOp->oldFlags()); pushedFlagsOp->setOldFlags(partFlagsOp->oldFlags());
partFlagsOp->undo(); partFlagsOp->undo();
@ -345,7 +345,7 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*&
if (pushedLabelOp && &partLabelOp->labeledPartition() == &pushedLabelOp->labeledPartition()) if (pushedLabelOp && &partLabelOp->labeledPartition() == &pushedLabelOp->labeledPartition())
{ {
log() << i18nc("@info/plain", "Changing label again for the same partition: Removing old operation."); Log() << i18nc("@info/plain", "Changing label again for the same partition: Removing old operation.");
pushedLabelOp->setOldLabel(partLabelOp->oldLabel()); pushedLabelOp->setOldLabel(partLabelOp->oldLabel());
partLabelOp->undo(); partLabelOp->undo();
@ -390,7 +390,7 @@ void OperationStack::push(Operation* o)
if (o != NULL) if (o != NULL)
{ {
log() << i18nc("@info/plain", "Add operation: %1", o->description()); Log() << i18nc("@info/plain", "Add operation: %1", o->description());
operations().append(o); operations().append(o);
o->preview(); o->preview();
o->setStatus(Operation::StatusPending); o->setStatus(Operation::StatusPending);

View File

@ -245,7 +245,7 @@ bool PartitionTable::isSnapped(const Device& d, const Partition& p)
if (delta) if (delta)
{ {
log(log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not start at a cylinder boundary (first sector: %2, modulo: %3).", p.deviceNode(), p.firstSector(), delta); Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not start at a cylinder boundary (first sector: %2, modulo: %3).", p.deviceNode(), p.firstSector(), delta);
rval = false; rval = false;
} }
@ -253,7 +253,7 @@ bool PartitionTable::isSnapped(const Device& d, const Partition& p)
if (delta) if (delta)
{ {
log(log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not end at a cylinder boundary (last sector: %2, modulo: %3).", p.deviceNode(), p.lastSector(), delta); Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not end at a cylinder boundary (last sector: %2, modulo: %3).", p.deviceNode(), p.lastSector(), delta);
rval = false; rval = false;
} }
@ -389,7 +389,7 @@ bool PartitionTable::snap(const Device& d, Partition& p, const Partition* origin
} }
if (p.length() < originalLength) if (p.length() < originalLength)
log(log::warning) << i18ncp("@info/plain", "The partition cannot be created with the requested length of 1 sector, ", "The partition cannot be created with the requested length of %1 sectors, ", originalLength) Log(Log::warning) << i18ncp("@info/plain", "The partition cannot be created with the requested length of 1 sector, ", "The partition cannot be created with the requested length of %1 sectors, ", originalLength)
+ i18ncp("@info/plain", "and will instead only be 1 sector long.", "and will instead only be %1 sectors long.", p.length()); + i18ncp("@info/plain", "and will instead only be 1 sector long.", "and will instead only be %1 sectors long.", p.length());
// In an extended partition we also need to snap unallocated children at the beginning and at the end // In an extended partition we also need to snap unallocated children at the beginning and at the end

View File

@ -175,23 +175,23 @@ namespace FS
QFile device(deviceNode); QFile device(deviceNode);
if (!device.open(QFile::ReadWrite | QFile::Unbuffered)) if (!device.open(QFile::ReadWrite | QFile::Unbuffered))
{ {
log() << i18nc("@info/plain", "Could not open partition <filename>%1</filename> for writing when trying to update the NTFS boot sector.", deviceNode); Log() << i18nc("@info/plain", "Could not open partition <filename>%1</filename> for writing when trying to update the NTFS boot sector.", deviceNode);
return false; return false;
} }
if (!device.seek(0x1c)) if (!device.seek(0x1c))
{ {
log() << i18nc("@info/plain", "Could not seek to position 0x1c on partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); Log() << i18nc("@info/plain", "Could not seek to position 0x1c on partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode);
return false; return false;
} }
if (device.write(s, 4) != 4) if (device.write(s, 4) != 4)
{ {
log() << i18nc("@info/plain", "Could not write new start sector to partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); Log() << i18nc("@info/plain", "Could not write new start sector to partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode);
return false; return false;
} }
log() << i18nc("@info/plain", "Updated NTFS boot sector for partition <filename>%1</filename> successfully.", deviceNode); Log() << i18nc("@info/plain", "Updated NTFS boot sector for partition <filename>%1</filename> successfully.", deviceNode);
return true; return true;
} }

View File

@ -55,7 +55,7 @@ void MainWindow::init()
{ {
treeLog().init(actionCollection(), &pmWidget()); treeLog().init(actionCollection(), &pmWidget());
connect(GlobalLog::instance(), SIGNAL(newMessage(log::Level, const QString&)), &treeLog(), SLOT(onNewLogMessage(log::Level, const QString&))); connect(GlobalLog::instance(), SIGNAL(newMessage(Log::Level, const QString&)), &treeLog(), SLOT(onNewLogMessage(Log::Level, const QString&)));
setupActions(); setupActions();
setupStatusBar(); setupStatusBar();

View File

@ -301,7 +301,7 @@ void PartitionManagerWidget::setupConnections()
void PartitionManagerWidget::scanDevices() void PartitionManagerWidget::scanDevices()
{ {
log() << i18nc("@info/plain", "Rescanning devices..."); Log() << i18nc("@info/plain", "Rescanning devices...");
KApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); KApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -316,7 +316,7 @@ void PartitionManagerWidget::scanDevices()
updatePartitions(); updatePartitions();
log() << i18nc("@info/plain", "Rescan finished."); Log() << i18nc("@info/plain", "Rescan finished.");
KApplication::restoreOverrideCursor(); KApplication::restoreOverrideCursor();
emit selectionChanged(NULL); emit selectionChanged(NULL);
@ -782,7 +782,7 @@ void PartitionManagerWidget::onResizePartition()
PartitionTable::snap(*selectedDevice(), resizedPartition, selectedPartition()); PartitionTable::snap(*selectedDevice(), resizedPartition, selectedPartition());
if (resizedPartition.firstSector() == selectedPartition()->firstSector() && resizedPartition.lastSector() == selectedPartition()->lastSector()) if (resizedPartition.firstSector() == selectedPartition()->firstSector() && resizedPartition.lastSector() == selectedPartition()->lastSector())
log(log::information) << i18nc("@info/plain", "Partition <filename>%1</filename> has the same position and size after resize/move. Ignoring operation.", selectedPartition()->deviceNode()); Log(Log::information) << i18nc("@info/plain", "Partition <filename>%1</filename> has the same position and size after resize/move. Ignoring operation.", selectedPartition()->deviceNode());
else else
{ {
operationStack().push(new ResizeOperation(*selectedDevice(), *selectedPartition(), resizedPartition.firstSector(), resizedPartition.lastSector())); operationStack().push(new ResizeOperation(*selectedDevice(), *selectedPartition(), resizedPartition.firstSector(), resizedPartition.lastSector()));
@ -807,7 +807,7 @@ void PartitionManagerWidget::onCopyPartition()
} }
setClipboardPartition(selectedPartition()); setClipboardPartition(selectedPartition());
log() << i18nc("@info/plain", "Partition <filename>%1</filename> has been copied to the clipboard.", selectedPartition()->deviceNode()); Log() << i18nc("@info/plain", "Partition <filename>%1</filename> has been copied to the clipboard.", selectedPartition()->deviceNode());
enableActions(); enableActions();
} }
@ -947,7 +947,7 @@ void PartitionManagerWidget::onRefreshDevices()
void PartitionManagerWidget::onUndoOperation() void PartitionManagerWidget::onUndoOperation()
{ {
log() << i18nc("@info/plain", "Undoing operation: %1", operationStack().operations().last()->description()); Log() << i18nc("@info/plain", "Undoing operation: %1", operationStack().operations().last()->description());
operationStack().pop(); operationStack().pop();
updatePartitions(); updatePartitions();
@ -964,7 +964,7 @@ void PartitionManagerWidget::onClearAllOperations()
KGuiItem(i18nc("@action:button", "&Clear Pending Operations")), KGuiItem(i18nc("@action:button", "&Clear Pending Operations")),
KStandardGuiItem::cancel(), "reallyClearPendingOperations") == KMessageBox::Continue) KStandardGuiItem::cancel(), "reallyClearPendingOperations") == KMessageBox::Continue)
{ {
log() << i18nc("@info/plain", "Clearing the list of pending operations."); Log() << i18nc("@info/plain", "Clearing the list of pending operations.");
operationStack().clearOperations(); operationStack().clearOperations();
updatePartitions(); updatePartitions();
@ -989,7 +989,7 @@ void PartitionManagerWidget::onApplyAllOperations()
KGuiItem(i18nc("@action:button", "&Apply Pending Operations")), KGuiItem(i18nc("@action:button", "&Apply Pending Operations")),
KStandardGuiItem::cancel()) == KMessageBox::Continue) KStandardGuiItem::cancel()) == KMessageBox::Continue)
{ {
log() << i18nc("@info/plain", "Applying operations..."); Log() << i18nc("@info/plain", "Applying operations...");
progressDialog().show(); progressDialog().show();

View File

@ -42,7 +42,7 @@ TreeLog::TreeLog(QWidget* parent) :
setupUi(this); setupUi(this);
} }
void TreeLog::onNewLogMessage(log::Level logLevel, const QString& s) void TreeLog::onNewLogMessage(Log::Level logLevel, const QString& s)
{ {
static const char* icons[] = static const char* icons[] =
{ {

View File

@ -50,7 +50,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT TreeLog: public QWidget, public Ui::Tree
void init(KActionCollection* coll, PartitionManagerWidget* pm_widget) { m_ActionCollection = coll; m_PartitionManagerWidget = pm_widget; } void init(KActionCollection* coll, PartitionManagerWidget* pm_widget) { m_ActionCollection = coll; m_PartitionManagerWidget = pm_widget; }
public slots: public slots:
void onNewLogMessage(log::Level logLevel, const QString& s); void onNewLogMessage(Log::Level logLevel, const QString& s);
protected: protected:
QTreeWidget& treeLog() { Q_ASSERT(m_TreeLog); return *m_TreeLog; } QTreeWidget& treeLog() { Q_ASSERT(m_TreeLog); return *m_TreeLog; }

View File

@ -49,7 +49,7 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
{ {
setupUi(this); setupUi(this);
connect(GlobalLog::instance(), SIGNAL(newMessage(log::Level, const QString&)), SLOT(onNewLogMessage(log::Level, const QString&))); connect(GlobalLog::instance(), SIGNAL(newMessage(Log::Level, const QString&)), SLOT(onNewLogMessage(Log::Level, const QString&)));
// workaround for https://bugs.launchpad.net/kdesudo/+bug/272427 // workaround for https://bugs.launchpad.net/kdesudo/+bug/272427
unblockSigChild(); unblockSigChild();
@ -95,7 +95,7 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
setAboutData(createPartitionManagerAboutData()); setAboutData(createPartitionManagerAboutData());
} }
void PartitionManagerKCM::onNewLogMessage(log::Level, const QString& s) void PartitionManagerKCM::onNewLogMessage(Log::Level, const QString& s)
{ {
kDebug() << s; kDebug() << s;
} }

View File

@ -59,7 +59,7 @@ class PartitionManagerKCM : public KCModule, public Ui::PartitionManagerKCMBase
KActionCollection* actionCollection() { return m_ActionCollection; } KActionCollection* actionCollection() { return m_ActionCollection; }
protected slots: protected slots:
void onNewLogMessage(log::Level logLevel, const QString& s); void onNewLogMessage(Log::Level logLevel, const QString& s);
void onStatusChanged(); void onStatusChanged();
void onApplyClicked(); void onApplyClicked();

View File

@ -29,7 +29,7 @@ GlobalLog* GlobalLog::instance()
return p; return p;
} }
void GlobalLog::flush(log::Level lev) void GlobalLog::flush(Log::Level lev)
{ {
emit newMessage(lev, msg); emit newMessage(lev, msg);
msg.clear(); msg.clear();
@ -37,7 +37,7 @@ void GlobalLog::flush(log::Level lev)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
log::~log() Log::~Log()
{ {
if (--ref == 0) if (--ref == 0)
GlobalLog::instance()->flush(level); GlobalLog::instance()->flush(level);

View File

@ -27,7 +27,7 @@
#include <QObject> #include <QObject>
#include <qglobal.h> #include <qglobal.h>
class log class Log
{ {
public: public:
enum Level enum Level
@ -39,9 +39,9 @@ class log
}; };
public: public:
log(Level lev = information) : ref(1), level(lev) {} Log(Level lev = information) : ref(1), level(lev) {}
~log(); ~Log();
log(const log& other) : ref(other.ref + 1), level(other.level) {} Log(const Log& other) : ref(other.ref + 1), level(other.level) {}
private: private:
quint32 ref; quint32 ref;
@ -56,34 +56,34 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT GlobalLog : public QObject
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(GlobalLog) Q_DISABLE_COPY(GlobalLog)
friend class log; friend class Log;
friend log operator<<(log l, const QString& s); friend Log operator<<(Log l, const QString& s);
friend log operator<<(log l, qint64 i); friend Log operator<<(Log l, qint64 i);
private: private:
GlobalLog() : msg() {} GlobalLog() : msg() {}
signals: signals:
void newMessage(log::Level, const QString&); void newMessage(Log::Level, const QString&);
public: public:
static GlobalLog* instance(); static GlobalLog* instance();
private: private:
void append(const QString& s) { msg += s; } void append(const QString& s) { msg += s; }
void flush(log::Level level); void flush(Log::Level level);
private: private:
QString msg; QString msg;
}; };
inline log operator<<(log l, const QString& s) inline Log operator<<(Log l, const QString& s)
{ {
GlobalLog::instance()->append(s); GlobalLog::instance()->append(s);
return l; return l;
} }
inline log operator<<(log l, qint64 i) inline Log operator<<(Log l, qint64 i)
{ {
GlobalLog::instance()->append(QString::number(i)); GlobalLog::instance()->append(QString::number(i));
return l; return l;

View File

@ -41,7 +41,7 @@
void registerMetaTypes() void registerMetaTypes()
{ {
qRegisterMetaType<Operation*>("Operation*"); qRegisterMetaType<Operation*>("Operation*");
qRegisterMetaType<log::Level>("log::Level"); qRegisterMetaType<Log::Level>("log::Level");
} }
void unblockSigChild() void unblockSigChild()