diff --git a/autotests/configloadertest.cpp b/autotests/configloadertest.cpp index 46b8798bc..a89d95168 100644 --- a/autotests/configloadertest.cpp +++ b/autotests/configloadertest.cpp @@ -54,70 +54,70 @@ void ConfigLoaderTest::cleanup() void ConfigLoaderTest::boolDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool*, "DefaultBoolItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); QVERIFY(typeItem->isEqual(true)); } void ConfigLoaderTest::colorDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor*, "DefaultColorItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); QVERIFY(typeItem->isEqual(QColor("#00FF00"))); } void ConfigLoaderTest::dateTimeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime*, "DefaultDateTimeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); } void ConfigLoaderTest::enumDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum*, "DefaultEnumItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); QVERIFY(typeItem->isEqual(3)); } void ConfigLoaderTest::fontDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont*, "DefaultFontItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); } void ConfigLoaderTest::intDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt*, "DefaultIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); QVERIFY(typeItem->isEqual(27)); } void ConfigLoaderTest::passwordDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword*, "DefaultPasswordItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); } void ConfigLoaderTest::pathDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath*, "DefaultPathItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); } void ConfigLoaderTest::stringDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString*, "DefaultStringItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); } void ConfigLoaderTest::stringListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList*, "DefaultStringListItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); // Create a string list with the expected values. QStringList expected; @@ -132,28 +132,28 @@ void ConfigLoaderTest::stringListDefaultValue() void ConfigLoaderTest::uintDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt*, "DefaultUIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); QVERIFY(typeItem->isEqual(7U)); } void ConfigLoaderTest::urlDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl*, "DefaultUrlItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); } void ConfigLoaderTest::doubleDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble*, "DefaultDoubleItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); QVERIFY(typeItem->isEqual(13.37)); } void ConfigLoaderTest::intListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList*, "DefaultIntListItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); // Create a int list with the expected values. QList expected; @@ -169,21 +169,21 @@ void ConfigLoaderTest::intListDefaultValue() void ConfigLoaderTest::longLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong*, "DefaultLongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); } void ConfigLoaderTest::pointDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint*, "DefaultPointItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); QVERIFY(typeItem->isEqual(QPoint(185, 857))); } void ConfigLoaderTest::rectDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect*, "DefaultRectItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); // Create a new QRect with the expected value. QRect expected; @@ -194,19 +194,17 @@ void ConfigLoaderTest::rectDefaultValue() void ConfigLoaderTest::sizeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize*, "DefaultSizeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); QVERIFY(typeItem->isEqual(QSize(640, 480))); } void ConfigLoaderTest::ulongLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong*, "DefaultULongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); } - QTEST_MAIN(ConfigLoaderTest) - diff --git a/autotests/configloadertest.h b/autotests/configloadertest.h index 18fd64f66..791b0f610 100644 --- a/autotests/configloadertest.h +++ b/autotests/configloadertest.h @@ -24,7 +24,7 @@ namespace Plasma { - class ConfigLoader; +class ConfigLoader; } class QFile; @@ -59,8 +59,8 @@ private Q_SLOTS: void ulongLongDefaultValue(); private: - Plasma::ConfigLoader* cl; - QFile* configFile; + Plasma::ConfigLoader *cl; + QFile *configFile; }; #endif diff --git a/autotests/dynamictreemodel.cpp b/autotests/dynamictreemodel.cpp index fa634b6a5..190298e95 100644 --- a/autotests/dynamictreemodel.cpp +++ b/autotests/dynamictreemodel.cpp @@ -45,10 +45,9 @@ #include #include - DynamicTreeModel::DynamicTreeModel(QObject *parent) - : QAbstractItemModel(parent), - nextId(1) + : QAbstractItemModel(parent), + nextId(1) { } @@ -57,125 +56,130 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare // if (column != 0) // return QModelIndex(); + if (column < 0 || row < 0) { + return QModelIndex(); + } - if ( column < 0 || row < 0 ) - return QModelIndex(); + QList > childIdColumns = m_childItems.value(parent.internalId()); - QList > childIdColumns = m_childItems.value(parent.internalId()); + const qint64 grandParent = findParentId(parent.internalId()); + if (grandParent >= 0) { + QList > parentTable = m_childItems.value(grandParent); + Q_ASSERT(parent.column() < parentTable.size()); + QList parentSiblings = parentTable.at(parent.column()); + Q_ASSERT(parent.row() < parentSiblings.size()); + } - const qint64 grandParent = findParentId(parent.internalId()); - if (grandParent >= 0) { - QList > parentTable = m_childItems.value(grandParent); - Q_ASSERT(parent.column() < parentTable.size()); - QList parentSiblings = parentTable.at(parent.column()); - Q_ASSERT(parent.row() < parentSiblings.size()); - } + if (childIdColumns.size() == 0) { + return QModelIndex(); + } - if (childIdColumns.size() == 0) - return QModelIndex(); + if (column >= childIdColumns.size()) { + return QModelIndex(); + } - if (column >= childIdColumns.size()) - return QModelIndex(); + QList rowIds = childIdColumns.at(column); - QList rowIds = childIdColumns.at(column); + if (row >= rowIds.size()) { + return QModelIndex(); + } - if ( row >= rowIds.size()) - return QModelIndex(); + qint64 id = rowIds.at(row); - qint64 id = rowIds.at(row); - - return createIndex(row, column, reinterpret_cast(id)); + return createIndex(row, column, reinterpret_cast(id)); } qint64 DynamicTreeModel::findParentId(qint64 searchId) const { - if (searchId <= 0) - return -1; - - QHashIterator > > i(m_childItems); - while (i.hasNext()) - { - i.next(); - QListIterator > j(i.value()); - while (j.hasNext()) - { - QList l = j.next(); - if (l.contains(searchId)) - { - return i.key(); - } + if (searchId <= 0) { + return -1; } - } - return -1; + + QHashIterator > > i(m_childItems); + while (i.hasNext()) { + i.next(); + QListIterator > j(i.value()); + while (j.hasNext()) { + QList l = j.next(); + if (l.contains(searchId)) { + return i.key(); + } + } + } + return -1; } QModelIndex DynamicTreeModel::parent(const QModelIndex &index) const { - if (!index.isValid()) - return QModelIndex(); + if (!index.isValid()) { + return QModelIndex(); + } - qint64 searchId = index.internalId(); - qint64 parentId = findParentId(searchId); - // Will never happen for valid index, but what the hey... - if (parentId <= 0) - return QModelIndex(); + qint64 searchId = index.internalId(); + qint64 parentId = findParentId(searchId); + // Will never happen for valid index, but what the hey... + if (parentId <= 0) { + return QModelIndex(); + } - qint64 grandParentId = findParentId(parentId); - if (grandParentId < 0) - grandParentId = 0; + qint64 grandParentId = findParentId(parentId); + if (grandParentId < 0) { + grandParentId = 0; + } - int column = 0; - QList childList = m_childItems.value(grandParentId).at(column); + int column = 0; + QList childList = m_childItems.value(grandParentId).at(column); - int row = childList.indexOf(parentId); + int row = childList.indexOf(parentId); - return createIndex(row, column, reinterpret_cast(parentId)); + return createIndex(row, column, reinterpret_cast(parentId)); } -int DynamicTreeModel::rowCount(const QModelIndex &index ) const +int DynamicTreeModel::rowCount(const QModelIndex &index) const { - QList > cols = m_childItems.value(index.internalId()); + QList > cols = m_childItems.value(index.internalId()); - if (cols.size() == 0 ) - return 0; + if (cols.size() == 0) { + return 0; + } - if (index.column() > 0) - return 0; + if (index.column() > 0) { + return 0; + } - return cols.at(0).size(); + return cols.at(0).size(); } -int DynamicTreeModel::columnCount(const QModelIndex &index ) const +int DynamicTreeModel::columnCount(const QModelIndex &index) const { // Q_UNUSED(index); - return m_childItems.value(index.internalId()).size(); + return m_childItems.value(index.internalId()).size(); } QVariant DynamicTreeModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - return QVariant(); + if (!index.isValid()) { + return QVariant(); + } - if (Qt::DisplayRole == role) - { - return m_items.value(index.internalId()); - } - return QVariant(); + if (Qt::DisplayRole == role) { + return m_items.value(index.internalId()); + } + return QVariant(); } void DynamicTreeModel::clear() { - beginResetModel(); - m_items.clear(); - m_childItems.clear(); - nextId = 1; - endResetModel(); + beginResetModel(); + m_items.clear(); + m_childItems.clear(); + nextId = 1; + endResetModel(); } - -ModelChangeCommand::ModelChangeCommand( DynamicTreeModel *model, QObject *parent ) +ModelChangeCommand::ModelChangeCommand(DynamicTreeModel *model, QObject *parent) : QObject(parent), m_model(model), m_numCols(1), m_startRow(-1), m_endRow(-1) { @@ -183,18 +187,17 @@ ModelChangeCommand::ModelChangeCommand( DynamicTreeModel *model, QObject *parent QModelIndex ModelChangeCommand::findIndex(QList rows) { - const int col = 0; - QModelIndex parent = QModelIndex(); - QListIterator i(rows); - while (i.hasNext()) - { - parent = m_model->index(i.next(), col, parent); - Q_ASSERT(parent.isValid()); - } - return parent; + const int col = 0; + QModelIndex parent = QModelIndex(); + QListIterator i(rows); + while (i.hasNext()) { + parent = m_model->index(i.next(), col, parent); + Q_ASSERT(parent.isValid()); + } + return parent; } -ModelInsertCommand::ModelInsertCommand(DynamicTreeModel *model, QObject *parent ) +ModelInsertCommand::ModelInsertCommand(DynamicTreeModel *model, QObject *parent) : ModelChangeCommand(model, parent) { @@ -202,38 +205,34 @@ ModelInsertCommand::ModelInsertCommand(DynamicTreeModel *model, QObject *parent void ModelInsertCommand::doCommand() { - QModelIndex parent = findIndex(m_rowNumbers); - m_model->beginInsertRows(parent, m_startRow, m_endRow); - qint64 parentId = parent.internalId(); - for (int row = m_startRow; row <= m_endRow; row++) - { - for(int col = 0; col < m_numCols; col++ ) - { - if (m_model->m_childItems[parentId].size() <= col) - { - m_model->m_childItems[parentId].append(QList()); - } + QModelIndex parent = findIndex(m_rowNumbers); + m_model->beginInsertRows(parent, m_startRow, m_endRow); + qint64 parentId = parent.internalId(); + for (int row = m_startRow; row <= m_endRow; row++) { + for (int col = 0; col < m_numCols; col++) { + if (m_model->m_childItems[parentId].size() <= col) { + m_model->m_childItems[parentId].append(QList()); + } // QString name = QUuid::createUuid().toString(); - qint64 id = m_model->newId(); - QString name = QString::number(id); + qint64 id = m_model->newId(); + QString name = QString::number(id); - m_model->m_items.insert(id, name); - m_model->m_childItems[parentId][col].insert(row, id); + m_model->m_items.insert(id, name); + m_model->m_childItems[parentId][col].insert(row, id); + } } - } - m_model->endInsertRows(); + m_model->endInsertRows(); } - ModelMoveCommand::ModelMoveCommand(DynamicTreeModel *model, QObject *parent) - : ModelChangeCommand(model, parent) + : ModelChangeCommand(model, parent) { } bool ModelMoveCommand::emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow) { - return m_model->beginMoveRows(srcParent, srcStart, srcEnd, destParent, destRow); + return m_model->beginMoveRows(srcParent, srcStart, srcEnd, destParent, destRow); } void ModelMoveCommand::doCommand() @@ -241,32 +240,28 @@ void ModelMoveCommand::doCommand() QModelIndex srcParent = findIndex(m_rowNumbers); QModelIndex destParent = findIndex(m_destRowNumbers); - if (!emitPreSignal(srcParent, m_startRow, m_endRow, destParent, m_destRow)) - { + if (!emitPreSignal(srcParent, m_startRow, m_endRow, destParent, m_destRow)) { return; } - for (int column = 0; column < m_numCols; ++column) - { - QList l = m_model->m_childItems.value(srcParent.internalId())[column].mid(m_startRow, m_endRow - m_startRow + 1 ); + for (int column = 0; column < m_numCols; ++column) { + QList l = m_model->m_childItems.value(srcParent.internalId())[column].mid(m_startRow, m_endRow - m_startRow + 1); - for (int i = m_startRow; i <= m_endRow ; i++) - { + for (int i = m_startRow; i <= m_endRow; i++) { m_model->m_childItems[srcParent.internalId()][column].removeAt(m_startRow); } int d; - if (m_destRow < m_startRow) + if (m_destRow < m_startRow) { d = m_destRow; - else - { - if (srcParent == destParent) + } else { + if (srcParent == destParent) { d = m_destRow - (m_endRow - m_startRow + 1); - else + } else { d = m_destRow - (m_endRow - m_startRow) + 1; + } } - foreach(const qint64 id, l) - { + foreach (const qint64 id, l) { m_model->m_childItems[destParent.internalId()][column].insert(d++, id); } } @@ -279,8 +274,8 @@ void ModelMoveCommand::emitPostSignal() m_model->endMoveRows(); } -ModelResetCommand::ModelResetCommand(DynamicTreeModel* model, QObject* parent) - : ModelMoveCommand(model, parent) +ModelResetCommand::ModelResetCommand(DynamicTreeModel *model, QObject *parent) + : ModelMoveCommand(model, parent) { } @@ -306,8 +301,8 @@ void ModelResetCommand::emitPostSignal() m_model->reset(); } -ModelResetCommandFixed::ModelResetCommandFixed(DynamicTreeModel* model, QObject* parent) - : ModelMoveCommand(model, parent) +ModelResetCommandFixed::ModelResetCommandFixed(DynamicTreeModel *model, QObject *parent) + : ModelMoveCommand(model, parent) { } diff --git a/autotests/dynamictreemodel.h b/autotests/dynamictreemodel.h index 122d80401..283d6ed3f 100644 --- a/autotests/dynamictreemodel.h +++ b/autotests/dynamictreemodel.h @@ -47,118 +47,136 @@ #include #include - class DynamicTreeModel : public QAbstractItemModel { - Q_OBJECT + Q_OBJECT public: - DynamicTreeModel(QObject *parent = 0); + DynamicTreeModel(QObject *parent = 0); - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &index = QModelIndex()) const; - int columnCount(const QModelIndex &index = QModelIndex()) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &index = QModelIndex()) const; + int columnCount(const QModelIndex &index = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - void clear(); + void clear(); protected Q_SLOTS: - /** - Finds the parent id of the string with id @p searchId. + /** + Finds the parent id of the string with id @p searchId. - Returns -1 if not found. - */ - qint64 findParentId(qint64 searchId) const; + Returns -1 if not found. + */ + qint64 findParentId(qint64 searchId) const; private: - QHash m_items; - QHash > > m_childItems; - qint64 nextId; - qint64 newId() { return nextId++; }; + QHash m_items; + QHash > > m_childItems; + qint64 nextId; + qint64 newId() + { + return nextId++; + }; - QModelIndex m_nextParentIndex; - int m_nextRow; + QModelIndex m_nextParentIndex; + int m_nextRow; - int m_depth; - int maxDepth; + int m_depth; + int maxDepth; - friend class ModelInsertCommand; - friend class ModelMoveCommand; - friend class ModelResetCommand; - friend class ModelResetCommandFixed; + friend class ModelInsertCommand; + friend class ModelMoveCommand; + friend class ModelResetCommand; + friend class ModelResetCommandFixed; }; - class ModelChangeCommand : public QObject { - Q_OBJECT + Q_OBJECT public: - explicit ModelChangeCommand( DynamicTreeModel *model, QObject *parent = 0 ); + explicit ModelChangeCommand(DynamicTreeModel *model, QObject *parent = 0); - virtual ~ModelChangeCommand() {} + virtual ~ModelChangeCommand() {} - void setAncestorRowNumbers(QList rowNumbers) { m_rowNumbers = rowNumbers; } + void setAncestorRowNumbers(QList rowNumbers) + { + m_rowNumbers = rowNumbers; + } - QModelIndex findIndex(QList rows); + QModelIndex findIndex(QList rows); - void setStartRow(int row) { m_startRow = row; } + void setStartRow(int row) + { + m_startRow = row; + } - void setEndRow(int row) { m_endRow = row; } + void setEndRow(int row) + { + m_endRow = row; + } - void setNumCols(int cols) { m_numCols = cols; } + void setNumCols(int cols) + { + m_numCols = cols; + } - virtual void doCommand() = 0; + virtual void doCommand() = 0; protected: - DynamicTreeModel* m_model; - QList m_rowNumbers; - int m_numCols; - int m_startRow; - int m_endRow; + DynamicTreeModel *m_model; + QList m_rowNumbers; + int m_numCols; + int m_startRow; + int m_endRow; }; -typedef QList ModelChangeCommandList; +typedef QList ModelChangeCommandList; class ModelInsertCommand : public ModelChangeCommand { - Q_OBJECT + Q_OBJECT public: - explicit ModelInsertCommand(DynamicTreeModel *model, QObject *parent = 0 ); - virtual ~ModelInsertCommand() {} + explicit ModelInsertCommand(DynamicTreeModel *model, QObject *parent = 0); + virtual ~ModelInsertCommand() {} - virtual void doCommand(); + virtual void doCommand(); }; - class ModelMoveCommand : public ModelChangeCommand { - Q_OBJECT + Q_OBJECT public: - ModelMoveCommand(DynamicTreeModel *model, QObject *parent); + ModelMoveCommand(DynamicTreeModel *model, QObject *parent); - virtual ~ModelMoveCommand() {} + virtual ~ModelMoveCommand() {} - virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); + virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); - virtual void doCommand(); + virtual void doCommand(); - virtual void emitPostSignal(); + virtual void emitPostSignal(); - void setDestAncestors( QList rows ) { m_destRowNumbers = rows; } + void setDestAncestors(QList rows) + { + m_destRowNumbers = rows; + } - void setDestRow(int row) { m_destRow = row; } + void setDestRow(int row) + { + m_destRow = row; + } protected: - QList m_destRowNumbers; - int m_destRow; + QList m_destRowNumbers; + int m_destRow; }; /** @@ -166,14 +184,14 @@ protected: */ class ModelResetCommand : public ModelMoveCommand { - Q_OBJECT + Q_OBJECT public: - explicit ModelResetCommand(DynamicTreeModel* model, QObject* parent = 0); + explicit ModelResetCommand(DynamicTreeModel *model, QObject *parent = 0); - virtual ~ModelResetCommand(); + virtual ~ModelResetCommand(); - virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); - virtual void emitPostSignal(); + virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); + virtual void emitPostSignal(); }; @@ -182,16 +200,15 @@ public: */ class ModelResetCommandFixed : public ModelMoveCommand { - Q_OBJECT + Q_OBJECT public: - explicit ModelResetCommandFixed(DynamicTreeModel* model, QObject* parent = 0); + explicit ModelResetCommandFixed(DynamicTreeModel *model, QObject *parent = 0); - virtual ~ModelResetCommandFixed(); + virtual ~ModelResetCommandFixed(); - virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); - virtual void emitPostSignal(); + virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); + virtual void emitPostSignal(); }; - #endif diff --git a/autotests/modeltest.cpp b/autotests/modeltest.cpp index 88677cc88..a69b51f1a 100644 --- a/autotests/modeltest.cpp +++ b/autotests/modeltest.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include #include "modeltest.h" @@ -48,61 +47,62 @@ //#undef Q_ASSERT //#define Q_ASSERT QVERIFY -Q_DECLARE_METATYPE ( QModelIndex ) +Q_DECLARE_METATYPE(QModelIndex) /*! Connect to all of the models signals. Whenever anything happens recheck everything. */ -ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false ) +ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(parent), model(_model), fetchingMore(false) { - Q_ASSERT ( model ); + Q_ASSERT(model); - connect ( model, SIGNAL (columnsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (columnsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (columnsInserted(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (columnsRemoved(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (dataChanged(QModelIndex,QModelIndex)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (headerDataChanged(Qt::Orientation,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (layoutAboutToBeChanged()), this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (layoutChanged()), this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (modelReset()), this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (rowsInserted(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); - connect ( model, SIGNAL (rowsRemoved(QModelIndex,int,int)), - this, SLOT (runAllTests()) ); + connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(columnsInserted(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests())); + connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests())); + connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(runAllTests())); // Special checks for inserting/removing - connect ( model, SIGNAL (layoutAboutToBeChanged()), - this, SLOT (layoutAboutToBeChanged()) ); - connect ( model, SIGNAL (layoutChanged()), - this, SLOT (layoutChanged()) ); + connect(model, SIGNAL(layoutAboutToBeChanged()), + this, SLOT(layoutAboutToBeChanged())); + connect(model, SIGNAL(layoutChanged()), + this, SLOT(layoutChanged())); - connect ( model, SIGNAL (rowsAboutToBeInserted(QModelIndex,int,int)), - this, SLOT (rowsAboutToBeInserted(QModelIndex,int,int)) ); - connect ( model, SIGNAL (rowsAboutToBeRemoved(QModelIndex,int,int)), - this, SLOT (rowsAboutToBeRemoved(QModelIndex,int,int)) ); - connect ( model, SIGNAL (rowsInserted(QModelIndex,int,int)), - this, SLOT (rowsInserted(QModelIndex,int,int)) ); - connect ( model, SIGNAL (rowsRemoved(QModelIndex,int,int)), - this, SLOT (rowsRemoved(QModelIndex,int,int)) ); + connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); + connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), + this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(rowsInserted(QModelIndex,int,int))); + connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), + this, SLOT(rowsRemoved(QModelIndex,int,int))); runAllTests(); } void ModelTest::runAllTests() { - if ( fetchingMore ) + if (fetchingMore) { return; + } nonDestructiveBasicTest(); rowCount(); columnCount(); @@ -118,32 +118,32 @@ void ModelTest::runAllTests() */ void ModelTest::nonDestructiveBasicTest() { - Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() ); - model->canFetchMore ( QModelIndex() ); - Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 ); - Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() ); + Q_ASSERT(model->buddy(QModelIndex()) == QModelIndex()); + model->canFetchMore(QModelIndex()); + Q_ASSERT(model->columnCount(QModelIndex()) >= 0); + Q_ASSERT(model->data(QModelIndex()) == QVariant()); fetchingMore = true; - model->fetchMore ( QModelIndex() ); + model->fetchMore(QModelIndex()); fetchingMore = false; - Qt::ItemFlags flags = model->flags ( QModelIndex() ); - Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 ); - model->hasChildren ( QModelIndex() ); - model->hasIndex ( 0, 0 ); - model->headerData ( 0, Qt::Horizontal ); - model->index ( 0, 0 ); - model->itemData ( QModelIndex() ); + Qt::ItemFlags flags = model->flags(QModelIndex()); + Q_ASSERT(flags == Qt::ItemIsDropEnabled || flags == 0); + model->hasChildren(QModelIndex()); + model->hasIndex(0, 0); + model->headerData(0, Qt::Horizontal); + model->index(0, 0); + model->itemData(QModelIndex()); QVariant cache; - model->match ( QModelIndex(), -1, cache ); + model->match(QModelIndex(), -1, cache); model->mimeTypes(); - Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() ); - Q_ASSERT ( model->rowCount() >= 0 ); + Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); + Q_ASSERT(model->rowCount() >= 0); QVariant variant; - model->setData ( QModelIndex(), variant, -1 ); - model->setHeaderData ( -1, Qt::Horizontal, QVariant() ); - model->setHeaderData ( 999999, Qt::Horizontal, QVariant() ); + model->setData(QModelIndex(), variant, -1); + model->setHeaderData(-1, Qt::Horizontal, QVariant()); + model->setHeaderData(999999, Qt::Horizontal, QVariant()); QMap roles; - model->sibling ( 0, 0, QModelIndex() ); - model->span ( QModelIndex() ); + model->sibling(0, 0, QModelIndex()); + model->span(QModelIndex()); model->supportedDropActions(); } @@ -156,19 +156,21 @@ void ModelTest::rowCount() { // qDebug() << "rc"; // check top row - QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - int rows = model->rowCount ( topIndex ); - Q_ASSERT ( rows >= 0 ); - if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( topIndex ) == true ); + QModelIndex topIndex = model->index(0, 0, QModelIndex()); + int rows = model->rowCount(topIndex); + Q_ASSERT(rows >= 0); + if (rows > 0) { + Q_ASSERT(model->hasChildren(topIndex) == true); + } - QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex ); - if ( secondLevelIndex.isValid() ) { // not the top level + QModelIndex secondLevelIndex = model->index(0, 0, topIndex); + if (secondLevelIndex.isValid()) { // not the top level // check a row count where parent is valid - rows = model->rowCount ( secondLevelIndex ); - Q_ASSERT ( rows >= 0 ); - if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true ); + rows = model->rowCount(secondLevelIndex); + Q_ASSERT(rows >= 0); + if (rows > 0) { + Q_ASSERT(model->hasChildren(secondLevelIndex) == true); + } } // The models rowCount() is tested more extensively in checkChildren(), @@ -181,13 +183,14 @@ void ModelTest::rowCount() void ModelTest::columnCount() { // check top row - QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - Q_ASSERT ( model->columnCount ( topIndex ) >= 0 ); + QModelIndex topIndex = model->index(0, 0, QModelIndex()); + Q_ASSERT(model->columnCount(topIndex) >= 0); // check a column count where parent is valid - QModelIndex childIndex = model->index ( 0, 0, topIndex ); - if ( childIndex.isValid() ) - Q_ASSERT ( model->columnCount ( childIndex ) >= 0 ); + QModelIndex childIndex = model->index(0, 0, topIndex); + if (childIndex.isValid()) { + Q_ASSERT(model->columnCount(childIndex) >= 0); + } // columnCount() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -200,19 +203,20 @@ void ModelTest::hasIndex() { // qDebug() << "hi"; // Make sure that invalid values returns an invalid index - Q_ASSERT ( model->hasIndex ( -2, -2 ) == false ); - Q_ASSERT ( model->hasIndex ( -2, 0 ) == false ); - Q_ASSERT ( model->hasIndex ( 0, -2 ) == false ); + Q_ASSERT(model->hasIndex(-2, -2) == false); + Q_ASSERT(model->hasIndex(-2, 0) == false); + Q_ASSERT(model->hasIndex(0, -2) == false); int rows = model->rowCount(); int columns = model->columnCount(); // check out of bounds - Q_ASSERT ( model->hasIndex ( rows, columns ) == false ); - Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false ); + Q_ASSERT(model->hasIndex(rows, columns) == false); + Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false); - if ( rows > 0 ) - Q_ASSERT ( model->hasIndex ( 0, 0 ) == true ); + if (rows > 0) { + Q_ASSERT(model->hasIndex(0, 0) == true); + } // hasIndex() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -225,24 +229,25 @@ void ModelTest::index() { // qDebug() << "i"; // Make sure that invalid values returns an invalid index - Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() ); - Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() ); - Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() ); + Q_ASSERT(model->index(-2, -2) == QModelIndex()); + Q_ASSERT(model->index(-2, 0) == QModelIndex()); + Q_ASSERT(model->index(0, -2) == QModelIndex()); int rows = model->rowCount(); int columns = model->columnCount(); - if ( rows == 0 ) + if (rows == 0) { return; + } // Catch off by one errors - Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() ); - Q_ASSERT ( model->index ( 0, 0 ).isValid() == true ); + Q_ASSERT(model->index(rows, columns) == QModelIndex()); + Q_ASSERT(model->index(0, 0).isValid() == true); // Make sure that the same index is *always* returned - QModelIndex a = model->index ( 0, 0 ); - QModelIndex b = model->index ( 0, 0 ); - Q_ASSERT ( a == b ); + QModelIndex a = model->index(0, 0); + QModelIndex b = model->index(0, 0); + Q_ASSERT(a == b); // index() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -256,10 +261,11 @@ void ModelTest::parent() // qDebug() << "p"; // Make sure the model wont crash and will return an invalid QModelIndex // when asked for the parent of an invalid index. - Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() ); + Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); - if ( model->rowCount() == 0 ) + if (model->rowCount() == 0) { return; + } // Column 0 | Column 1 | // QModelIndex() | | @@ -268,29 +274,29 @@ void ModelTest::parent() // Common error test #1, make sure that a top level index has a parent // that is a invalid QModelIndex. - QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() ); + QModelIndex topIndex = model->index(0, 0, QModelIndex()); + Q_ASSERT(model->parent(topIndex) == QModelIndex()); // Common error test #2, make sure that a second level index has a parent // that is the first level index. - if ( model->rowCount ( topIndex ) > 0 ) { - QModelIndex childIndex = model->index ( 0, 0, topIndex ); - Q_ASSERT ( model->parent ( childIndex ) == topIndex ); + if (model->rowCount(topIndex) > 0) { + QModelIndex childIndex = model->index(0, 0, topIndex); + Q_ASSERT(model->parent(childIndex) == topIndex); } // Common error test #3, the second column should NOT have the same children // as the first column in a row. // Usually the second column shouldn't have children. - QModelIndex topIndex1 = model->index ( 0, 1, QModelIndex() ); - if ( model->rowCount ( topIndex1 ) > 0 ) { - QModelIndex childIndex = model->index ( 0, 0, topIndex ); - QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 ); - Q_ASSERT ( childIndex != childIndex1 ); + QModelIndex topIndex1 = model->index(0, 1, QModelIndex()); + if (model->rowCount(topIndex1) > 0) { + QModelIndex childIndex = model->index(0, 0, topIndex); + QModelIndex childIndex1 = model->index(0, 0, topIndex1); + Q_ASSERT(childIndex != childIndex1); } // Full test, walk n levels deep through the model making sure that all // parent's children correctly specify their parent. - checkChildren ( QModelIndex() ); + checkChildren(QModelIndex()); } /*! @@ -307,62 +313,65 @@ void ModelTest::parent() found the basic bugs because it is easier to figure out the problem in those tests then this one. */ -void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) +void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) { // First just try walking back up the tree. QModelIndex p = parent; - while ( p.isValid() ) + while (p.isValid()) { p = p.parent(); + } // For models that are dynamically populated - if ( model->canFetchMore ( parent ) ) { + if (model->canFetchMore(parent)) { fetchingMore = true; - model->fetchMore ( parent ); + model->fetchMore(parent); fetchingMore = false; } - int rows = model->rowCount ( parent ); - int columns = model->columnCount ( parent ); + int rows = model->rowCount(parent); + int columns = model->columnCount(parent); - if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( parent ) ); + if (rows > 0) { + Q_ASSERT(model->hasChildren(parent)); + } // Some further testing against rows(), columns(), and hasChildren() - Q_ASSERT ( rows >= 0 ); - Q_ASSERT ( columns >= 0 ); - if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( parent ) == true ); + Q_ASSERT(rows >= 0); + Q_ASSERT(columns >= 0); + if (rows > 0) { + Q_ASSERT(model->hasChildren(parent) == true); + } //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows // << "columns:" << columns << "parent column:" << parent.column(); - Q_ASSERT ( model->hasIndex ( rows + 1, 0, parent ) == false ); - for ( int r = 0; r < rows; ++r ) { - if ( model->canFetchMore ( parent ) ) { + Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false); + for (int r = 0; r < rows; ++r) { + if (model->canFetchMore(parent)) { fetchingMore = true; - model->fetchMore ( parent ); + model->fetchMore(parent); fetchingMore = false; } - Q_ASSERT ( model->hasIndex ( r, columns + 1, parent ) == false ); - for ( int c = 0; c < columns; ++c ) { - Q_ASSERT ( model->hasIndex ( r, c, parent ) == true ); - QModelIndex index = model->index ( r, c, parent ); + Q_ASSERT(model->hasIndex(r, columns + 1, parent) == false); + for (int c = 0; c < columns; ++c) { + Q_ASSERT(model->hasIndex(r, c, parent) == true); + QModelIndex index = model->index(r, c, parent); // rowCount() and columnCount() said that it existed... - Q_ASSERT ( index.isValid() == true ); + Q_ASSERT(index.isValid() == true); // index() should always return the same index when called twice in a row - QModelIndex modifiedIndex = model->index ( r, c, parent ); - Q_ASSERT ( index == modifiedIndex ); + QModelIndex modifiedIndex = model->index(r, c, parent); + Q_ASSERT(index == modifiedIndex); // Make sure we get the same index if we request it twice in a row - QModelIndex a = model->index ( r, c, parent ); - QModelIndex b = model->index ( r, c, parent ); - Q_ASSERT ( a == b ); + QModelIndex a = model->index(r, c, parent); + QModelIndex b = model->index(r, c, parent); + Q_ASSERT(a == b); // Some basic checking on the index that is returned - Q_ASSERT ( index.model() == model ); - Q_ASSERT ( index.row() == r ); - Q_ASSERT ( index.column() == c ); + Q_ASSERT(index.model() == model); + Q_ASSERT(index.row() == r); + Q_ASSERT(index.column() == c); // While you can technically return a QVariant usually this is a sign // of an bug in data() Disable if this really is ok in your model. // Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true ); @@ -381,17 +390,17 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) // Check that we can get back our real parent. // qDebug() << model->parent ( index ) << parent ; - Q_ASSERT ( model->parent ( index ) == parent ); + Q_ASSERT(model->parent(index) == parent); // recursively go down the children - if ( model->hasChildren ( index ) && currentDepth < 10 ) { + if (model->hasChildren(index) && currentDepth < 10) { //qDebug() << r << c << "has children" << model->rowCount(index); - checkChildren ( index, ++currentDepth ); + checkChildren(index, ++currentDepth); }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/ // make sure that after testing the children that the index doesn't change. - QModelIndex newerIndex = model->index ( r, c, parent ); - Q_ASSERT ( index == newerIndex ); + QModelIndex newerIndex = model->index(r, c, parent); + Q_ASSERT(index == newerIndex); } } } @@ -402,68 +411,69 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) void ModelTest::data() { // Invalid index should return an invalid qvariant - Q_ASSERT ( !model->data ( QModelIndex() ).isValid() ); + Q_ASSERT(!model->data(QModelIndex()).isValid()); - if ( model->rowCount() == 0 ) + if (model->rowCount() == 0) { return; + } // A valid index should have a valid QVariant data - Q_ASSERT ( model->index ( 0, 0 ).isValid() ); + Q_ASSERT(model->index(0, 0).isValid()); // shouldn't be able to set data on an invalid index - Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false ); + Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole) == false); // General Purpose roles that should return a QString - QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole ); - if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( variant ) ); + QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); + if (variant.isValid()) { + Q_ASSERT(qVariantCanConvert (variant)); } - variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole ); - if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( variant ) ); + variant = model->data(model->index(0, 0), Qt::StatusTipRole); + if (variant.isValid()) { + Q_ASSERT(qVariantCanConvert (variant)); } - variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole ); - if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( variant ) ); + variant = model->data(model->index(0, 0), Qt::WhatsThisRole); + if (variant.isValid()) { + Q_ASSERT(qVariantCanConvert (variant)); } // General Purpose roles that should return a QSize - variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole ); - if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( variant ) ); + variant = model->data(model->index(0, 0), Qt::SizeHintRole); + if (variant.isValid()) { + Q_ASSERT(qVariantCanConvert (variant)); } // General Purpose roles that should return a QFont - QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole ); - if ( fontVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( fontVariant ) ); + QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole); + if (fontVariant.isValid()) { + Q_ASSERT(qVariantCanConvert (fontVariant)); } // Check that the alignment is one we know about - QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole ); - if ( textAlignmentVariant.isValid() ) { + QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole); + if (textAlignmentVariant.isValid()) { int alignment = textAlignmentVariant.toInt(); - Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); + Q_ASSERT(alignment == (alignment & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask))); } // General Purpose roles that should return a QColor - QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); - if ( colorVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( colorVariant ) ); + QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole); + if (colorVariant.isValid()) { + Q_ASSERT(qVariantCanConvert (colorVariant)); } - colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); - if ( colorVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert ( colorVariant ) ); + colorVariant = model->data(model->index(0, 0), Qt::TextColorRole); + if (colorVariant.isValid()) { + Q_ASSERT(qVariantCanConvert (colorVariant)); } // Check that the "check state" is one we know about. - QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole ); - if ( checkStateVariant.isValid() ) { + QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole); + if (checkStateVariant.isValid()) { int state = checkStateVariant.toInt(); - Q_ASSERT ( state == Qt::Unchecked || - state == Qt::PartiallyChecked || - state == Qt::Checked ); + Q_ASSERT(state == Qt::Unchecked || + state == Qt::PartiallyChecked || + state == Qt::Checked); } } @@ -472,7 +482,7 @@ void ModelTest::data() \sa rowsInserted() */ -void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end ) +void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) { // Q_UNUSED(end); // qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).toString() @@ -480,10 +490,10 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in // qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) ); Changing c; c.parent = parent; - c.oldSize = model->rowCount ( parent ); - c.last = model->data ( model->index ( start - 1, 0, parent ) ); - c.next = model->data ( model->index ( start, 0, parent ) ); - insert.push ( c ); + c.oldSize = model->rowCount(parent); + c.last = model->data(model->index(start - 1, 0, parent)); + c.next = model->data(model->index(start, 0, parent)); + insert.push(c); } /*! @@ -491,10 +501,10 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in \sa rowsAboutToBeInserted() */ -void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) +void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end) { Changing c = insert.pop(); - Q_ASSERT ( c.parent == parent ); + Q_ASSERT(c.parent == parent); // qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize // << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); @@ -504,30 +514,32 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) // } // qDebug(); - Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); - Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); + Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent)); + Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); if (c.next != model->data(model->index(end + 1, 0, c.parent))) { qDebug() << start << end; - for (int i=0; i < model->rowCount(); ++i) + for (int i = 0; i < model->rowCount(); ++i) { qDebug() << model->index(i, 0).data().toString(); + } qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); } - Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) ); + Q_ASSERT(c.next == model->data(model->index(end + 1, 0, c.parent))); } void ModelTest::layoutAboutToBeChanged() { - for ( int i = 0; i < qBound ( 0, model->rowCount(), 100 ); ++i ) - changing.append ( QPersistentModelIndex ( model->index ( i, 0 ) ) ); + for (int i = 0; i < qBound(0, model->rowCount(), 100); ++i) { + changing.append(QPersistentModelIndex(model->index(i, 0))); + } } void ModelTest::layoutChanged() { - for ( int i = 0; i < changing.count(); ++i ) { + for (int i = 0; i < changing.count(); ++i) { QPersistentModelIndex p = changing[i]; - Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) ); + Q_ASSERT(p == model->index(p.row(), p.column(), p.parent())); } changing.clear(); } @@ -537,15 +549,15 @@ void ModelTest::layoutChanged() \sa rowsRemoved() */ -void ModelTest::rowsAboutToBeRemoved ( const QModelIndex &parent, int start, int end ) +void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { -qDebug() << "ratbr" << parent << start << end; + qDebug() << "ratbr" << parent << start << end; Changing c; c.parent = parent; - c.oldSize = model->rowCount ( parent ); - c.last = model->data ( model->index ( start - 1, 0, parent ) ); - c.next = model->data ( model->index ( end + 1, 0, parent ) ); - remove.push ( c ); + c.oldSize = model->rowCount(parent); + c.last = model->data(model->index(start - 1, 0, parent)); + c.next = model->data(model->index(end + 1, 0, parent)); + remove.push(c); } /*! @@ -553,14 +565,13 @@ qDebug() << "ratbr" << parent << start << end; \sa rowsAboutToBeRemoved() */ -void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end ) +void ModelTest::rowsRemoved(const QModelIndex &parent, int start, int end) { - qDebug() << "rr" << parent << start << end; + qDebug() << "rr" << parent << start << end; Changing c = remove.pop(); - Q_ASSERT ( c.parent == parent ); - Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) ); - Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); - Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) ); + Q_ASSERT(c.parent == parent); + Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent)); + Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); + Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent))); } - diff --git a/autotests/modeltest.h b/autotests/modeltest.h index f042ed2c5..9b1eaadc3 100644 --- a/autotests/modeltest.h +++ b/autotests/modeltest.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #ifndef MODELTEST_H #define MODELTEST_H @@ -49,46 +48,46 @@ class ModelTest : public QObject { - Q_OBJECT + Q_OBJECT public: - explicit ModelTest( QAbstractItemModel *model, QObject *parent = 0 ); + explicit ModelTest(QAbstractItemModel *model, QObject *parent = 0); private Q_SLOTS: - void nonDestructiveBasicTest(); - void rowCount(); - void columnCount(); - void hasIndex(); - void index(); - void parent(); - void data(); + void nonDestructiveBasicTest(); + void rowCount(); + void columnCount(); + void hasIndex(); + void index(); + void parent(); + void data(); protected Q_SLOTS: - void runAllTests(); - void layoutAboutToBeChanged(); - void layoutChanged(); - void rowsAboutToBeInserted( const QModelIndex &parent, int start, int end ); - void rowsInserted( const QModelIndex & parent, int start, int end ); - void rowsAboutToBeRemoved( const QModelIndex &parent, int start, int end ); - void rowsRemoved( const QModelIndex & parent, int start, int end ); + void runAllTests(); + void layoutAboutToBeChanged(); + void layoutChanged(); + void rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); + void rowsInserted(const QModelIndex &parent, int start, int end); + void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); + void rowsRemoved(const QModelIndex &parent, int start, int end); private: - void checkChildren( const QModelIndex &parent, int currentDepth = 0 ); + void checkChildren(const QModelIndex &parent, int currentDepth = 0); - QAbstractItemModel *model; + QAbstractItemModel *model; - struct Changing { - QModelIndex parent; - int oldSize; - QVariant last; - QVariant next; - }; - QStack insert; - QStack remove; + struct Changing { + QModelIndex parent; + int oldSize; + QVariant last; + QVariant next; + }; + QStack insert; + QStack remove; - bool fetchingMore; + bool fetchingMore; - QList changing; + QList changing; }; #endif diff --git a/autotests/packagestructuretest.cpp b/autotests/packagestructuretest.cpp index f59f04250..d0852d2f3 100644 --- a/autotests/packagestructuretest.cpp +++ b/autotests/packagestructuretest.cpp @@ -42,7 +42,6 @@ public: } }; - void PackageStructureTest::initTestCase() { m_packagePath = QFINDTESTDATA("data/testpackage"); @@ -82,10 +81,10 @@ void PackageStructureTest::multiplePaths() void PackageStructureTest::directories() { - QList dirs; + QList dirs; dirs << "config" << "data" << "images" << "theme" << "scripts" << "translations" << "ui"; - QList psDirs = ps.directories(); + QList psDirs = ps.directories(); QCOMPARE(dirs.count(), psDirs.count()); @@ -114,16 +113,16 @@ void PackageStructureTest::directories() void PackageStructureTest::requiredDirectories() { - QList dirs; + QList dirs; QCOMPARE(ps.requiredDirectories(), dirs); } void PackageStructureTest::files() { - QList files; + QList files; files << "mainconfigui" << "mainconfigxml" << "mainscript"; - QList psFiles = ps.files(); + QList psFiles = ps.files(); //for (int i = 0; i < psFiles.count(); ++i) { // qDebug() << psFiles[i]; @@ -142,10 +141,10 @@ void PackageStructureTest::files() void PackageStructureTest::requiredFiles() { - QList files; + QList files; files << "mainscript"; - QList psFiles = ps.requiredFiles(); + QList psFiles = ps.requiredFiles(); QCOMPARE(files.count(), psFiles.count()); for (int i = 0; i < files.count(); ++i) { @@ -181,4 +180,3 @@ void PackageStructureTest::mimeTypes() QTEST_MAIN(PackageStructureTest) - diff --git a/autotests/packageurlinterceptortest.h b/autotests/packageurlinterceptortest.h index 7255da8cd..303554881 100644 --- a/autotests/packageurlinterceptortest.h +++ b/autotests/packageurlinterceptortest.h @@ -25,11 +25,11 @@ class PackageUrlInterceptorTest : public QObject { Q_OBJECT - public: - PackageUrlInterceptorTest() {} +public: + PackageUrlInterceptorTest() {} - private Q_SLOTS: - void loadAccessManager(); +private Q_SLOTS: + void loadAccessManager(); }; #endif diff --git a/autotests/plasmoidpackagetest.cpp b/autotests/plasmoidpackagetest.cpp index 6698a86a2..c000b4b59 100644 --- a/autotests/plasmoidpackagetest.cpp +++ b/autotests/plasmoidpackagetest.cpp @@ -90,7 +90,6 @@ void PlasmoidPackageTest::createTestPackage(const QString &packageName) file.flush(); file.close(); - qDebug() << "THIS IS A PLASMOID SCRIPT THING"; // Now we have a minimal plasmoid package which is valid. Let's add some // files to it for test purposes. @@ -274,31 +273,29 @@ void PlasmoidPackageTest::createAndInstallPackage() qDebug() << "Installing " << archivePath; //const QString packageRoot = "plasma/plasmoids/"; //const QString servicePrefix = "plasma-applet-"; - KJob* job = p->install(archivePath, m_packageRoot); + KJob *job = p->install(archivePath, m_packageRoot); connect(job, SIGNAL(finished(KJob*)), SLOT(packageInstalled(KJob*))); //QVERIFY(p->isValid()); delete p; } -void PlasmoidPackageTest::packageInstalled(KJob* j) +void PlasmoidPackageTest::packageInstalled(KJob *j) { qDebug() << "!!!!!!!!!!!!!!!!!!!! package installed" << (j->error() == KJob::NoError); QVERIFY(j->error() == KJob::NoError); //QVERIFY(p->path()); Plasma::Package *p = new Plasma::Package(m_defaultPackageStructure); - KJob* jj = p->uninstall("org.kde.microblog-qml", m_packageRoot); + KJob *jj = p->uninstall("org.kde.microblog-qml", m_packageRoot); //QObject::disconnect(j, SIGNAL(finished(KJob*)), this, SLOT(packageInstalled(KJob*))); connect(jj, SIGNAL(finished(KJob*)), SLOT(packageInstalled(KJob*))); } - -void PlasmoidPackageTest::packageUninstalled(KJob* j) +void PlasmoidPackageTest::packageUninstalled(KJob *j) { qDebug() << "!!!!!!!!!!!!!!!!!!!!! package uninstalled"; QVERIFY(j->error() == KJob::NoError); } - QTEST_MAIN(PlasmoidPackageTest) diff --git a/autotests/plasmoidpackagetest.h b/autotests/plasmoidpackagetest.h index 6c6b9f45c..6c475ba94 100644 --- a/autotests/plasmoidpackagetest.h +++ b/autotests/plasmoidpackagetest.h @@ -39,17 +39,17 @@ private Q_SLOTS: void filePath(); void entryList(); - void packageInstalled(KJob* j); - void packageUninstalled(KJob* j); + void packageInstalled(KJob *j); + void packageUninstalled(KJob *j); private: void createTestPackage(const QString &packageName); QString m_packageRoot; QString m_package; - KJob* m_packageJob; + KJob *m_packageJob; Plasma::Package m_defaultPackage; - Plasma::PackageStructure* m_defaultPackageStructure; + Plasma::PackageStructure *m_defaultPackageStructure; }; #endif diff --git a/autotests/pluginloadertest.cpp b/autotests/pluginloadertest.cpp index 991493717..868d5f861 100644 --- a/autotests/pluginloadertest.cpp +++ b/autotests/pluginloadertest.cpp @@ -75,6 +75,5 @@ void PluginTest::loadDataEngine() } - #include "moc_pluginloadertest.cpp" diff --git a/autotests/pluginloadertest.h b/autotests/pluginloadertest.h index 88a6c03ff..61fc96305 100644 --- a/autotests/pluginloadertest.h +++ b/autotests/pluginloadertest.h @@ -25,18 +25,18 @@ class PluginTest : public QObject { Q_OBJECT - public: - PluginTest() {} +public: + PluginTest() {} - private Q_SLOTS: - void listEngines(); - void listAppletCategories(); - void listContainmentActions(); - void listContainmentsOfType(); +private Q_SLOTS: + void listEngines(); + void listAppletCategories(); + void listContainmentActions(); + void listContainmentsOfType(); - void loadDataEngine(); + void loadDataEngine(); - private: +private: }; #endif diff --git a/autotests/sortfiltermodeltest.cpp b/autotests/sortfiltermodeltest.cpp index 0c8dafbb7..f23c5a7d4 100644 --- a/autotests/sortfiltermodeltest.cpp +++ b/autotests/sortfiltermodeltest.cpp @@ -43,7 +43,7 @@ void SortFilterModelTest::setModel() filterModel.setModel(&model); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); - QCOMPARE(arguments.at(0).value(), static_cast(&model)); + QCOMPARE(arguments.at(0).value(), static_cast(&model)); filterModel.setModel(&model); QCOMPARE(spy.count(), 0); @@ -54,9 +54,9 @@ void SortFilterModelTest::setEmptyModel() SortFilterModel filterModel; QStandardItemModel model; filterModel.setModel(&model); - QCOMPARE(filterModel.sourceModel(), static_cast(&model)); + QCOMPARE(filterModel.sourceModel(), static_cast(&model)); filterModel.setModel(0); - QCOMPARE(filterModel.sourceModel(), static_cast(0)); + QCOMPARE(filterModel.sourceModel(), static_cast(0)); } void SortFilterModelTest::setFilterRegExp() diff --git a/autotests/storagetest.h b/autotests/storagetest.h index da1f1c493..1fc3e3eac 100644 --- a/autotests/storagetest.h +++ b/autotests/storagetest.h @@ -34,7 +34,6 @@ private Q_SLOTS: void retrieve(); void deleteEntry(); - private: QVariantMap m_data; }; diff --git a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp index 42b20b72b..13e682e3d 100644 --- a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp +++ b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp @@ -31,7 +31,7 @@ #include "httpContainer.h" /* - This DataEngine shows how to use a subclass of DataContainer to create and + This DataEngine shows how to use a subclass of DataContainer to create and manage sources. This is particularly useful when managing asynchronous requests, such as sources that reflect network, D-Bus, etc. results. */ diff --git a/examples/dataengines/customDataContainers/httpContainer.h b/examples/dataengines/customDataContainers/httpContainer.h index 24e5db72c..1e6e3a206 100644 --- a/examples/dataengines/customDataContainers/httpContainer.h +++ b/examples/dataengines/customDataContainers/httpContainer.h @@ -32,7 +32,7 @@ namespace KIO { - class Job; +class Job; }; class HttpContainer : public Plasma::DataContainer diff --git a/examples/kpart/appletselector.cpp b/examples/kpart/appletselector.cpp index 87263a975..5c6cef5c2 100644 --- a/examples/kpart/appletselector.cpp +++ b/examples/kpart/appletselector.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright 2010 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or @@ -23,13 +23,13 @@ #include #include -AppletSelector::AppletSelector(QObject* parent, const QVariantList& args) +AppletSelector::AppletSelector(QObject *parent, const QVariantList &args) : KDialog() { Q_UNUSED(args); setButtons(Close); - QWidget* w = new QWidget(this); + QWidget *w = new QWidget(this); m_ui = new Ui::AppletSelector; m_ui->setupUi(w); @@ -38,13 +38,13 @@ AppletSelector::AppletSelector(QObject* parent, const QVariantList& args) setMainWidget(w); - QStandardItemModel* model = new QStandardItemModel(this); - const KPluginInfo::List list= Plasma::Applet::listAppletInfo(); - foreach(const KPluginInfo& info, list) { - QStandardItem* item = new QStandardItem(KIcon(info.icon()), info.name()); + QStandardItemModel *model = new QStandardItemModel(this); + const KPluginInfo::List list = Plasma::Applet::listAppletInfo(); + foreach (const KPluginInfo &info, list) { + QStandardItem *item = new QStandardItem(KIcon(info.icon()), info.name()); item->setEditable(false); item->setToolTip(info.comment()); - item->setData(info.pluginName(), Qt::UserRole+1); + item->setData(info.pluginName(), Qt::UserRole + 1); model->appendRow(item); } @@ -59,9 +59,9 @@ AppletSelector::~AppletSelector() delete m_ui; } -void AppletSelector::selected(const QModelIndex& idx) +void AppletSelector::selected(const QModelIndex &idx) { - emit addApplet(idx.data(Qt::UserRole+1).toString()); + emit addApplet(idx.data(Qt::UserRole + 1).toString()); } #include "appletselector.moc" diff --git a/examples/kpart/appletselector.h b/examples/kpart/appletselector.h index b646b359e..166c410f2 100644 --- a/examples/kpart/appletselector.h +++ b/examples/kpart/appletselector.h @@ -23,22 +23,25 @@ #include class QModelIndex; -namespace Ui { class AppletSelector; } +namespace Ui +{ +class AppletSelector; +} class AppletSelector : public KDialog { -Q_OBJECT + Q_OBJECT public: - explicit AppletSelector(QObject* parent = 0, const QVariantList& args = QVariantList()); + explicit AppletSelector(QObject *parent = 0, const QVariantList &args = QVariantList()); ~AppletSelector(); public slots: - void selected(const QModelIndex& idx); + void selected(const QModelIndex &idx); signals: - void addApplet(const QString& name); + void addApplet(const QString &name); private: - Ui::AppletSelector* m_ui; + Ui::AppletSelector *m_ui; }; #endif // APPLETSELECTOR_H diff --git a/examples/kpart/containmentshell.cpp b/examples/kpart/containmentshell.cpp index bdd432fc9..24a1f0aa3 100644 --- a/examples/kpart/containmentshell.cpp +++ b/examples/kpart/containmentshell.cpp @@ -27,13 +27,12 @@ #include #include - #include #include ContainmentShell::ContainmentShell() - : KParts::MainWindow( ), + : KParts::MainWindow(), m_dialog(0) { setXMLFile("plasma-kpart-shellui.rc"); @@ -46,7 +45,7 @@ ContainmentShell::ContainmentShell() // this routine will find and load our Part. it finds the Part by // name which is a bad idea usually.. but it's alright in this // case since our Part is made for this Shell - KService::Ptr service = KService::serviceByDesktopPath( "plasma-kpart.desktop" ); + KService::Ptr service = KService::serviceByDesktopPath("plasma-kpart.desktop"); if (service) { Plasma::PluginLoader *loader = new TestShellPluginLoader(); @@ -86,8 +85,8 @@ ContainmentShell::~ContainmentShell() void ContainmentShell::optionsPreferences() { if (!m_dialog) { - m_dialog = new AppletSelector( m_part ); - connect( m_dialog, SIGNAL(addApplet(QString)), m_part, SLOT(addApplet(QString)) ); + m_dialog = new AppletSelector(m_part); + connect(m_dialog, SIGNAL(addApplet(QString)), m_part, SLOT(addApplet(QString))); } m_dialog->show(); } diff --git a/examples/kpart/containmentshell.h b/examples/kpart/containmentshell.h index 0b4618a35..467eba7fb 100644 --- a/examples/kpart/containmentshell.h +++ b/examples/kpart/containmentshell.h @@ -33,7 +33,7 @@ */ class ContainmentShell : public KParts::MainWindow { -Q_OBJECT + Q_OBJECT public: ContainmentShell(); virtual ~ContainmentShell(); @@ -42,8 +42,8 @@ public Q_SLOTS: void optionsPreferences(); private: - KParts::Part* m_part; - KDialog* m_dialog; + KParts::Part *m_part; + KDialog *m_dialog; }; #endif // CONTAINMENTSHELL_H diff --git a/examples/kpart/main.cpp b/examples/kpart/main.cpp index b6abe516f..c7c7302bb 100644 --- a/examples/kpart/main.cpp +++ b/examples/kpart/main.cpp @@ -23,10 +23,10 @@ static const char version[] = "0.1"; -int main(int argc, char** argv) +int main(int argc, char **argv) { KAboutData about("plasma-kpart-shell", 0, ki18n("Plasma KPart Shell"), version, ki18n("A KDE KPart Application"), KAboutData::License_GPL, ki18n("(C) 2010 Ryan Rix"), KLocalizedString(), 0, "ry@n.rix.si"); - about.addAuthor( ki18n("Ryan Rix"), KLocalizedString(), "ry@n.rix.si" ); + about.addAuthor(ki18n("Ryan Rix"), KLocalizedString(), "ry@n.rix.si"); KCmdLineArgs::init(argc, argv, &about); KApplication app; diff --git a/examples/kpart/testshellpluginloader.cpp b/examples/kpart/testshellpluginloader.cpp index 084f6a32d..fb0b9043f 100644 --- a/examples/kpart/testshellpluginloader.cpp +++ b/examples/kpart/testshellpluginloader.cpp @@ -29,19 +29,19 @@ TestShellPluginLoader::~TestShellPluginLoader() { } -Plasma::Applet* TestShellPluginLoader::internalLoadApplet (const QString &name, uint appletId, const QVariantList &args) +Plasma::Applet *TestShellPluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args) { kDebug() << "loadApplet called with" << name << appletId << args; return 0; } -Plasma::DataEngine* TestShellPluginLoader::internalLoadDataEngine(const QString &name) +Plasma::DataEngine *TestShellPluginLoader::internalLoadDataEngine(const QString &name) { kDebug() << "loadEngine called with" << name; return 0; } -Plasma::Service* TestShellPluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent) +Plasma::Service *TestShellPluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent) { kDebug() << "loadService called with" << name << args << parent; return 0; diff --git a/examples/kpart/testshellpluginloader.h b/examples/kpart/testshellpluginloader.h index 01fd4ae80..b649fa76b 100644 --- a/examples/kpart/testshellpluginloader.h +++ b/examples/kpart/testshellpluginloader.h @@ -26,10 +26,10 @@ class TestShellPluginLoader : public Plasma::PluginLoader public: ~TestShellPluginLoader(); - Plasma::Applet* internalLoadApplet (const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()); - Plasma::DataEngine* internalLoadDataEngine(const QString &name); - Plasma::Service* internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0); + Plasma::Applet *internalLoadApplet(const QString &name, uint appletId = 0, + const QVariantList &args = QVariantList()); + Plasma::DataEngine *internalLoadDataEngine(const QString &name); + Plasma::Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0); }; #endif diff --git a/src/declarativeimports/calendar/calendar.cpp b/src/declarativeimports/calendar/calendar.cpp index b1bf95ac2..422557981 100644 --- a/src/declarativeimports/calendar/calendar.cpp +++ b/src/declarativeimports/calendar/calendar.cpp @@ -19,7 +19,6 @@ #include - #include "calendar.h" Calendar::Calendar(QObject *parent) @@ -35,8 +34,8 @@ Calendar::Calendar(QObject *parent) m_daysModel = new DaysModel(this); m_daysModel->setSourceData(&m_dayList); - // m_dayHelper = new CalendarDayHelper(this); - // connect(m_dayHelper, SIGNAL(calendarChanged()), this, SLOT(updateData())); + // m_dayHelper = new CalendarDayHelper(this); +// connect(m_dayHelper, SIGNAL(calendarChanged()), this, SLOT(updateData())); } QDate Calendar::startDate() const @@ -46,11 +45,11 @@ QDate Calendar::startDate() const void Calendar::setStartDate(const QDate &dateTime) { - if(m_startDate == dateTime) { + if (m_startDate == dateTime) { return; } m_startDate = dateTime; - // m_dayHelper->setDate(m_startDate.year(), m_startDate.month()); + // m_dayHelper->setDate(m_startDate.year(), m_startDate.month()); updateData(); emit startDateChanged(); } @@ -62,8 +61,9 @@ int Calendar::types() const void Calendar::setTypes(int types) { - if (m_types == types) + if (m_types == types) { return; + } // m_types = static_cast(types); // updateTypes(); @@ -78,7 +78,7 @@ int Calendar::days() void Calendar::setDays(int days) { - if(m_days != days) { + if (m_days != days) { m_days = days; updateData(); emit daysChanged(); @@ -92,7 +92,7 @@ int Calendar::weeks() void Calendar::setWeeks(int weeks) { - if(m_weeks != weeks) { + if (m_weeks != weeks) { m_weeks = weeks; updateData(); emit weeksChanged(); @@ -168,7 +168,7 @@ QList Calendar::weeksModel() const void Calendar::updateData() { - if(m_days == 0 || m_weeks == 0) { + if (m_days == 0 || m_weeks == 0) { return; } @@ -182,7 +182,6 @@ void Calendar::updateData() QDate firstDay(m_startDate.year(), m_startDate.month(), 1); - // If the first day is the same as the starting day then we add a complete row before it. if (m_firstDayOfWeek < firstDay.dayOfWeek()) { daysBeforeCurrentMonth = firstDay.dayOfWeek() - m_firstDayOfWeek; @@ -191,48 +190,48 @@ void Calendar::updateData() } int daysThusFar = daysBeforeCurrentMonth + m_startDate.daysInMonth(); - if(daysThusFar < totalDays) { + if (daysThusFar < totalDays) { daysAfterCurrentMonth = totalDays - daysThusFar; } - if(daysBeforeCurrentMonth > 0) { + if (daysBeforeCurrentMonth > 0) { QDate previousMonth = m_startDate.addMonths(-1); //QDate previousMonth(m_startDate.year(), m_startDate.month() - 1, 1); - for(int i = 0; i < daysBeforeCurrentMonth; i++) { + for (int i = 0; i < daysBeforeCurrentMonth; i++) { DayData day; day.isCurrentMonth = false; day.isNextMonth = false; day.isPreviousMonth = true; day.dayNumber = previousMonth.daysInMonth() - (daysBeforeCurrentMonth - (i + 1)); - day.monthNumber =previousMonth.month(); - day.yearNumber =previousMonth.year(); - // day.containsEventItems = false; + day.monthNumber = previousMonth.month(); + day.yearNumber = previousMonth.year(); + // day.containsEventItems = false; m_dayList << day; } } - for(int i = 0; i < m_startDate.daysInMonth(); i++) { + for (int i = 0; i < m_startDate.daysInMonth(); i++) { DayData day; day.isCurrentMonth = true; day.isNextMonth = false; day.isPreviousMonth = false; day.dayNumber = i + 1; // +1 to go form 0 based index to 1 based calendar dates - // day.containsEventItems = m_dayHelper->containsEventItems(i + 1); + // day.containsEventItems = m_dayHelper->containsEventItems(i + 1); day.monthNumber = m_startDate.month(); day.yearNumber = m_startDate.year(); m_dayList << day; - + } - if(daysAfterCurrentMonth > 0) { - for(int i = 0; i < daysAfterCurrentMonth; i++) { + if (daysAfterCurrentMonth > 0) { + for (int i = 0; i < daysAfterCurrentMonth; i++) { DayData day; day.isCurrentMonth = false; day.isNextMonth = true; day.isPreviousMonth = false; day.dayNumber = i + 1; // +1 to go form 0 based index to 1 based calendar dates - // day.containsEventItems = false; - day.monthNumber = m_startDate.addMonths(1).month(); + // day.containsEventItems = false; + day.monthNumber = m_startDate.addMonths(1).month(); day.yearNumber = m_startDate.addMonths(1).year(); m_dayList << day; } @@ -240,12 +239,11 @@ void Calendar::updateData() const int numOfDaysInCalendar = m_dayList.count(); // Fill weeksModel (just a QList) with the week numbers. This needs some tweaking! - for(int i = 0; i < numOfDaysInCalendar; i += 7) { - const DayData& data = m_dayList.at(i); + for (int i = 0; i < numOfDaysInCalendar; i += 7) { + const DayData &data = m_dayList.at(i); m_weekList << QDate(data.yearNumber, data.monthNumber, data.dayNumber).weekNumber(); } - m_daysModel->update(); // qDebug() << "---------------------------------------------------------------"; diff --git a/src/declarativeimports/calendar/calendar.h b/src/declarativeimports/calendar/calendar.h index 264ad35e7..fd2c53497 100644 --- a/src/declarativeimports/calendar/calendar.h +++ b/src/declarativeimports/calendar/calendar.h @@ -27,7 +27,6 @@ #include "daydata.h" #include "daysmodel.h" - class Calendar : public QObject { Q_OBJECT @@ -111,7 +110,7 @@ class Calendar : public QObject * metadata about the current day. The exact metadata can be found in "daysmodel.cpp" * where the exact names usable in QML are being set. */ - Q_PROPERTY(QAbstractListModel* daysModel READ daysModel CONSTANT) + Q_PROPERTY(QAbstractListModel *daysModel READ daysModel CONSTANT) Q_ENUMS(Type) @@ -124,7 +123,6 @@ public: }; Q_DECLARE_FLAGS(Types, Type) - explicit Calendar(QObject *parent = 0); // Start date @@ -155,18 +153,17 @@ public: int year() const; // Models - QAbstractListModel* daysModel() const; - QList weeksModel() const; - + QAbstractListModel *daysModel() const; + QList weeksModel() const; // QML invokables Q_INVOKABLE void nextMonth(); Q_INVOKABLE void previousMonth(); Q_INVOKABLE void nextYear(); Q_INVOKABLE void previousYear(); - Q_INVOKABLE QString dayName(int weekday) const ; + Q_INVOKABLE QString dayName(int weekday) const; Q_INVOKABLE int currentWeek() const; - + Q_SIGNALS: void startDateChanged(); void typesChanged(); @@ -179,12 +176,12 @@ Q_SIGNALS: public Q_SLOTS: void updateData(); - + private: QDate m_startDate; Types m_types; QList m_dayList; - DaysModel* m_daysModel; + DaysModel *m_daysModel; QList m_weekList; int m_days; diff --git a/src/declarativeimports/calendar/calendardata.cpp b/src/declarativeimports/calendar/calendardata.cpp index 7eec373c2..e2a0e1a84 100644 --- a/src/declarativeimports/calendar/calendardata.cpp +++ b/src/declarativeimports/calendar/calendardata.cpp @@ -19,32 +19,28 @@ #include "calendardata.h" - - CalendarData::CalendarData(QObject *parent) : QObject(parent) , m_types(Holiday | Event | Todo | Journal) { - // m_etmCalendar = new ETMCalendar(); - // m_etmCalendar->setParent(this); //TODO: hit sergio +// m_etmCalendar = new ETMCalendar(); +// m_etmCalendar->setParent(this); //TODO: hit sergio - // EntityTreeModel *model = m_etmCalendar->entityTreeModel(); - // model->setCollectionFetchStrategy(EntityTreeModel::InvisibleCollectionFetch); + // EntityTreeModel *model = m_etmCalendar->entityTreeModel(); + // model->setCollectionFetchStrategy(EntityTreeModel::InvisibleCollectionFetch); - // m_itemList = new EntityMimeTypeFilterModel(this); - // m_itemList->setSourceModel(model); + // m_itemList = new EntityMimeTypeFilterModel(this); + // m_itemList->setSourceModel(model); - // CalendarRoleProxyModel *roleModel = new CalendarRoleProxyModel(this); - // roleModel->setSourceModel(m_itemList); + // CalendarRoleProxyModel *roleModel = new CalendarRoleProxyModel(this); + // roleModel->setSourceModel(m_itemList); - // m_filteredList = new DateTimeRangeFilterModel(this); - // m_filteredList->setSourceModel(roleModel); + // m_filteredList = new DateTimeRangeFilterModel(this); + // m_filteredList->setSourceModel(roleModel); - // updateTypes(); +// updateTypes(); } - - QDate CalendarData::startDate() const { return m_startDate; @@ -52,11 +48,12 @@ QDate CalendarData::startDate() const void CalendarData::setStartDate(const QDate &dateTime) { - if (m_startDate == dateTime) + if (m_startDate == dateTime) { return; + } m_startDate = dateTime; - // m_filteredList->setStartDate(m_startDate); +// m_filteredList->setStartDate(m_startDate); emit startDateChanged(); } @@ -67,11 +64,12 @@ QDate CalendarData::endDate() const void CalendarData::setEndDate(const QDate &dateTime) { - if (m_endDate == dateTime) + if (m_endDate == dateTime) { return; + } m_endDate = dateTime; - // m_filteredList->setEndDate(m_endDate); + // m_filteredList->setEndDate(m_endDate); emit endDateChanged(); } diff --git a/src/declarativeimports/calendar/calendardata.h b/src/declarativeimports/calendar/calendardata.h index bad6d182f..b8ee7b933 100644 --- a/src/declarativeimports/calendar/calendardata.h +++ b/src/declarativeimports/calendar/calendardata.h @@ -24,9 +24,6 @@ #include #include - - - class QAbstractItemModel; class CalendarData : public QObject @@ -35,10 +32,10 @@ class CalendarData : public QObject Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) - // Q_PROPERTY(int types READ types WRITE setTypes NOTIFY typesChanged) + // Q_PROPERTY(int types READ types WRITE setTypes NOTIFY typesChanged) Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged) Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) - // Q_PROPERTY(QAbstractItemModel* model READ model CONSTANT) + // Q_PROPERTY(QAbstractItemModel* model READ model CONSTANT) Q_ENUMS(Type) @@ -66,20 +63,20 @@ private: QDate endDate() const; void setEndDate(const QDate &dateTime); int types() const; - // void setTypes(int types); + // void setTypes(int types); QString errorMessage() const; bool loading() const; - // QAbstractItemModel* model() const; + // QAbstractItemModel* model() const; - // void updateTypes(); + // void updateTypes(); QDate m_startDate; QDate m_endDate; Types m_types; - // Akonadi::ETMCalendar *m_etmCalendar; - // Akonadi::EntityMimeTypeFilterModel *m_itemList; - // DateTimeRangeFilterModel *m_filteredList; + // Akonadi::ETMCalendar *m_etmCalendar; + // Akonadi::EntityMimeTypeFilterModel *m_itemList; + // DateTimeRangeFilterModel *m_filteredList; }; #endif // CALENDARDATA_H diff --git a/src/declarativeimports/calendar/calendarplugin.cpp b/src/declarativeimports/calendar/calendarplugin.cpp index 37e2b2c20..bafe80cf7 100644 --- a/src/declarativeimports/calendar/calendarplugin.cpp +++ b/src/declarativeimports/calendar/calendarplugin.cpp @@ -24,15 +24,12 @@ #include #include - - - void CalendarPlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.plasma.calendar")); - qmlRegisterType(uri, 2, 0, "CalendarData"); + qmlRegisterType(uri, 2, 0, "CalendarData"); qmlRegisterType(uri, 2, 0, "Calendar"); - // qmlRegisterType(uri, 1, 0, "CalendarData"); +// qmlRegisterType(uri, 1, 0, "CalendarData"); // qmlRegisterType(uri, 1, 0, "Calendar"); qmlRegisterType(); qmlRegisterType(); diff --git a/src/declarativeimports/calendar/calendarplugin.h b/src/declarativeimports/calendar/calendarplugin.h index e8acc757d..568da274a 100644 --- a/src/declarativeimports/calendar/calendarplugin.h +++ b/src/declarativeimports/calendar/calendarplugin.h @@ -20,8 +20,6 @@ #ifndef CALENDARPLUGIN_H #define CALENDARPLUGIN_H - - #include class QQmlEngine; @@ -29,7 +27,7 @@ class QQmlEngine; class CalendarPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes(const char *uri); diff --git a/src/declarativeimports/calendar/daydata.h b/src/declarativeimports/calendar/daydata.h index 5bc7d3aa7..39ac086e0 100644 --- a/src/declarativeimports/calendar/daydata.h +++ b/src/declarativeimports/calendar/daydata.h @@ -7,14 +7,13 @@ public: bool isPreviousMonth; bool isCurrentMonth; bool isNextMonth; - // bool containsHolidayItems; - // bool containsEventItems; - // bool containsTodoItems; - // bool containsJournalItems; +// bool containsHolidayItems; +// bool containsEventItems; +// bool containsTodoItems; +// bool containsJournalItems; int dayNumber; int monthNumber; int yearNumber; }; - #endif // DAYDATA_H diff --git a/src/declarativeimports/calendar/daysmodel.cpp b/src/declarativeimports/calendar/daysmodel.cpp index 23d9b853a..1a6f4546c 100644 --- a/src/declarativeimports/calendar/daysmodel.cpp +++ b/src/declarativeimports/calendar/daysmodel.cpp @@ -31,8 +31,8 @@ DaysModel::DaysModel(QObject *parent) : roleNames.insert(isNextMonth, "isNextMonth"); //roleNames.insert(containsHolidayItems, "containsHolidayItems"); //roleNames.insert(containsEventItems, "containsEventItems"); - // roleNames.insert(containsTodoItems, "containsTodoItems"); - // roleNames.insert(containsJournalItems, "containsJournalItems"); + // roleNames.insert(containsTodoItems, "containsTodoItems"); + // roleNames.insert(containsJournalItems, "containsJournalItems"); roleNames.insert(dayNumber, "dayNumber"); roleNames.insert(monthNumber, "monthNumber"); roleNames.insert(yearNumber, "yearNumber"); @@ -43,7 +43,7 @@ DaysModel::DaysModel(QObject *parent) : void DaysModel::setSourceData(QList *data) { - if(m_data != data) { + if (m_data != data) { m_data = data; reset(); } @@ -52,7 +52,7 @@ void DaysModel::setSourceData(QList *data) int DaysModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) - if(m_data->size() <= 0) { + if (m_data->size() <= 0) { return 0; } else { return m_data->size(); @@ -65,19 +65,19 @@ QVariant DaysModel::data(const QModelIndex &index, int role) const DayData currentData = m_data->at(index.row()); - switch(role) { + switch (role) { case isPreviousMonth: return currentData.isPreviousMonth; case isNextMonth: return currentData.isNextMonth; - // case containsHolidayItems: - // return currentData.containsHolidayItems; - /* case containsEventItems: - return currentData.containsEventItems; - case containsTodoItems: - return currentData.containsTodoItems; - case containsJournalItems: - return currentData.containsJournalItems;*/ + // case containsHolidayItems: + // return currentData.containsHolidayItems; + /* case containsEventItems: + return currentData.containsEventItems; + case containsTodoItems: + return currentData.containsTodoItems; + case containsJournalItems: + return currentData.containsJournalItems;*/ case dayNumber: return currentData.dayNumber; case monthNumber: @@ -91,7 +91,7 @@ QVariant DaysModel::data(const QModelIndex &index, int role) const void DaysModel::update() { - if(m_data->size() <= 0) { + if (m_data->size() <= 0) { return; } diff --git a/src/declarativeimports/calendar/daysmodel.h b/src/declarativeimports/calendar/daysmodel.h index 738c5733c..ec888374a 100644 --- a/src/declarativeimports/calendar/daysmodel.h +++ b/src/declarativeimports/calendar/daysmodel.h @@ -41,7 +41,7 @@ public: }; explicit DaysModel(QObject *parent = 0); - void setSourceData(QList* data); + void setSourceData(QList *data); virtual int rowCount(const QModelIndex &parent) const; virtual QVariant data(const QModelIndex &index, int role) const; void update(); diff --git a/src/declarativeimports/core/corebindingsplugin.cpp b/src/declarativeimports/core/corebindingsplugin.cpp index 3630e1748..e4064707e 100644 --- a/src/declarativeimports/core/corebindingsplugin.cpp +++ b/src/declarativeimports/core/corebindingsplugin.cpp @@ -46,7 +46,6 @@ // #include "dataenginebindings_p.h" - #include void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) @@ -61,7 +60,6 @@ void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) Units *units = new Units(context); context->setContextProperty("units", units); - if (!engine->rootContext()->contextObject()) { KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine); @@ -92,9 +90,9 @@ void CoreBindingsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "ToolTipArea"); qmlRegisterInterface("Service"); - qRegisterMetaType("Service"); + qRegisterMetaType("Service"); qmlRegisterInterface("ServiceJob"); - qRegisterMetaType("ServiceJob"); + qRegisterMetaType("ServiceJob"); qmlRegisterType(uri, 2, 0, "ServiceOperationStatus"); qmlRegisterType(); @@ -102,11 +100,10 @@ void CoreBindingsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "IconItem"); qmlRegisterInterface("DataSource"); - qRegisterMetaType("DataSource"); + qRegisterMetaType("DataSource"); qmlRegisterType(uri, 2, 0, "WindowThumbnail"); } - #include "corebindingsplugin.moc" diff --git a/src/declarativeimports/core/corebindingsplugin.h b/src/declarativeimports/core/corebindingsplugin.h index 43109448e..7d6156e18 100644 --- a/src/declarativeimports/core/corebindingsplugin.h +++ b/src/declarativeimports/core/corebindingsplugin.h @@ -38,5 +38,4 @@ public: void registerTypes(const char *uri); }; - #endif diff --git a/src/declarativeimports/core/dataenginebindings_p.h b/src/declarativeimports/core/dataenginebindings_p.h index 4d1cf899e..3309d2ba4 100644 --- a/src/declarativeimports/core/dataenginebindings_p.h +++ b/src/declarativeimports/core/dataenginebindings_p.h @@ -67,7 +67,7 @@ int qScriptRegisterMapMetaType( QScriptEngine *engine, const QScriptValue &prototype = QScriptValue() #ifndef qdoc - , T * /* dummy */ = 0 + , T * /* dummy */ = 0 #endif ) { diff --git a/src/declarativeimports/core/datamodel.cpp b/src/declarativeimports/core/datamodel.cpp index 64a5bf1dc..8e233a048 100644 --- a/src/declarativeimports/core/datamodel.cpp +++ b/src/declarativeimports/core/datamodel.cpp @@ -27,14 +27,14 @@ namespace Plasma { -SortFilterModel::SortFilterModel(QObject* parent) +SortFilterModel::SortFilterModel(QObject *parent) : QSortFilterProxyModel(parent) { setObjectName("SortFilterModel"); setDynamicSortFilter(true); - connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); - connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged())); @@ -70,7 +70,7 @@ int SortFilterModel::roleNameToId(const QString &name) return m_roleIds.value(name); } -void SortFilterModel::setModel(QAbstractItemModel* model) +void SortFilterModel::setModel(QAbstractItemModel *model) { if (model == sourceModel()) { return; @@ -165,10 +165,10 @@ int SortFilterModel::mapRowFromSource(int row) const return mapFromSource(idx).row(); } -DataModel::DataModel(QObject* parent) +DataModel::DataModel(QObject *parent) : QAbstractItemModel(parent), m_dataSource(0), - m_maxRoleId(Qt::UserRole+1) + m_maxRoleId(Qt::UserRole + 1) { //There is one reserved role name: DataEngineSource m_roleNames[m_maxRoleId] = "DataEngineSource"; @@ -176,9 +176,9 @@ DataModel::DataModel(QObject* parent) ++m_maxRoleId; setObjectName("DataModel"); - connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); - connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged())); @@ -215,7 +215,7 @@ void DataModel::dataUpdated(const QString &sourceName, const QVariantMap &data) } else { //a key that matches the one we want exists and is a list of DataEngine::Data if (data.contains(m_keyRoleFilter) && - data.value(m_keyRoleFilter).canConvert()) { + data.value(m_keyRoleFilter).canConvert()) { setItems(sourceName, data.value(m_keyRoleFilter).value()); } else if (m_keyRoleFilterRE.isValid()) { //try to match the key we want with a regular expression if set @@ -265,7 +265,7 @@ QObject *DataModel::dataSource() const return m_dataSource; } -void DataModel::setKeyRoleFilter(const QString& key) +void DataModel::setKeyRoleFilter(const QString &key) { // the "key role filter" can be used in one of three ways: // @@ -287,7 +287,7 @@ QString DataModel::keyRoleFilter() const return m_keyRoleFilter; } -void DataModel::setSourceFilter(const QString& key) +void DataModel::setSourceFilter(const QString &key) { if (m_sourceFilter == key) { return; @@ -410,7 +410,7 @@ void DataModel::removeSource(const QString &sourceName) QVariant DataModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.column() > 0 || - index.row() < 0 || index.row() >= countItems()){ + index.row() < 0 || index.row() >= countItems()) { return QVariant(); } diff --git a/src/declarativeimports/core/datamodel.h b/src/declarativeimports/core/datamodel.h index 168aa7aa1..aca78e243 100644 --- a/src/declarativeimports/core/datamodel.h +++ b/src/declarativeimports/core/datamodel.h @@ -34,7 +34,6 @@ namespace Plasma class DataSource; class DataModel; - class SortFilterModel : public QSortFilterProxyModel { Q_OBJECT @@ -71,7 +70,7 @@ class SortFilterModel : public QSortFilterProxyModel friend class DataModel; public: - SortFilterModel(QObject* parent=0); + SortFilterModel(QObject *parent = 0); ~SortFilterModel(); void setModel(QAbstractItemModel *source); @@ -87,7 +86,10 @@ public: void setSortOrder(const Qt::SortOrder order); - int count() const {return QSortFilterProxyModel::rowCount();} + int count() const + { + return QSortFilterProxyModel::rowCount(); + } /** * Returns the item at index in the list model. @@ -145,7 +147,7 @@ class DataModel : public QAbstractItemModel Q_PROPERTY(int count READ count NOTIFY countChanged) public: - DataModel(QObject* parent=0); + DataModel(QObject *parent = 0); ~DataModel(); void setDataSource(QObject *source); @@ -154,13 +156,13 @@ public: /** * Include only items with a key that matches this regexp in the model */ - void setKeyRoleFilter(const QString& key); + void setKeyRoleFilter(const QString &key); QString keyRoleFilter() const; /** * Include only sources that matches this regexp in the model */ - void setSourceFilter(const QString& key); + void setSourceFilter(const QString &key); QString sourceFilter() const; int roleNameToId(const QString &name); @@ -175,7 +177,10 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - int count() const {return countItems();} + int count() const + { + return countItems(); + } /** * Returns the item at index in the list model. diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp index 5c5fa670e..2e7a2af49 100644 --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -24,7 +24,7 @@ namespace Plasma { -DataSource::DataSource(QObject* parent) +DataSource::DataSource(QObject *parent) : QObject(parent), m_interval(0), m_dataEngine(0), @@ -120,7 +120,7 @@ void DataSource::setupData() * It is due little explanation why this is a queued connection: * If sourceAdded arrives immediately, in the case we have a datamodel * with items at source level we connect too soon (before setData for - * all roles is done), having a dataupdated in the datamodel with only + * all roles is done), having a dataupdated in the datamodel with only * the first role, killing off the other roles. * Besides causing a model reset more, unfortunately setRoleNames can be done a single time, so is not possible adding new roles after the * first setRoleNames() is called. @@ -128,12 +128,12 @@ void DataSource::setupData() * recommendations engine. */ m_dataEngine = engine; - connect(m_dataEngine, SIGNAL(sourceAdded(const QString&)), this, SIGNAL(sourcesChanged()), Qt::QueuedConnection); - connect(m_dataEngine, SIGNAL(sourceRemoved(const QString&)), this, SIGNAL(sourcesChanged())); + connect(m_dataEngine, SIGNAL(sourceAdded(QString)), this, SIGNAL(sourcesChanged()), Qt::QueuedConnection); + connect(m_dataEngine, SIGNAL(sourceRemoved(QString)), this, SIGNAL(sourcesChanged())); - connect(m_dataEngine, SIGNAL(sourceAdded(const QString&)), this, SIGNAL(sourceAdded(const QString&)), Qt::QueuedConnection); - connect(m_dataEngine, SIGNAL(sourceRemoved(const QString&)), this, SLOT(removeSource(const QString&))); - connect(m_dataEngine, SIGNAL(sourceRemoved(const QString&)), this, SIGNAL(sourceRemoved(const QString&))); + connect(m_dataEngine, SIGNAL(sourceAdded(QString)), this, SIGNAL(sourceAdded(QString)), Qt::QueuedConnection); + connect(m_dataEngine, SIGNAL(sourceRemoved(QString)), this, SLOT(removeSource(QString))); + connect(m_dataEngine, SIGNAL(sourceRemoved(QString)), this, SIGNAL(sourceRemoved(QString))); } foreach (const QString &source, m_connectedSources) { @@ -163,7 +163,7 @@ void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *mod m_models->insert(sourceName, QVariant::fromValue(model)); //FIXME: this will break in the case a second model is set - connect(model, &QObject::destroyed, [=]() { + connect(model, &QObject::destroyed, [ = ]() { m_models->clear(sourceName); }); } @@ -189,7 +189,7 @@ void DataSource::removeSource(const QString &source) } } -QObject* DataSource::serviceForSource(const QString &source) +QObject *DataSource::serviceForSource(const QString &source) { if (!m_services.contains(source)) { Plasma::Service *service = m_dataEngine->serviceForSource(source); diff --git a/src/declarativeimports/core/datasource.h b/src/declarativeimports/core/datasource.h index 66a3a5dad..06283ad06 100644 --- a/src/declarativeimports/core/datasource.h +++ b/src/declarativeimports/core/datasource.h @@ -30,10 +30,8 @@ #include #include - class QQmlPropertyMap; - namespace Plasma { class DataEngine; @@ -51,19 +49,25 @@ public: typedef QMap Data; - DataSource(QObject* parent=0); + DataSource(QObject *parent = 0); /** * true if the connection to the Plasma DataEngine is valid */ Q_PROPERTY(bool valid READ valid) - bool valid() const {return m_dataEngine && m_dataEngine->isValid();} + bool valid() const + { + return m_dataEngine && m_dataEngine->isValid(); + } /** * Polling interval in milliseconds when the data will be fetched again. If 0 no polling will be done. */ Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) - int interval() const {return m_interval;} + int interval() const + { + return m_interval; + } void setInterval(const int interval); /** @@ -71,28 +75,44 @@ public: */ Q_PROPERTY(QString dataEngine READ engine WRITE setEngine NOTIFY engineChanged) Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged) - QString engine() const {return m_engine;} + QString engine() const + { + return m_engine; + } void setEngine(const QString &e); /** * String array of all the source names connected to the DataEngine */ Q_PROPERTY(QStringList connectedSources READ connectedSources WRITE setConnectedSources NOTIFY connectedSourcesChanged) - QStringList connectedSources() const {return m_connectedSources;} + QStringList connectedSources() const + { + return m_connectedSources; + } void setConnectedSources(const QStringList &s); /** * Read only string array of all the sources available from the DataEngine (connected or not) */ Q_PROPERTY(QStringList sources READ sources NOTIFY sourcesChanged) - QStringList sources() const {if (m_dataEngine) return m_dataEngine->sources(); else return QStringList();} + QStringList sources() const + { + if (m_dataEngine) { + return m_dataEngine->sources(); + } else { + return QStringList(); + } + } /** * All the data fetched by this dataengine. * This is a map of maps. At the first level, there are the source names, at the second, they keys set by the DataEngine */ Q_PROPERTY(QQmlPropertyMap *data READ data CONSTANT); - QQmlPropertyMap *data() const {return m_data;} + QQmlPropertyMap *data() const + { + return m_data; + } /** * All the models associated to this DataEngine, indexed by source. @@ -100,13 +120,16 @@ public: * The user has to be connected to its source, so the source name has to be present in the connectedSources property. */ Q_PROPERTY(QQmlPropertyMap *models READ models CONSTANT); - QQmlPropertyMap *models() const {return m_models;} + QQmlPropertyMap *models() const + { + return m_models; + } /** * @returns a Plasma::Service given a source name * @arg QString source source name we want a service of */ - Q_INVOKABLE QObject* serviceForSource(const QString &source); + Q_INVOKABLE QObject *serviceForSource(const QString &source); /** * Connect a new source. It adds it to connectedSources @@ -142,8 +165,8 @@ private: QString m_engine; QQmlPropertyMap *m_data; QQmlPropertyMap *m_models; - Plasma::DataEngine* m_dataEngine; - Plasma::DataEngineConsumer* m_dataEngineConsumer; + Plasma::DataEngine *m_dataEngine; + Plasma::DataEngineConsumer *m_dataEngineConsumer; QStringList m_connectedSources; QStringList m_oldSources; QStringList m_newSources; diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index c346d35e8..1717c65bc 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -96,7 +96,7 @@ bool FrameSvgItemMargins::isFixed() const FrameSvgItem::FrameSvgItem(QQuickItem *parent) : QQuickItem(parent), - m_textureChanged(false) + m_textureChanged(false) { m_frameSvg = new Plasma::FrameSvg(this); m_margins = new FrameSvgItemMargins(m_frameSvg, this); @@ -107,7 +107,6 @@ FrameSvgItem::FrameSvgItem(QQuickItem *parent) connect(&m_units, &Units::devicePixelRatioChanged, this, &FrameSvgItem::updateDevicePixelRatio); } - FrameSvgItem::~FrameSvgItem() { } @@ -145,7 +144,6 @@ QString FrameSvgItem::imagePath() const return m_frameSvg->imagePath(); } - void FrameSvgItem::setPrefix(const QString &prefix) { if (m_prefix == prefix) { @@ -190,8 +188,9 @@ FrameSvgItemMargins *FrameSvgItem::fixedMargins() const void FrameSvgItem::setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders) { - if (m_frameSvg->enabledBorders() == borders) + if (m_frameSvg->enabledBorders() == borders) { return; + } m_frameSvg->setEnabledBorders(borders); emit enabledBordersChanged(); @@ -210,7 +209,7 @@ bool FrameSvgItem::hasElementPrefix(const QString &prefix) const } void FrameSvgItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) + const QRectF &oldGeometry) { if (isComponentComplete()) { m_frameSvg->resizeFrame(newGeometry.size()); @@ -270,7 +269,7 @@ Plasma::FrameSvg *FrameSvgItem::frameSvg() const return m_frameSvg; } -QSGNode* FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData*) +QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { if (!window() || !m_frameSvg || !m_frameSvg->hasElementPrefix(m_prefix)) { delete oldNode; @@ -303,7 +302,6 @@ void FrameSvgItem::componentComplete() m_textureChanged = true; } - void FrameSvgItem::updateDevicePixelRatio() { //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index c3811c257..e155f6a33 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -27,9 +27,10 @@ #include "units.h" -namespace Plasma { +namespace Plasma +{ - class FrameSvg; +class FrameSvg; class FrameSvgItemMargins : public QObject { @@ -128,7 +129,7 @@ class FrameSvgItem : public QQuickItem Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged) public: - FrameSvgItem(QQuickItem *parent=0); + FrameSvgItem(QQuickItem *parent = 0); ~FrameSvgItem(); void setImagePath(const QString &path); @@ -144,7 +145,7 @@ public: FrameSvgItemMargins *fixedMargins() const; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); + const QRectF &oldGeometry); void setImplicitWidth(qreal width); qreal implicitWidth() const; @@ -162,9 +163,9 @@ public: * to draw a frame * @param prefix the given prefix we want to check if drawable */ - Q_INVOKABLE bool hasElementPrefix(const QString & prefix) const; + Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const; - virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*); + virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); protected: virtual void componentComplete(); diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index fed2f9b3c..825764f86 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -29,7 +29,6 @@ #include - QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) { if (from.isNull() && to.isNull()) { @@ -43,7 +42,7 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) QRect startRect(from.rect()); QRect targetRect(to.rect()); QSize pixmapSize = startRect.size().expandedTo(targetRect.size()); - QRect toRect = QRect(QPoint(0,0), pixmapSize); + QRect toRect = QRect(QPoint(0, 0), pixmapSize); targetRect.moveCenter(toRect.center()); startRect.moveCenter(toRect.center()); @@ -54,8 +53,8 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) // If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus QPaintEngine *paintEngine = from.paintEngine(); if (paintEngine && - paintEngine->hasFeature(QPaintEngine::PorterDuff) && - paintEngine->hasFeature(QPaintEngine::BlendModes)) { + paintEngine->hasFeature(QPaintEngine::PorterDuff) && + paintEngine->hasFeature(QPaintEngine::BlendModes)) { QPixmap startPixmap(pixmapSize); startPixmap.fill(Qt::transparent); @@ -163,7 +162,7 @@ IconItem::IconItem(QQuickItem *parent) { m_loadPixmapTimer.setSingleShot(true); m_loadPixmapTimer.setInterval(150); - connect(&m_loadPixmapTimer, &QTimer::timeout, [=] () { + connect(&m_loadPixmapTimer, &QTimer::timeout, [ = ]() { loadPixmap(); }); @@ -183,7 +182,6 @@ IconItem::IconItem(QQuickItem *parent) connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()), this, SIGNAL(implicitHeightChanged())); - connect(this, SIGNAL(enabledChanged()), &m_loadPixmapTimer, SLOT(start())); @@ -192,7 +190,6 @@ IconItem::IconItem(QQuickItem *parent) setImplicitHeight(KIconLoader::global()->currentSize(KIconLoader::Dialog)); } - IconItem::~IconItem() { } @@ -226,7 +223,7 @@ void IconItem::setSource(const QVariant &source) m_icon = QIcon(); connect(m_svgIcon, SIGNAL(repaintNeeded()), this, SLOT(loadPixmap())); - //ok, svg not available + //ok, svg not available } else { m_icon = QIcon::fromTheme(source.toString()); delete m_svgIcon; @@ -318,7 +315,7 @@ void IconItem::paint(QPainter *painter) const int iconSize = adjustedSize(qMin(boundingRect().size().width(), boundingRect().size().height())); - const QRect destRect(QPointF(boundingRect().center() - QPointF(iconSize/2, iconSize/2)).toPoint(), + const QRect destRect(QPointF(boundingRect().center() - QPointF(iconSize / 2, iconSize / 2)).toPoint(), QSize(iconSize, iconSize)); if (m_animation->state() == QAbstractAnimation::Running) { @@ -326,7 +323,7 @@ void IconItem::paint(QPainter *painter) result = transition(result, m_iconPixmaps.last(), m_animValue); painter->drawPixmap(destRect, result); - //simpler logic for just paint + //simpler logic for just paint } else { painter->drawPixmap(destRect, m_iconPixmaps.first()); } @@ -349,13 +346,13 @@ void IconItem::valueChanged(const QVariant &value) int IconItem::adjustedSize(int size) { - //FIXME: Heuristic: allow 24x24 for icons/ that are in the systray(ugly) + //FIXME: Heuristic: allow 24x24 for icons/ that are in the systray(ugly) if (m_svgIcon && m_svgIcon->imagePath().contains("icons/") && - size > KIconLoader::SizeSmallMedium && - size < KIconLoader::SizeMedium) { + size > KIconLoader::SizeSmallMedium && + size < KIconLoader::SizeMedium) { return 24; - //if size is less than 16, leave as is + //if size is less than 16, leave as is } else if (size < KIconLoader::SizeSmall) { //do nothing } else if (size < KIconLoader::SizeSmallMedium) { @@ -366,7 +363,7 @@ int IconItem::adjustedSize(int size) return KIconLoader::SizeMedium; } else if (size < KIconLoader::SizeHuge) { return KIconLoader::SizeLarge; - //if size is more than 64, leave as is + //if size is more than 64, leave as is } return size; @@ -378,7 +375,7 @@ void IconItem::loadPixmap() //final pixmap to paint QPixmap result; - if (size<=0) { + if (size <= 0) { //m_iconPixmaps.clear(); m_animation->stop(); update(); diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 26ee4106c..92a523318 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -28,8 +28,9 @@ class QPropertyAnimation; -namespace Plasma { - class Svg; +namespace Plasma +{ +class Svg; } class IconItem : public QQuickPaintedItem @@ -43,7 +44,7 @@ class IconItem : public QQuickPaintedItem public: - IconItem(QQuickItem *parent=0); + IconItem(QQuickItem *parent = 0); ~IconItem(); void setSource(const QVariant &source); diff --git a/src/declarativeimports/core/serviceoperationstatus.cpp b/src/declarativeimports/core/serviceoperationstatus.cpp index aa9f76ccc..7cd2debaa 100644 --- a/src/declarativeimports/core/serviceoperationstatus.cpp +++ b/src/declarativeimports/core/serviceoperationstatus.cpp @@ -19,8 +19,6 @@ #include "serviceoperationstatus.h" - - ServiceOperationStatus::ServiceOperationStatus(QObject *parent) : QObject(parent), m_enabled(false) diff --git a/src/declarativeimports/core/serviceoperationstatus.h b/src/declarativeimports/core/serviceoperationstatus.h index ce93132fe..10f5ba572 100644 --- a/src/declarativeimports/core/serviceoperationstatus.h +++ b/src/declarativeimports/core/serviceoperationstatus.h @@ -23,8 +23,9 @@ #include "plasma/service.h" -namespace Plasma { - class Service; +namespace Plasma +{ +class Service; } class ServiceOperationStatus : public QObject @@ -47,7 +48,7 @@ class ServiceOperationStatus : public QObject Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) public: - ServiceOperationStatus(QObject *parent=0); + ServiceOperationStatus(QObject *parent = 0); ~ServiceOperationStatus(); void setService(Plasma::Service *service); @@ -73,5 +74,4 @@ private: bool m_enabled; }; - #endif diff --git a/src/declarativeimports/core/svgitem.cpp b/src/declarativeimports/core/svgitem.cpp index d1c9952bb..f56eb82cf 100644 --- a/src/declarativeimports/core/svgitem.cpp +++ b/src/declarativeimports/core/svgitem.cpp @@ -43,7 +43,6 @@ SvgItem::SvgItem(QQuickItem *parent) connect(&m_units, &Units::devicePixelRatioChanged, this, &SvgItem::updateDevicePixelRatio); } - SvgItem::~SvgItem() { } @@ -85,7 +84,6 @@ QSizeF SvgItem::naturalSize() const return m_svg.data()->size(); } - void SvgItem::setSvg(Plasma::Svg *svg) { if (m_svg) { @@ -100,7 +98,6 @@ void SvgItem::setSvg(Plasma::Svg *svg) connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged())); } - if (implicitWidth() <= 0) { setImplicitWidth(naturalSize().width()); } diff --git a/src/declarativeimports/core/svgitem.h b/src/declarativeimports/core/svgitem.h index 2e0d9af8b..84f59fc6b 100644 --- a/src/declarativeimports/core/svgitem.h +++ b/src/declarativeimports/core/svgitem.h @@ -24,9 +24,10 @@ #include "units.h" -namespace Plasma { +namespace Plasma +{ - class Svg; +class Svg; class SvgItem : public QQuickItem { @@ -47,7 +48,7 @@ class SvgItem : public QQuickItem * * Instead of a Svg declaration it can also be the id of a Svg declared elsewhere, useful to share Svg instances. */ - Q_PROPERTY(Plasma::Svg * svg READ svg WRITE setSvg NOTIFY svgChanged) + Q_PROPERTY(Plasma::Svg *svg READ svg WRITE setSvg NOTIFY svgChanged) /** * The natural, unscaled size of the svg document or the element. useful if a pixel perfect rendering of outlines is needed. @@ -70,7 +71,7 @@ class SvgItem : public QQuickItem Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged) public: - SvgItem(QQuickItem *parent=0); + SvgItem(QQuickItem *parent = 0); ~SvgItem(); void setElementId(const QString &elementID); @@ -90,7 +91,7 @@ public: void setImplicitHeight(qreal height); qreal implicitHeight() const; - QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData); + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData); Q_SIGNALS: void elementIdChanged(); diff --git a/src/declarativeimports/core/svgtexturenode.h b/src/declarativeimports/core/svgtexturenode.h index dbaccc08e..21b9b2f8d 100644 --- a/src/declarativeimports/core/svgtexturenode.h +++ b/src/declarativeimports/core/svgtexturenode.h @@ -22,7 +22,8 @@ #include -namespace Plasma { +namespace Plasma +{ /** * This class wraps QSGSimpleTextureNode @@ -31,18 +32,19 @@ namespace Plasma { class SVGTextureNode : public QSGSimpleTextureNode { - public: - SVGTextureNode() {} - /** - * Set the current texture - * the object takes ownership of the texture - */ - void setTexture(QSGTexture *texture) { - m_texture.reset(texture); - QSGSimpleTextureNode::setTexture(texture); - } - private: - QScopedPointer m_texture; +public: + SVGTextureNode() {} + /** + * Set the current texture + * the object takes ownership of the texture + */ + void setTexture(QSGTexture *texture) + { + m_texture.reset(texture); + QSGSimpleTextureNode::setTexture(texture); + } +private: + QScopedPointer m_texture; }; } diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index d3571da1b..2bd0482fc 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -316,7 +316,7 @@ void ToolTip::hoverEnterEvent(QHoverEvent *event) //FIXME: showToolTip needs to be renamed in sync or something like that showToolTip(); } else if (m_mainItem || - (!mainText().isEmpty() && !subText().isEmpty())) { + (!mainText().isEmpty() && !subText().isEmpty())) { m_showTimer->start(m_interval); } } diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index e8bc552c2..c8ad88663 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -109,7 +109,7 @@ class ToolTip : public QQuickItem Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) /** - * if interactive is false (default), the tooltip will automatically hide + * if interactive is false (default), the tooltip will automatically hide * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, so it will be possible to interact with tooltip contents */ Q_PROPERTY(bool interactive MEMBER m_interactive WRITE setInteractive NOTIFY interactiveChanged) diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp index ce4f9ef8e..dc7b8e9bf 100644 --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -47,7 +47,7 @@ ToolTipDialog::ToolTipDialog(QQuickItem *parent) m_showTimer = new QTimer(this); m_showTimer->setSingleShot(true); - connect(m_showTimer, &QTimer::timeout, [=]() { + connect(m_showTimer, &QTimer::timeout, [ = ]() { setVisible(false); }); } diff --git a/src/declarativeimports/core/tooltipdialog.h b/src/declarativeimports/core/tooltipdialog.h index 79c07e13d..d0bf784a5 100644 --- a/src/declarativeimports/core/tooltipdialog.h +++ b/src/declarativeimports/core/tooltipdialog.h @@ -33,7 +33,7 @@ class QPropertyAnimation; namespace KDeclarative { - class QmlObject; +class QmlObject; } /** diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index bf9509227..7bd37c69b 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -36,7 +36,7 @@ const QString plasmarc = QStringLiteral("plasmarc"); const QString groupName = QStringLiteral("Units"); const int defaultLongDuration = 250; -Units::Units (QObject *parent) +Units::Units(QObject *parent) : QObject(parent), m_gridUnit(-1), m_devicePixelRatio(-1), @@ -194,7 +194,6 @@ void Units::updateSpacing() } } - int Units::longDuration() const { return m_longDuration; diff --git a/src/declarativeimports/core/windowthumbnail.cpp b/src/declarativeimports/core/windowthumbnail.cpp index 59255f759..d1a7fef1f 100644 --- a/src/declarativeimports/core/windowthumbnail.cpp +++ b/src/declarativeimports/core/windowthumbnail.cpp @@ -30,18 +30,19 @@ #include #if HAVE_GLX #include -typedef void (*glXBindTexImageEXT_func)(Display* dpy, GLXDrawable drawable, - int buffer, const int* attrib_list); -typedef void (*glXReleaseTexImageEXT_func)(Display* dpy, GLXDrawable drawable, int buffer); +typedef void (*glXBindTexImageEXT_func)(Display *dpy, GLXDrawable drawable, + int buffer, const int *attrib_list); +typedef void (*glXReleaseTexImageEXT_func)(Display *dpy, GLXDrawable drawable, int buffer); #endif #if HAVE_EGL -typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); +typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); typedef EGLBoolean(*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR); typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); #endif // HAVE_EGL #endif -namespace Plasma { +namespace Plasma +{ WindowTextureNode::WindowTextureNode() : QSGSimpleTextureNode() @@ -58,7 +59,7 @@ void WindowTextureNode::reset(QSGTexture *texture) m_texture.reset(texture); } -WindowThumbnail::WindowThumbnail(QQuickItem* parent) +WindowThumbnail::WindowThumbnail(QQuickItem *parent) : QQuickItem(parent) , QAbstractNativeEventFilter() , m_xcb(false) @@ -80,7 +81,7 @@ WindowThumbnail::WindowThumbnail(QQuickItem* parent) #endif { setFlag(ItemHasContents); - connect(this, &QQuickItem::windowChanged, [this](QQuickWindow *window) { + connect(this, &QQuickItem::windowChanged, [this](QQuickWindow * window) { if (!window) { return; } @@ -88,7 +89,7 @@ WindowThumbnail::WindowThumbnail(QQuickItem* parent) stopRedirecting(); startRedirecting(); }); - if (QGuiApplication *gui = dynamic_cast(QCoreApplication::instance())) { + if (QGuiApplication *gui = dynamic_cast(QCoreApplication::instance())) { m_xcb = (gui->platformName() == QStringLiteral("xcb")); if (m_xcb) { gui->installNativeEventFilter(this); @@ -141,7 +142,7 @@ void WindowThumbnail::setWinId(uint32_t winId) QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { Q_UNUSED(updatePaintNodeData) - auto *node = static_cast(oldNode); + auto *node = static_cast(oldNode); if (!node) { node = new WindowTextureNode(); node->setFiltering(QSGTexture::Linear); @@ -153,8 +154,8 @@ QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData } node->setRect(boundingRect()); const QSize size(node->texture()->textureSize().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio)); - const qreal x = boundingRect().x() + (boundingRect().width() - size.width())/2; - const qreal y = boundingRect().y() + (boundingRect().height() - size.height())/2; + const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2; + const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2; node->setRect(QRectF(QPointF(x, y), size)); return node; } @@ -167,15 +168,15 @@ bool WindowThumbnail::nativeEventFilter(const QByteArray &eventType, void *messa return false; } #if HAVE_XCB_COMPOSITE - xcb_generic_event_t *event = static_cast(message); + xcb_generic_event_t *event = static_cast(message); const uint8_t responseType = event->response_type & ~0x80; if (responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY) { - if (reinterpret_cast(event)->drawable == m_winId) { + if (reinterpret_cast(event)->drawable == m_winId) { m_damaged = true; update(); } } else if (responseType == XCB_CONFIGURE_NOTIFY) { - if (reinterpret_cast(event)->window == m_winId) { + if (reinterpret_cast(event)->window == m_winId) { // TODO: only discard if size changes discardPixmap(); } @@ -253,8 +254,8 @@ bool WindowThumbnail::xcbWindowToTextureEGL(WindowTextureNode *textureNode) EGL_NONE }; m_image = ((eglCreateImageKHR_func)(m_eglCreateImageKHR))(eglGetCurrentDisplay(), EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)m_pixmap, attribs); + EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)m_pixmap, attribs); if (m_image == EGL_NO_IMAGE_KHR) { qDebug() << "failed to create egl image"; @@ -402,10 +403,11 @@ bool WindowThumbnail::loadGLXTexture() XVisualInfo *vi = glXGetVisualFromFBConfig(d, fbConfigs[0]); int textureFormat; - if (window()->openglContext()->format().hasAlpha()) + if (window()->openglContext()->format().hasAlpha()) { textureFormat = bindRgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT; - else + } else { textureFormat = bindRgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT; + } XFree(vi); // we assume that Texture_2D is supported as we have a QtQuick OpenGL context diff --git a/src/declarativeimports/core/windowthumbnail.h b/src/declarativeimports/core/windowthumbnail.h index aa10e7ebe..d3a7b64ad 100644 --- a/src/declarativeimports/core/windowthumbnail.h +++ b/src/declarativeimports/core/windowthumbnail.h @@ -37,7 +37,8 @@ #endif // HAVE_XCB_COMPOSITE class KWindowInfo; -namespace Plasma { +namespace Plasma +{ class WindowTextureNode; diff --git a/src/declarativeimports/plasmacomponents/enums.cpp b/src/declarativeimports/plasmacomponents/enums.cpp index ab9eeaaa3..5607c5fe7 100644 --- a/src/declarativeimports/plasmacomponents/enums.cpp +++ b/src/declarativeimports/plasmacomponents/enums.cpp @@ -19,6 +19,4 @@ #include "enums.h" - - #include "moc_enums.cpp" diff --git a/src/declarativeimports/plasmacomponents/enums.h b/src/declarativeimports/plasmacomponents/enums.h index 46a40d70c..c769067ac 100644 --- a/src/declarativeimports/plasmacomponents/enums.h +++ b/src/declarativeimports/plasmacomponents/enums.h @@ -22,7 +22,6 @@ #include - class DialogStatus : public QObject { Q_OBJECT @@ -66,5 +65,4 @@ public: }; }; - #endif // ENUMS_H diff --git a/src/declarativeimports/plasmacomponents/fullscreensheet.cpp b/src/declarativeimports/plasmacomponents/fullscreensheet.cpp index 28f9dbe05..d801b2370 100644 --- a/src/declarativeimports/plasmacomponents/fullscreensheet.cpp +++ b/src/declarativeimports/plasmacomponents/fullscreensheet.cpp @@ -138,6 +138,5 @@ void FullScreenSheet::open() } } - #include "fullscreensheet.moc" diff --git a/src/declarativeimports/plasmacomponents/fullscreenwindow.cpp b/src/declarativeimports/plasmacomponents/fullscreenwindow.cpp index 4d8451ab3..60d372562 100644 --- a/src/declarativeimports/plasmacomponents/fullscreenwindow.cpp +++ b/src/declarativeimports/plasmacomponents/fullscreenwindow.cpp @@ -41,18 +41,17 @@ #include #include - uint FullScreenWindow::s_numItems = 0; class Background : public QWidget { public: Background(FullScreenWindow *dialog) - : QWidget( 0L ), + : QWidget(0L), m_dialog(dialog) { - setAttribute( Qt::WA_NoSystemBackground ); - setAttribute( Qt::WA_TranslucentBackground ); + setAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_TranslucentBackground); setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint); KWindowSystem::setOnAllDesktops(winId(), true); @@ -63,9 +62,9 @@ public: ~Background() {} - void paintEvent( QPaintEvent *e ) + void paintEvent(QPaintEvent *e) { - QPainter painter( this ); + QPainter painter(this); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(e->rect(), QColor(0, 0, 0, 80)); } @@ -151,7 +150,7 @@ void FullScreenWindow::init(const QString &componentName) QDeclarativeContext *creationContext = component->creationContext(); m_rootObject = component->create(creationContext); if (component->status() == QDeclarativeComponent::Error) { - qWarning()<errors(); + qWarning() << component->errors(); } if (m_rootObject) { @@ -220,8 +219,8 @@ void FullScreenWindow::syncViewToMainItem() } m_declarativeItemContainer->setDeclarativeItem(di); } else { - m_mainItem.data()->setY(-10000*s_numItems); - m_mainItem.data()->setY(10000*s_numItems); + m_mainItem.data()->setY(-10000 * s_numItems); + m_mainItem.data()->setY(10000 * s_numItems); } break; } @@ -235,7 +234,6 @@ void FullScreenWindow::syncViewToMainItem() m_view->setScene(scene); - QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()), QSizeF(m_mainItem.data()->boundingRect().size())); if (m_declarativeItemContainer) { @@ -244,12 +242,12 @@ void FullScreenWindow::syncViewToMainItem() } else { QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()), - QSizeF(m_mainItem.data()->boundingRect().size())); + QSizeF(m_mainItem.data()->boundingRect().size())); m_view->resize(itemGeometry.size().toSize()); m_view->setSceneRect(itemGeometry); } - m_view->move(QApplication::desktop()->availableGeometry().center() - QPoint(m_view->width()/2, m_view->height()/2)); + m_view->move(QApplication::desktop()->availableGeometry().center() - QPoint(m_view->width() / 2, m_view->height() / 2)); } void FullScreenWindow::syncMainItemToView() @@ -266,7 +264,7 @@ void FullScreenWindow::syncMainItemToView() m_view->setSceneRect(m_declarativeItemContainer->geometry()); } else { QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()), - QSizeF(m_mainItem.data()->boundingRect().size())); + QSizeF(m_mainItem.data()->boundingRect().size())); m_view->setSceneRect(itemGeometry); } } @@ -297,7 +295,6 @@ QGraphicsView *FullScreenWindow::view() const return m_view; } - QDeclarativeListProperty FullScreenWindow::title() { if (m_rootObject) { @@ -334,7 +331,6 @@ DialogStatus::Status FullScreenWindow::status() const } } - void FullScreenWindow::statusHasChanged() { if (status() == DialogStatus::Closed) { @@ -373,22 +369,17 @@ void FullScreenWindow::close() } } - - - bool FullScreenWindow::eventFilter(QObject *watched, QEvent *event) { if (watched == m_mainItem.data() && - (event->type() == QEvent::GraphicsSceneResize)) { + (event->type() == QEvent::GraphicsSceneResize)) { syncViewToMainItem(); } else if (watched == m_view && - (event->type() == QEvent::Resize)) { + (event->type() == QEvent::Resize)) { syncMainItemToView(); } return false; } - - #include "fullscreenwindow.moc" diff --git a/src/declarativeimports/plasmacomponents/fullscreenwindow.h b/src/declarativeimports/plasmacomponents/fullscreenwindow.h index 1f0eb225e..8632acb5a 100644 --- a/src/declarativeimports/plasmacomponents/fullscreenwindow.h +++ b/src/declarativeimports/plasmacomponents/fullscreenwindow.h @@ -43,7 +43,6 @@ class FullScreenWindow : public QDeclarativeItem Q_PROPERTY(QDeclarativeListProperty buttons READ buttons DESIGNABLE false) Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged) - public: FullScreenWindow(QDeclarativeItem *parent = 0); ~FullScreenWindow(); @@ -73,7 +72,6 @@ Q_SIGNALS: void clickedOutside(); void statusChanged(); - private Q_SLOTS: void syncViewToMainItem(); void syncMainItemToView(); diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp index 007a04d73..d2ddc8e68 100644 --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp @@ -37,7 +37,7 @@ class BKSingleton { public: - EngineBookKeeping self; + EngineBookKeeping self; }; Q_GLOBAL_STATIC(BKSingleton, privateBKSelf) @@ -63,8 +63,8 @@ QQmlEngine *EngineBookKeeping::engine() const void EngineBookKeeping::insertEngine(QQmlEngine *engine) { - connect(engine, SIGNAL(destroyed(QObject *)), - this, SLOT(engineDestroyed(QObject *))); + connect(engine, SIGNAL(destroyed(QObject*)), + this, SLOT(engineDestroyed(QObject*))); m_engines.insert(engine); } @@ -73,8 +73,6 @@ void EngineBookKeeping::engineDestroyed(QObject *deleted) m_engines.remove(static_cast(deleted)); } - - void PlasmaComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { QQmlExtensionPlugin::initializeEngine(engine, uri); @@ -91,7 +89,7 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "Menu"); qmlRegisterType(uri, 2, 0, "MenuItem"); } else { - // qmlRegisterType(uri, 2, 0, "Sheet"); + // qmlRegisterType(uri, 2, 0, "Sheet"); } qmlRegisterType(uri, 2, 0, "RangeModel"); @@ -101,6 +99,5 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri) qmlRegisterUncreatableType(uri, 2, 0, "PageStatus", ""); } - #include "moc_plasmacomponentsplugin.cpp" diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h index 3a2a9a26d..035a40f80 100644 --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h @@ -42,7 +42,7 @@ private Q_SLOTS: void engineDestroyed(QObject *deleted); private: - QSet m_engines; + QSet m_engines; }; class PlasmaComponentsPlugin : public QQmlExtensionPlugin diff --git a/src/declarativeimports/plasmacomponents/qmenu.cpp b/src/declarativeimports/plasmacomponents/qmenu.cpp index 743df29d2..ee7bfff15 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.cpp +++ b/src/declarativeimports/plasmacomponents/qmenu.cpp @@ -26,13 +26,13 @@ #include #include "plasmacomponentsplugin.h" -QMenuProxy::QMenuProxy (QObject *parent) +QMenuProxy::QMenuProxy(QObject *parent) : QObject(parent), m_status(DialogStatus::Closed) { m_menu = new QMenu(0); connect(m_menu, &QMenu::triggered, this, &QMenuProxy::itemTriggered); - connect(m_menu, &QMenu::aboutToHide, [=]() { + connect(m_menu, &QMenu::aboutToHide, [ = ]() { m_status = DialogStatus::Closed; emit statusChanged(); }); @@ -85,7 +85,7 @@ void QMenuProxy::setVisualParent(QObject *parent) if (action) { action->setMenu(m_menu); m_menu->clear(); - foreach(QMenuItem* item, m_items) { + foreach (QMenuItem *item, m_items) { m_menu->addAction(item->action()); } m_menu->updateGeometry(); @@ -179,8 +179,8 @@ void QMenuProxy::open(int x, int y) { qDebug() << "opening menu at " << x << y; m_menu->clear(); - foreach(QMenuItem* item, m_items) { - qDebug() <<"Adding action: " << item->text(); + foreach (QMenuItem *item, m_items) { + qDebug() << "Adding action: " << item->text(); m_menu->addAction(item->action()); } @@ -200,7 +200,6 @@ void QMenuProxy::open(int x, int y) emit statusChanged(); } - void QMenuProxy::close() { m_menu->hide(); diff --git a/src/declarativeimports/plasmacomponents/qmenu.h b/src/declarativeimports/plasmacomponents/qmenu.h index d1a5b7390..14403bfdf 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.h +++ b/src/declarativeimports/plasmacomponents/qmenu.h @@ -82,7 +82,7 @@ private Q_SLOTS: void itemTriggered(QAction *item); private: - QList m_items; + QList m_items; QMenu *m_menu; DialogStatus::Status m_status; QWeakPointer m_visualParent; diff --git a/src/declarativeimports/plasmacomponents/qmenuitem.cpp b/src/declarativeimports/plasmacomponents/qmenuitem.cpp index f9c86a7d1..6bffa08be 100644 --- a/src/declarativeimports/plasmacomponents/qmenuitem.cpp +++ b/src/declarativeimports/plasmacomponents/qmenuitem.cpp @@ -20,22 +20,21 @@ #include "qmenuitem.h" - QMenuItem::QMenuItem(QQuickItem *parent) : QQuickItem(parent), - m_action(0) + m_action(0) { setAction(new QAction(this)); connect(m_action, &QAction::triggered, this, &QMenuItem::clicked); } -QAction* QMenuItem::action() const +QAction *QMenuItem::action() const { return m_action; } -void QMenuItem::setAction(QAction* a) +void QMenuItem::setAction(QAction *a) { if (m_action != a) { if (m_action) { @@ -54,7 +53,7 @@ QVariant QMenuItem::icon() const return m_icon; } -void QMenuItem::setIcon(const QVariant& i) +void QMenuItem::setIcon(const QVariant &i) { m_icon = i; if (i.canConvert()) { @@ -80,7 +79,7 @@ QString QMenuItem::text() const return m_action->text(); } -void QMenuItem::setText(const QString& t) +void QMenuItem::setText(const QString &t) { if (m_action->text() != t) { m_action->setText(t); diff --git a/src/declarativeimports/plasmacomponents/qmenuitem.h b/src/declarativeimports/plasmacomponents/qmenuitem.h index 0bb7b09e1..f78656443 100644 --- a/src/declarativeimports/plasmacomponents/qmenuitem.h +++ b/src/declarativeimports/plasmacomponents/qmenuitem.h @@ -39,17 +39,17 @@ class QMenuItem : public QQuickItem Q_PROPERTY(bool separator READ separator WRITE setSeparator NOTIFY separatorChanged) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged) - Q_PROPERTY(QAction* action READ action WRITE setAction NOTIFY actionChanged) + Q_PROPERTY(QAction *action READ action WRITE setAction NOTIFY actionChanged) Q_PROPERTY(bool checkable READ checkable WRITE setCheckable NOTIFY checkableChanged) Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY toggled) public: QMenuItem(QQuickItem *parent = 0); - QAction* action() const; - void setAction(QAction* a); + QAction *action() const; + void setAction(QAction *a); QVariant icon() const; - void setIcon(const QVariant& i); + void setIcon(const QVariant &i); bool separator() const; void setSeparator(bool s); QString text() const; @@ -72,7 +72,7 @@ Q_SIGNALS: void checkableChanged(); private: - QAction* m_action; + QAction *m_action; QVariant m_icon; }; diff --git a/src/declarativeimports/plasmacomponents/qrangemodel.cpp b/src/declarativeimports/plasmacomponents/qrangemodel.cpp index 434d4b575..6253f5801 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel.cpp +++ b/src/declarativeimports/plasmacomponents/qrangemodel.cpp @@ -104,14 +104,16 @@ qreal QRangeModelPrivate::publicPosition(qreal position) const const qreal positionValueRatio = valueRange ? (max - min) / valueRange : 0; const qreal positionStep = stepSize * positionValueRatio; - if (positionStep == 0) + if (positionStep == 0) { return (min < max) ? qBound(min, position, max) : qBound(max, position, min); + } const int stepSizeMultiplier = (position - min) / positionStep; // Test whether value is below minimum range - if (stepSizeMultiplier < 0) + if (stepSizeMultiplier < 0) { return min; + } qreal leftEdge = (stepSizeMultiplier * positionStep) + min; qreal rightEdge = ((stepSizeMultiplier + 1) * positionStep) + min; @@ -124,8 +126,9 @@ qreal QRangeModelPrivate::publicPosition(qreal position) const rightEdge = qMax(rightEdge, max); } - if (qAbs(leftEdge - position) <= qAbs(rightEdge - position)) + if (qAbs(leftEdge - position) <= qAbs(rightEdge - position)) { return leftEdge; + } return rightEdge; } @@ -143,14 +146,16 @@ qreal QRangeModelPrivate::publicValue(qreal value) const // QML bindings; a position that is initially invalid because it lays // outside the range, might become valid later if the range changes. - if (stepSize == 0) + if (stepSize == 0) { return qBound(minimum, value, maximum); + } const int stepSizeMultiplier = (value - minimum) / stepSize; // Test whether value is below minimum range - if (stepSizeMultiplier < 0) + if (stepSizeMultiplier < 0) { return minimum; + } const qreal leftEdge = qMin(maximum, (stepSizeMultiplier * stepSize) + minimum); const qreal rightEdge = qMin(maximum, ((stepSizeMultiplier + 1) * stepSize) + minimum); @@ -172,10 +177,12 @@ void QRangeModelPrivate::emitValueAndPositionIfChanged(const qreal oldValue, con // unchanged. This will be the case when operating with values outside range: const qreal newValue = q->value(); const qreal newPosition = q->position(); - if (!qFuzzyCompare(newValue, oldValue)) + if (!qFuzzyCompare(newValue, oldValue)) { emit q->valueChanged(newValue); - if (!qFuzzyCompare(newPosition, oldPosition)) + } + if (!qFuzzyCompare(newPosition, oldPosition)) { emit q->positionChanged(newPosition); + } } /*! @@ -224,8 +231,9 @@ void QRangeModel::setPositionRange(qreal min, qreal max) bool emitPosAtMinChanged = !qFuzzyCompare(min, d->posatmin); bool emitPosAtMaxChanged = !qFuzzyCompare(max, d->posatmax); - if (!(emitPosAtMinChanged || emitPosAtMaxChanged)) + if (!(emitPosAtMinChanged || emitPosAtMaxChanged)) { return; + } const qreal oldPosition = position(); d->posatmin = min; @@ -239,10 +247,12 @@ void QRangeModel::setPositionRange(qreal min, qreal max) // the positionChanged signal. d->pos = d->equivalentPosition(d->value); - if (emitPosAtMinChanged) + if (emitPosAtMinChanged) { emit positionAtMinimumChanged(d->posatmin); - if (emitPosAtMaxChanged) + } + if (emitPosAtMaxChanged) { emit positionAtMaximumChanged(d->posatmax); + } d->emitValueAndPositionIfChanged(value(), oldPosition); } @@ -259,8 +269,9 @@ void QRangeModel::setRange(qreal min, qreal max) bool emitMinimumChanged = !qFuzzyCompare(min, d->minimum); bool emitMaximumChanged = !qFuzzyCompare(max, d->maximum); - if (!(emitMinimumChanged || emitMaximumChanged)) + if (!(emitMinimumChanged || emitMaximumChanged)) { return; + } const qreal oldValue = value(); const qreal oldPosition = position(); @@ -271,10 +282,12 @@ void QRangeModel::setRange(qreal min, qreal max) // Update internal position if it was changed. It can occurs if internal value changes, due to range update d->pos = d->equivalentPosition(d->value); - if (emitMinimumChanged) + if (emitMinimumChanged) { emit minimumChanged(d->minimum); - if (emitMaximumChanged) + } + if (emitMaximumChanged) { emit maximumChanged(d->maximum); + } d->emitValueAndPositionIfChanged(oldValue, oldPosition); } @@ -332,8 +345,9 @@ void QRangeModel::setStepSize(qreal stepSize) Q_D(QRangeModel); stepSize = qMax(qreal(0.0), stepSize); - if (qFuzzyCompare(stepSize, d->stepSize)) + if (qFuzzyCompare(stepSize, d->stepSize)) { return; + } const qreal oldValue = value(); const qreal oldPosition = position(); @@ -386,8 +400,9 @@ void QRangeModel::setPosition(qreal newPosition) { Q_D(QRangeModel); - if (qFuzzyCompare(newPosition, d->pos)) + if (qFuzzyCompare(newPosition, d->pos)) { return; + } const qreal oldPosition = position(); const qreal oldValue = value(); @@ -473,8 +488,9 @@ void QRangeModel::setValue(qreal newValue) { Q_D(QRangeModel); - if (qFuzzyCompare(newValue, d->value)) + if (qFuzzyCompare(newValue, d->value)) { return; + } const qreal oldValue = value(); const qreal oldPosition = position(); @@ -497,8 +513,9 @@ void QRangeModel::setValue(qreal newValue) void QRangeModel::setInverted(bool inverted) { Q_D(QRangeModel); - if (inverted == d->inverted) + if (inverted == d->inverted) { return; + } d->inverted = inverted; emit invertedChanged(d->inverted); diff --git a/src/declarativeimports/plasmacomponents/qrangemodel.h b/src/declarativeimports/plasmacomponents/qrangemodel.h index 04d103745..1e34acf0b 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel.h +++ b/src/declarativeimports/plasmacomponents/qrangemodel.h @@ -113,7 +113,7 @@ Q_SIGNALS: protected: QRangeModel(QRangeModelPrivate &dd, QObject *parent); - QRangeModelPrivate* d_ptr; + QRangeModelPrivate *d_ptr; private: Q_DISABLE_COPY(QRangeModel) diff --git a/src/declarativeimports/plasmacomponents/qrangemodel_p.h b/src/declarativeimports/plasmacomponents/qrangemodel_p.h index 5eb628671..2fbada479 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel_p.h +++ b/src/declarativeimports/plasmacomponents/qrangemodel_p.h @@ -59,29 +59,35 @@ public: QRangeModel *q_ptr; - inline qreal effectivePosAtMin() const { + inline qreal effectivePosAtMin() const + { return inverted ? posatmax : posatmin; } - inline qreal effectivePosAtMax() const { + inline qreal effectivePosAtMax() const + { return inverted ? posatmin : posatmax; } - inline qreal equivalentPosition(qreal value) const { + inline qreal equivalentPosition(qreal value) const + { // Return absolute position from absolute value const qreal valueRange = maximum - minimum; - if (valueRange == 0) + if (valueRange == 0) { return effectivePosAtMin(); + } const qreal scale = (effectivePosAtMax() - effectivePosAtMin()) / valueRange; return (value - minimum) * scale + effectivePosAtMin(); } - inline qreal equivalentValue(qreal pos) const { + inline qreal equivalentValue(qreal pos) const + { // Return absolute value from absolute position const qreal posRange = effectivePosAtMax() - effectivePosAtMin(); - if (posRange == 0) + if (posRange == 0) { return minimum; + } const qreal scale = (maximum - minimum) / posRange; return (pos - effectivePosAtMin()) * scale + minimum; diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp index c25e6cc35..d807009c1 100644 --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp @@ -27,7 +27,7 @@ #include AppBackgroundProvider::AppBackgroundProvider() - : QQuickImageProvider(QQuickImageProvider::Image) + : QQuickImageProvider(QQuickImageProvider::Image) { m_theme = new Plasma::Theme(); } diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h index ff466994b..02e14af6c 100644 --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h @@ -24,7 +24,7 @@ namespace Plasma { - class Theme; +class Theme; } class AppBackgroundProvider : public QQuickImageProvider diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp index ea1389cea..9828cdc29 100644 --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp @@ -25,7 +25,6 @@ #include - FallbackComponent::FallbackComponent(QObject *parent) : QObject(parent) { diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h index 58e930c8f..c6187325a 100644 --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h @@ -20,7 +20,6 @@ #ifndef FALLBACKCOMPONENT_H #define FALLBACKCOMPONENT_H - #include #include #include @@ -55,16 +54,14 @@ public: * * @param key the name of the file to search for **/ - Q_INVOKABLE QString filePath(const QString& key = QString()); + Q_INVOKABLE QString filePath(const QString &key = QString()); QString basePath() const; void setBasePath(const QString &basePath); - QStringList candidates() const; void setCandidates(const QStringList &candidates); - Q_SIGNALS: void basePathChanged(); void candidatesChanged(); diff --git a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp index bc1b9dab5..448e13a73 100644 --- a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp +++ b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp @@ -1,6 +1,6 @@ /* * Copyright 2012 by Sebastian Kügler - + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or @@ -26,7 +26,6 @@ #include #include - // #include // #include @@ -43,6 +42,5 @@ void PlasmaExtraComponentsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "FallbackComponent"); } - #include "plasmaextracomponentsplugin.moc" diff --git a/src/declarativeimports/plasmaextracomponents/resourceinstance.cpp b/src/declarativeimports/plasmaextracomponents/resourceinstance.cpp index 218137e34..af84cc0c5 100644 --- a/src/declarativeimports/plasmaextracomponents/resourceinstance.cpp +++ b/src/declarativeimports/plasmaextracomponents/resourceinstance.cpp @@ -26,7 +26,6 @@ #include #include - ResourceInstance::ResourceInstance(QQuickItem *parent) : QQuickItem(parent) { @@ -56,7 +55,7 @@ void ResourceInstance::syncWid() } else { if (m_uri.scheme().startsWith(QLatin1String("http")) && !m_uri.hasQuery() && m_uri.path().endsWith('/')) { - const QString & oldPath = m_uri.path(); + const QString &oldPath = m_uri.path(); m_uri.setPath(oldPath.left(oldPath.length() - 1)); // qDebug() << "Old and new path" << oldPath << m_uri; @@ -129,7 +128,6 @@ void ResourceInstance::notifyFocusedIn() m_resourceInstance->notifyFocusedIn(); } - void ResourceInstance::notifyFocusedOut() { //ensure the resource instance exists diff --git a/src/declarativeimports/plasmaextracomponents/resourceinstance.h b/src/declarativeimports/plasmaextracomponents/resourceinstance.h index ddd9a9871..c6c3f52f4 100644 --- a/src/declarativeimports/plasmaextracomponents/resourceinstance.h +++ b/src/declarativeimports/plasmaextracomponents/resourceinstance.h @@ -22,8 +22,9 @@ #include #include -namespace KActivities { - class ResourceInstance; +namespace KActivities +{ +class ResourceInstance; } class QTimer; diff --git a/src/declarativeimports/platformcomponents/application.cpp b/src/declarativeimports/platformcomponents/application.cpp index ecd62f5e8..7613ff07d 100644 --- a/src/declarativeimports/platformcomponents/application.cpp +++ b/src/declarativeimports/platformcomponents/application.cpp @@ -24,13 +24,13 @@ #include -Application::Private::Private(Application * parent) +Application::Private::Private(Application *parent) : q(parent) { connect( &process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(stateChanged(QProcess::ProcessState)) - ); + ); process.setProcessChannelMode(QProcess::MergedChannels); } @@ -40,7 +40,7 @@ void Application::Private::stateChanged(QProcess::ProcessState newState) //q->runningChanged(running); } -Application::Application(QObject * parent) +Application::Application(QObject *parent) : QObject(parent), d(this) { } @@ -60,7 +60,7 @@ QString Application::application() const return d->application; } -void Application::setApplication(const QString & application) +void Application::setApplication(const QString &application) { qDebug() << "setting the application to" << application; @@ -87,10 +87,11 @@ void Application::setRunning(bool run) qDebug() << "running?" << run; d->running = run; - if (run) + if (run) { start(); - else + } else { terminate(); + } } void Application::start() @@ -107,7 +108,7 @@ void Application::start() qDebug() << "Starting" << d->application; d->process.start(d->application); - if(!d->process.waitForStarted()) { + if (!d->process.waitForStarted()) { qWarning() << "Error" << d->process.error() << "while starting" << d->application; } diff --git a/src/declarativeimports/platformcomponents/application.h b/src/declarativeimports/platformcomponents/application.h index da1a053d0..8da770371 100644 --- a/src/declarativeimports/platformcomponents/application.h +++ b/src/declarativeimports/platformcomponents/application.h @@ -36,7 +36,8 @@ * } * */ -class Application: public QObject { +class Application: public QObject +{ Q_OBJECT /** @@ -51,14 +52,14 @@ class Application: public QObject { Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged); public: - Application(QObject * parent = Q_NULLPTR); + Application(QObject *parent = Q_NULLPTR); ~Application(); QString application() const; bool running() const; public: - void setApplication(const QString & application); + void setApplication(const QString &application); void setRunning(bool run); public Q_SLOTS: @@ -66,7 +67,7 @@ public Q_SLOTS: void terminate(); Q_SIGNALS: - void applicationChanged(const QString & application); + void applicationChanged(const QString &application); void runningChanged(bool running); private: diff --git a/src/declarativeimports/platformcomponents/application_p.h b/src/declarativeimports/platformcomponents/application_p.h index 54498f110..6e5160cb6 100644 --- a/src/declarativeimports/platformcomponents/application_p.h +++ b/src/declarativeimports/platformcomponents/application_p.h @@ -24,7 +24,8 @@ #include -class Application::Private: public QObject { +class Application::Private: public QObject +{ Q_OBJECT public: Private(Application *); @@ -37,7 +38,7 @@ private Q_SLOTS: void stateChanged(QProcess::ProcessState newState); private: - Application * const q; + Application *const q; }; #endif /* APPLICATION_P_H */ diff --git a/src/declarativeimports/platformcomponents/icondialog.cpp b/src/declarativeimports/platformcomponents/icondialog.cpp index fb42c39e7..c823a7a52 100644 --- a/src/declarativeimports/platformcomponents/icondialog.cpp +++ b/src/declarativeimports/platformcomponents/icondialog.cpp @@ -31,13 +31,14 @@ /** * */ -class IconDialog::Private { +class IconDialog::Private +{ public: utils::SharedSingleton dialog; }; -IconDialog::IconDialog(QObject * parent) +IconDialog::IconDialog(QObject *parent) : QObject(parent) { } diff --git a/src/declarativeimports/platformcomponents/icondialog.h b/src/declarativeimports/platformcomponents/icondialog.h index e268a8a74..11ab148b4 100644 --- a/src/declarativeimports/platformcomponents/icondialog.h +++ b/src/declarativeimports/platformcomponents/icondialog.h @@ -39,11 +39,12 @@ * icon = iconDialog.openDialog() * */ -class IconDialog: public QObject { +class IconDialog: public QObject +{ Q_OBJECT public: - IconDialog(QObject * parent = Q_NULLPTR); + IconDialog(QObject *parent = Q_NULLPTR); ~IconDialog(); Q_INVOKABLE QString openDialog(); diff --git a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp index 03b907e98..c934ef280 100644 --- a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp +++ b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp @@ -24,25 +24,25 @@ #include "application.h" #include "icondialog.h" -class PlatformComponentsPlugin: public QQmlExtensionPlugin { +class PlatformComponentsPlugin: public QQmlExtensionPlugin +{ Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.plasma.platformcomponents") public: - PlatformComponentsPlugin(QObject * parent = Q_NULLPTR) + PlatformComponentsPlugin(QObject *parent = Q_NULLPTR) : QQmlExtensionPlugin(parent) { qDebug() << "instantiated plugin object"; } - void registerTypes(const char * uri) Q_DECL_OVERRIDE - { + void registerTypes(const char *uri) Q_DECL_OVERRIDE { qDebug() << "plugin loaded, registering types " << uri; Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.platformcomponents")); qmlRegisterType (uri, 2, 0, "Application"); - qmlRegisterType (uri, 2, 0, "IconDialog"); + qmlRegisterType (uri, 2, 0, "IconDialog"); } }; diff --git a/src/declarativeimports/platformcomponents/utils/d_ptr.h b/src/declarativeimports/platformcomponents/utils/d_ptr.h index e93873ec3..c1e37a755 100644 --- a/src/declarativeimports/platformcomponents/utils/d_ptr.h +++ b/src/declarativeimports/platformcomponents/utils/d_ptr.h @@ -22,10 +22,12 @@ #include -namespace utils { +namespace utils +{ template -class d_ptr { +class d_ptr +{ private: std::unique_ptr d; @@ -33,18 +35,18 @@ public: d_ptr(); template - d_ptr(Args && ...); + d_ptr(Args &&...); ~d_ptr(); - T * operator->() const; + T *operator->() const; }; #define D_PTR \ class Private; \ friend class Private; \ const ::utils::d_ptr d \ - + } // namespace utils #endif diff --git a/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h b/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h index 5e52a8cbb..faad5744d 100644 --- a/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h +++ b/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h @@ -22,7 +22,8 @@ #include -namespace utils { +namespace utils +{ template d_ptr::d_ptr() : d(new T()) @@ -31,8 +32,8 @@ d_ptr::d_ptr() : d(new T()) template template -d_ptr::d_ptr(Args && ... args) - : d(new T(std::forward(args)... )) +d_ptr::d_ptr(Args &&... args) + : d(new T(std::forward(args)...)) { } @@ -42,7 +43,7 @@ d_ptr::~d_ptr() } template -T * d_ptr::operator->() const +T *d_ptr::operator->() const { return d.get(); } diff --git a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h index 96b34eaa6..2aa87a384 100644 --- a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h +++ b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h @@ -22,10 +22,12 @@ #include -namespace utils { +namespace utils +{ template -class SharedSingleton { +class SharedSingleton +{ public: static std::shared_ptr instance() { diff --git a/src/kpart/plasmakpart.cpp b/src/kpart/plasmakpart.cpp index cfdd47416..dfe8ca476 100644 --- a/src/kpart/plasmakpart.cpp +++ b/src/kpart/plasmakpart.cpp @@ -88,14 +88,14 @@ PlasmaKPart::~PlasmaKPart() void PlasmaKPart::setThemeDefaults() { - KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-kpart" ); + KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-kpart"); const QString themeName = cg.readEntry("name", "appdashboard"); Plasma::Theme::defaultTheme()->setUseGlobalSettings(false); Plasma::Theme::defaultTheme()->setThemeName(themeName); cg = KConfigGroup(KSharedConfig::openConfig(), "General"); - Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", QFont("Sans") )); + Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", QFont("Sans"))); } void PlasmaKPart::syncConfig() @@ -119,7 +119,7 @@ void PlasmaKPart::initCorona() m_view->show(); } -PlasmaKPartCorona* PlasmaKPart::corona() const +PlasmaKPartCorona *PlasmaKPart::corona() const { Q_ASSERT(m_corona); return m_corona; @@ -131,7 +131,7 @@ void PlasmaKPart::createView(Plasma::Containment *containment) m_view->setContainment(containment); } -void PlasmaKPart::addApplet(const QString& name, const QVariantList& args, const QRectF& geometry ) +void PlasmaKPart::addApplet(const QString &name, const QVariantList &args, const QRectF &geometry) { Q_ASSERT(containment()); containment()->createApplet(name, args, geometry); @@ -155,7 +155,7 @@ void PlasmaKPart::setConfigFile(const QString &file) } } -Plasma::Containment* PlasmaKPart::containment() const +Plasma::Containment *PlasmaKPart::containment() const { Q_ASSERT(corona()); Q_ASSERT(!corona()->containments().isEmpty()); diff --git a/src/kpart/plasmakpart.h b/src/kpart/plasmakpart.h index 92de38524..db3aa8994 100644 --- a/src/kpart/plasmakpart.h +++ b/src/kpart/plasmakpart.h @@ -30,8 +30,8 @@ class PlasmaKPartCorona; Q_DECLARE_METATYPE(Plasma::Containment *) namespace Plasma { - class Applet; - class PluginLoader; +class Applet; +class PluginLoader; } #include @@ -85,14 +85,14 @@ public Q_SLOTS: private Q_SLOTS: void initCorona(); void syncConfig(); - void createView(Plasma::Containment* containment); + void createView(Plasma::Containment *containment); void setThemeDefaults(); private: - PlasmaKPartCorona* m_corona; - PlasmaKPartView* m_view; - QHash* m_appletList; - QVBoxLayout* m_configLayout; + PlasmaKPartCorona *m_corona; + PlasmaKPartView *m_view; + QHash *m_appletList; + QVBoxLayout *m_configLayout; QString m_configFile; }; diff --git a/src/kpart/plasmakpartcorona.cpp b/src/kpart/plasmakpartcorona.cpp index 84ecb76a2..5325c4b26 100644 --- a/src/kpart/plasmakpartcorona.cpp +++ b/src/kpart/plasmakpartcorona.cpp @@ -2,7 +2,7 @@ * Copyright 2008 Aaron Seigo * Copyright 2010 Ryan Rix * Copyright 2010 Siddharth Sharma - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or @@ -61,7 +61,7 @@ void PlasmaKPartCorona::evaluateScripts(const QStringList &scripts) connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString))); QFile file(script); - if (file.open(QIODevice::ReadOnly | QIODevice::Text) ) { + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QString code = file.readAll(); // qDebug() << "evaluating startup script:" << script; scriptEngine.evaluateScript(code); diff --git a/src/kpart/plasmakpartcorona.h b/src/kpart/plasmakpartcorona.h index 6137b8c8b..825736e4b 100644 --- a/src/kpart/plasmakpartcorona.h +++ b/src/kpart/plasmakpartcorona.h @@ -26,7 +26,7 @@ namespace Plasma { - class Applet; +class Applet; } // namespace Plasma /** @@ -34,9 +34,9 @@ namespace Plasma */ class PlasmaKPartCorona : public Plasma::Corona { -Q_OBJECT + Q_OBJECT public: - PlasmaKPartCorona(QObject* parent); + PlasmaKPartCorona(QObject *parent); protected: void loadDefaultLayout(); diff --git a/src/kpart/plasmakpartview.cpp b/src/kpart/plasmakpartview.cpp index a65201ce9..13b9070de 100644 --- a/src/kpart/plasmakpartview.cpp +++ b/src/kpart/plasmakpartview.cpp @@ -26,7 +26,7 @@ #include #include -PlasmaKPartView::PlasmaKPartView(Plasma::Containment* containment, int uid, QWidget* parent) +PlasmaKPartView::PlasmaKPartView(Plasma::Containment *containment, int uid, QWidget *parent) : Plasma::View(containment, uid, parent), m_configurationMode(false) { @@ -41,7 +41,7 @@ PlasmaKPartView::~PlasmaKPartView() { } -void PlasmaKPartView::connectContainment(Plasma::Containment* containment) +void PlasmaKPartView::connectContainment(Plasma::Containment *containment) { if (!containment) { return; @@ -51,7 +51,7 @@ void PlasmaKPartView::connectContainment(Plasma::Containment* containment) connect(containment, SIGNAL(toolBoxVisibilityChanged(bool)), this, SLOT(updateConfigurationMode(bool))); } -void PlasmaKPartView::setContainment(Plasma::Containment* c) +void PlasmaKPartView::setContainment(Plasma::Containment *c) { if (containment()) { disconnect(containment(), 0, this, 0); @@ -71,7 +71,7 @@ void PlasmaKPartView::resizeEvent(QResizeEvent *event) void PlasmaKPartView::updateGeometry() { - Plasma::Containment* c = containment(); + Plasma::Containment *c = containment(); if (!c) { return; } @@ -85,5 +85,4 @@ void PlasmaKPartView::updateGeometry() } } - #include "plasmakpartview.moc" diff --git a/src/kpart/plasmakpartview.h b/src/kpart/plasmakpartview.h index 04d5dfc26..366c242aa 100644 --- a/src/kpart/plasmakpartview.h +++ b/src/kpart/plasmakpartview.h @@ -27,12 +27,12 @@ namespace Plasma { - class Containment; +class Containment; } // namespace Plasma class PlasmaKPartView : public Plasma::View { -Q_OBJECT + Q_OBJECT public: typedef Plasma::Types::ImmutabilityType ImmutabilityType; PlasmaKPartView(Plasma::Containment *containment, int uid, QWidget *parent = 0); @@ -55,7 +55,7 @@ Q_SIGNALS: void geometryChanged(); protected: - void resizeEvent( QResizeEvent* event ); + void resizeEvent(QResizeEvent *event); private: bool m_configurationMode; diff --git a/src/kpart/scripting/backportglobal.h b/src/kpart/scripting/backportglobal.h index 45587a1cf..d0dfc2b71 100644 --- a/src/kpart/scripting/backportglobal.h +++ b/src/kpart/scripting/backportglobal.h @@ -28,7 +28,7 @@ ** functionality provided by Qt Designer and its related libraries. ** ** Trolltech reserves all rights not expressly granted herein. -** +** ** Trolltech ASA (c) 2007 ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE @@ -45,21 +45,19 @@ Class* self = qscriptvalue_cast(ctx->thisObject()); \ if (!self) { \ return ctx->throwError(QScriptContext::TypeError, \ - QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ - .arg(#Class).arg(#__fn__)); \ + QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ + .arg(#Class).arg(#__fn__)); \ } #define DECLARE_SELF2(Class, __fn__, __ret__) \ Class* self = qscriptvalue_cast(thisObject()); \ if (!self) { \ context()->throwError(QScriptContext::TypeError, \ - QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ - .arg(#Class).arg(#__fn__)); \ + QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ + .arg(#Class).arg(#__fn__)); \ return __ret__; \ } - - #define ADD_METHOD(__p__, __f__) \ __p__.setProperty(#__f__, __p__.engine()->newFunction(__f__)) @@ -67,53 +65,49 @@ ADD_METHOD(__p__, __get__) #define ADD_GET_SET_METHODS(__p__, __get__, __set__) \ -do { \ - ADD_METHOD(__p__, __get__); \ - ADD_METHOD(__p__, __set__); \ -} while (0); + do { \ + ADD_METHOD(__p__, __get__); \ + ADD_METHOD(__p__, __set__); \ + } while (0); #define ADD_CTOR_FUNCTION(__c__, __f__) ADD_METHOD(__c__, __f__) #define ADD_ENUM_VALUE(__c__, __ns__, __v__) \ __c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__)) - #define BEGIN_DECLARE_METHOD(Class, __mtd__) \ -static QScriptValue __mtd__(QScriptContext *ctx, QScriptEngine *eng) \ -{ \ - DECLARE_SELF(Class, __mtd__); + static QScriptValue __mtd__(QScriptContext *ctx, QScriptEngine *eng) \ + { \ + DECLARE_SELF(Class, __mtd__); #define END_DECLARE_METHOD \ -} - + } #define DECLARE_GET_METHOD(Class, __get__) \ -BEGIN_DECLARE_METHOD(Class, __get__) { \ - return qScriptValueFromValue(eng, self->__get__()); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __get__) { \ + return qScriptValueFromValue(eng, self->__get__()); \ + } END_DECLARE_METHOD #define DECLARE_SET_METHOD(Class, T, __set__) \ -BEGIN_DECLARE_METHOD(Class, __set__) { \ - self->__set__(qscriptvalue_cast(ctx->argument(0))); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __set__) { \ + self->__set__(qscriptvalue_cast(ctx->argument(0))); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_GET_SET_METHODS(Class, T, __get__, __set__) \ -DECLARE_GET_METHOD(Class, /*T,*/ __get__) \ -DECLARE_SET_METHOD(Class, T, __set__) - - + DECLARE_GET_METHOD(Class, /*T,*/ __get__) \ + DECLARE_SET_METHOD(Class, T, __set__) #define DECLARE_SIMPLE_GET_METHOD(Class, __get__) \ -BEGIN_DECLARE_METHOD(Class, __get__) { \ - return QScriptValue(eng, self->__get__()); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __get__) { \ + return QScriptValue(eng, self->__get__()); \ + } END_DECLARE_METHOD #define DECLARE_SIMPLE_SET_METHOD(Class, ToType, __set__) \ -BEGIN_DECLARE_METHOD(Class, __set__) { \ - self->__set__(ctx->argument(0).ToType()); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __set__) { \ + self->__set__(ctx->argument(0).ToType()); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_BOOLEAN_GET_METHOD(Class, __set__) \ DECLARE_SIMPLE_GET_METHOD(Class, __set__) @@ -136,9 +130,9 @@ BEGIN_DECLARE_METHOD(Class, __set__) { \ DECLARE_SIMPLE_SET_METHOD(Class, toString, __set__) #define DECLARE_QOBJECT_GET_METHOD(Class, __get__) \ -BEGIN_DECLARE_METHOD(Class, __get__) { \ - return eng->newQObject(self->__get__()); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __get__) { \ + return eng->newQObject(self->__get__()); \ + } END_DECLARE_METHOD #define DECLARE_QOBJECT_SET_METHOD(Class, __set__) \ DECLARE_SIMPLE_SET_METHOD(Class, toQObject, __set__) @@ -162,42 +156,40 @@ BEGIN_DECLARE_METHOD(Class, __get__) { \ DECLARE_QOBJECT_GET_METHOD(Class, __get__) \ DECLARE_QOBJECT_SET_METHOD(Class, __set__) - #define DECLARE_VOID_METHOD(Class, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - self->__fun__(); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + self->__fun__(); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_VOID_NUMBER_METHOD(Class, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - self->__fun__(ctx->argument(0).toNumber()); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + self->__fun__(ctx->argument(0).toNumber()); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_VOID_NUMBER_NUMBER_METHOD(Class, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber()); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber()); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_VOID_QUAD_NUMBER_METHOD(Class, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber(), ctx->argument(2).toNumber(), ctx->argument(3).toNumber()); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber(), ctx->argument(2).toNumber(), ctx->argument(3).toNumber()); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_VOID_1ARG_METHOD(Class, ArgType, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - self->__fun__(qscriptvalue_cast(ctx->argument(0))); \ - return eng->undefinedValue(); \ -} END_DECLARE_METHOD + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + self->__fun__(qscriptvalue_cast(ctx->argument(0))); \ + return eng->undefinedValue(); \ + } END_DECLARE_METHOD #define DECLARE_BOOLEAN_1ARG_METHOD(Class, ArgType, __fun__) \ -BEGIN_DECLARE_METHOD(Class, __fun__) { \ - return QScriptValue(eng, self->__fun__(qscriptvalue_cast(ctx->argument(0)))); \ -} END_DECLARE_METHOD - + BEGIN_DECLARE_METHOD(Class, __fun__) { \ + return QScriptValue(eng, self->__fun__(qscriptvalue_cast(ctx->argument(0)))); \ + } END_DECLARE_METHOD #define DECLARE_POINTER_METATYPE(T) \ Q_DECLARE_METATYPE(T*) \ @@ -214,21 +206,22 @@ template class Pointer : public QSharedData { public: - typedef T* pointer_type; + typedef T *pointer_type; typedef QExplicitlySharedDataPointer > wrapped_pointer_type; ~Pointer() { - if (!(m_flags & UserOwnership)) + if (!(m_flags & UserOwnership)) { delete m_value; + } } - operator T*() + operator T *() { return m_value; } - operator const T*() const + operator const T *() const { return m_value; } @@ -238,25 +231,26 @@ public: return wrapped_pointer_type(new Pointer(value, flags)); } - static QScriptValue toScriptValue(QScriptEngine *engine, T* const &source) + static QScriptValue toScriptValue(QScriptEngine *engine, T *const &source) { - if (!source) + if (!source) { return engine->nullValue(); + } return engine->newVariant(qVariantFromValue(source)); } - static void fromScriptValue(const QScriptValue &value, T* &target) + static void fromScriptValue(const QScriptValue &value, T *&target) { if (value.isVariant()) { QVariant var = value.toVariant(); - if (qVariantCanConvert(var)) { - target = qvariant_cast(var); + if (qVariantCanConvert(var)) { + target = qvariant_cast(var); } else if (qVariantCanConvert(var)) { - target = qvariant_cast(var)->operator T*(); + target = qvariant_cast(var)->operator T * (); } else { // look in prototype chain target = 0; - int type = qMetaTypeId(); + int type = qMetaTypeId(); int pointerType = qMetaTypeId(); QScriptValue proto = value.prototype(); while (proto.isObject() && proto.isVariant()) { @@ -264,10 +258,10 @@ public: if ((type == protoType) || (pointerType == protoType)) { QByteArray name = QMetaType::typeName(var.userType()); if (name.startsWith("QScript::Pointer<")) { - target = (*reinterpret_cast(var.data()))->operator T*(); + target = (*reinterpret_cast(var.data()))->operator T * (); break; } else { - target = static_cast(var.data()); + target = static_cast(var.data()); break; } } @@ -276,28 +270,34 @@ public: } } else if (value.isQObject()) { QObject *qobj = value.toQObject(); - QByteArray typeName = QMetaType::typeName(qMetaTypeId()); - target = reinterpret_cast(qobj->qt_metacast(typeName.left(typeName.size()-1))); + QByteArray typeName = QMetaType::typeName(qMetaTypeId()); + target = reinterpret_cast(qobj->qt_metacast(typeName.left(typeName.size() - 1))); } else { target = 0; } } uint flags() const - { return m_flags; } + { + return m_flags; + } void setFlags(uint flags) - { m_flags = flags; } + { + m_flags = flags; + } void unsetFlags(uint flags) - { m_flags &= ~flags; } + { + m_flags &= ~flags; + } protected: - Pointer(T* value, uint flags) + Pointer(T *value, uint flags) : m_flags(flags), m_value(value) {} private: uint m_flags; - T* m_value; + T *m_value; }; template @@ -307,9 +307,9 @@ int registerPointerMetaType( T * /* dummy */ = 0 ) { - QScriptValue (*mf)(QScriptEngine *, T* const &) = Pointer::toScriptValue; - void (*df)(const QScriptValue &, T* &) = Pointer::fromScriptValue; - const int id = qMetaTypeId(); + QScriptValue(*mf)(QScriptEngine *, T * const &) = Pointer::toScriptValue; + void (*df)(const QScriptValue &, T *&) = Pointer::fromScriptValue; + const int id = qMetaTypeId(); qScriptRegisterMetaType_helper( eng, id, reinterpret_cast(mf), reinterpret_cast(df), @@ -323,8 +323,9 @@ inline void maybeReleaseOwnership(const QScriptValue &value) if (value.isVariant()) { QVariant var = value.toVariant(); QByteArray name = QMetaType::typeName(var.userType()); - if (name.startsWith("QScript::Pointer<")) - (*reinterpret_cast::wrapped_pointer_type *>(var.data()))->setFlags(UserOwnership); + if (name.startsWith("QScript::Pointer<")) { + (*reinterpret_cast::wrapped_pointer_type *>(var.data()))->setFlags(UserOwnership); + } } } @@ -333,8 +334,9 @@ inline void maybeTakeOwnership(const QScriptValue &value) if (value.isVariant()) { QVariant var = value.toVariant(); QByteArray name = QMetaType::typeName(var.userType()); - if (name.startsWith("QScript::Pointer<")) - (*reinterpret_cast::wrapped_pointer_type *>(var.data()))->unsetFlags(UserOwnership); + if (name.startsWith("QScript::Pointer<")) { + (*reinterpret_cast::wrapped_pointer_type *>(var.data()))->unsetFlags(UserOwnership); + } } } @@ -348,7 +350,8 @@ inline QScriptValue wrapPointer(QScriptEngine *eng, T *ptr, uint flags = 0) #ifdef QGRAPHICSITEM_H -namespace QScript { +namespace QScript +{ template inline QScriptValue wrapGVPointer(QScriptEngine *eng, T *item) diff --git a/src/kpart/scripting/rect.cpp b/src/kpart/scripting/rect.cpp index 1c2a22260..1e3d7228b 100644 --- a/src/kpart/scripting/rect.cpp +++ b/src/kpart/scripting/rect.cpp @@ -19,13 +19,12 @@ #include #include "backportglobal.h" -Q_DECLARE_METATYPE(QRectF*) +Q_DECLARE_METATYPE(QRectF *) Q_DECLARE_METATYPE(QRectF) static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng) { - if (ctx->argumentCount() == 4) - { + if (ctx->argumentCount() == 4) { qreal x = ctx->argument(0).toNumber(); qreal y = ctx->argument(1).toNumber(); qreal width = ctx->argument(2).toNumber(); @@ -158,7 +157,6 @@ static QScriptValue moveRight(QScriptContext *ctx, QScriptEngine *) return QScriptValue(); } - static QScriptValue moveTo(QScriptContext *ctx, QScriptEngine *) { DECLARE_SELF(QRectF, moveTo); @@ -321,7 +319,7 @@ QScriptValue constructQRectFClass(QScriptEngine *eng) proto.setProperty("y", eng->newFunction(y), getter | setter); eng->setDefaultPrototype(qMetaTypeId(), proto); - eng->setDefaultPrototype(qMetaTypeId(), proto); + eng->setDefaultPrototype(qMetaTypeId(), proto); return eng->newFunction(ctor, proto); } diff --git a/src/kpart/scripting/scriptengine.cpp b/src/kpart/scripting/scriptengine.cpp index a38d0f1df..11e436b32 100644 --- a/src/kpart/scripting/scriptengine.cpp +++ b/src/kpart/scripting/scriptengine.cpp @@ -134,7 +134,7 @@ QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine * } const QString constraint = QString("[X-Plasma-Shell] == '%1' and [X-KDE-PluginInfo-Name] == '%2'") - .arg(KGlobal::mainComponent().componentName(),layout); + .arg(KGlobal::mainComponent().componentName(), layout); KService::List offers = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint); if (offers.isEmpty()) { @@ -145,8 +145,8 @@ QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine * Plasma::PackageStructure::Ptr structure(new LayoutTemplatePackageStructure); KPluginInfo info(offers.first()); const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - structure->defaultPackageRoot() + '/' + info.pluginName() + '/', - QStandardPaths::LocateDirectory); + structure->defaultPackageRoot() + '/' + info.pluginName() + '/', + QStandardPaths::LocateDirectory); if (path.isEmpty()) { // qDebug() << "script path is empty"; return false; @@ -189,11 +189,11 @@ void ScriptEngine::setupEngine() v.setProperty("widgets", newFunction(ScriptEngine::widgets)); v.setProperty("addWidget", newFunction(ScriptEngine::addWidget)); v.setProperty("applicationVersion", KGlobal::mainComponent().aboutData()->version(), - QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); + QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); v.setProperty("scriptingVersion", newVariant(PLASMA_KPART_SCRIPTING_VERSION), - QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); + QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); v.setProperty("platformVersion", KDE::versionString(), - QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); + QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable); setGlobalObject(v); } @@ -205,9 +205,9 @@ bool ScriptEngine::evaluateScript(const QString &script, const QString &path) if (hasUncaughtException()) { //qDebug() << "catch the exception!"; QString error = QString("Error: %1 at line %2\n\nBacktrace:\n%3").arg( - uncaughtException().toString(), - QString::number(uncaughtExceptionLineNumber()), - uncaughtExceptionBacktrace().join("\n ")); + uncaughtException().toString(), + QString::number(uncaughtExceptionLineNumber()), + uncaughtExceptionBacktrace().join("\n ")); emit printError(error); return false; } @@ -334,24 +334,24 @@ QScriptValue ScriptEngine::addWidget(QScriptContext *context, QScriptEngine *eng if (v.isString()) { // FIXME: Using QMetaObject::invokeMethod until the newspaper's API is exported... Fuuuu // applet = env->m_containment->addApplet(v.toString(), row, column); - QMetaObject::invokeMethod(env->m_containment, "addApplet", - Qt::DirectConnection, - Q_RETURN_ARG(Plasma::Applet*, applet), - Q_ARG(QString, v.toString()), + QMetaObject::invokeMethod(env->m_containment, "addApplet", + Qt::DirectConnection, + Q_RETURN_ARG(Plasma::Applet *, applet), + Q_ARG(QString, v.toString()), Q_ARG(int, row), Q_ARG(int, column)); if (applet) { ScriptEngine *env = ScriptEngine::envFor(engine); return env->wrap(applet); } - } else if (Widget *widget = qobject_cast(v.toQObject())) { + } else if (Widget *widget = qobject_cast(v.toQObject())) { applet = widget->applet(); // FIXME: Using QMetaObject::invokeMethod until the newspaper's API is exported... Fuuuu // env->m_containment->addApplet(applet, row, column); - QMetaObject::invokeMethod(env->m_containment, "addApplet", - Qt::DirectConnection, - Q_RETURN_ARG(Plasma::Applet*, applet), - Q_ARG(QString, v.toString()), + QMetaObject::invokeMethod(env->m_containment, "addApplet", + Qt::DirectConnection, + Q_RETURN_ARG(Plasma::Applet *, applet), + Q_ARG(QString, v.toString()), Q_ARG(int, row), Q_ARG(int, column)); return v; } diff --git a/src/kpart/scripting/scriptengine.h b/src/kpart/scripting/scriptengine.h index 046a73943..460c73388 100644 --- a/src/kpart/scripting/scriptengine.h +++ b/src/kpart/scripting/scriptengine.h @@ -25,9 +25,9 @@ namespace Plasma { - class Applet; - class Containment; - class Corona; +class Applet; +class Containment; +class Corona; } // namespace Plasma namespace PlasmaKPartScripting diff --git a/src/kpart/scripting/widget.h b/src/kpart/scripting/widget.h index d7d5409b4..75e04dd38 100644 --- a/src/kpart/scripting/widget.h +++ b/src/kpart/scripting/widget.h @@ -26,7 +26,7 @@ namespace Plasma { - class Applet; +class Applet; } // namespace Plasma namespace PlasmaKPartScripting @@ -71,7 +71,7 @@ public: QString type() const; /** -FIXME: what should the index(es?) be given that we're in the newspaper containment + FIXME: what should the index(es?) be given that we're in the newspaper containment int index() const; void setIndex(int index); */ @@ -89,7 +89,7 @@ public Q_SLOTS: private: class Private; - Private * const d; + Private *const d; }; } diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 73168f49b..88c4973d4 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -56,7 +56,6 @@ #include "private/associatedapplicationmanager_p.h" #include "private/containment_p.h" - namespace Plasma { @@ -168,12 +167,12 @@ void Applet::restore(KConfigGroup &group) if (!shortcutText.isEmpty()) { setGlobalShortcut(QKeySequence(shortcutText)); /* -#ifndef NDEBUG + #ifndef NDEBUG // qDebug() << "got global shortcut for" << name() << "of" << QKeySequence(shortcutText); -#endif -#ifndef NDEBUG + #endif + #ifndef NDEBUG // qDebug() << "set to" << d->activationAction->objectName() -#endif + #endif << d->activationAction->globalShortcut().primary(); */ } @@ -181,10 +180,10 @@ void Applet::restore(KConfigGroup &group) // local shortcut, if any //TODO: implement; the shortcut will need to be registered with the containment /* -#include "accessmanager.h" -#include "private/plasmoidservice_p.h" -#include "authorizationmanager.h" -#include "authorizationmanager.h" + #include "accessmanager.h" + #include "private/plasmoidservice_p.h" + #include "authorizationmanager.h" + #include "authorizationmanager.h" shortcutText = shortcutConfig.readEntryUntranslated("local", QString()); if (!shortcutText.isEmpty()) { //TODO: implement; the shortcut @@ -268,7 +267,7 @@ bool Applet::destroyed() const ConfigLoader *Applet::configScheme() const { if (!d->configLoader) { - const QString xmlPath = d->package? d->package->filePath("mainconfigxml") : QString(); + const QString xmlPath = d->package ? d->package->filePath("mainconfigxml") : QString(); KConfigGroup cfg = config(); if (xmlPath.isEmpty()) { d->configLoader = new ConfigLoader(&cfg, 0); @@ -352,7 +351,7 @@ Types::Types::ImmutabilityType Applet::immutability() const Types::ImmutabilityType upperImmutability = Types::Mutable; if (isContainment()) { - Corona *cor = static_cast(const_cast(this))->corona(); + Corona *cor = static_cast(const_cast(this))->corona(); if (cor) { upperImmutability = cor->immutability(); } @@ -506,7 +505,7 @@ void Applet::flushPendingConstraintsEvents() } // now take care of constraints in special subclass: Contaiment - Containment* containment = qobject_cast(this); + Containment *containment = qobject_cast(this); if (containment) { containment->d->containmentConstraintsEvent(c); } @@ -534,10 +533,10 @@ void Applet::flushPendingConstraintsEvents() } } -QList Applet::contextualActions() +QList Applet::contextualActions() { //qDebug() << "empty context actions"; - return d->script ? d->script->contextualActions() : QList(); + return d->script ? d->script->contextualActions() : QList(); } KActionCollection *Applet::actions() const @@ -561,7 +560,7 @@ Types::FormFactor Applet::formFactor() const Containment *Applet::containment() const { - Containment *c = qobject_cast(const_cast(this)); + Containment *c = qobject_cast(const_cast(this)); if (c && c->isContainment()) { return c; } else { @@ -571,7 +570,7 @@ Containment *Applet::containment() const QObject *parent = this->parent(); while (parent) { - Containment *possibleC = qobject_cast(parent); + Containment *possibleC = qobject_cast(parent); if (possibleC && possibleC->isContainment()) { c = possibleC; @@ -612,7 +611,6 @@ QKeySequence Applet::globalShortcut() const } } - return QKeySequence(); } @@ -731,7 +729,7 @@ void Applet::timerEvent(QTimerEvent *event) // Don't flushPendingConstraints if we're just starting up // flushPendingConstraints will be called by Corona - if(!(d->pendingConstraints & Plasma::Types::StartupCompletedConstraint)) { + if (!(d->pendingConstraints & Plasma::Types::StartupCompletedConstraint)) { flushPendingConstraintsEvents(); } } else if (d->modificationsTimer && event->timerId() == d->modificationsTimer->timerId()) { @@ -753,7 +751,7 @@ bool Applet::isContainment() const return true; } //normal "acting as a containment" condition - return qobject_cast(this) && qobject_cast(parent()); + return qobject_cast(this) && qobject_cast(parent()); } } // Plasma namespace diff --git a/src/plasma/applet.h b/src/plasma/applet.h index 7784ae5b0..06147fbe1 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -47,7 +47,6 @@ class Containment; class DataEngine; class Package; - /** * @class Applet plasma/applet.h * @@ -70,544 +69,537 @@ class PLASMA_EXPORT Applet : public QObject { Q_OBJECT - public: +public: //CONSTRUCTORS - /** - * @param parent the QObject this applet is parented to - * @param serviceId the name of the .desktop file containing the - * information about the widget - * @param appletId a unique id used to differentiate between multiple - * instances of the same Applet type - */ - explicit Applet(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0); + /** + * @param parent the QObject this applet is parented to + * @param serviceId the name of the .desktop file containing the + * information about the widget + * @param appletId a unique id used to differentiate between multiple + * instances of the same Applet type + */ + explicit Applet(QObject *parent = 0, const QString &serviceId = QString(), uint appletId = 0); - /** - * @param parent the QObject this applet is parented to - * @param info the plugin information object for this Applet - * @param appletId a unique id used to differentiate between multiple - * instances of the same Applet type - * @since 4.6 - */ - explicit Applet(const KPluginInfo &info, QObject *parent = 0, uint appletId = 0); + /** + * @param parent the QObject this applet is parented to + * @param info the plugin information object for this Applet + * @param appletId a unique id used to differentiate between multiple + * instances of the same Applet type + * @since 4.6 + */ + explicit Applet(const KPluginInfo &info, QObject *parent = 0, uint appletId = 0); - ~Applet(); + ~Applet(); //BOOKKEEPING - /** - * @return the id of this applet - */ - uint id() const; + /** + * @return the id of this applet + */ + uint id() const; - /** - * @return The type of immutability of this applet - */ - Types::ImmutabilityType immutability() const; + /** + * @return The type of immutability of this applet + */ + Types::ImmutabilityType immutability() const; - /** - * If for some reason, the applet fails to get up on its feet (the - * library couldn't be loaded, necessary hardware support wasn't found, - * etc..) this method returns the reason why, in an user-readable way. - * @since 5.0 - **/ - QString launchErrorMessage() const; + /** + * If for some reason, the applet fails to get up on its feet (the + * library couldn't be loaded, necessary hardware support wasn't found, + * etc..) this method returns the reason why, in an user-readable way. + * @since 5.0 + **/ + QString launchErrorMessage() const; - /** - * If for some reason, the applet fails to get up on its feet (the - * library couldn't be loaded, necessary hardware support wasn't found, - * etc..) this method returns true. - **/ - bool failedToLaunch() const; + /** + * If for some reason, the applet fails to get up on its feet (the + * library couldn't be loaded, necessary hardware support wasn't found, + * etc..) this method returns true. + **/ + bool failedToLaunch() const; - /** - * @return true if destroy() was called; useful for Applets which should avoid - * certain tasks if they are about to be deleted permanently - */ - bool destroyed() const; + /** + * @return true if destroy() was called; useful for Applets which should avoid + * certain tasks if they are about to be deleted permanently + */ + bool destroyed() const; - /** - * @return the Containment, if any, this applet belongs to - **/ - Containment *containment() const; + /** + * @return the Containment, if any, this applet belongs to + **/ + Containment *containment() const; - /** - * @return true if this Applet is currently being used as a Containment, false otherwise - */ - bool isContainment() const; + /** + * @return true if this Applet is currently being used as a Containment, false otherwise + */ + bool isContainment() const; - /** - * @return the status of the applet - * @since 4.4 - */ - Types::ItemStatus status() const; + /** + * @return the status of the applet + * @since 4.4 + */ + Types::ItemStatus status() const; - /** - * Returns the current form factor the applet is being displayed in. - * - * @see Plasma::FormFactor - */ - Types::FormFactor formFactor() const; + /** + * Returns the current form factor the applet is being displayed in. + * + * @see Plasma::FormFactor + */ + Types::FormFactor formFactor() const; - /** - * Returns the location of the scene which is displaying applet. - * - * @see Plasma::Types::Location - */ - Types::Location location() const; + /** + * Returns the location of the scene which is displaying applet. + * + * @see Plasma::Types::Location + */ + Types::Location location() const; //CONFIGURATION - /** - * Returns the KConfigGroup to access the applets configuration. - * - * This config object will write to an instance - * specific config file named \\rc - * in the Plasma appdata directory. - **/ - KConfigGroup config() const; + /** + * Returns the KConfigGroup to access the applets configuration. + * + * This config object will write to an instance + * specific config file named \\rc + * in the Plasma appdata directory. + **/ + KConfigGroup config() const; - /** - * Returns a KConfigGroup object to be shared by all applets of this - * type. - * - * This config object will write to an applet-specific config object - * named plasma_\rc in the local config directory. - */ - KConfigGroup globalConfig() const; + /** + * Returns a KConfigGroup object to be shared by all applets of this + * type. + * + * This config object will write to an applet-specific config object + * named plasma_\rc in the local config directory. + */ + KConfigGroup globalConfig() const; - /** - * Returns the config skeleton object from this applet's package, - * if any. - * - * @return config skeleton object, or 0 if none - **/ - ConfigLoader *configScheme() const; + /** + * Returns the config skeleton object from this applet's package, + * if any. + * + * @return config skeleton object, or 0 if none + **/ + ConfigLoader *configScheme() const; - /** - * Saves state information about this applet that will - * be accessed when next instantiated in the restore(KConfigGroup&) method. - * - * This method does not need to be reimplmented by Applet - * subclasses, but can be useful for Applet specializations - * (such as Containment) to do so. - * - * Applet subclasses may instead want to reimplement saveState(). - **/ - virtual void save(KConfigGroup &group) const; + /** + * Saves state information about this applet that will + * be accessed when next instantiated in the restore(KConfigGroup&) method. + * + * This method does not need to be reimplmented by Applet + * subclasses, but can be useful for Applet specializations + * (such as Containment) to do so. + * + * Applet subclasses may instead want to reimplement saveState(). + **/ + virtual void save(KConfigGroup &group) const; - /** - * Restores state information about this applet saved previously - * in save(KConfigGroup&). - * - * This method does not need to be reimplmented by Applet - * subclasses, but can be useful for Applet specializations - * (such as Containment) to do so. - **/ - virtual void restore(KConfigGroup &group); + /** + * Restores state information about this applet saved previously + * in save(KConfigGroup&). + * + * This method does not need to be reimplmented by Applet + * subclasses, but can be useful for Applet specializations + * (such as Containment) to do so. + **/ + virtual void restore(KConfigGroup &group); - /** - * @return true if the applet currently needs to be configured, - * otherwise, false - */ - bool configurationRequired() const; + /** + * @return true if the applet currently needs to be configured, + * otherwise, false + */ + bool configurationRequired() const; - /** - * @return true when the configuration interface is being shown - * @since 4.5 - */ - bool isUserConfiguring() const; + /** + * @return true when the configuration interface is being shown + * @since 4.5 + */ + bool isUserConfiguring() const; - /** - * Tells the applet the user is configuring - * @param configuring true if the configuration ui is showing - */ - void setUserConfiguring(bool configuring); + /** + * Tells the applet the user is configuring + * @param configuring true if the configuration ui is showing + */ + void setUserConfiguring(bool configuring); //UTILS - /** - * Accessor for the associated Package object if any. - * Generally, only Plasmoids come in a Package. - * - * @return the Package object, or an invalid one if none - **/ - Package package() const; - - /** - * Called when any of the geometry constraints have been updated. - * This method calls constraintsEvent, which may be reimplemented, - * once the Applet has been prepared for updating the constraints. - * - * @param constraints the type of constraints that were updated - */ - void updateConstraints(Plasma::Types::Constraints constraints = Plasma::Types::AllConstraints); + /** + * Accessor for the associated Package object if any. + * Generally, only Plasmoids come in a Package. + * + * @return the Package object, or an invalid one if none + **/ + Package package() const; + /** + * Called when any of the geometry constraints have been updated. + * This method calls constraintsEvent, which may be reimplemented, + * once the Applet has been prepared for updating the constraints. + * + * @param constraints the type of constraints that were updated + */ + void updateConstraints(Plasma::Types::Constraints constraints = Plasma::Types::AllConstraints); //METADATA - /** - * @return metadata information about this plugin - * @see KPluginInfo - * @since 5.0 - */ - KPluginInfo pluginInfo() const; + /** + * @return metadata information about this plugin + * @see KPluginInfo + * @since 5.0 + */ + KPluginInfo pluginInfo() const; - /** - * Returns the user-visible title for the applet, as specified in the - * Name field of the .desktop file. Can be changed with @see setTitle - * - * @since 5.0 - * @return the user-visible title for the applet. - **/ - QString title() const; + /** + * Returns the user-visible title for the applet, as specified in the + * Name field of the .desktop file. Can be changed with @see setTitle + * + * @since 5.0 + * @return the user-visible title for the applet. + **/ + QString title() const; - /** - * Sets a custom title for this instance of the applet. E.g. a clock might - * use the timezone as its name rather than the .desktop file - * - * @since 5.0 - * @param title the user-visible title for the applet. - */ - void setTitle(const QString &title) const; + /** + * Sets a custom title for this instance of the applet. E.g. a clock might + * use the timezone as its name rather than the .desktop file + * + * @since 5.0 + * @param title the user-visible title for the applet. + */ + void setTitle(const QString &title) const; - /** - * Attempts to load an applet from a package - * - * Returns a pointer to the applet if successful. - * The caller takes responsibility for the applet, including - * deleting it when no longer needed. - * - * @param path the path to the package - * @param appletId unique ID to assign the applet, or zero to have one - * assigned automatically. - * @return a pointer to the loaded applet, or 0 on load failure - * @since 4.3 - **/ - static Applet *loadPlasmoid(const QString &path, uint appletId = 0); + /** + * Attempts to load an applet from a package + * + * Returns a pointer to the applet if successful. + * The caller takes responsibility for the applet, including + * deleting it when no longer needed. + * + * @param path the path to the package + * @param appletId unique ID to assign the applet, or zero to have one + * assigned automatically. + * @return a pointer to the loaded applet, or 0 on load failure + * @since 4.3 + **/ + static Applet *loadPlasmoid(const QString &path, uint appletId = 0); - /** - * @returns The icon name related to this applet - * By default is the one in the plasmoid desktop file - **/ - QString icon() const; - - /** - * Sets an icon name for this applet - * @param icon Freedesktop compatible icon name - */ - void setIcon(const QString &icon); + /** + * @returns The icon name related to this applet + * By default is the one in the plasmoid desktop file + **/ + QString icon() const; + /** + * Sets an icon name for this applet + * @param icon Freedesktop compatible icon name + */ + void setIcon(const QString &icon); //ACTIONS - /** - * Returns a list of context-related QAction instances. - * - * This is used e.g. within the \a DesktopView to display a - * contextmenu. - * - * @return A list of actions. The default implementation returns an - * empty list. - **/ - virtual QList contextualActions(); + /** + * Returns a list of context-related QAction instances. + * + * This is used e.g. within the \a DesktopView to display a + * contextmenu. + * + * @return A list of actions. The default implementation returns an + * empty list. + **/ + virtual QList contextualActions(); - /** - * Returns the collection of actions for this Applet - */ - KActionCollection *actions() const; + /** + * Returns the collection of actions for this Applet + */ + KActionCollection *actions() const; - /** - * Sets the global shortcut to associate with this widget. - */ - void setGlobalShortcut(const QKeySequence &shortcut); + /** + * Sets the global shortcut to associate with this widget. + */ + void setGlobalShortcut(const QKeySequence &shortcut); - /** - * @return the global shortcut associated with this wiget, or - * an empty shortcut if no global shortcut is associated. - */ - QKeySequence globalShortcut() const; + /** + * @return the global shortcut associated with this wiget, or + * an empty shortcut if no global shortcut is associated. + */ + QKeySequence globalShortcut() const; // ASSOCIATED APPLICATION - /** - * Sets an application associated to this applet, that will be - * regarded as a full view of what is represented in the applet - * - * @param string the name of the application. it can be - * \li a name understood by KService::serviceByDesktopName - * (e.g. "konqueror") - * \li a command in $PATH - * \li or an absolute path to an executable - * @since 4.4 - */ - void setAssociatedApplication(const QString &string); + /** + * Sets an application associated to this applet, that will be + * regarded as a full view of what is represented in the applet + * + * @param string the name of the application. it can be + * \li a name understood by KService::serviceByDesktopName + * (e.g. "konqueror") + * \li a command in $PATH + * \li or an absolute path to an executable + * @since 4.4 + */ + void setAssociatedApplication(const QString &string); - /** - * Sets a list of urls associated to this application, - * they will be used as parameters for the associated application - * @see setAssociatedApplication() - * - * @param urls - */ - void setAssociatedApplicationUrls(const QList &urls); + /** + * Sets a list of urls associated to this application, + * they will be used as parameters for the associated application + * @see setAssociatedApplication() + * + * @param urls + */ + void setAssociatedApplicationUrls(const QList &urls); - /** - * @return the application associated to this applet - * @since 4.4 - */ - QString associatedApplication() const; + /** + * @return the application associated to this applet + * @since 4.4 + */ + QString associatedApplication() const; - /** - * @return the urls associated to this applet - * @since 4.4 - */ - QList associatedApplicationUrls() const; + /** + * @return the urls associated to this applet + * @since 4.4 + */ + QList associatedApplicationUrls() const; - /** - * @return true if the applet has a valid associated application or urls - * @since 4.4 - */ - bool hasValidAssociatedApplication() const; + /** + * @return true if the applet has a valid associated application or urls + * @since 4.4 + */ + bool hasValidAssociatedApplication() const; //Completely UI-specific, remove or move to scriptengine - /** - * @return true if this plasmoid provides a GUI configuration - **/ - bool hasConfigurationInterface() const; + /** + * @return true if this plasmoid provides a GUI configuration + **/ + bool hasConfigurationInterface() const; - Q_SIGNALS: +Q_SIGNALS: //BOOKEEPING - /** - * Emitted when the immutability changes - * @since 4.4 - */ - void immutabilityChanged(Plasma::Types::ImmutabilityType immutable); + /** + * Emitted when the immutability changes + * @since 4.4 + */ + void immutabilityChanged(Plasma::Types::ImmutabilityType immutable); - /** - * Emitted when the applet status changes - * @since 4.4 - */ - void statusChanged(Plasma::Types::ItemStatus status); + /** + * Emitted when the applet status changes + * @since 4.4 + */ + void statusChanged(Plasma::Types::ItemStatus status); //CONFIGURATION - /** - * Emitted when an applet has changed values in its configuration - * and wishes for them to be saved at the next save point. As this implies - * disk activity, this signal should be used with care. - * - * @note This does not need to be emitted from saveState by individual - * applets. - */ - void configNeedsSaving(); + /** + * Emitted when an applet has changed values in its configuration + * and wishes for them to be saved at the next save point. As this implies + * disk activity, this signal should be used with care. + * + * @note This does not need to be emitted from saveState by individual + * applets. + */ + void configNeedsSaving(); - /** - * emitted when the config ui appears or disappears - */ - void userConfiguringChanged(bool configuring); + /** + * emitted when the config ui appears or disappears + */ + void userConfiguringChanged(bool configuring); //ACTIONS - /** - * Emitted when activation is requested due to, for example, a global - * keyboard shortcut. By default the wiget is given focus. - */ - void activated(); - + /** + * Emitted when activation is requested due to, for example, a global + * keyboard shortcut. By default the wiget is given focus. + */ + void activated(); //TODO: fix usage in containment, port to QObject::destroyed - /** - * Emitted when the applet is deleted - */ - void appletDeleted(Plasma::Applet *applet); + /** + * Emitted when the applet is deleted + */ + void appletDeleted(Plasma::Applet *applet); - /** - * Emitted when the formfactor changes - */ - void formFactorChanged(Plasma::Types::FormFactor formFactor); + /** + * Emitted when the formfactor changes + */ + void formFactorChanged(Plasma::Types::FormFactor formFactor); - /** - * Emitted when the location changes - */ - void locationChanged(Plasma::Types::Location location); + /** + * Emitted when the location changes + */ + void locationChanged(Plasma::Types::Location location); - public Q_SLOTS: +public Q_SLOTS: //BOOKKEEPING - /** - * Call this method when the applet fails to launch properly. An - * optional reason can be provided. - * - * Not that all children items will be deleted when this method is - * called. If you have pointers to these items, you will need to - * reset them after calling this method. - * - * @param failed true when the applet failed, false when it succeeded - * @param reason an optional reason to show the user why the applet - * failed to launch - * @since 5.0 - **/ - void setLaunchErrorMessage(const QString &reason = QString()); + /** + * Call this method when the applet fails to launch properly. An + * optional reason can be provided. + * + * Not that all children items will be deleted when this method is + * called. If you have pointers to these items, you will need to + * reset them after calling this method. + * + * @param failed true when the applet failed, false when it succeeded + * @param reason an optional reason to show the user why the applet + * failed to launch + * @since 5.0 + **/ + void setLaunchErrorMessage(const QString &reason = QString()); - /** - * Sets the immutability type for this applet (not immutable, - * user immutable or system immutable) - * @param immutable the new immutability type of this applet - */ - void setImmutability(const Types::ImmutabilityType immutable); + /** + * Sets the immutability type for this applet (not immutable, + * user immutable or system immutable) + * @param immutable the new immutability type of this applet + */ + void setImmutability(const Types::ImmutabilityType immutable); - /** - * Destroys the applet; it will be removed nicely and deleted. - * Its configuration will also be deleted. - * If you want to remove the Applet configuration, use this, don't just delete the Applet * - */ - void destroy(); + /** + * Destroys the applet; it will be removed nicely and deleted. + * Its configuration will also be deleted. + * If you want to remove the Applet configuration, use this, don't just delete the Applet * + */ + void destroy(); - /** - * sets the status for this applet - * @since 4.4 - */ - void setStatus(const Types::ItemStatus stat); + /** + * sets the status for this applet + * @since 4.4 + */ + void setStatus(const Types::ItemStatus stat); //CONFIGURATION - /** - * Called when applet configuration values have changed. - */ - virtual void configChanged(); - + /** + * Called when applet configuration values have changed. + */ + virtual void configChanged(); //UTILS - /** - * Sends all pending constraints updates to the applet. Will usually - * be called automatically, but can also be called manually if needed. - */ - void flushPendingConstraintsEvents(); - - /** - * This method is called once the applet is loaded and added to a Corona. - * If the applet requires a Scene or has an particularly intensive - * set of initialization routines to go through, consider implementing it - * in this method instead of the constructor. - * - * Note: paintInterface may get called before init() depending on initialization - * order. Painting is managed by the canvas (QGraphisScene), and may schedule a - * paint event prior to init() being called. - **/ - virtual void init(); + /** + * Sends all pending constraints updates to the applet. Will usually + * be called automatically, but can also be called manually if needed. + */ + void flushPendingConstraintsEvents(); + /** + * This method is called once the applet is loaded and added to a Corona. + * If the applet requires a Scene or has an particularly intensive + * set of initialization routines to go through, consider implementing it + * in this method instead of the constructor. + * + * Note: paintInterface may get called before init() depending on initialization + * order. Painting is managed by the canvas (QGraphisScene), and may schedule a + * paint event prior to init() being called. + **/ + virtual void init(); //ASSOCIATED APPLICATION - /** - * Open the application associated to this applet, if it's not set - * but some urls are, open those urls with the proper application - * for their mimetype - * @see setAssociatedApplication() - * @see setAssociatedApplicationUrls() - * @since 4.4 - */ - void runAssociatedApplication(); + /** + * Open the application associated to this applet, if it's not set + * but some urls are, open those urls with the proper application + * for their mimetype + * @see setAssociatedApplication() + * @see setAssociatedApplicationUrls() + * @since 4.4 + */ + void runAssociatedApplication(); - - protected: +protected: //CONSTRUCTORS - /** - * This constructor is to be used with the plugin loading systems - * found in KPluginInfo and KService. The argument list is expected - * to have two elements: the KService service ID for the desktop entry - * and an applet ID which must be a base 10 number. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - */ - Applet(QObject *parent, const QVariantList &args); + /** + * This constructor is to be used with the plugin loading systems + * found in KPluginInfo and KService. The argument list is expected + * to have two elements: the KService service ID for the desktop entry + * and an applet ID which must be a base 10 number. + * + * @param parent a QObject parent; you probably want to pass in 0 + * @param args a list of strings containing two entries: the service id + * and the applet id + */ + Applet(QObject *parent, const QVariantList &args); //CONFIGURATION - /** - * When called, the Applet should write any information needed as part - * of the Applet's running state to the configuration object in config() - * and/or globalConfig(). - * - * Applets that always sync their settings/state with the config - * objects when these settings/states change do not need to reimplement - * this method. - **/ - virtual void saveState(KConfigGroup &config) const; + /** + * When called, the Applet should write any information needed as part + * of the Applet's running state to the configuration object in config() + * and/or globalConfig(). + * + * Applets that always sync their settings/state with the config + * objects when these settings/states change do not need to reimplement + * this method. + **/ + virtual void saveState(KConfigGroup &config) const; - /** - * Sets whether or not this applet provides a user interface for - * configuring the applet. - * - * It defaults to false, and if true is passed in you should - * also reimplement createConfigurationInterface() - * - * @param hasInterface whether or not there is a user interface available - **/ - void setHasConfigurationInterface(bool hasInterface); + /** + * Sets whether or not this applet provides a user interface for + * configuring the applet. + * + * It defaults to false, and if true is passed in you should + * also reimplement createConfigurationInterface() + * + * @param hasInterface whether or not there is a user interface available + **/ + void setHasConfigurationInterface(bool hasInterface); - /** - * When the applet needs to be configured before being usable, this - * method can be called to show a standard interface prompting the user - * to configure the applet - * - * @param needsConfiguring true if the applet needs to be configured, - * or false if it doesn't - * @param reason a translated message for the user explaining that the - * applet needs configuring; this should note what needs - * to be configured - */ - void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); + /** + * When the applet needs to be configured before being usable, this + * method can be called to show a standard interface prompting the user + * to configure the applet + * + * @param needsConfiguring true if the applet needs to be configured, + * or false if it doesn't + * @param reason a translated message for the user explaining that the + * applet needs configuring; this should note what needs + * to be configured + */ + void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); //UTILS - /** - * Called when any of the constraints for the applet have been updated. These constraints - * range from notifying when the applet has officially "started up" to when geometry changes - * to when the form factor changes. - * - * Each constraint that has been changed is passed in the constraints flag. - * All of the constraints and how they work is documented in the @see Plasma::Constraints - * enumeration. - * - * On applet creation, this is always called prior to painting and can be used as an - * opportunity to layout the widget, calculate sizings, etc. - * - * Do not call update() from this method; an update() will be triggered - * at the appropriate time for the applet. - * - * @param constraints the type of constraints that were updated - * @property constraint - */ - virtual void constraintsEvent(Plasma::Types::Constraints constraints); + /** + * Called when any of the constraints for the applet have been updated. These constraints + * range from notifying when the applet has officially "started up" to when geometry changes + * to when the form factor changes. + * + * Each constraint that has been changed is passed in the constraints flag. + * All of the constraints and how they work is documented in the @see Plasma::Constraints + * enumeration. + * + * On applet creation, this is always called prior to painting and can be used as an + * opportunity to layout the widget, calculate sizings, etc. + * + * Do not call update() from this method; an update() will be triggered + * at the appropriate time for the applet. + * + * @param constraints the type of constraints that were updated + * @property constraint + */ + virtual void constraintsEvent(Plasma::Types::Constraints constraints); //TODO: timerEvent should go into AppletPrivate - /** - * Reimplemented from QObject - */ - void timerEvent (QTimerEvent *event); + /** + * Reimplemented from QObject + */ + void timerEvent(QTimerEvent *event); +private: + /** + * @internal This constructor is to be used with the Package loading system. + * + * @param parent a QObject parent; you probably want to pass in 0 + * @param args a list of strings containing two entries: the service id + * and the applet id + * @since 4.3 + */ + Applet(const QString &packagePath, uint appletId); - private: - /** - * @internal This constructor is to be used with the Package loading system. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - * @since 4.3 - */ - Applet(const QString &packagePath, uint appletId); + Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) + Q_PRIVATE_SLOT(d, void askDestroy()) + Q_PRIVATE_SLOT(d, void updateShortcuts()) + Q_PRIVATE_SLOT(d, void globalShortcutChanged()) + Q_PRIVATE_SLOT(d, void propagateConfigChanged()) + Q_PRIVATE_SLOT(d, void requestConfiguration()) - Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) - Q_PRIVATE_SLOT(d, void askDestroy()) - Q_PRIVATE_SLOT(d, void updateShortcuts()) - Q_PRIVATE_SLOT(d, void globalShortcutChanged()) - Q_PRIVATE_SLOT(d, void propagateConfigChanged()) - Q_PRIVATE_SLOT(d, void requestConfiguration()) + AppletPrivate *const d; - AppletPrivate *const d; - - //Corona needs to access setLaunchErrorMessage and init - friend class Corona; - friend class CoronaPrivate; - friend class Containment; - friend class ContainmentPrivate; - friend class AppletScript; - friend class AppletPrivate; - friend class AccessAppletJobPrivate; - friend class GraphicsViewAppletPrivate; - friend class PluginLoader; - friend class AssociatedApplicationManager; + //Corona needs to access setLaunchErrorMessage and init + friend class Corona; + friend class CoronaPrivate; + friend class Containment; + friend class ContainmentPrivate; + friend class AppletScript; + friend class AppletPrivate; + friend class AccessAppletJobPrivate; + friend class GraphicsViewAppletPrivate; + friend class PluginLoader; + friend class AssociatedApplicationManager; }; } // Plasma namespace @@ -616,7 +608,7 @@ class PLASMA_EXPORT Applet : public QObject * Register an applet when it is contained in a loadable module */ #define K_EXPORT_PLASMA_APPLET(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY(factory, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/configloader.cpp b/src/plasma/configloader.cpp index 6db1b864b..4822548d9 100644 --- a/src/plasma/configloader.cpp +++ b/src/plasma/configloader.cpp @@ -155,7 +155,7 @@ QString ConfigLoaderHandler::defaultValue() const } bool ConfigLoaderHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) + const QString &localName, const QString &qName) { Q_UNUSED(namespaceURI) Q_UNUSED(qName) @@ -247,7 +247,7 @@ void ConfigLoaderHandler::addItem() item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); } else if (m_type == "int") { KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), - m_default.toInt(), m_key); + m_default.toInt(), m_key); if (m_haveMin) { intItem->setMinValue(m_min); @@ -313,11 +313,11 @@ void ConfigLoaderHandler::addItem() longlongItem->setMaxValue(m_max); } item = longlongItem; - /* No addItemPathList in KConfigSkeleton ? - } else if (m_type == "PathList") { - //FIXME: the split() is naive and will break on lists with ,'s in them - item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); - */ + /* No addItemPathList in KConfigSkeleton ? + } else if (m_type == "PathList") { + //FIXME: the split() is naive and will break on lists with ,'s in them + item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); + */ } else if (m_type == "point") { QPoint defaultPoint; QStringList tmpList = m_default.split(','); @@ -352,15 +352,15 @@ void ConfigLoaderHandler::addItem() ulonglongItem->setMaxValue(m_max); } item = ulonglongItem; - /* No addItemUrlList in KConfigSkeleton ? - } else if (m_type == "urllist") { - //FIXME: the split() is naive and will break on lists with ,'s in them - QStringList tmpList = m_default.split(","); - QList defaultList; - foreach (const QString& tmp, tmpList) { - defaultList.append(QUrl(tmp)); - } - item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ + /* No addItemUrlList in KConfigSkeleton ? + } else if (m_type == "urllist") { + //FIXME: the split() is naive and will break on lists with ,'s in them + QStringList tmpList = m_default.split(","); + QList defaultList; + foreach (const QString& tmp, tmpList) { + defaultList.append(QUrl(tmp)); + } + item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ } if (item) { @@ -456,7 +456,7 @@ bool ConfigLoader::usrWriteConfig() { if (d->saveDefaults) { KConfigSkeletonItem::List itemList = items(); - for(int i = 0; i < itemList.size(); i++) { + for (int i = 0; i < itemList.size(); i++) { KConfigGroup cg(config(), itemList.at(i)->group()); cg.writeEntry(itemList.at(i)->key(), ""); } diff --git a/src/plasma/configloader.h b/src/plasma/configloader.h index cc1a6ccd0..4ef9cb429 100644 --- a/src/plasma/configloader.h +++ b/src/plasma/configloader.h @@ -146,7 +146,7 @@ protected: private: friend class Service; - ConfigLoaderPrivate * const d; + ConfigLoaderPrivate *const d; }; } // Plasma namespace diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 3b7797e0c..95c9da0d7 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -107,7 +107,7 @@ void Containment::init() setContainmentType(Plasma::Types::CustomContainment); } else if (type == "CustomPanel") { setContainmentType(Plasma::Types::CustomPanelContainment); - //default to desktop + //default to desktop } else { setContainmentType(Plasma::Types::DesktopContainment); } @@ -157,20 +157,20 @@ bool appletConfigLessThan(const KConfigGroup &c1, const KConfigGroup &c2) void Containment::restore(KConfigGroup &group) { /* -#ifndef NDEBUG + #ifndef NDEBUG // qDebug() << "!!!!!!!!!!!!initConstraints" << group.name() << d->type; // qDebug() << " location:" << group.readEntry("location", (int)d->location); // qDebug() << " geom:" << group.readEntry("geometry", geometry()); // qDebug() << " formfactor:" << group.readEntry("formfactor", (int)d->formFactor); // qDebug() << " screen:" << group.readEntry("screen", d->screen); -#endif -*/ + #endif + */ setLocation((Plasma::Types::Location)group.readEntry("location", (int)d->location)); setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor)); d->lastScreen = group.readEntry("lastScreen", d->lastScreen); setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper)); - + d->activityId = group.readEntry("activityId", QString()); flushPendingConstraintsEvents(); @@ -181,7 +181,6 @@ void Containment::restore(KConfigGroup &group) KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins"); cfg = KConfigGroup(&cfg, QString::number(containmentType())); - //qDebug() << cfg.keyList(); if (cfg.exists()) { foreach (const QString &key, cfg.keyList()) { @@ -192,7 +191,7 @@ void Containment::restore(KConfigGroup &group) KConfigGroup defaultActionsCfg; if (d->type == Plasma::Types::PanelContainment) { defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Panel"); - //Plasma::Types::DesktopContainment + //Plasma::Types::DesktopContainment } else { defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Desktop"); } @@ -205,9 +204,9 @@ void Containment::restore(KConfigGroup &group) } /* -#ifndef NDEBUG + #ifndef NDEBUG // qDebug() << "Containment" << id() << -#endif + #endif "screen" << screen() << "geometry is" << geometry() << "config entries" << group.entryMap(); @@ -293,7 +292,7 @@ void Containment::setContainmentType(Plasma::Types::ContainmentType type) Corona *Containment::corona() const { - return qobject_cast(parent()); + return qobject_cast(parent()); } void Containment::setFormFactor(Types::FormFactor formFactor) @@ -444,7 +443,7 @@ int Containment::screen() const if (corona()) { return corona()->screenForContainment(this); - //case in which this containment is child of an applet, hello systray :) + //case in which this containment is child of an applet, hello systray :) } else if (Plasma::Applet *parentApplet = qobject_cast(parent())) { if (parentApplet->containment()) { return parentApplet->containment()->screen(); @@ -519,7 +518,7 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p emit configNeedsSaving(); } -QHash &Containment::containmentActions() +QHash &Containment::containmentActions() { return d->localActionPlugins; } @@ -565,6 +564,4 @@ void Containment::reactToScreenChange() } // Plasma namespace - - #include "moc_containment.cpp" diff --git a/src/plasma/containment.h b/src/plasma/containment.h index 2aaf615f9..dae61d84c 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -30,7 +30,6 @@ #include - namespace Plasma { @@ -66,271 +65,268 @@ class PLASMA_EXPORT Containment : public Applet Q_OBJECT Q_PROPERTY(QString wallpaper READ wallpaper WRITE setWallpaper NOTIFY wallpaperChanged) - public: - /** - * @param parent the QObject this applet is parented to - * @param serviceId the name of the .desktop file containing the - * information about the widget - * @param containmentId a unique id used to differentiate between multiple - * instances of the same Applet type - */ - explicit Containment(QObject *parent = 0, - const QString &serviceId = QString(), - uint containmentId = 0); +public: + /** + * @param parent the QObject this applet is parented to + * @param serviceId the name of the .desktop file containing the + * information about the widget + * @param containmentId a unique id used to differentiate between multiple + * instances of the same Applet type + */ + explicit Containment(QObject *parent = 0, + const QString &serviceId = QString(), + uint containmentId = 0); - /** - * This constructor is to be used with the plugin loading systems - * found in KPluginInfo and KService. The argument list is expected - * to have two elements: the KService service ID for the desktop entry - * and an applet ID which must be a base 10 number. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - */ - Containment(QObject *parent, const QVariantList &args); + /** + * This constructor is to be used with the plugin loading systems + * found in KPluginInfo and KService. The argument list is expected + * to have two elements: the KService service ID for the desktop entry + * and an applet ID which must be a base 10 number. + * + * @param parent a QObject parent; you probably want to pass in 0 + * @param args a list of strings containing two entries: the service id + * and the applet id + */ + Containment(QObject *parent, const QVariantList &args); - ~Containment(); + ~Containment(); - /** - * Reimplemented from Applet - */ - void init(); + /** + * Reimplemented from Applet + */ + void init(); - /** - * Returns the type of containment - */ - Plasma::Types::ContainmentType containmentType() const; + /** + * Returns the type of containment + */ + Plasma::Types::ContainmentType containmentType() const; - /** - * Returns the Corona (if any) that this Containment is hosted by - */ - Corona *corona() const; + /** + * Returns the Corona (if any) that this Containment is hosted by + */ + Corona *corona() const; - /** - * Adds an applet to this Containment - * - * @param name the plugin name for the applet, as given by - * KPluginInfo::pluginName() - * @param args argument list to pass to the plasmoid - * @param geometry where to place the applet, or to auto-place it if an invalid - * is provided - * - * @return a pointer to the applet on success, or 0 on failure - */ - Applet *createApplet(const QString &name, const QVariantList &args = QVariantList()); + /** + * Adds an applet to this Containment + * + * @param name the plugin name for the applet, as given by + * KPluginInfo::pluginName() + * @param args argument list to pass to the plasmoid + * @param geometry where to place the applet, or to auto-place it if an invalid + * is provided + * + * @return a pointer to the applet on success, or 0 on failure + */ + Applet *createApplet(const QString &name, const QVariantList &args = QVariantList()); - /** - * Add an existing applet to this Containment - * - * @param applet the applet that should be added - * @param pos the containment-relative position - */ - void addApplet(Applet *applet); + /** + * Add an existing applet to this Containment + * + * @param applet the applet that should be added + * @param pos the containment-relative position + */ + void addApplet(Applet *applet); - /** - * @return the applets currently in this Containment - */ - QList applets() const; + /** + * @return the applets currently in this Containment + */ + QList applets() const; - /** - * @return the screen number this containment is serving as the desktop for - * or -1 if none - */ - int screen() const; + /** + * @return the screen number this containment is serving as the desktop for + * or -1 if none + */ + int screen() const; - /** - * @return the last screen number this containment had - * only returns -1 if it's never ever been on a screen - * @since 4.5 - */ - int lastScreen() const; + /** + * @return the last screen number this containment had + * only returns -1 if it's never ever been on a screen + * @since 4.5 + */ + int lastScreen() const; - /** - * @reimp - * @sa Applet::save(KConfigGroup &) - */ - void save(KConfigGroup &group) const; + /** + * @reimp + * @sa Applet::save(KConfigGroup &) + */ + void save(KConfigGroup &group) const; - /** - * @reimp - * @sa Applet::restore(KConfigGroup &) - */ - void restore(KConfigGroup &group); + /** + * @reimp + * @sa Applet::restore(KConfigGroup &) + */ + void restore(KConfigGroup &group); - /** - * Sets wallpaper plugin. - * - * @param pluginName the name of the wallpaper to attempt to load - */ - void setWallpaper(const QString &pluginName); + /** + * Sets wallpaper plugin. + * + * @param pluginName the name of the wallpaper to attempt to load + */ + void setWallpaper(const QString &pluginName); - /** - * Return wallpaper plugin. - */ - QString wallpaper() const; + /** + * Return wallpaper plugin. + */ + QString wallpaper() const; - /** - * Sets the current activity by id - * - * @param activity the id of the activity - */ - void setActivity(const QString &activityId); + /** + * Sets the current activity by id + * + * @param activity the id of the activity + */ + void setActivity(const QString &activityId); - /** - * @return the current activity id associated with this containment - */ - QString activity() const; + /** + * @return the current activity id associated with this containment + */ + QString activity() const; - /** - * Sets a containmentactions plugin. - * - * @param trigger the mouse button (and optional modifier) to associate the plugin with - * @param pluginName the name of the plugin to attempt to load. blank = set no plugin. - * @since 4.4 - */ - void setContainmentActions(const QString &trigger, const QString &pluginName); + /** + * Sets a containmentactions plugin. + * + * @param trigger the mouse button (and optional modifier) to associate the plugin with + * @param pluginName the name of the plugin to attempt to load. blank = set no plugin. + * @since 4.4 + */ + void setContainmentActions(const QString &trigger, const QString &pluginName); - /** - * @return All the loaded containment action plugins, indexed by trigger name - * @since 5.0 - */ - QHash &containmentActions(); + /** + * @return All the loaded containment action plugins, indexed by trigger name + * @since 5.0 + */ + QHash &containmentActions(); - - /** - * @returns true when the ui of this containment is fully loaded, as well the ui of every applet in it - */ - bool isUiReady() const; + /** + * @returns true when the ui of this containment is fully loaded, as well the ui of every applet in it + */ + bool isUiReady() const; Q_SIGNALS: - /** - * This signal is emitted when a new applet is created by the containment - */ - void appletAdded(Plasma::Applet *applet); + /** + * This signal is emitted when a new applet is created by the containment + */ + void appletAdded(Plasma::Applet *applet); - /** - * This signal is emitted when an applet is destroyed - */ - void appletRemoved(Plasma::Applet *applet); + /** + * This signal is emitted when an applet is destroyed + */ + void appletRemoved(Plasma::Applet *applet); - /** - * Emitted when the activity id has changed - */ - void activityChanged(const QString &activity); + /** + * Emitted when the activity id has changed + */ + void activityChanged(const QString &activity); - /** - * Emitted when the containment requests an add widgets dialog is shown. - * Usually only used for desktop containments. - * - * @param pos where in the containment this request was made from, or - * an invalid position (QPointF()) is not location specific - */ - void showAddWidgetsInterface(const QPointF &pos); + /** + * Emitted when the containment requests an add widgets dialog is shown. + * Usually only used for desktop containments. + * + * @param pos where in the containment this request was made from, or + * an invalid position (QPointF()) is not location specific + */ + void showAddWidgetsInterface(const QPointF &pos); - /** - * This signal indicates that a containment has been - * associated (or dissociated) with a physical screen. - * - * @param newScreen the screen it is now associated with - */ - void screenChanged(int newScreen); + /** + * This signal indicates that a containment has been + * associated (or dissociated) with a physical screen. + * + * @param newScreen the screen it is now associated with + */ + void screenChanged(int newScreen); - /** - * Emitted when the user wants to configure/change the containment, or an applet inside it. - */ - void configureRequested(Plasma::Applet *applet); + /** + * Emitted when the user wants to configure/change the containment, or an applet inside it. + */ + void configureRequested(Plasma::Applet *applet); - /** - * Emitted when the wallpaper plugin is changed - */ - void wallpaperChanged(); + /** + * Emitted when the wallpaper plugin is changed + */ + void wallpaperChanged(); - /** - * Emitted when the location has changed - * @since 5.0 - */ - void locationChanged(Plasma::Types::Location location); + /** + * Emitted when the location has changed + * @since 5.0 + */ + void locationChanged(Plasma::Types::Location location); - /** - * Emitted when the formFactor has changed - * @since 5.0 - */ - void formFactorChanged(Plasma::Types::FormFactor formFactor); + /** + * Emitted when the formFactor has changed + * @since 5.0 + */ + void formFactorChanged(Plasma::Types::FormFactor formFactor); - /** - * Emitted when the ui has been fully loaded and is fully working - * @param uiReady true when the ui of the containment is ready, as well the ui of each applet in it - */ - void uiReadyChanged(bool uiReady); + /** + * Emitted when the ui has been fully loaded and is fully working + * @param uiReady true when the ui of the containment is ready, as well the ui of each applet in it + */ + void uiReadyChanged(bool uiReady); - /** - * emitted when the containment type changed - */ - void containmentTypeChanged(); + /** + * emitted when the containment type changed + */ + void containmentTypeChanged(); - public Q_SLOTS: - /** - * Informs the Corona as to what position it is in. This is informational - * only, as the Corona doesn't change its actual location. This is, - * however, passed on to Applets that may be managed by this Corona. - * - * @param location the new location of this Corona - */ - void setLocation(Plasma::Types::Location location); +public Q_SLOTS: + /** + * Informs the Corona as to what position it is in. This is informational + * only, as the Corona doesn't change its actual location. This is, + * however, passed on to Applets that may be managed by this Corona. + * + * @param location the new location of this Corona + */ + void setLocation(Plasma::Types::Location location); - /** - * Sets the form factor for this Containment. This may cause changes in both - * the arrangement of Applets as well as the display choices of individual - * Applets. - */ - void setFormFactor(Plasma::Types::FormFactor formFactor); + /** + * Sets the form factor for this Containment. This may cause changes in both + * the arrangement of Applets as well as the display choices of individual + * Applets. + */ + void setFormFactor(Plasma::Types::FormFactor formFactor); - /** - * Sets the type of this containment. - */ - void setContainmentType(Plasma::Types::ContainmentType type); + /** + * Sets the type of this containment. + */ + void setContainmentType(Plasma::Types::ContainmentType type); - void reactToScreenChange(); + void reactToScreenChange(); - protected: - /** - * Called when the contents of the containment should be saved. By default this saves - * all loaded Applets - * - * @param group the KConfigGroup to save settings under - */ - virtual void saveContents(KConfigGroup &group) const; +protected: + /** + * Called when the contents of the containment should be saved. By default this saves + * all loaded Applets + * + * @param group the KConfigGroup to save settings under + */ + virtual void saveContents(KConfigGroup &group) const; - /** - * Called when the contents of the containment should be loaded. By default this loads - * all previously saved Applets - * - * @param group the KConfigGroup to save settings under - */ - virtual void restoreContents(KConfigGroup &group); + /** + * Called when the contents of the containment should be loaded. By default this loads + * all previously saved Applets + * + * @param group the KConfigGroup to save settings under + */ + virtual void restoreContents(KConfigGroup &group); +private: + /** + * @internal This constructor is to be used with the Package loading system. + * + * @param parent a QObject parent; you probably want to pass in 0 + * @since 4.3 + */ + Containment(const QString &packagePath, uint appletId); + Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet *)) + Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) + Q_PRIVATE_SLOT(d, void checkStatus(Plasma::Types::ItemStatus)) - private: - /** - * @internal This constructor is to be used with the Package loading system. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @since 4.3 - */ - Containment(const QString &packagePath, uint appletId); - - Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet*)) - Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) - Q_PRIVATE_SLOT(d, void checkStatus(Plasma::Types::ItemStatus)) - - friend class Applet; - friend class AppletPrivate; - friend class CoronaPrivate; - friend class ContainmentPrivate; - friend class ContainmentActions; - ContainmentPrivate *const d; + friend class Applet; + friend class AppletPrivate; + friend class CoronaPrivate; + friend class ContainmentPrivate; + friend class ContainmentActions; + ContainmentPrivate *const d; }; } // Plasma namespace diff --git a/src/plasma/containmentactions.cpp b/src/plasma/containmentactions.cpp index e194f2c03..3abb7fe93 100644 --- a/src/plasma/containmentactions.cpp +++ b/src/plasma/containmentactions.cpp @@ -40,7 +40,7 @@ namespace Plasma { -ContainmentActions::ContainmentActions(QObject * parentObject) +ContainmentActions::ContainmentActions(QObject *parentObject) : d(new ContainmentActionsPrivate(KService::serviceByStorageId(QString()), this)) { setParent(parentObject); @@ -48,7 +48,7 @@ ContainmentActions::ContainmentActions(QObject * parentObject) ContainmentActions::ContainmentActions(QObject *parentObject, const QVariantList &args) : d(new ContainmentActionsPrivate(KService::serviceByStorageId(args.count() > 0 ? - args[0].toString() : QString()), this)) + args[0].toString() : QString()), this)) { // now remove first item since those are managed by Wallpaper and subclasses shouldn't // need to worry about them. yes, it violates the constness of this var, but it lets us add @@ -74,7 +74,7 @@ Containment *ContainmentActions::containment() if (d->containment) { return d->containment; } - return qobject_cast(parent()); + return qobject_cast(parent()); } void ContainmentActions::restore(const KConfigGroup &config) @@ -108,9 +108,9 @@ void ContainmentActions::performPreviousAction() //do nothing by default, implement in subclasses } -QList ContainmentActions::contextualActions() +QList ContainmentActions::contextualActions() { - return QList(); + return QList(); } QString ContainmentActions::eventToString(QEvent *event) @@ -119,37 +119,34 @@ QString ContainmentActions::eventToString(QEvent *event) Qt::KeyboardModifiers modifiers; switch (event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: - { - QMouseEvent *e = static_cast(event); - int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); - QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); - trigger += mouse.valueToKey(e->button()); - modifiers = e->modifiers(); - break; - } - case QEvent::Wheel: - { - QWheelEvent *e = static_cast(event); - int o = QObject::staticQtMetaObject.indexOfEnumerator("Orientations"); - QMetaEnum orient = QObject::staticQtMetaObject.enumerator(o); - trigger = "wheel:"; - trigger += orient.valueToKey(e->orientation()); - modifiers = e->modifiers(); - break; - } - case QEvent::ContextMenu: - { - int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); - QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); - trigger = mouse.valueToKey(Qt::RightButton); - modifiers = Qt::NoModifier; - break; - } - default: - return QString(); + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonDblClick: { + QMouseEvent *e = static_cast(event); + int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); + QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); + trigger += mouse.valueToKey(e->button()); + modifiers = e->modifiers(); + break; + } + case QEvent::Wheel: { + QWheelEvent *e = static_cast(event); + int o = QObject::staticQtMetaObject.indexOfEnumerator("Orientations"); + QMetaEnum orient = QObject::staticQtMetaObject.enumerator(o); + trigger = "wheel:"; + trigger += orient.valueToKey(e->orientation()); + modifiers = e->modifiers(); + break; + } + case QEvent::ContextMenu: { + int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); + QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); + trigger = mouse.valueToKey(Qt::RightButton); + modifiers = Qt::NoModifier; + break; + } + default: + return QString(); } int k = QObject::staticQtMetaObject.indexOfEnumerator("KeyboardModifiers"); @@ -167,5 +164,4 @@ void ContainmentActions::setContainment(Containment *newContainment) } // Plasma namespace - #include "moc_containmentactions.cpp" diff --git a/src/plasma/containmentactions.h b/src/plasma/containmentactions.h index 6aef7bf79..eab617911 100644 --- a/src/plasma/containmentactions.h +++ b/src/plasma/containmentactions.h @@ -55,98 +55,98 @@ class PLASMA_EXPORT ContainmentActions : public QObject { Q_OBJECT - public: - /** - * Default constructor for an empty or null containmentactions - */ - explicit ContainmentActions(QObject * parent = 0); +public: + /** + * Default constructor for an empty or null containmentactions + */ + explicit ContainmentActions(QObject *parent = 0); - ~ContainmentActions(); + ~ContainmentActions(); - /** - * @return the plugin info for this ContainmentActions instance, - * including name, pluginName and icon - * @since 5.0 - */ - KPluginInfo pluginInfo() const; + /** + * @return the plugin info for this ContainmentActions instance, + * including name, pluginName and icon + * @since 5.0 + */ + KPluginInfo pluginInfo() const; - /** - * This method should be called once the plugin is loaded or settings are changed. - * @param config Config group to load settings - * @see init - **/ - virtual void restore(const KConfigGroup &config); + /** + * This method should be called once the plugin is loaded or settings are changed. + * @param config Config group to load settings + * @see init + **/ + virtual void restore(const KConfigGroup &config); - /** - * This method is called when settings need to be saved. - * @param config Config group to save settings - **/ - virtual void save(KConfigGroup &config); + /** + * This method is called when settings need to be saved. + * @param config Config group to save settings + **/ + virtual void save(KConfigGroup &config); - /** - * Returns the widget used in the configuration dialog. - * Add the configuration interface of the containmentactions to this widget. - */ - virtual QWidget *createConfigurationInterface(QWidget *parent); + /** + * Returns the widget used in the configuration dialog. + * Add the configuration interface of the containmentactions to this widget. + */ + virtual QWidget *createConfigurationInterface(QWidget *parent); - /** - * This method is called when the user's configuration changes are accepted - */ - virtual void configurationAccepted(); + /** + * This method is called when the user's configuration changes are accepted + */ + virtual void configurationAccepted(); - /** - * Called when a "next" action is triggered (e.g. by mouse wheel scroll). This - * can be used to scroll through a list of items this plugin manages such as - * windows, virtual desktops, activities, etc. - * @see performPrevious - */ - virtual void performNextAction(); + /** + * Called when a "next" action is triggered (e.g. by mouse wheel scroll). This + * can be used to scroll through a list of items this plugin manages such as + * windows, virtual desktops, activities, etc. + * @see performPrevious + */ + virtual void performNextAction(); - /** - * Called when a "previous" action is triggered (e.g. by mouse wheel scroll). This - * can be used to scroll through a list of items this plugin manages such as - * windows, virtual desktops, activities, etc. - * @see performNext - */ - virtual void performPreviousAction(); + /** + * Called when a "previous" action is triggered (e.g. by mouse wheel scroll). This + * can be used to scroll through a list of items this plugin manages such as + * windows, virtual desktops, activities, etc. + * @see performNext + */ + virtual void performPreviousAction(); - /** - * Implement this to provide a list of actions that can be added to another menu - * for example, when right-clicking an applet, the "Activity Options" submenu is populated - * with this. - */ - virtual QList contextualActions(); + /** + * Implement this to provide a list of actions that can be added to another menu + * for example, when right-clicking an applet, the "Activity Options" submenu is populated + * with this. + */ + virtual QList contextualActions(); - /** - * Turns a mouse or wheel event into a string suitable for a ContainmentActions - * @return the string representation of the event - */ - static QString eventToString(QEvent *event); + /** + * Turns a mouse or wheel event into a string suitable for a ContainmentActions + * @return the string representation of the event + */ + static QString eventToString(QEvent *event); - /** - * @p newContainment the containment the plugin should be associated with. - * @since 4.6 - */ - void setContainment(Containment *newContainment); + /** + * @p newContainment the containment the plugin should be associated with. + * @since 4.6 + */ + void setContainment(Containment *newContainment); - /** - * @return the containment the plugin is associated with. - */ - Containment *containment(); + /** + * @return the containment the plugin is associated with. + */ + Containment *containment(); - protected: - /** - * This constructor is to be used with the plugin loading systems - * found in KPluginInfo and KService. The argument list is expected - * to have one element: the KService service ID for the desktop entry. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing one entry: the service id - */ - ContainmentActions(QObject *parent, const QVariantList &args); +protected: + /** + * This constructor is to be used with the plugin loading systems + * found in KPluginInfo and KService. The argument list is expected + * to have one element: the KService service ID for the desktop entry. + * + * @param parent a QObject parent; you probably want to pass in 0 + * @param args a list of strings containing one entry: the service id + */ + ContainmentActions(QObject *parent, const QVariantList &args); - private: - ContainmentActionsPrivate *const d; +private: + ContainmentActionsPrivate *const d; }; } // Plasma namespace @@ -156,9 +156,9 @@ class PLASMA_EXPORT ContainmentActions : public QObject */ #define K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(libname, classname, jsonFile) \ -K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -Q_DECLARE_METATYPE(Plasma::ContainmentActions*) +Q_DECLARE_METATYPE(Plasma::ContainmentActions *) #endif // PLASMA_CONTAINMENTACTIONS_H diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index c689cb6d6..9bed3487d 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -89,7 +89,7 @@ void Corona::saveLayout(const QString &configName) const d->saveLayout(c); } -void Corona::exportLayout(KConfigGroup &config, QList containments) +void Corona::exportLayout(KConfigGroup &config, QList containments) { foreach (const QString &group, config.groupList()) { KConfigGroup cg(&config, group); @@ -166,8 +166,8 @@ Containment *Corona::containmentForScreen(int screen) const { foreach (Containment *containment, d->containments) { if (containment->screen() == screen && - (containment->containmentType() == Plasma::Types::DesktopContainment || - containment->containmentType() == Plasma::Types::CustomContainment)) { + (containment->containmentType() == Plasma::Types::DesktopContainment || + containment->containmentType() == Plasma::Types::CustomContainment)) { return containment; } } @@ -175,7 +175,7 @@ Containment *Corona::containmentForScreen(int screen) const return 0; } -QList Corona::containments() const +QList Corona::containments() const { return d->containments; } @@ -212,12 +212,11 @@ Containment *Corona::createContainmentDelayed(const QString &name, const QVarian return 0; } -int Corona::screenForContainment(const Containment* containment) const +int Corona::screenForContainment(const Containment *containment) const { return -1; } - int Corona::numScreens() const { return 1; @@ -295,7 +294,7 @@ QList Corona::freeEdges(int screen) const foreach (Containment *containment, containments()) { if (containment->screen() == screen && - freeEdges.contains(containment->location())) { + freeEdges.contains(containment->location())) { freeEdges.removeAll(containment->location()); } } @@ -384,18 +383,18 @@ void CoronaPrivate::updateContainmentImmutability() void CoronaPrivate::containmentDestroyed(QObject *obj) { - // we do a static_cast here since it really isn't an Containment by this - // point anymore since we are in the qobject dtor. we don't actually - // try and do anything with it, we just need the value of the pointer - // so this unsafe looking code is actually just fine. - Containment* containment = static_cast(obj); - int index = containments.indexOf(containment); + // we do a static_cast here since it really isn't an Containment by this + // point anymore since we are in the qobject dtor. we don't actually + // try and do anything with it, we just need the value of the pointer + // so this unsafe looking code is actually just fine. + Containment *containment = static_cast(obj); + int index = containments.indexOf(containment); - if (index > -1) { - containments.removeAt(index); - q->requestConfigSync(); - } + if (index > -1) { + containments.removeAt(index); + q->requestConfigSync(); } +} void CoronaPrivate::syncConfig() { @@ -419,7 +418,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi bool loadingNull = pluginName == "null"; if (!loadingNull) { applet = PluginLoader::self()->loadApplet(pluginName, id, args); - containment = dynamic_cast(applet); + containment = dynamic_cast(applet); if (containment) { containment->setParent(q); } @@ -457,11 +456,11 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi containments.append(containment); QObject::connect(containment, SIGNAL(destroyed(QObject*)), - q, SLOT(containmentDestroyed(QObject*))); + q, SLOT(containmentDestroyed(QObject*))); QObject::connect(containment, SIGNAL(configNeedsSaving()), - q, SLOT(requestConfigSync())); + q, SLOT(requestConfigSync())); QObject::connect(containment, SIGNAL(screenChanged(int)), - q, SIGNAL(screenOwnerChanged(int))); + q, SIGNAL(screenOwnerChanged(int))); if (!delayedInit) { containment->init(); @@ -536,7 +535,7 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con foreach (Containment *containment, containments) { if (!containment->isUiReady() && containment->lastScreen() < q->numScreens()) { ++containmentsStarting; - QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [=](){ + QObject::connect(containment, &Plasma::Containment::uiReadyChanged, [ = ]() { --containmentsStarting; if (containmentsStarting <= 0) { qDebug() << "Corona Startup Completed"; @@ -552,6 +551,4 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con } // namespace Plasma - - #include "moc_corona.cpp" diff --git a/src/plasma/corona.h b/src/plasma/corona.h index 882666385..ab926c7fd 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -43,7 +43,7 @@ class PLASMA_EXPORT Corona : public QObject Q_OBJECT public: - explicit Corona(QObject * parent = 0); + explicit Corona(QObject *parent = 0); ~Corona(); /** @@ -66,7 +66,7 @@ public: /** * @return all containments on this Corona */ - QList containments() const; + QList containments() const; /** * @returns true when the startup is over, and @@ -154,7 +154,7 @@ public: /** * The actions assocated with this Corona */ - KActionCollection* actions() const; + KActionCollection *actions() const; /** * Imports an applet layout from a config file. The results will be added to the @@ -174,7 +174,7 @@ public: * @param containments the list of containments to save * @since 4.6 */ - void exportLayout(KConfigGroup &config, QList containments); + void exportLayout(KConfigGroup &config, QList containments); /** * @returns the id of the screen which is showing @p containment @@ -305,7 +305,7 @@ protected: private: CoronaPrivate *const d; - Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*)) + Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject *)) Q_PRIVATE_SLOT(d, void syncConfig()) Q_PRIVATE_SLOT(d, void toggleImmutability()) diff --git a/src/plasma/datacontainer.cpp b/src/plasma/datacontainer.cpp index e8463927a..f4008daf9 100644 --- a/src/plasma/datacontainer.cpp +++ b/src/plasma/datacontainer.cpp @@ -104,7 +104,7 @@ bool DataContainer::visualizationIsConnected(QObject *visualization) const } void DataContainer::connectVisualization(QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment alignment) + Plasma::Types::IntervalAlignment alignment) { //qDebug() << "connecting visualization" <isUnused(); } } else if (pollingInterval < 1) { @@ -144,12 +144,12 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt } else { disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); - disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), - visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); + disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), + visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); } } else { connect(visualization, SIGNAL(destroyed(QObject*)), - this, SLOT(disconnectVisualization(QObject*)));//, Qt::QueuedConnection); + this, SLOT(disconnectVisualization(QObject*))); //, Qt::QueuedConnection); } if (pollingInterval < 1) { @@ -157,8 +157,8 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt d->relayObjects[visualization] = 0; connect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); - connect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), - visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); + connect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), + visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); } else { //qDebug() << " connecting to a relay"; // we only want to do an imediate update if this is not the first object to connect to us @@ -170,8 +170,8 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt connect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); //modelChanged is always emitted by the dataSource since there is no polling there - connect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), - visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); + connect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), + visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); } } @@ -181,7 +181,7 @@ void DataContainer::setStorageEnabled(bool store) qsrand((uint)time.msec()); d->enableStorage = store; if (store) { - QTimer::singleShot(qrand() % (2000 + 1) , this, SLOT(retrieve())); + QTimer::singleShot(qrand() % (2000 + 1), this, SLOT(retrieve())); } } @@ -200,17 +200,16 @@ void DataContainer::setNeedsToBeStored(bool store) d->isStored = !store; } -DataEngine* DataContainer::getDataEngine() +DataEngine *DataContainer::getDataEngine() { QObject *o = this; DataEngine *de = NULL; - while (de == NULL) - { - o = dynamic_cast (o->parent()); + while (de == NULL) { + o = dynamic_cast(o->parent()); if (o == NULL) { return NULL; } - de = dynamic_cast (o); + de = dynamic_cast(o); } return de; } @@ -221,7 +220,7 @@ void DataContainerPrivate::store() return; } - DataEngine* de = q->getDataEngine(); + DataEngine *de = q->getDataEngine(); if (!de) { return; } @@ -240,7 +239,7 @@ void DataContainerPrivate::store() QObject::connect(job, SIGNAL(finished(KJob*)), q, SLOT(storeJobFinished(KJob*))); } -void DataContainerPrivate::storeJobFinished(KJob* ) +void DataContainerPrivate::storeJobFinished(KJob *) { --storageCount; if (storageCount < 1) { @@ -251,7 +250,7 @@ void DataContainerPrivate::storeJobFinished(KJob* ) void DataContainerPrivate::retrieve() { - DataEngine* de = q->getDataEngine(); + DataEngine *de = q->getDataEngine(); if (de == NULL) { return; } @@ -262,9 +261,9 @@ void DataContainerPrivate::retrieve() QVariantMap retrieveGroup = storage->operationDescription("retrieve"); retrieveGroup["group"] = q->objectName(); - ServiceJob* retrieveJob = storage->startOperationCall(retrieveGroup); + ServiceJob *retrieveJob = storage->startOperationCall(retrieveGroup); QObject::connect(retrieveJob, SIGNAL(result(KJob*)), q, - SLOT(populateFromStoredData(KJob*))); + SLOT(populateFromStoredData(KJob*))); } void DataContainerPrivate::populateFromStoredData(KJob *job) @@ -273,7 +272,7 @@ void DataContainerPrivate::populateFromStoredData(KJob *job) return; } - StorageJob *ret = dynamic_cast(job); + StorageJob *ret = dynamic_cast(job); if (!ret) { return; } @@ -296,14 +295,14 @@ void DataContainer::disconnectVisualization(QObject *visualization) { QMap::iterator objIt = d->relayObjects.find(visualization); disconnect(visualization, SIGNAL(destroyed(QObject*)), - this, SLOT(disconnectVisualization(QObject*)));//, Qt::QueuedConnection); + this, SLOT(disconnectVisualization(QObject*))); //, Qt::QueuedConnection); if (objIt == d->relayObjects.end() || !objIt.value()) { // it is connected directly to the DataContainer itself disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); - disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), - visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); + disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), + visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); } else { SignalRelay *relay = objIt.value(); @@ -314,8 +313,8 @@ void DataContainer::disconnectVisualization(QObject *visualization) disconnect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); //modelChanged is always emitted by the dataSource since there is no polling there - disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), - visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); + disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), + visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); } } @@ -364,7 +363,7 @@ void DataContainer::setNeedsUpdate(bool update) bool DataContainer::isUsed() const { return !d->relays.isEmpty() || - receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) > 0; + receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) > 0; } void DataContainerPrivate::checkUsage() @@ -374,13 +373,13 @@ void DataContainerPrivate::checkUsage() } } -void DataContainer::timerEvent(QTimerEvent * event) +void DataContainer::timerEvent(QTimerEvent *event) { if (event->timerId() == d->checkUsageTimer.timerId()) { if (!isUsed()) { // DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED! //qDebug() << objectName() << "is unused"; - + //NOTE: Notifying visualization of the model destruction before actual deletion avoids crashes in some edge cases if (d->model) { d->model.clear(); @@ -397,6 +396,4 @@ void DataContainer::timerEvent(QTimerEvent * event) } // Plasma namespace - - #include "moc_datacontainer.cpp" diff --git a/src/plasma/datacontainer.h b/src/plasma/datacontainer.h index 57fac3f59..c58c8e19a 100644 --- a/src/plasma/datacontainer.h +++ b/src/plasma/datacontainer.h @@ -68,224 +68,224 @@ class PLASMA_EXPORT DataContainer : public QObject friend class DataEnginePrivate; Q_OBJECT - public: - /** - * Constructs a default DataContainer that has no name or data - * associated with it - **/ - explicit DataContainer(QObject *parent = 0); - virtual ~DataContainer(); +public: + /** + * Constructs a default DataContainer that has no name or data + * associated with it + **/ + explicit DataContainer(QObject *parent = 0); + virtual ~DataContainer(); - /** - * Returns the data for this DataContainer - **/ - const DataEngine::Data data() const; + /** + * Returns the data for this DataContainer + **/ + const DataEngine::Data data() const; - /** - * Set a value for a key. - * - * This also marks this source as needing to signal an update. - * - * If you call setData() directly on a DataContainer, you need to - * either trigger the scheduleSourcesUpdated() slot for the - * data engine it belongs to or call checkForUpdate() on the - * DataContainer. - * - * @param key a string used as the key for the data - * @param value a QVariant holding the actual data. If a invalid - * QVariant is passed in and the key currently exists in the - * data, then the data entry is removed - **/ - void setData(const QString &key, const QVariant &value); + /** + * Set a value for a key. + * + * This also marks this source as needing to signal an update. + * + * If you call setData() directly on a DataContainer, you need to + * either trigger the scheduleSourcesUpdated() slot for the + * data engine it belongs to or call checkForUpdate() on the + * DataContainer. + * + * @param key a string used as the key for the data + * @param value a QVariant holding the actual data. If a invalid + * QVariant is passed in and the key currently exists in the + * data, then the data entry is removed + **/ + void setData(const QString &key, const QVariant &value); - /** - * Removes all data currently associated with this source - * - * If you call removeAllData() on a DataContainer, you need to - * either trigger the scheduleSourcesUpdated() slot for the - * data engine it belongs to or call checkForUpdate() on the - * DataContainer. - **/ - void removeAllData(); + /** + * Removes all data currently associated with this source + * + * If you call removeAllData() on a DataContainer, you need to + * either trigger the scheduleSourcesUpdated() slot for the + * data engine it belongs to or call checkForUpdate() on the + * DataContainer. + **/ + void removeAllData(); - /** - * Associates a model with this DataContainer. Use this for data - * that is intended to be a long list of items. - * - * The ownership of the model is transferred to the DataContainer, - * so the model will be deletd when a new one is set or when the - * DataContainer itself is deleted, so it will be deleted when there won't be any - * visualization associated to this source. - * - * Normally you should set the model from DataEngine::setModel instead from here. - * - * @param model the model that will be associated with this DataContainer - */ - void setModel(QAbstractItemModel *model); + /** + * Associates a model with this DataContainer. Use this for data + * that is intended to be a long list of items. + * + * The ownership of the model is transferred to the DataContainer, + * so the model will be deletd when a new one is set or when the + * DataContainer itself is deleted, so it will be deleted when there won't be any + * visualization associated to this source. + * + * Normally you should set the model from DataEngine::setModel instead from here. + * + * @param model the model that will be associated with this DataContainer + */ + void setModel(QAbstractItemModel *model); - /** - * @return the model owned by this DataSource - */ - QAbstractItemModel *model(); + /** + * @return the model owned by this DataSource + */ + QAbstractItemModel *model(); - /** - * @return true if the visualization is currently connected - */ - bool visualizationIsConnected(QObject *visualization) const; + /** + * @return true if the visualization is currently connected + */ + bool visualizationIsConnected(QObject *visualization) const; - /** - * Connects an object to this DataContainer. - * - * May be called repeatedly for the same visualization without - * side effects - * - * @param visualization the object to connect to this DataContainer - * @param pollingInterval the time in milliseconds between updates - * @param alignment the clock position to align updates to - **/ - void connectVisualization(QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment alignment); + /** + * Connects an object to this DataContainer. + * + * May be called repeatedly for the same visualization without + * side effects + * + * @param visualization the object to connect to this DataContainer + * @param pollingInterval the time in milliseconds between updates + * @param alignment the clock position to align updates to + **/ + void connectVisualization(QObject *visualization, uint pollingInterval, + Plasma::Types::IntervalAlignment alignment); - /** - * sets this data container to be automatically stored. - * @param whether this data container should be stored - * @since 4.6 - */ - void setStorageEnabled(bool store); + /** + * sets this data container to be automatically stored. + * @param whether this data container should be stored + * @since 4.6 + */ + void setStorageEnabled(bool store); - /** - * @return true if the data container has been marked for storage - * @since 4.6 - */ - bool isStorageEnabled() const; + /** + * @return true if the data container has been marked for storage + * @since 4.6 + */ + bool isStorageEnabled() const; - /** - * @return true if the data container has been updated, but not stored - */ - bool needsToBeStored() const; + /** + * @return true if the data container has been updated, but not stored + */ + bool needsToBeStored() const; - /** - * sets that the data container needs to be stored or not. - * @param whether the data container needs to be stored - */ - void setNeedsToBeStored(bool store); + /** + * sets that the data container needs to be stored or not. + * @param whether the data container needs to be stored + */ + void setNeedsToBeStored(bool store); - /** - * @return the DataEngine that the DataContainer is - * a child of. - */ - DataEngine* getDataEngine(); + /** + * @return the DataEngine that the DataContainer is + * a child of. + */ + DataEngine *getDataEngine(); - /** - * @return true if one or more visualizations is connected to this DataContainer - */ - bool isUsed() const; + /** + * @return true if one or more visualizations is connected to this DataContainer + */ + bool isUsed() const; - public Q_SLOTS: - /** - * Disconnects an object from this DataContainer. - * - * Note that if this source was created by DataEngine::sourceRequestEvent(), - * it will be deleted by DataEngine once control returns to the event loop. - **/ - void disconnectVisualization(QObject *visualization); +public Q_SLOTS: + /** + * Disconnects an object from this DataContainer. + * + * Note that if this source was created by DataEngine::sourceRequestEvent(), + * it will be deleted by DataEngine once control returns to the event loop. + **/ + void disconnectVisualization(QObject *visualization); - /** - * Forces immediate update signals to all visualizations - * @since 4.4 - */ - void forceImmediateUpdate(); + /** + * Forces immediate update signals to all visualizations + * @since 4.4 + */ + void forceImmediateUpdate(); - Q_SIGNALS: - /** - * Emitted when the data has been updated, allowing visualizations to - * reflect the new data. - * - * Note that you should not normally emit this directly. Instead, use - * checkForUpdate() or the DataEngine::scheduleSourcesUpdated() slot. - * - * @param source the objectName() of the DataContainer (and hence the name - * of the source) that updated its data - * @param data the updated data - **/ - void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data); +Q_SIGNALS: + /** + * Emitted when the data has been updated, allowing visualizations to + * reflect the new data. + * + * Note that you should not normally emit this directly. Instead, use + * checkForUpdate() or the DataEngine::scheduleSourcesUpdated() slot. + * + * @param source the objectName() of the DataContainer (and hence the name + * of the source) that updated its data + * @param data the updated data + **/ + void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data); - /** - * A new model has been associated to this source, - * visualizations can safely use it as long they are connected to this source. - * - * @param source the objectName() of the DataContainer (and hence the name - * of the source) that owns the model - * @param model the QAbstractItemModel instance - */ - void modelChanged(const QString &source, QAbstractItemModel *model); + /** + * A new model has been associated to this source, + * visualizations can safely use it as long they are connected to this source. + * + * @param source the objectName() of the DataContainer (and hence the name + * of the source) that owns the model + * @param model the QAbstractItemModel instance + */ + void modelChanged(const QString &source, QAbstractItemModel *model); - /** - * Emitted when the last visualization is disconnected. - * - * Note that if this source was created by DataEngine::sourceRequestEvent(), - * it will be deleted by DataEngine once control returns to the event loop - * after this signal is emitted. - * - * @param source the name of the source that became unused - **/ - void becameUnused(const QString &source); + /** + * Emitted when the last visualization is disconnected. + * + * Note that if this source was created by DataEngine::sourceRequestEvent(), + * it will be deleted by DataEngine once control returns to the event loop + * after this signal is emitted. + * + * @param source the name of the source that became unused + **/ + void becameUnused(const QString &source); - /** - * Emitted when an update is requested. - * - * If a polling interval was passed connectVisualization(), this signal - * will be emitted every time the interval expires. - * - * Note that if you create your own DataContainer (and pass it to - * DataEngine::addSource()), you will need to listen to this signal - * and refresh the data when it is triggered. - * - * @param source the datacontainer the update was requested for. Useful - * for classes that update the data for several containers. - **/ - void updateRequested(DataContainer *source); + /** + * Emitted when an update is requested. + * + * If a polling interval was passed connectVisualization(), this signal + * will be emitted every time the interval expires. + * + * Note that if you create your own DataContainer (and pass it to + * DataEngine::addSource()), you will need to listen to this signal + * and refresh the data when it is triggered. + * + * @param source the datacontainer the update was requested for. Useful + * for classes that update the data for several containers. + **/ + void updateRequested(DataContainer *source); - protected: - /** - * Checks whether any data has changed and, if so, emits dataUpdated(). - **/ - void checkForUpdate(); +protected: + /** + * Checks whether any data has changed and, if so, emits dataUpdated(). + **/ + void checkForUpdate(); - /** - * Returns how long ago, in msecs, that the data in this container was last updated. - * - * This is used by DataEngine to compress updates that happen more quickly than the - * minimum polling interval by calling setNeedsUpdate() instead of calling - * updateSourceEvent() immediately. - **/ - uint timeSinceLastUpdate() const; + /** + * Returns how long ago, in msecs, that the data in this container was last updated. + * + * This is used by DataEngine to compress updates that happen more quickly than the + * minimum polling interval by calling setNeedsUpdate() instead of calling + * updateSourceEvent() immediately. + **/ + uint timeSinceLastUpdate() const; - /** - * Indicates that the data should be treated as dirty the next time hasUpdates() is called. - * - * This is needed for the case where updateRequested() is triggered but we don't want to - * update the data immediately because it has just been updated. The second request won't - * be fulfilled in this case, because we never updated the data and so never called - * checkForUpdate(). So we claim it needs an update anyway. - **/ - void setNeedsUpdate(bool update = true); + /** + * Indicates that the data should be treated as dirty the next time hasUpdates() is called. + * + * This is needed for the case where updateRequested() is triggered but we don't want to + * update the data immediately because it has just been updated. The second request won't + * be fulfilled in this case, because we never updated the data and so never called + * checkForUpdate(). So we claim it needs an update anyway. + **/ + void setNeedsUpdate(bool update = true); - protected Q_SLOTS: - /** - * @reimp from QObject - */ - void timerEvent(QTimerEvent * event); +protected Q_SLOTS: + /** + * @reimp from QObject + */ + void timerEvent(QTimerEvent *event); - private: - friend class SignalRelay; - friend class DataContainerPrivate; - friend class DataEngineManager; - DataContainerPrivate *const d; +private: + friend class SignalRelay; + friend class DataContainerPrivate; + friend class DataEngineManager; + DataContainerPrivate *const d; - Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job)) - Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job)) - Q_PRIVATE_SLOT(d, void retrieve()) + Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job)) + Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job)) + Q_PRIVATE_SLOT(d, void retrieve()) }; } // Plasma namespace diff --git a/src/plasma/dataengine.cpp b/src/plasma/dataengine.cpp index 312802906..86e33d195 100644 --- a/src/plasma/dataengine.cpp +++ b/src/plasma/dataengine.cpp @@ -60,7 +60,7 @@ DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent) } } -DataEngine::DataEngine(QObject* parent, const QVariantList &args) +DataEngine::DataEngine(QObject *parent, const QVariantList &args) : QObject(parent), d(new DataEnginePrivate(this, KPluginInfo(args))) { @@ -88,7 +88,7 @@ QStringList DataEngine::sources() const Service *DataEngine::serviceForSource(const QString &source) { if (d->script) { - Service * s = d->script->serviceForSource(source); + Service *s = d->script->serviceForSource(source); if (s) { return s; } @@ -293,7 +293,7 @@ void DataEngine::setPollingInterval(uint frequency) void DataEngine::removeSource(const QString &source) { - QHash::iterator it = d->sources.find(source); + QHash::iterator it = d->sources.find(source); if (it != d->sources.end()) { DataContainer *s = it.value(); s->d->store(); @@ -306,7 +306,7 @@ void DataEngine::removeSource(const QString &source) void DataEngine::removeAllSources() { - QMutableHashIterator it(d->sources); + QMutableHashIterator it(d->sources); while (it.hasNext()) { it.next(); Plasma::DataContainer *s = it.value(); @@ -333,7 +333,7 @@ void DataEngine::setValid(bool valid) d->valid = valid; } -QHash DataEngine::containerDict() const +QHash DataEngine::containerDict() const { return d->sources; } @@ -360,7 +360,7 @@ void DataEngine::timerEvent(QTimerEvent *event) killTimer(d->checkSourcesTimerId); d->checkSourcesTimerId = 0; - QHashIterator it(d->sources); + QHashIterator it(d->sources); while (it.hasNext()) { it.next(); it.value()->checkForUpdate(); @@ -372,7 +372,7 @@ void DataEngine::timerEvent(QTimerEvent *event) void DataEngine::updateAllSources() { - QHashIterator it(d->sources); + QHashIterator it(d->sources); while (it.hasNext()) { it.next(); //qDebug() << "updating" << it.key(); @@ -460,7 +460,7 @@ DataEnginePrivate::~DataEnginePrivate() void DataEnginePrivate::internalUpdateSource(DataContainer *source) { if (minPollingInterval > 0 && - source->timeSinceLastUpdate() < (uint)minPollingInterval) { + source->timeSinceLastUpdate() < (uint)minPollingInterval) { // skip updating this source; it's been too soon //qDebug() << "internal update source is delaying" << source->timeSinceLastUpdate() << minPollingInterval; //but fake an update so that the signalrelay that triggered this gets the data from the @@ -497,7 +497,7 @@ bool DataEnginePrivate::isUsed() const DataContainer *DataEnginePrivate::source(const QString &sourceName, bool createWhenMissing) { - QHash::const_iterator it = sources.constFind(sourceName); + QHash::const_iterator it = sources.constFind(sourceName); if (it != sources.constEnd()) { DataContainer *s = it.value(); return s; @@ -550,8 +550,8 @@ void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization, Q_ARG(Plasma::DataEngine::Data, s->data())); if (s->d->model) { QMetaObject::invokeMethod(visualization, "modelChanged", - Q_ARG(QString, s->objectName()), - Q_ARG(QAbstractItemModel *, s->d->model.data())); + Q_ARG(QString, s->objectName()), + Q_ARG(QAbstractItemModel *, s->d->model.data())); } s->d->dirty = false; } @@ -559,7 +559,7 @@ void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization, void DataEnginePrivate::sourceDestroyed(QObject *object) { - QHash::iterator it = sources.begin(); + QHash::iterator it = sources.begin(); while (it != sources.end()) { if (it.value() == object) { sources.erase(it); @@ -612,9 +612,9 @@ void DataEnginePrivate::setupScriptSupport() } /* -#ifndef NDEBUG + #ifndef NDEBUG // qDebug() << "sletting up script support, package is in" << package->path() -#endif + #endif << "which is a" << package->structure()->type() << "package" << ", main script is" << package->filePath("mainscript"); */ @@ -637,5 +637,4 @@ void DataEnginePrivate::scheduleSourcesUpdated() } - #include "moc_dataengine.cpp" diff --git a/src/plasma/dataengine.h b/src/plasma/dataengine.h index 1552d2ab3..d87a6f836 100644 --- a/src/plasma/dataengine.h +++ b/src/plasma/dataengine.h @@ -61,388 +61,388 @@ class PLASMA_EXPORT DataEngine : public QObject { Q_OBJECT - public: - typedef QHash Dict; - typedef QMap Data; - typedef QMapIterator DataIterator; - typedef QHash SourceDict; +public: + typedef QHash Dict; + typedef QMap Data; + typedef QMapIterator DataIterator; + typedef QHash SourceDict; - /** - * Constructor. - * - * @param parent The parent object. - * @param plugin plugin info that describes the engine - **/ - explicit DataEngine(const KPluginInfo &plugin, QObject *parent = 0); + /** + * Constructor. + * + * @param parent The parent object. + * @param plugin plugin info that describes the engine + **/ + explicit DataEngine(const KPluginInfo &plugin, QObject *parent = 0); - explicit DataEngine(QObject *parent = 0, const QVariantList &args = QVariantList()); + explicit DataEngine(QObject *parent = 0, const QVariantList &args = QVariantList()); - ~DataEngine(); + ~DataEngine(); - /** - * @return a list of all the data sources available via this DataEngine - * Whether these sources are currently available (which is what - * the default implementation provides) or not is up to the - * DataEngine to decide. - **/ - virtual QStringList sources() const; + /** + * @return a list of all the data sources available via this DataEngine + * Whether these sources are currently available (which is what + * the default implementation provides) or not is up to the + * DataEngine to decide. + **/ + virtual QStringList sources() const; - /** - * @param source the source to target the Service at - * @return a Service that has the source as a destination. The service - * is parented to the DataEngine, but should be deleted by the - * caller when finished with it - */ - Q_INVOKABLE virtual Service *serviceForSource(const QString &source); + /** + * @param source the source to target the Service at + * @return a Service that has the source as a destination. The service + * is parented to the DataEngine, but should be deleted by the + * caller when finished with it + */ + Q_INVOKABLE virtual Service *serviceForSource(const QString &source); - /** - * @return description of the plugin that implements this DataEngine - */ - KPluginInfo pluginInfo() const; + /** + * @return description of the plugin that implements this DataEngine + */ + KPluginInfo pluginInfo() const; - /** - * Connects a source to an object for data updates. The object must - * have a slot with the following signature: - * - * dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) - * - * The data is a QHash of QVariants keyed by QString names, allowing - * one data source to provide sets of related data. - * - * @param source the name of the data source - * @param visualization the object to connect the data source to - * @param pollingInterval the frequency, in milliseconds, with which to check for updates; - * a value of 0 (the default) means to update only - * when there is new data spontaneously generated - * (e.g. by the engine); any other value results in - * periodic updates from this source. This value is - * per-visualization and can be handy for items that require - * constant updates such as scrolling graphs or clocks. - * If the data has not changed, no update will be sent. - * @param intervalAlignment the number of ms to align the interval to - **/ - Q_INVOKABLE void connectSource( - const QString &source, QObject *visualization, - uint pollingInterval = 0, - Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; + /** + * Connects a source to an object for data updates. The object must + * have a slot with the following signature: + * + * dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) + * + * The data is a QHash of QVariants keyed by QString names, allowing + * one data source to provide sets of related data. + * + * @param source the name of the data source + * @param visualization the object to connect the data source to + * @param pollingInterval the frequency, in milliseconds, with which to check for updates; + * a value of 0 (the default) means to update only + * when there is new data spontaneously generated + * (e.g. by the engine); any other value results in + * periodic updates from this source. This value is + * per-visualization and can be handy for items that require + * constant updates such as scrolling graphs or clocks. + * If the data has not changed, no update will be sent. + * @param intervalAlignment the number of ms to align the interval to + **/ + Q_INVOKABLE void connectSource( + const QString &source, QObject *visualization, + uint pollingInterval = 0, + Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; - /** - * Connects all currently existing sources to an object for data updates. - * The object must have a slot with the following signature: - * - * SLOT(dataUpdated(QString,Plasma::DataEngine::Data)) - * - * The data is a QHash of QVariants keyed by QString names, allowing - * one data source to provide sets of related data. - * - * This method may be called multiple times for the same visualization - * without side-effects. This can be useful to change the pollingInterval. - * - * Note that this method does not automatically connect sources that - * may appear later on. Connecting and responding to the sourceAdded signal - * is still required to achieve that. - * - * @param visualization the object to connect the data source to - * @param pollingInterval the frequency, in milliseconds, with which to check for updates; - * a value of 0 (the default) means to update only - * when there is new data spontaneously generated - * (e.g. by the engine); any other value results in - * periodic updates from this source. This value is - * per-visualization and can be handy for items that require - * constant updates such as scrolling graphs or clocks. - * If the data has not changed, no update will be sent. - * @param intervalAlignment the number of ms to align the interval to - **/ - Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0, - Plasma::Types::IntervalAlignment intervalAlignment = -Types::NoAlignment) const; + /** + * Connects all currently existing sources to an object for data updates. + * The object must have a slot with the following signature: + * + * SLOT(dataUpdated(QString,Plasma::DataEngine::Data)) + * + * The data is a QHash of QVariants keyed by QString names, allowing + * one data source to provide sets of related data. + * + * This method may be called multiple times for the same visualization + * without side-effects. This can be useful to change the pollingInterval. + * + * Note that this method does not automatically connect sources that + * may appear later on. Connecting and responding to the sourceAdded signal + * is still required to achieve that. + * + * @param visualization the object to connect the data source to + * @param pollingInterval the frequency, in milliseconds, with which to check for updates; + * a value of 0 (the default) means to update only + * when there is new data spontaneously generated + * (e.g. by the engine); any other value results in + * periodic updates from this source. This value is + * per-visualization and can be handy for items that require + * constant updates such as scrolling graphs or clocks. + * If the data has not changed, no update will be sent. + * @param intervalAlignment the number of ms to align the interval to + **/ + Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0, + Plasma::Types::IntervalAlignment intervalAlignment = + Types::NoAlignment) const; - /** - * Disconnects a source from an object that was receiving data updates. - * - * @param source the name of the data source - * @param visualization the object to connect the data source to - **/ - Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const; + /** + * Disconnects a source from an object that was receiving data updates. + * + * @param source the name of the data source + * @param visualization the object to connect the data source to + **/ + Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const; - /** - * Retrieves a pointer to the DataContainer for a given source. This method - * should not be used if possible. An exception is for script engines that - * can not provide a QMetaObject as required by connectSource for the initial - * call to dataUpdated. Using this method, such engines can provide their own - * connectSource API. - * - * @param source the name of the source. - * @return pointer to a DataContainer, or zero on failure - **/ - Q_INVOKABLE DataContainer *containerForSource(const QString &source); + /** + * Retrieves a pointer to the DataContainer for a given source. This method + * should not be used if possible. An exception is for script engines that + * can not provide a QMetaObject as required by connectSource for the initial + * call to dataUpdated. Using this method, such engines can provide their own + * connectSource API. + * + * @param source the name of the source. + * @return pointer to a DataContainer, or zero on failure + **/ + Q_INVOKABLE DataContainer *containerForSource(const QString &source); - /** - * @return The model associated to a source if any. The ownership of the model stays with the DataContainer. - * Returns 0 if there isn't any model associated or if the source doesn't exists. - */ - QAbstractItemModel *modelForSource(const QString &source); + /** + * @return The model associated to a source if any. The ownership of the model stays with the DataContainer. + * Returns 0 if there isn't any model associated or if the source doesn't exists. + */ + QAbstractItemModel *modelForSource(const QString &source); - /** - * Returns true if this engine is valid, otherwise returns false - * - * @return true if the engine is valid - **/ - bool isValid() const; + /** + * Returns true if this engine is valid, otherwise returns false + * + * @return true if the engine is valid + **/ + bool isValid() const; - /** - * Returns true if the data engine is empty, which is to say that it has no - * data sources currently. - * - * @return true if the engine has no sources currently - */ - bool isEmpty() const; + /** + * Returns true if the data engine is empty, which is to say that it has no + * data sources currently. + * + * @return true if the engine has no sources currently + */ + bool isEmpty() const; - /** - * @return the name of the icon for this data engine; and empty string - * is returned if there is no associated icon. - **/ - QString icon() const; + /** + * @return the name of the icon for this data engine; and empty string + * is returned if there is no associated icon. + **/ + QString icon() const; - /** - * Accessor for the associated Package object if any. - * - * @return the Package object, or 0 if none - **/ - Package package() const; + /** + * Accessor for the associated Package object if any. + * + * @return the Package object, or 0 if none + **/ + Package package() const; - Q_SIGNALS: - /** - * Emitted when a new data source is created - * - * Note that you do not need to emit this yourself unless - * you are reimplementing sources() and want to advertise - * that a new source is available (but hasn't been created - * yet). - * - * @param source the name of the new data source - **/ - void sourceAdded(const QString &source); +Q_SIGNALS: + /** + * Emitted when a new data source is created + * + * Note that you do not need to emit this yourself unless + * you are reimplementing sources() and want to advertise + * that a new source is available (but hasn't been created + * yet). + * + * @param source the name of the new data source + **/ + void sourceAdded(const QString &source); - /** - * Emitted when a data source is removed. - * - * Note that you do not need to emit this yourself unless - * you have reimplemented sources() and want to signal that - * a source that was available but was never created is no - * longer available. - * - * @param source the name of the data source that was removed - **/ - void sourceRemoved(const QString &source); + /** + * Emitted when a data source is removed. + * + * Note that you do not need to emit this yourself unless + * you have reimplemented sources() and want to signal that + * a source that was available but was never created is no + * longer available. + * + * @param source the name of the data source that was removed + **/ + void sourceRemoved(const QString &source); - protected: - /** - * When a source that does not currently exist is requested by the - * consumer, this method is called to give the DataEngine the - * opportunity to create one. - * - * The name of the data source (e.g. the source parameter passed into - * setData) must be the same as the name passed to sourceRequestEvent - * otherwise the requesting visualization may not receive notice of a - * data update. - * - * If the source can not be populated with data immediately (e.g. due to - * an asynchronous data acquisition method such as an HTTP request) - * the source must still be created, even if it is empty. This can - * be accomplished in these cases with the follow line: - * - * setData(name, DataEngine::Data()); - * - * @param source the name of the source that has been requested - * @return true if a DataContainer was set up, false otherwise - */ - virtual bool sourceRequestEvent(const QString &source); +protected: + /** + * When a source that does not currently exist is requested by the + * consumer, this method is called to give the DataEngine the + * opportunity to create one. + * + * The name of the data source (e.g. the source parameter passed into + * setData) must be the same as the name passed to sourceRequestEvent + * otherwise the requesting visualization may not receive notice of a + * data update. + * + * If the source can not be populated with data immediately (e.g. due to + * an asynchronous data acquisition method such as an HTTP request) + * the source must still be created, even if it is empty. This can + * be accomplished in these cases with the follow line: + * + * setData(name, DataEngine::Data()); + * + * @param source the name of the source that has been requested + * @return true if a DataContainer was set up, false otherwise + */ + virtual bool sourceRequestEvent(const QString &source); - /** - * Called by internal updating mechanisms to trigger the engine - * to refresh the data contained in a given source. Reimplement this - * method when using facilities such as setPollingInterval. - * @see setPollingInterval - * - * @param source the name of the source that should be updated - * @return true if the data was changed, or false if there was no - * change or if the change will occur later - **/ - virtual bool updateSourceEvent(const QString &source); + /** + * Called by internal updating mechanisms to trigger the engine + * to refresh the data contained in a given source. Reimplement this + * method when using facilities such as setPollingInterval. + * @see setPollingInterval + * + * @param source the name of the source that should be updated + * @return true if the data was changed, or false if there was no + * change or if the change will occur later + **/ + virtual bool updateSourceEvent(const QString &source); - /** - * Sets a value for a data source. If the source - * doesn't exist then it is created. - * - * @param source the name of the data source - * @param value the data to associated with the source - **/ - void setData(const QString &source, const QVariant &value); + /** + * Sets a value for a data source. If the source + * doesn't exist then it is created. + * + * @param source the name of the data source + * @param value the data to associated with the source + **/ + void setData(const QString &source, const QVariant &value); - /** - * Sets a value for a data source. If the source - * doesn't exist then it is created. - * - * @param source the name of the data source - * @param key the key to use for the data - * @param value the data to associated with the source - **/ - void setData(const QString &source, const QString &key, const QVariant &value); + /** + * Sets a value for a data source. If the source + * doesn't exist then it is created. + * + * @param source the name of the data source + * @param key the key to use for the data + * @param value the data to associated with the source + **/ + void setData(const QString &source, const QString &key, const QVariant &value); - /** - * Adds a set of data to a data source. If the source - * doesn't exist then it is created. - * - * @param source the name of the data source - * @param data the data to add to the source - **/ - void setData(const QString &source, const QVariantMap &data); + /** + * Adds a set of data to a data source. If the source + * doesn't exist then it is created. + * + * @param source the name of the data source + * @param data the data to add to the source + **/ + void setData(const QString &source, const QVariantMap &data); - /** - * Removes all the data associated with a data source. - * - * @param source the name of the data source - **/ - void removeAllData(const QString &source); + /** + * Removes all the data associated with a data source. + * + * @param source the name of the data source + **/ + void removeAllData(const QString &source); - /** - * Removes a data entry from a source - * - * @param source the name of the data source - * @param key the data entry to remove - **/ - void removeData(const QString &source, const QString &key); + /** + * Removes a data entry from a source + * + * @param source the name of the data source + * @param key the data entry to remove + **/ + void removeData(const QString &source, const QString &key); - /** - * Associates a model to a data source. If the source - * doesn't exist then it is created. The source will have the key "HasModel" to easily indicate there is a model present. - * - * The ownership of the model is transferred to the DataContainer, - * so the model will be deletd when a new one is set or when the - * DataContainer itself is deleted. As the DataContainer, it will be - * deleted when there won't be any - * visualization associated to this source. - * - * @param source the name of the data source - * @param model the model instance - */ - void setModel(const QString &source, QAbstractItemModel *model); + /** + * Associates a model to a data source. If the source + * doesn't exist then it is created. The source will have the key "HasModel" to easily indicate there is a model present. + * + * The ownership of the model is transferred to the DataContainer, + * so the model will be deletd when a new one is set or when the + * DataContainer itself is deleted. As the DataContainer, it will be + * deleted when there won't be any + * visualization associated to this source. + * + * @param source the name of the data source + * @param model the model instance + */ + void setModel(const QString &source, QAbstractItemModel *model); - /** - * Adds an already constructed data source. The DataEngine takes - * ownership of the DataContainer object. The objectName of the source - * is used for the source name. - * - * @param source the DataContainer to add to the DataEngine - **/ - void addSource(DataContainer *source); + /** + * Adds an already constructed data source. The DataEngine takes + * ownership of the DataContainer object. The objectName of the source + * is used for the source name. + * + * @param source the DataContainer to add to the DataEngine + **/ + void addSource(DataContainer *source); - /** - * Sets the minimum amount of time, in milliseconds, that must pass between - * successive updates of data. This can help prevent too many updates happening - * due to multiple update requests coming in, which can be useful for - * expensive (time- or resource-wise) update mechanisms. - * - * The default minimumPollingInterval is -1, or "never perform automatic updates" - * - * @param minimumMs the minimum time lapse, in milliseconds, between updates. - * A value less than 0 means to never perform automatic updates, - * a value of 0 means update immediately on every update request, - * a value >0 will result in a minimum time lapse being enforced. - **/ - void setMinimumPollingInterval(int minimumMs); + /** + * Sets the minimum amount of time, in milliseconds, that must pass between + * successive updates of data. This can help prevent too many updates happening + * due to multiple update requests coming in, which can be useful for + * expensive (time- or resource-wise) update mechanisms. + * + * The default minimumPollingInterval is -1, or "never perform automatic updates" + * + * @param minimumMs the minimum time lapse, in milliseconds, between updates. + * A value less than 0 means to never perform automatic updates, + * a value of 0 means update immediately on every update request, + * a value >0 will result in a minimum time lapse being enforced. + **/ + void setMinimumPollingInterval(int minimumMs); - /** - * @return the minimum time between updates. @see setMinimumPollingInterval - **/ - int minimumPollingInterval() const; + /** + * @return the minimum time between updates. @see setMinimumPollingInterval + **/ + int minimumPollingInterval() const; - /** - * Sets up an internal update tick for all data sources. On every update, - * updateSourceEvent will be called for each applicable source. - * @see updateSourceEvent - * - * @param frequency the time, in milliseconds, between updates. A value of 0 - * will stop internally triggered updates. - **/ - void setPollingInterval(uint frequency); + /** + * Sets up an internal update tick for all data sources. On every update, + * updateSourceEvent will be called for each applicable source. + * @see updateSourceEvent + * + * @param frequency the time, in milliseconds, between updates. A value of 0 + * will stop internally triggered updates. + **/ + void setPollingInterval(uint frequency); - /** - * Removes all data sources - **/ - void removeAllSources(); + /** + * Removes all data sources + **/ + void removeAllSources(); - /** - * Sets whether or not this engine is valid, e.g. can be used. - * In practice, only the internal fall-back engine, the NullEngine - * should have need for this. - * - * @param valid whether or not the engine is valid - **/ - void setValid(bool valid); + /** + * Sets whether or not this engine is valid, e.g. can be used. + * In practice, only the internal fall-back engine, the NullEngine + * should have need for this. + * + * @param valid whether or not the engine is valid + **/ + void setValid(bool valid); - /** - * @return the list of active DataContainers. - */ - QHash containerDict() const; + /** + * @return the list of active DataContainers. + */ + QHash containerDict() const; - /** - * Reimplemented from QObject - **/ - void timerEvent(QTimerEvent *event); + /** + * Reimplemented from QObject + **/ + void timerEvent(QTimerEvent *event); - /** - * Sets the icon for this data engine - **/ - void setIcon(const QString &icon); + /** + * Sets the icon for this data engine + **/ + void setIcon(const QString &icon); - /** - * Sets a source to be stored for easy retrieval - * when the real source of the data (usually a network connection) - * is unavailable. - * @param source the name of the source - * @param store if source should be stored - * @since 4.6 - */ - void setStorageEnabled(const QString &source, bool store); + /** + * Sets a source to be stored for easy retrieval + * when the real source of the data (usually a network connection) + * is unavailable. + * @param source the name of the source + * @param store if source should be stored + * @since 4.6 + */ + void setStorageEnabled(const QString &source, bool store); - protected Q_SLOTS: - /** - * Removes a data source. - * @param source the name of the data source to remove - **/ - void removeSource(const QString &source); +protected Q_SLOTS: + /** + * Removes a data source. + * @param source the name of the data source to remove + **/ + void removeSource(const QString &source); - /** - * Immediately updates all existing sources when called - */ - void updateAllSources(); + /** + * Immediately updates all existing sources when called + */ + void updateAllSources(); - /** - * Forces an immediate update to all connected sources, even those with - * timeouts that haven't yet expired. This should _only_ be used when - * there was no data available, e.g. due to network non-availability, - * and then it becomes available. Normal changes in data values due to - * calls to updateSource or in the natural progression of the monitored - * object (e.g. CPU heat) should not result in a call to this method! - * - * @since 4.4 - */ - void forceImmediateUpdateOfAllVisualizations(); + /** + * Forces an immediate update to all connected sources, even those with + * timeouts that haven't yet expired. This should _only_ be used when + * there was no data available, e.g. due to network non-availability, + * and then it becomes available. Normal changes in data values due to + * calls to updateSource or in the natural progression of the monitored + * object (e.g. CPU heat) should not result in a call to this method! + * + * @since 4.4 + */ + void forceImmediateUpdateOfAllVisualizations(); - private: - friend class DataEnginePrivate; - friend class DataEngineScript; - friend class DataEngineManager; - friend class PlasmoidServiceJob; - friend class NullEngine; +private: + friend class DataEnginePrivate; + friend class DataEngineScript; + friend class DataEngineManager; + friend class PlasmoidServiceJob; + friend class NullEngine; - Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source)) - Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object)) - Q_PRIVATE_SLOT(d, void scheduleSourcesUpdated()) + Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source)) + Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object)) + Q_PRIVATE_SLOT(d, void scheduleSourcesUpdated()) - DataEnginePrivate *const d; + DataEnginePrivate *const d; }; } // Plasma namespace @@ -451,13 +451,13 @@ Types::NoAlignment) const; * Register a data engine when it is contained in a loadable module */ #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY(factory, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #define K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(libname, classname, jsonFile) \ -K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -Q_DECLARE_METATYPE(Plasma::DataEngine*) +Q_DECLARE_METATYPE(Plasma::DataEngine *) #endif // multiple inclusion guard diff --git a/src/plasma/dataengineconsumer.cpp b/src/plasma/dataengineconsumer.cpp index 87e8ddfeb..c1e886bb7 100644 --- a/src/plasma/dataengineconsumer.cpp +++ b/src/plasma/dataengineconsumer.cpp @@ -111,4 +111,3 @@ DataEngine *DataEngineConsumer::dataEngine(const QString &name) #include "private/moc_dataengineconsumer_p.cpp" - diff --git a/src/plasma/dataengineconsumer.h b/src/plasma/dataengineconsumer.h index d1c8d6b71..16bd97a66 100644 --- a/src/plasma/dataengineconsumer.h +++ b/src/plasma/dataengineconsumer.h @@ -68,11 +68,10 @@ public: DataEngine *dataEngine(const QString &name); private: - DataEngineConsumerPrivate * const d; + DataEngineConsumerPrivate *const d; }; } // namespace Plasma #endif - diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp index d581c5d9f..d657d863c 100644 --- a/src/plasma/framesvg.cpp +++ b/src/plasma/framesvg.cpp @@ -38,7 +38,6 @@ namespace Plasma { - QHash FrameSvgPrivate::s_sharedFrames; // Any attempt to generate a frame whose width or height is larger than this @@ -171,7 +170,7 @@ FrameSvg::EnabledBorders FrameSvg::enabledBorders() const return NoBorder; } - QHash::const_iterator it = d->frames.constFind(d->prefix); + QHash::const_iterator it = d->frames.constFind(d->prefix); if (it != d->frames.constEnd()) { return it.value()->enabledBorders; @@ -183,21 +182,21 @@ FrameSvg::EnabledBorders FrameSvg::enabledBorders() const void FrameSvg::setElementPrefix(Plasma::Types::Location location) { switch (location) { - case Types::TopEdge: - setElementPrefix("north"); - break; - case Types::BottomEdge: - setElementPrefix("south"); - break; - case Types::LeftEdge: - setElementPrefix("west"); - break; - case Types::RightEdge: - setElementPrefix("east"); - break; - default: - setElementPrefix(QString()); - break; + case Types::TopEdge: + setElementPrefix("north"); + break; + case Types::BottomEdge: + setElementPrefix("south"); + break; + case Types::LeftEdge: + setElementPrefix("west"); + break; + case Types::RightEdge: + setElementPrefix("east"); + break; + default: + setElementPrefix(QString()); + break; } d->location = location; @@ -272,7 +271,7 @@ void FrameSvg::setElementPrefix(const QString &prefix) d->location = Types::Floating; } -bool FrameSvg::hasElementPrefix(const QString & prefix) const +bool FrameSvg::hasElementPrefix(const QString &prefix) const { //for now it simply checks if a center element exists, //because it could make sense for certain themes to not have all the elements @@ -286,21 +285,21 @@ bool FrameSvg::hasElementPrefix(const QString & prefix) const bool FrameSvg::hasElementPrefix(Plasma::Types::Location location) const { switch (location) { - case Types::TopEdge: - return hasElementPrefix("north"); - break; - case Types::BottomEdge: - return hasElementPrefix("south"); - break; - case Types::LeftEdge: - return hasElementPrefix("west"); - break; - case Types::RightEdge: - return hasElementPrefix("east"); - break; - default: - return hasElementPrefix(QString()); - break; + case Types::TopEdge: + return hasElementPrefix("north"); + break; + case Types::BottomEdge: + return hasElementPrefix("south"); + break; + case Types::LeftEdge: + return hasElementPrefix("west"); + break; + case Types::RightEdge: + return hasElementPrefix("east"); + break; + default: + return hasElementPrefix(QString()); + break; } } @@ -377,7 +376,7 @@ void FrameSvg::resizeFrame(const QSizeF &size) QSizeF FrameSvg::frameSize() const { - QHash::const_iterator it = d->frames.constFind(d->prefix); + QHash::const_iterator it = d->frames.constFind(d->prefix); if (it == d->frames.constEnd()) { return QSize(-1, -1); @@ -395,20 +394,20 @@ qreal FrameSvg::marginSize(const Plasma::Types::MarginEdge edge) const switch (edge) { case Plasma::Types::TopMargin: return d->frames[d->prefix]->topMargin; - break; + break; case Plasma::Types::LeftMargin: return d->frames[d->prefix]->leftMargin; - break; + break; case Plasma::Types::RightMargin: return d->frames[d->prefix]->rightMargin; - break; + break; //Plasma::BottomMargin default: return d->frames[d->prefix]->bottomMargin; - break; + break; } } @@ -421,20 +420,20 @@ qreal FrameSvg::fixedMarginSize(const Plasma::Types::MarginEdge edge) const switch (edge) { case Plasma::Types::TopMargin: return d->frames[d->prefix]->fixedTopMargin; - break; + break; case Plasma::Types::LeftMargin: return d->frames[d->prefix]->fixedLeftMargin; - break; + break; case Plasma::Types::RightMargin: return d->frames[d->prefix]->fixedRightMargin; - break; + break; //Plasma::BottomMargin default: return d->frames[d->prefix]->fixedBottomMargin; - break; + break; } } @@ -485,7 +484,7 @@ QRectF FrameSvg::contentsRect() const QPixmap FrameSvg::alphaMask() const { - //FIXME: the distinction between overlay and + //FIXME: the distinction between overlay and return d->alphaMask(); } @@ -522,7 +521,7 @@ void FrameSvg::clearCache() FrameData *frame = d->frames[d->prefix]; // delete all the frames that aren't this one - QMutableHashIterator it(d->frames); + QMutableHashIterator it(d->frames); while (it.hasNext()) { FrameData *p = it.next().value(); if (frame != p) { @@ -632,7 +631,7 @@ FrameSvgPrivate::~FrameSvgPrivate() #endif foreach (FrameSvg *data, it2.value()->references.keys()) { #ifndef NDEBUG - qDebug()<< " " << (void*)data << it2.value()->references[data]; + qDebug() << " " << (void *)data << it2.value()->references[data]; #endif } shares += rc - 1; @@ -746,7 +745,7 @@ void FrameSvgPrivate::generateBackground(FrameData *frame) actualOverlayPos.setX(frame->frameSize.width() - overlaySize.width()); } else if (q->hasElement(prefix % "hint-overlay-pos-bottom")) { actualOverlayPos.setY(frame->frameSize.height() - overlaySize.height()); - //Stretched or Tiled? + //Stretched or Tiled? } else if (q->hasElement(prefix % "hint-overlay-stretch")) { overlaySize = frameSize(frame).toSize(); } else { @@ -763,12 +762,12 @@ void FrameSvgPrivate::generateBackground(FrameData *frame) overlayPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); //Tiling? if (q->hasElement(prefix % "hint-overlay-tile-horizontal") || - q->hasElement(prefix % "hint-overlay-tile-vertical")) { + q->hasElement(prefix % "hint-overlay-tile-vertical")) { QSize s = q->size(); q->resize(q->elementSize(prefix % "overlay")); - overlayPainter.drawTiledPixmap(QRect(QPoint(0,0), overlaySize), q->pixmap(prefix % "overlay")); + overlayPainter.drawTiledPixmap(QRect(QPoint(0, 0), overlaySize), q->pixmap(prefix % "overlay")); q->resize(s); } else { q->paint(&overlayPainter, QRect(actualOverlayPos, overlaySize), prefix % "overlay"); @@ -797,7 +796,6 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame) const int topOffset = 0; const int leftOffset = 0; - if (!size.isValid()) { #ifndef NDEBUG // qDebug() << "Invalid frame size" << size; @@ -848,11 +846,11 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame) if (contentHeight > 0 && contentWidth > 0) { if (frame->composeOverBorder) { q->paint(&p, QRect(QPoint(0, 0), size.toSize()), - prefix % "center"); + prefix % "center"); } else { q->paint(&p, QRect(frame->leftWidth, frame->topHeight, - contentWidth, contentHeight), - prefix % "center"); + contentWidth, contentHeight), + prefix % "center"); } } } @@ -899,26 +897,26 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame) if (frame->stretchBorders) { if (frame->enabledBorders & FrameSvg::LeftBorder || frame->enabledBorders & FrameSvg::RightBorder) { if (q->hasElement(prefix % "left") && - frame->enabledBorders & FrameSvg::LeftBorder && - contentHeight > 0) { + frame->enabledBorders & FrameSvg::LeftBorder && + contentHeight > 0) { q->paint(&p, QRect(leftOffset, contentTop, frame->leftWidth, contentHeight), prefix % "left"); } if (q->hasElement(prefix % "right") && - frame->enabledBorders & FrameSvg::RightBorder && - contentHeight > 0) { + frame->enabledBorders & FrameSvg::RightBorder && + contentHeight > 0) { q->paint(&p, QRect(rightOffset, contentTop, frame->rightWidth, contentHeight), prefix % "right"); } } if (frame->enabledBorders & FrameSvg::TopBorder || frame->enabledBorders & FrameSvg::BottomBorder) { if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(prefix % "top") && - contentWidth > 0) { + contentWidth > 0) { q->paint(&p, QRect(contentLeft, topOffset, contentWidth, frame->topHeight), prefix % "top"); } if (frame->enabledBorders & FrameSvg::BottomBorder && q->hasElement(prefix % "bottom") && - contentWidth > 0) { + contentWidth > 0) { q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, frame->bottomHeight), prefix % "bottom"); } } @@ -978,7 +976,7 @@ QString FrameSvgPrivate::cacheId(FrameData *frame, const QString &prefixToSave) { const QSize size = frameSize(frame).toSize(); const QLatin1Char s('_'); - return QString::number(frame->enabledBorders) % s % QString::number(size.width()) % s % QString::number(size.height()) % s % prefixToSave % s % q->imagePath(); + return QString::number(frame->enabledBorders) % s % QString::number(size.width()) % s % QString::number(size.height()) % s % prefixToSave % s % q->imagePath(); } void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay) @@ -1025,7 +1023,6 @@ void FrameSvgPrivate::updateSizes() const frame->fixedTopMargin = frame->fixedTopHeight; } - //The same, but its size depends from the margin being enabled if (frame->enabledBorders & FrameSvg::TopBorder) { frame->topHeight = q->elementSize(prefix % "top").height(); @@ -1167,5 +1164,4 @@ int FrameData::refcount() const } // Plasma namespace - #include "moc_framesvg.cpp" diff --git a/src/plasma/framesvg.h b/src/plasma/framesvg.h index f4b166980..29bfba915 100644 --- a/src/plasma/framesvg.h +++ b/src/plasma/framesvg.h @@ -80,219 +80,219 @@ class PLASMA_EXPORT FrameSvg : public Svg Q_FLAGS(EnabledBorders) Q_PROPERTY(EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders) - public: - /** - * These flags represents what borders should be drawn - */ - enum EnabledBorder { - NoBorder = 0, - TopBorder = 1, - BottomBorder = 2, - LeftBorder = 4, - RightBorder = 8, - AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder - }; - Q_DECLARE_FLAGS(EnabledBorders, EnabledBorder) +public: + /** + * These flags represents what borders should be drawn + */ + enum EnabledBorder { + NoBorder = 0, + TopBorder = 1, + BottomBorder = 2, + LeftBorder = 4, + RightBorder = 8, + AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder + }; + Q_DECLARE_FLAGS(EnabledBorders, EnabledBorder) - /** - * Constructs a new FrameSvg that paints the proper named subelements - * as borders. It may also be used as a regular Plasma::Svg object - * for direct access to elements in the Svg. - * - * @param parent options QObject to parent this to - * - * @related Plasma::Theme - */ - explicit FrameSvg(QObject *parent = 0); - ~FrameSvg(); + /** + * Constructs a new FrameSvg that paints the proper named subelements + * as borders. It may also be used as a regular Plasma::Svg object + * for direct access to elements in the Svg. + * + * @param parent options QObject to parent this to + * + * @related Plasma::Theme + */ + explicit FrameSvg(QObject *parent = 0); + ~FrameSvg(); - /** - * Loads a new Svg - * @param imagePath the new file - */ - Q_INVOKABLE void setImagePath(const QString &path); + /** + * Loads a new Svg + * @param imagePath the new file + */ + Q_INVOKABLE void setImagePath(const QString &path); - /** - * Sets what borders should be painted - * @param flags borders we want to paint - */ - void setEnabledBorders(const EnabledBorders borders); + /** + * Sets what borders should be painted + * @param flags borders we want to paint + */ + void setEnabledBorders(const EnabledBorders borders); - /** - * Convenience method to get the enabled borders - * @return what borders are painted - */ - EnabledBorders enabledBorders() const; + /** + * Convenience method to get the enabled borders + * @return what borders are painted + */ + EnabledBorders enabledBorders() const; - /** - * Resize the frame maintaining the same border size - * @param size the new size of the frame - */ - Q_INVOKABLE void resizeFrame(const QSizeF &size); + /** + * Resize the frame maintaining the same border size + * @param size the new size of the frame + */ + Q_INVOKABLE void resizeFrame(const QSizeF &size); - /** - * @returns the size of the frame - */ - Q_INVOKABLE QSizeF frameSize() const; + /** + * @returns the size of the frame + */ + Q_INVOKABLE QSizeF frameSize() const; - /** - * Returns the margin size given the margin edge we want - * If the given margin is disabled, it will return 0. - * If you don't care about the margin being on or off, use fixedMarginSize() - * @param edge the margin edge we want, top, bottom, left or right - * @return the margin size - */ - Q_INVOKABLE qreal marginSize(const Plasma::Types::MarginEdge edge) const; + /** + * Returns the margin size given the margin edge we want + * If the given margin is disabled, it will return 0. + * If you don't care about the margin being on or off, use fixedMarginSize() + * @param edge the margin edge we want, top, bottom, left or right + * @return the margin size + */ + Q_INVOKABLE qreal marginSize(const Plasma::Types::MarginEdge edge) const; - /** - * Convenience method that extracts the size of the four margins - * in the four output parameters - * The disabled margins will be 0. - * If you don't care about the margins being on or off, use getFixedMargins() - * @param left left margin size - * @param top top margin size - * @param right right margin size - * @param bottom bottom margin size - */ - Q_INVOKABLE void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; + /** + * Convenience method that extracts the size of the four margins + * in the four output parameters + * The disabled margins will be 0. + * If you don't care about the margins being on or off, use getFixedMargins() + * @param left left margin size + * @param top top margin size + * @param right right margin size + * @param bottom bottom margin size + */ + Q_INVOKABLE void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; - /** - * Returns the margin size given the margin edge we want. - * Compared to marginSize(), this doesn't depend whether the margin is enabled or not - * @param edge the margin edge we want, top, bottom, left or right - * @return the margin size - */ - Q_INVOKABLE qreal fixedMarginSize(const Plasma::Types::MarginEdge edge) const; + /** + * Returns the margin size given the margin edge we want. + * Compared to marginSize(), this doesn't depend whether the margin is enabled or not + * @param edge the margin edge we want, top, bottom, left or right + * @return the margin size + */ + Q_INVOKABLE qreal fixedMarginSize(const Plasma::Types::MarginEdge edge) const; - /** - * Convenience method that extracts the size of the four margins - * in the four output parameters - * Compared to getMargins(), this doesn't depend whether the margins are enabled or not - * @param left left margin size - * @param top top margin size - * @param right right margin size - * @param bottom bottom margin size - */ - Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; + /** + * Convenience method that extracts the size of the four margins + * in the four output parameters + * Compared to getMargins(), this doesn't depend whether the margins are enabled or not + * @param left left margin size + * @param top top margin size + * @param right right margin size + * @param bottom bottom margin size + */ + Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; - /** - * @return the rectangle of the center element, taking the margins into account. - */ - Q_INVOKABLE QRectF contentsRect() const; + /** + * @return the rectangle of the center element, taking the margins into account. + */ + Q_INVOKABLE QRectF contentsRect() const; - /** - * Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east' - * when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, - * respectively. Clears the prefix in other cases. - * - * The prefix must exist in the SVG document, which means that this can only be - * called successfully after setImagePath is called. - * @param location location in the UI this frame will be drawn - */ - Q_INVOKABLE void setElementPrefix(Plasma::Types::Location location); + /** + * Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east' + * when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, + * respectively. Clears the prefix in other cases. + * + * The prefix must exist in the SVG document, which means that this can only be + * called successfully after setImagePath is called. + * @param location location in the UI this frame will be drawn + */ + Q_INVOKABLE void setElementPrefix(Plasma::Types::Location location); - /** - * Sets the prefix for the SVG elements to be used for painting. For example, - * if prefix is 'active', then instead of using the 'top' element of the SVG - * file to paint the top border, 'active-top' element will be used. The same - * goes for other SVG elements. - * - * If the elements with prefixes are not present, the default ones are used. - * (for the sake of speed, the test is present only for the 'center' element) - * - * Setting the prefix manually resets the location to Floating. - * - * The prefix must exist in the SVG document, which means that this can only be - * called successfully after setImagePath is called. - * - * @param prefix prefix for the SVG elements that make up the frame - */ - Q_INVOKABLE void setElementPrefix(const QString & prefix); + /** + * Sets the prefix for the SVG elements to be used for painting. For example, + * if prefix is 'active', then instead of using the 'top' element of the SVG + * file to paint the top border, 'active-top' element will be used. The same + * goes for other SVG elements. + * + * If the elements with prefixes are not present, the default ones are used. + * (for the sake of speed, the test is present only for the 'center' element) + * + * Setting the prefix manually resets the location to Floating. + * + * The prefix must exist in the SVG document, which means that this can only be + * called successfully after setImagePath is called. + * + * @param prefix prefix for the SVG elements that make up the frame + */ + Q_INVOKABLE void setElementPrefix(const QString &prefix); - /** - * @return true if the svg has the necessary elements with the given prefix - * to draw a frame - * @param prefix the given prefix we want to check if drawable - */ - Q_INVOKABLE bool hasElementPrefix(const QString & prefix) const; + /** + * @return true if the svg has the necessary elements with the given prefix + * to draw a frame + * @param prefix the given prefix we want to check if drawable + */ + Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const; - /** - * This is an overloaded method provided for convenience equivalent to - * hasElementPrefix("north"), hasElementPrefix("south") - * hasElementPrefix("west") and hasElementPrefix("east") - * @return true if the svg has the necessary elements with the given prefix - * to draw a frame. - * @param location the given prefix we want to check if drawable - */ - Q_INVOKABLE bool hasElementPrefix(Plasma::Types::Location location) const; + /** + * This is an overloaded method provided for convenience equivalent to + * hasElementPrefix("north"), hasElementPrefix("south") + * hasElementPrefix("west") and hasElementPrefix("east") + * @return true if the svg has the necessary elements with the given prefix + * to draw a frame. + * @param location the given prefix we want to check if drawable + */ + Q_INVOKABLE bool hasElementPrefix(Plasma::Types::Location location) const; - /** - * Returns the prefix for SVG elements of the FrameSvg - * @return the prefix - */ - Q_INVOKABLE QString prefix(); + /** + * Returns the prefix for SVG elements of the FrameSvg + * @return the prefix + */ + Q_INVOKABLE QString prefix(); - /** - * Returns a mask that tightly contains the fully opaque areas of the svg - * @return a region of opaque areas - */ - Q_INVOKABLE QRegion mask() const; + /** + * Returns a mask that tightly contains the fully opaque areas of the svg + * @return a region of opaque areas + */ + Q_INVOKABLE QRegion mask() const; - /** - * @return a pixmap whose alpha channel is the opacity of the frame. It may be the frame itself or a special frame with the mask- prefix - */ - QPixmap alphaMask() const; + /** + * @return a pixmap whose alpha channel is the opacity of the frame. It may be the frame itself or a special frame with the mask- prefix + */ + QPixmap alphaMask() const; - /** - * Sets whether saving all the rendered prefixes in a cache or not - * @param cache if use the cache or not - */ - Q_INVOKABLE void setCacheAllRenderedFrames(bool cache); + /** + * Sets whether saving all the rendered prefixes in a cache or not + * @param cache if use the cache or not + */ + Q_INVOKABLE void setCacheAllRenderedFrames(bool cache); - /** - * @return if all the different prefixes should be kept in a cache when rendered - */ - Q_INVOKABLE bool cacheAllRenderedFrames() const; + /** + * @return if all the different prefixes should be kept in a cache when rendered + */ + Q_INVOKABLE bool cacheAllRenderedFrames() const; - /** - * Deletes the internal cache freeing memory: use this if you want to switch the rendered - * element and you don't plan to switch back to the previous one for a long time and you - * used setUsingRenderingCache(true) - */ - Q_INVOKABLE void clearCache(); + /** + * Deletes the internal cache freeing memory: use this if you want to switch the rendered + * element and you don't plan to switch back to the previous one for a long time and you + * used setUsingRenderingCache(true) + */ + Q_INVOKABLE void clearCache(); - /** - * Returns a pixmap of the SVG represented by this object. - * - * @param elelementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - * @return a QPixmap of the rendered SVG - */ - Q_INVOKABLE QPixmap framePixmap(); + /** + * Returns a pixmap of the SVG represented by this object. + * + * @param elelementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + * @return a QPixmap of the rendered SVG + */ + Q_INVOKABLE QPixmap framePixmap(); - /** - * Paints the loaded SVG with the elements that represents the border - * @param painter the QPainter to use - * @param target the target rectangle on the paint device - * @param source the portion rectangle of the source image - */ - Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, - const QRectF &source = QRectF()); + /** + * Paints the loaded SVG with the elements that represents the border + * @param painter the QPainter to use + * @param target the target rectangle on the paint device + * @param source the portion rectangle of the source image + */ + Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, + const QRectF &source = QRectF()); - /** - * Paints the loaded SVG with the elements that represents the border - * This is an overloaded member provided for convenience - * @param painter the QPainter to use - * @param pos where to paint the svg - */ - Q_INVOKABLE void paintFrame(QPainter *painter, const QPointF &pos = QPointF(0, 0)); + /** + * Paints the loaded SVG with the elements that represents the border + * This is an overloaded member provided for convenience + * @param painter the QPainter to use + * @param pos where to paint the svg + */ + Q_INVOKABLE void paintFrame(QPainter *painter, const QPointF &pos = QPointF(0, 0)); - private: - FrameSvgPrivate *const d; - friend class Applet; +private: + FrameSvgPrivate *const d; + friend class Applet; - Q_PRIVATE_SLOT(d, void updateSizes()) - Q_PRIVATE_SLOT(d, void updateNeeded()) + Q_PRIVATE_SLOT(d, void updateSizes()) + Q_PRIVATE_SLOT(d, void updateNeeded()) }; } // Plasma namespace diff --git a/src/plasma/package.cpp b/src/plasma/package.cpp index 442171651..98befb795 100644 --- a/src/plasma/package.cpp +++ b/src/plasma/package.cpp @@ -233,7 +233,7 @@ KPluginInfo Package::metadata() const return *d->metadata; } -QString PackagePrivate::unpack(const QString& filePath) +QString PackagePrivate::unpack(const QString &filePath) { KArchive *archive = 0; QMimeDatabase db; @@ -242,8 +242,8 @@ QString PackagePrivate::unpack(const QString& filePath) if (mimeType.inherits("application/zip")) { archive = new KZip(filePath); } else if (mimeType.inherits("application/x-compressed-tar") || mimeType.inherits("application/x-gzip") || - mimeType.inherits("application/x-tar") || mimeType.inherits("application/x-bzip-compressed-tar") || - mimeType.inherits("application/x-xz") || mimeType.inherits("application/x-lzma")) { + mimeType.inherits("application/x-tar") || mimeType.inherits("application/x-bzip-compressed-tar") || + mimeType.inherits("application/x-xz") || mimeType.inherits("application/x-lzma")) { archive = new KTar(filePath); } else { qWarning() << "Could not open package file, unsupported archive format:" << filePath << mimeType.name(); @@ -256,14 +256,14 @@ QString PackagePrivate::unpack(const QString& filePath) tempRoot = tempdir.path() + '/'; source->copyTo(tempRoot); - if (!QFile::exists(tempdir.path()+"/metadata.desktop")) { + if (!QFile::exists(tempdir.path() + "/metadata.desktop")) { // search metadata.desktop, the zip file might have the package contents in a subdirectory QDir unpackedPath(tempdir.path()); const QStringList &entries = unpackedPath.entryList(QDir::Dirs); foreach (const QString &pack, entries) { if ((pack != "." && pack != "..") && - (QFile::exists(unpackedPath.absolutePath()+'/'+pack+"/metadata.desktop"))) { - tempRoot = unpackedPath.absolutePath()+'/'+pack+'/'; + (QFile::exists(unpackedPath.absolutePath() + '/' + pack + "/metadata.desktop"))) { + tempRoot = unpackedPath.absolutePath() + '/' + pack + '/'; } } } @@ -286,7 +286,7 @@ QString Package::filePath(const char *fileType, const QString &filename) const const QString discoveryKey(fileType + filename); if (d->discoveries.contains(discoveryKey)) { - //qDebug() << "looking for" << discoveryKey << d->discoveries.value(discoveryKey); + //qDebug() << "looking for" << discoveryKey << d->discoveries.value(discoveryKey); return d->discoveries[discoveryKey]; } @@ -654,9 +654,9 @@ void Package::setMimeTypes(const char *key, QStringList mimeTypes) #endif } -QList Package::directories() const +QList Package::directories() const { - QList dirs; + QList dirs; QHash::const_iterator it = d->contents.constBegin(); while (it != d->contents.constEnd()) { if (it.value().directory) { @@ -667,13 +667,13 @@ QList Package::directories() const return dirs; } -QList Package::requiredDirectories() const +QList Package::requiredDirectories() const { - QList dirs; + QList dirs; QHash::const_iterator it = d->contents.constBegin(); while (it != d->contents.constEnd()) { if (it.value().directory && - it.value().required) { + it.value().required) { dirs << it.key(); } ++it; @@ -681,9 +681,9 @@ QList Package::requiredDirectories() const return dirs; } -QList Package::files() const +QList Package::files() const { - QList files; + QList files; QHash::const_iterator it = d->contents.constBegin(); while (it != d->contents.constEnd()) { if (!it.value().directory) { @@ -694,9 +694,9 @@ QList Package::files() const return files; } -QList Package::requiredFiles() const +QList Package::requiredFiles() const { - QList files; + QList files; QHash::const_iterator it = d->contents.constBegin(); while (it != d->contents.constEnd()) { if (!it.value().directory && it.value().required) { @@ -708,7 +708,7 @@ QList Package::requiredFiles() const return files; } -KJob* Package::install(const QString &sourcePackage, const QString &packageRoot) +KJob *Package::install(const QString &sourcePackage, const QString &packageRoot) { const QString src = sourcePackage; const QString dest = packageRoot.isEmpty() ? defaultPackageRoot() : packageRoot; @@ -719,7 +719,7 @@ KJob* Package::install(const QString &sourcePackage, const QString &packageRoot) return j; } -KJob* Package::uninstall(const QString &packageName, const QString &packageRoot) +KJob *Package::uninstall(const QString &packageName, const QString &packageRoot) { //FIXME:packageName unused, name taken from metadata().pluginName() ? //can this become either just uninstall() otherwise maintain parameters and be static? @@ -732,12 +732,12 @@ KJob* Package::uninstall(const QString &packageName, const QString &packageRoot) } PackagePrivate::PackagePrivate() - : QSharedData(), - servicePrefix("plasma-applet-"), - metadata(0), - externalPaths(false), - valid(false), - checkedValid(false) + : QSharedData(), + servicePrefix("plasma-applet-"), + metadata(0), + externalPaths(false), + valid(false), + checkedValid(false) { contentsPrefixPaths << "contents/"; } diff --git a/src/plasma/package.h b/src/plasma/package.h index afc04dd2e..829fa2080 100644 --- a/src/plasma/package.h +++ b/src/plasma/package.h @@ -286,22 +286,22 @@ public: /** * @return all directories registered as part of this Package's structure */ - QList directories() const; + QList directories() const; /** * @return all directories registered as part of this Package's required structure */ - QList requiredDirectories() const; + QList requiredDirectories() const; /** * @return all files registered as part of this Package's structure */ - QList files() const; + QList files() const; /** * @return all files registered as part of this Package's required structure */ - QList requiredFiles() const; + QList requiredFiles() const; /** * Installs a package matching this package structure. By default installs a @@ -309,14 +309,14 @@ public: * * @return KJob to track installation progress and result **/ - KJob* install(const QString &sourcePackage, const QString &packageRoot = QString()); + KJob *install(const QString &sourcePackage, const QString &packageRoot = QString()); /** * Uninstalls a package matching this package structure. * * @return KJob to track removal progress and result */ - KJob* uninstall(const QString &packageName, const QString &packageRoot); + KJob *uninstall(const QString &packageName, const QString &packageRoot); private: QExplicitlySharedDataPointer d; diff --git a/src/plasma/packagestructure.cpp b/src/plasma/packagestructure.cpp index b8d84b260..a08269bd9 100644 --- a/src/plasma/packagestructure.cpp +++ b/src/plasma/packagestructure.cpp @@ -46,22 +46,20 @@ void PackageStructure::pathChanged(Package *package) Q_UNUSED(package) } -KJob* PackageStructure::install(Package *package, const QString &archivePath, const QString &packageRoot) +KJob *PackageStructure::install(Package *package, const QString &archivePath, const QString &packageRoot) { - PackageJob* j = new PackageJob(package->servicePrefix(), this); + PackageJob *j = new PackageJob(package->servicePrefix(), this); j->install(archivePath, packageRoot); return j; } -KJob* PackageStructure::uninstall(Package *package, const QString &packageRoot) +KJob *PackageStructure::uninstall(Package *package, const QString &packageRoot) { - PackageJob* j = new PackageJob(package->servicePrefix(), this); + PackageJob *j = new PackageJob(package->servicePrefix(), this); j->uninstall(packageRoot + package->metadata().pluginName()); return j; } } - - #include "moc_packagestructure.cpp" diff --git a/src/plasma/packagestructure.h b/src/plasma/packagestructure.h index 1292f3db5..fb32c22a6 100644 --- a/src/plasma/packagestructure.h +++ b/src/plasma/packagestructure.h @@ -73,7 +73,7 @@ public: * installed to * @return KJob* to track the installation status **/ - virtual KJob* install(Package *package, const QString &archivePath, const QString &packageRoot); + virtual KJob *install(Package *package, const QString &archivePath, const QString &packageRoot); /** * Uninstalls a package matching this package structure. @@ -84,10 +84,10 @@ public: * @param packageRoot path to the directory where the package should be installed to * @return KJob* to track the installation status */ - virtual KJob* uninstall(Package *package, const QString &packageRoot); + virtual KJob *uninstall(Package *package, const QString &packageRoot); private: - PackageStructurePrivate* d; + PackageStructurePrivate *d; }; } // Plasma namespace @@ -96,7 +96,7 @@ private: * Register a Package class when it is contained in a loadable module */ #define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY(factory, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif diff --git a/src/plasma/plasma.h b/src/plasma/plasma.h index e50ab42d5..a21f7f2a6 100644 --- a/src/plasma/plasma.h +++ b/src/plasma/plasma.h @@ -40,242 +40,242 @@ class PLASMA_EXPORT Types : public QObject public: ~Types(); -/** - * The Constraint enumeration lists the various constraints that Plasma - * objects have managed for them and which they may wish to react to, - * for instance in Applet::constraintsUpdated - */ -enum Constraint { - NoConstraint = 0, /**< No constraint; never passed in to Applet::constraintsEvent on its own */ - FormFactorConstraint = 1, /**< The FormFactor for an object */ - LocationConstraint = 2, /**< The Location of an object */ - ScreenConstraint = 4, /**< Which screen an object is on */ - ImmutableConstraint = 8, /**< the immutability (locked) nature of the applet changed */ - StartupCompletedConstraint = 16, /**< application startup has completed */ - ContextConstraint = 32, /**< the context (e.g. activity) has changed */ - UiReadyConstraint = 64, /** The ui has been completely loaded (FIXME: merged with StartupCompletedConstraint?) */ - AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | - ImmutableConstraint -}; -Q_ENUMS(Constraint) -Q_DECLARE_FLAGS(Constraints, Constraint) + /** + * The Constraint enumeration lists the various constraints that Plasma + * objects have managed for them and which they may wish to react to, + * for instance in Applet::constraintsUpdated + */ + enum Constraint { + NoConstraint = 0, /**< No constraint; never passed in to Applet::constraintsEvent on its own */ + FormFactorConstraint = 1, /**< The FormFactor for an object */ + LocationConstraint = 2, /**< The Location of an object */ + ScreenConstraint = 4, /**< Which screen an object is on */ + ImmutableConstraint = 8, /**< the immutability (locked) nature of the applet changed */ + StartupCompletedConstraint = 16, /**< application startup has completed */ + ContextConstraint = 32, /**< the context (e.g. activity) has changed */ + UiReadyConstraint = 64, /** The ui has been completely loaded (FIXME: merged with StartupCompletedConstraint?) */ + AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | + ImmutableConstraint + }; + Q_ENUMS(Constraint) + Q_DECLARE_FLAGS(Constraints, Constraint) -/** - * The FormFactor enumeration describes how a Plasma::Applet should arrange - * itself. The value is derived from the container managing the Applet - * (e.g. in Plasma, a Corona on the desktop or on a panel). - **/ -enum FormFactor { - Planar = 0, /**< The applet lives in a plane and has two + /** + * The FormFactor enumeration describes how a Plasma::Applet should arrange + * itself. The value is derived from the container managing the Applet + * (e.g. in Plasma, a Corona on the desktop or on a panel). + **/ + enum FormFactor { + Planar = 0, /**< The applet lives in a plane and has two degrees of freedom to grow. Optimize for desktop, laptop or tablet usage: a high resolution screen 1-3 feet distant from the viewer. */ - MediaCenter, /**< As with Planar, the applet lives in a plane + MediaCenter, /**< As with Planar, the applet lives in a plane but the interface should be optimized for medium-to-high resolution screens that are 5-15 feet distant from the viewer. Sometimes referred to as a "ten foot interface".*/ - Horizontal, /**< The applet is constrained vertically, but + Horizontal, /**< The applet is constrained vertically, but can expand horizontally. */ - Vertical, /**< The applet is constrained horizontally, but + Vertical, /**< The applet is constrained horizontally, but can expand vertically. */ - Application /**< The Applet lives in a plane and should be optimized to look as a full application, + Application /**< The Applet lives in a plane and should be optimized to look as a full application, for the desktop or the particular device. */ -}; -Q_ENUMS(FormFactor) + }; + Q_ENUMS(FormFactor) -/** - * This enumeration describes the type of the Containment. - * DesktopContainments represent main containments that will own a screen in a mutually exclusive fashion, - * while PanelContainments are accessories which can be present multiple per screen. - */ -enum ContainmentType { - NoContainmentType = -1, /**< @internal */ - DesktopContainment = 0, /**< A desktop containment */ - PanelContainment, /**< A desktop panel */ - CustomContainment = 127, /**< A containment that is neither a desktop nor a panel + /** + * This enumeration describes the type of the Containment. + * DesktopContainments represent main containments that will own a screen in a mutually exclusive fashion, + * while PanelContainments are accessories which can be present multiple per screen. + */ + enum ContainmentType { + NoContainmentType = -1, /**< @internal */ + DesktopContainment = 0, /**< A desktop containment */ + PanelContainment, /**< A desktop panel */ + CustomContainment = 127, /**< A containment that is neither a desktop nor a panel but something application specific */ - CustomPanelContainment = 128 /**< A customized desktop panel */ -}; -Q_ENUMS(ContainmentType) + CustomPanelContainment = 128 /**< A customized desktop panel */ + }; + Q_ENUMS(ContainmentType) -/** - * A descriptrive type for QActions, to help categorizing them when presented to the user - */ -enum ActionType { - AddAction = 0, /**The action will cause something new being created*/ - ConfigureAction = 100, /** The Action will make some kind of configuration ui to appear */ - ControlAction = 200, /** Generic control, similar to ConfigureAction TODO: better doc */ - MiscAction = 300, /** A type of action that doesn't fit in the oher categories */ - DestructiveAction = 400, /** A dangerous action, such as deletion of objects, plasmoids and files. They are intended to be shown separed from other actions */ - UserAction = DestructiveAction + 1000 /** If new types are needed in a C++ implementation, define them as ids more than UserAction*/ -}; -Q_ENUMS(ActionType) + /** + * A descriptrive type for QActions, to help categorizing them when presented to the user + */ + enum ActionType { + AddAction = 0, /**The action will cause something new being created*/ + ConfigureAction = 100, /** The Action will make some kind of configuration ui to appear */ + ControlAction = 200, /** Generic control, similar to ConfigureAction TODO: better doc */ + MiscAction = 300, /** A type of action that doesn't fit in the oher categories */ + DestructiveAction = 400, /** A dangerous action, such as deletion of objects, plasmoids and files. They are intended to be shown separed from other actions */ + UserAction = DestructiveAction + 1000 /** If new types are needed in a C++ implementation, define them as ids more than UserAction*/ + }; + Q_ENUMS(ActionType) -/** - * The Direction enumeration describes in which direction, relative to the - * Applet (and its managing container), popup menus, expanders, balloons, - * message boxes, arrows and other such visually associated widgets should - * appear in. This is usually the oposite of the Location. - **/ -enum Direction { - Down = 0, /**< Display downards */ - Up, /**< Display upwards */ - Left, /**< Display to the left */ - Right /**< Display to the right */ -}; -Q_ENUMS(Direction) + /** + * The Direction enumeration describes in which direction, relative to the + * Applet (and its managing container), popup menus, expanders, balloons, + * message boxes, arrows and other such visually associated widgets should + * appear in. This is usually the oposite of the Location. + **/ + enum Direction { + Down = 0, /**< Display downards */ + Up, /**< Display upwards */ + Left, /**< Display to the left */ + Right /**< Display to the right */ + }; + Q_ENUMS(Direction) -/** - * The Location enumeration describes where on screen an element, such as an - * Applet or its managing container, is positioned on the screen. - **/ -enum Location { - Floating = 0, /**< Free floating. Neither geometry or z-ordering + /** + * The Location enumeration describes where on screen an element, such as an + * Applet or its managing container, is positioned on the screen. + **/ + enum Location { + Floating = 0, /**< Free floating. Neither geometry or z-ordering is described precisely by this value. */ - Desktop, /**< On the planar desktop layer, extending across + Desktop, /**< On the planar desktop layer, extending across the full screen from edge to edge */ - FullScreen, /**< Full screen */ - TopEdge, /**< Along the top of the screen*/ - BottomEdge, /**< Along the bottom of the screen*/ - LeftEdge, /**< Along the left side of the screen */ - RightEdge /**< Along the right side of the screen */ -}; -Q_ENUMS(Location) + FullScreen, /**< Full screen */ + TopEdge, /**< Along the top of the screen*/ + BottomEdge, /**< Along the bottom of the screen*/ + LeftEdge, /**< Along the left side of the screen */ + RightEdge /**< Along the right side of the screen */ + }; + Q_ENUMS(Location) -/** - * The position enumeration - * - **/ -enum Position { - LeftPositioned, /**< Positioned left */ - RightPositioned, /**< Positioned right */ - TopPositioned, /**< Positioned top */ - BottomPositioned, /**< Positioned bottom */ - CenterPositioned /**< Positioned in the center */ -}; -Q_ENUMS(Position) + /** + * The position enumeration + * + **/ + enum Position { + LeftPositioned, /**< Positioned left */ + RightPositioned, /**< Positioned right */ + TopPositioned, /**< Positioned top */ + BottomPositioned, /**< Positioned bottom */ + CenterPositioned /**< Positioned in the center */ + }; + Q_ENUMS(Position) -/** - * The popup position enumeration relatively to his attached widget - * - **/ -enum PopupPlacement { - FloatingPopup = 0, /**< Free floating, non attached popup */ - TopPosedLeftAlignedPopup, /**< Popup positioned on the top, aligned + /** + * The popup position enumeration relatively to his attached widget + * + **/ + enum PopupPlacement { + FloatingPopup = 0, /**< Free floating, non attached popup */ + TopPosedLeftAlignedPopup, /**< Popup positioned on the top, aligned to the left of the wigdet */ - TopPosedRightAlignedPopup, /**< Popup positioned on the top, aligned + TopPosedRightAlignedPopup, /**< Popup positioned on the top, aligned to the right of the widget */ - LeftPosedTopAlignedPopup, /**< Popup positioned on the left, aligned + LeftPosedTopAlignedPopup, /**< Popup positioned on the left, aligned to the right of the wigdet */ - LeftPosedBottomAlignedPopup, /**< Popup positioned on the left, aligned + LeftPosedBottomAlignedPopup, /**< Popup positioned on the left, aligned to the bottom of the widget */ - BottomPosedLeftAlignedPopup, /**< Popup positioned on the bottom, aligned + BottomPosedLeftAlignedPopup, /**< Popup positioned on the bottom, aligned to the left of the wigdet */ - BottomPosedRightAlignedPopup, /**< Popup positioned on the bottom, aligned + BottomPosedRightAlignedPopup, /**< Popup positioned on the bottom, aligned to the right of the widget */ - RightPosedTopAlignedPopup, /**< Popup positioned on the right, aligned + RightPosedTopAlignedPopup, /**< Popup positioned on the right, aligned to the top of the wigdet */ - RightPosedBottomAlignedPopup /**< Popup positioned on the right, aligned + RightPosedBottomAlignedPopup /**< Popup positioned on the right, aligned to the bottom of the widget */ -}; -Q_ENUMS(PopupPlacement) + }; + Q_ENUMS(PopupPlacement) -/** - * Flip enumeration - */ -enum FlipDirection { - NoFlip = 0, /**< Do not flip */ - HorizontalFlip = 1, /**< Flip horizontally */ - VerticalFlip = 2 /**< Flip vertically */ -}; -Q_ENUMS(FlipDirection) -Q_DECLARE_FLAGS(Flip, FlipDirection) + /** + * Flip enumeration + */ + enum FlipDirection { + NoFlip = 0, /**< Do not flip */ + HorizontalFlip = 1, /**< Flip horizontally */ + VerticalFlip = 2 /**< Flip vertically */ + }; + Q_ENUMS(FlipDirection) + Q_DECLARE_FLAGS(Flip, FlipDirection) -/** - * Possible timing alignments - **/ -enum IntervalAlignment { - NoAlignment = 0, /**< No alignment **/ - AlignToMinute, /**< Align to the minute **/ - AlignToHour /**< Align to the hour **/ -}; -Q_ENUMS(IntervalAlignment) + /** + * Possible timing alignments + **/ + enum IntervalAlignment { + NoAlignment = 0, /**< No alignment **/ + AlignToMinute, /**< Align to the minute **/ + AlignToHour /**< Align to the hour **/ + }; + Q_ENUMS(IntervalAlignment) -/** - * Defines the immutability of items like applets, corona and containments - * they can be free to modify, locked down by the user or locked down by the - * system (e.g. kiosk setups). - */ -enum ImmutabilityType { - Mutable = 1, /**< The item can be modified in any way **/ - UserImmutable = 2, /**< The user has requested a lock down, and can undo + /** + * Defines the immutability of items like applets, corona and containments + * they can be free to modify, locked down by the user or locked down by the + * system (e.g. kiosk setups). + */ + enum ImmutabilityType { + Mutable = 1, /**< The item can be modified in any way **/ + UserImmutable = 2, /**< The user has requested a lock down, and can undo the lock down at any time **/ - SystemImmutable = 4 /**< the item is locked down by the system, the user + SystemImmutable = 4 /**< the item is locked down by the system, the user can't unlock it **/ -}; -Q_ENUMS(ImmutabilityType) + }; + Q_ENUMS(ImmutabilityType) -/** - * The ComonentType enumeration refers to the various types of components, - * or plugins, supported by plasma. - */ -enum ComponentType { - AppletComponent = 1, /**< Plasma::Applet based plugins **/ - DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/ - ContainmentComponent = 4,/**< Plasma::Containment based plugins **/ - WallpaperComponent = 8, /**< Plasma::Wallpaper based plugins **/ - GenericComponent = 16 /** Generic repositories of files, usually they keep QML files and their assets **/ -}; -Q_ENUMS(ComponentType) -Q_DECLARE_FLAGS(ComponentTypes, ComponentType) + /** + * The ComonentType enumeration refers to the various types of components, + * or plugins, supported by plasma. + */ + enum ComponentType { + AppletComponent = 1, /**< Plasma::Applet based plugins **/ + DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/ + ContainmentComponent = 4,/**< Plasma::Containment based plugins **/ + WallpaperComponent = 8, /**< Plasma::Wallpaper based plugins **/ + GenericComponent = 16 /** Generic repositories of files, usually they keep QML files and their assets **/ + }; + Q_ENUMS(ComponentType) + Q_DECLARE_FLAGS(ComponentTypes, ComponentType) -enum MarginEdge { - TopMargin = 0, /**< The top margin **/ - BottomMargin, /**< The bottom margin **/ - LeftMargin, /**< The left margin **/ - RightMargin /**< The right margin **/ -}; -Q_ENUMS(MarginEdge) + enum MarginEdge { + TopMargin = 0, /**< The top margin **/ + BottomMargin, /**< The bottom margin **/ + LeftMargin, /**< The left margin **/ + RightMargin /**< The right margin **/ + }; + Q_ENUMS(MarginEdge) -/** - * Status of an applet - * @since 4.3 - */ -enum ItemStatus { - UnknownStatus = 0, /**< The status is unknown **/ - PassiveStatus = 1, /**< The Item is passive **/ - ActiveStatus = 2, /**< The Item is active **/ - NeedsAttentionStatus = 3, /**< The Item needs attention **/ - RequiresAttentionStatus = 4, /**< The Item needs persistent attention **/ - AcceptingInputStatus = 5 /**< The Item is accepting input **/ -}; -Q_ENUMS(ItemStatus) + /** + * Status of an applet + * @since 4.3 + */ + enum ItemStatus { + UnknownStatus = 0, /**< The status is unknown **/ + PassiveStatus = 1, /**< The Item is passive **/ + ActiveStatus = 2, /**< The Item is active **/ + NeedsAttentionStatus = 3, /**< The Item needs attention **/ + RequiresAttentionStatus = 4, /**< The Item needs persistent attention **/ + AcceptingInputStatus = 5 /**< The Item is accepting input **/ + }; + Q_ENUMS(ItemStatus) -enum TrustLevel { - UnverifiableTrust = 0, /**< The trust of the object can not be verified, usually because no + enum TrustLevel { + UnverifiableTrust = 0, /**< The trust of the object can not be verified, usually because no trust information (e.g. a cryptographic signature) was provided */ - CompletelyUntrusted, /**< The signature is broken/expired/false */ - UnknownTrusted, /**< The signature is valid, but the key is unknown */ - UserTrusted, /**< The signature is valid and made with a key signed by one of the + CompletelyUntrusted, /**< The signature is broken/expired/false */ + UnknownTrusted, /**< The signature is valid, but the key is unknown */ + UserTrusted, /**< The signature is valid and made with a key signed by one of the user's own keys*/ - SelfTrusted, /**< The signature is valid and made with one of the user's own keys*/ - FullyTrusted, /**< The signature is valid and made with a key signed by the vendor's key*/ - UltimatelyTrusted /**< The signature is valid and made with the vendor's key*/ -}; -Q_ENUMS(TrustLevel) + SelfTrusted, /**< The signature is valid and made with one of the user's own keys*/ + FullyTrusted, /**< The signature is valid and made with a key signed by the vendor's key*/ + UltimatelyTrusted /**< The signature is valid and made with the vendor's key*/ + }; + Q_ENUMS(TrustLevel) -/** - * Description on how draw a background for the applet - */ -enum BackgroundHints { - NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */ - StandardBackground = 1, /**< The standard background from the theme is drawn */ - TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */ - DefaultBackground = StandardBackground /**< Default settings: both standard background */ -}; -Q_ENUMS(BackgroundHints) + /** + * Description on how draw a background for the applet + */ + enum BackgroundHints { + NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */ + StandardBackground = 1, /**< The standard background from the theme is drawn */ + TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */ + DefaultBackground = StandardBackground /**< Default settings: both standard background */ + }; + Q_ENUMS(BackgroundHints) private: Types(QObject *parent = 0); @@ -301,8 +301,6 @@ PLASMA_EXPORT Types::Direction locationToInverseDirection(Types::Location locati } // Plasma namespace - - Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Types::Constraints) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Types::Flip) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Types::ComponentTypes) diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 1dc1e94e0..625f4d20e 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -42,7 +42,8 @@ #include "private/service_p.h" // for NullService #include "private/storage_p.h" -namespace Plasma { +namespace Plasma +{ static PluginLoader *s_pluginLoader = 0; @@ -103,14 +104,12 @@ QString PluginLoaderPrivate::parentAppConstraint(const QString &parentApp) } return QString("((not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '') or [X-KDE-ParentApp] == '%1')") - .arg(app->applicationName()); + .arg(app->applicationName()); } return QString("[X-KDE-ParentApp] == '%1'").arg(parentApp); } - - PluginLoader::PluginLoader() : d(new PluginLoaderPrivate) { @@ -127,7 +126,7 @@ PluginLoader::~PluginLoader() delete d; } -void PluginLoader::setPluginLoader(PluginLoader* loader) +void PluginLoader::setPluginLoader(PluginLoader *loader) { if (!s_pluginLoader) { s_pluginLoader = loader; @@ -220,7 +219,6 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari return 0; } - QString error; applet = offer->createInstance(0, allArgs, &error); @@ -241,7 +239,7 @@ DataEngine *PluginLoader::loadDataEngine(const QString &name) // load the engine, add it to the engines QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name); KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", - constraint); + constraint); QString error; if (offers.isEmpty()) { @@ -371,7 +369,7 @@ ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, co if (offers.isEmpty()) { #ifndef NDEBUG - qDebug() << "offers is empty for " << name; + qDebug() << "offers is empty for " << name; #endif return 0; } @@ -596,7 +594,7 @@ QStringList PluginLoader::customAppletCategories() const return PluginLoaderPrivate::s_customCategories.toList(); } -QString PluginLoader::appletCategory(const QString& appletName) +QString PluginLoader::appletCategory(const QString &appletName) { if (appletName.isEmpty()) { return QString(); @@ -613,15 +611,14 @@ QString PluginLoader::appletCategory(const QString& appletName) } KPluginInfo::List PluginLoader::listContainments(const QString &category, - const QString &parentApp) + const QString &parentApp) { return listContainmentsOfType(QString(), category, parentApp); } - KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, - const QString &category, - const QString &parentApp) + const QString &category, + const QString &parentApp) { QString constraint; @@ -683,7 +680,6 @@ QStringList PluginLoader::listContainmentTypes() return types.toList(); } - KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp) { KPluginInfo::List list; @@ -722,7 +718,7 @@ KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parent return KPluginInfo::fromServices(offers); } -Applet* PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args) +Applet *PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args) { Q_UNUSED(name) Q_UNUSED(appletId) @@ -783,8 +779,8 @@ KPluginInfo::List PluginLoader::internalContainmentActionsInfo() const static KPluginInfo::List standardInternalInfo(const QString &type, const QString &category = QString()) { QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, - "plasma/internal/" + type + "/*.desktop", - QStandardPaths::LocateFile); + "plasma/internal/" + type + "/*.desktop", + QStandardPaths::LocateFile); KPluginInfo::List allInfo = KPluginInfo::fromFiles(files); diff --git a/src/plasma/pluginloader.h b/src/plasma/pluginloader.h index d4c5ad946..76549c6bd 100644 --- a/src/plasma/pluginloader.h +++ b/src/plasma/pluginloader.h @@ -24,7 +24,8 @@ #include #include -namespace Plasma { +namespace Plasma +{ class Applet; class Containment; @@ -39,7 +40,7 @@ class PluginLoaderPrivate; // * add KPluginInfo listing support for Containments (already loaded via the applet loading code) /** - * This is an abstract base class which defines an interface to which Plasma's + * This is an abstract base class which defines an interface to which Plasma's * Applet Loading logic can communicate with a parent application. The plugin loader * must be set before any plugins are loaded, otherwise (for safety reasons), the * default PluginLoader implementation will be used. The reimplemented version should @@ -52,7 +53,7 @@ class PluginLoaderPrivate; **/ class PLASMA_EXPORT PluginLoader { -public: +public: /** * Load an Applet plugin. * @@ -138,7 +139,7 @@ public: * @return a ContaimentActions object **/ ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName, - const QVariantList &args = QVariantList()); + const QVariantList &args = QVariantList()); /** * Load a Package plugin. @@ -235,7 +236,7 @@ public: * @return list of applets **/ static KPluginInfo::List listContainments(const QString &category = QString(), - const QString &parentApp = QString()); + const QString &parentApp = QString()); /** * Returns a list of all known Containments that match the parameters. @@ -257,8 +258,8 @@ public: * @return list of applets **/ static KPluginInfo::List listContainmentsOfType(const QString &type, - const QString &category = QString(), - const QString &parentApp = QString()); + const QString &category = QString(), + const QString &parentApp = QString()); /** * @return a list of all known types of Containments on this system @@ -302,7 +303,7 @@ public: * @param loader A subclass of PluginLoader which will be supplied * by the application **/ - static void setPluginLoader(PluginLoader* loader); + static void setPluginLoader(PluginLoader *loader); /** * Return the active plugin loader @@ -388,7 +389,7 @@ protected: /** * A re-implementable method that allows subclasses to provide additional applets - * for listAppletInfo. If the application has no applets to give to the application, + * for listAppletInfo. If the application has no applets to give to the application, * then the implementation should return an empty list. * * This method is called by listAppletInfo prior to generating the list of applets installed @@ -470,11 +471,11 @@ protected: virtual ~PluginLoader(); private: - PluginLoaderPrivate * const d; + PluginLoaderPrivate *const d; }; } -Q_DECLARE_METATYPE(Plasma::PluginLoader*) +Q_DECLARE_METATYPE(Plasma::PluginLoader *) #endif diff --git a/src/plasma/private/actionwidgetinterface_p.h b/src/plasma/private/actionwidgetinterface_p.h index 744caf3f9..2b7fe58e4 100644 --- a/src/plasma/private/actionwidgetinterface_p.h +++ b/src/plasma/private/actionwidgetinterface_p.h @@ -86,7 +86,7 @@ public: if (action) { QObject::connect(action, SIGNAL(changed()), this->q, SLOT(syncToAction())); - QObject::connect(action, SIGNAL(destroyed(QObject*)), this->q, SLOT(clearAction())); + QObject::connect(action, SIGNAL(destroyed(QObject *)), this->q, SLOT(clearAction())); QObject::connect(this->q, SIGNAL(clicked()), action, SLOT(trigger())); syncToAction(); } diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index b815c29fa..d0ac89ece 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -46,28 +46,28 @@ namespace Plasma { AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet) - : appletId(uniqueID), - q(applet), - immutability(Types::Mutable), - appletDescription(info ? *info : KPluginInfo(service)), - icon(appletDescription.isValid() ? appletDescription.icon() : QString()), - mainConfig(0), - pendingConstraints(Types::NoConstraint), - script(0), - package(0), - configLoader(0), - actions(AppletPrivate::defaultActions(applet)), - activationAction(0), - itemStatus(Types::UnknownStatus), - modificationsTimer(0), - hasConfigurationInterface(false), - failed(false), - transient(false), - needsConfig(false), - started(false), - globalShortcutEnabled(false), - uiReady(false), - userConfiguring(false) + : appletId(uniqueID), + q(applet), + immutability(Types::Mutable), + appletDescription(info ? *info : KPluginInfo(service)), + icon(appletDescription.isValid() ? appletDescription.icon() : QString()), + mainConfig(0), + pendingConstraints(Types::NoConstraint), + script(0), + package(0), + configLoader(0), + actions(AppletPrivate::defaultActions(applet)), + activationAction(0), + itemStatus(Types::UnknownStatus), + modificationsTimer(0), + hasConfigurationInterface(false), + failed(false), + transient(false), + needsConfig(false), + started(false), + globalShortcutEnabled(false), + uiReady(false), + userConfiguring(false) { if (appletId == 0) { appletId = ++s_maxAppletId; @@ -136,8 +136,8 @@ void AppletPrivate::init(const QString &packagePath) delete package; package = 0; q->setLaunchErrorMessage(i18nc("Package file, name of the widget", - "Could not open the %1 package required for the %2 widget.", - appletDescription.pluginName(), appletDescription.name())); + "Could not open the %1 package required for the %2 widget.", + appletDescription.pluginName(), appletDescription.name())); return; } @@ -150,9 +150,9 @@ void AppletPrivate::init(const QString &packagePath) delete package; package = 0; q->setLaunchErrorMessage( - i18nc("API or programming language the widget was written in, name of the widget", - "Could not create a %1 ScriptEngine for the %2 widget.", - api, appletDescription.name())); + i18nc("API or programming language the widget was written in, name of the widget", + "Could not create a %1 ScriptEngine for the %2 widget.", + api, appletDescription.name())); } } @@ -188,15 +188,15 @@ void AppletPrivate::askDestroy() } if (q->isContainment()) { - QMessageBox *box = new QMessageBox(QMessageBox::Warning, i18nc("@title:window %1 is the name of the containment", "Remove %1", q->title()), i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", q->title()), QMessageBox::StandardButtons( QMessageBox::Yes | QMessageBox::No )); + QMessageBox *box = new QMessageBox(QMessageBox::Warning, i18nc("@title:window %1 is the name of the containment", "Remove %1", q->title()), i18nc("%1 is the name of the containment", "Do you really want to remove this %1?", q->title()), QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No)); box->setWindowFlags((Qt::WindowFlags)(box->windowFlags() | Qt::WA_DeleteOnClose)); box->open(); QObject::connect(box->button(QMessageBox::Yes), &QAbstractButton::clicked, - [=] () { - transient = true; - cleanUpAndDelete(); - }); + [ = ]() { + transient = true; + cleanUpAndDelete(); + }); return; } @@ -213,14 +213,14 @@ void AppletPrivate::globalShortcutChanged() KConfigGroup shortcutConfig(mainConfigGroup(), "Shortcuts"); QString newShortCut = activationAction->shortcut().toString(); QString oldShortCut = shortcutConfig.readEntry("global", QString()); - if(newShortCut != oldShortCut) { + if (newShortCut != oldShortCut) { shortcutConfig.writeEntry("global", newShortCut); scheduleModificationNotification(); } //qDebug() << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary(); } -KActionCollection* AppletPrivate::defaultActions(QObject *parent) +KActionCollection *AppletPrivate::defaultActions(QObject *parent) { KActionCollection *actions = new KActionCollection(parent); actions->setConfigGroup("Shortcuts-Applet"); @@ -264,7 +264,7 @@ void AppletPrivate::updateShortcuts() //a horrible hack to avoid clobbering corona settings //we pull them out, then read, then put them back QList names; - QList qactions; + QList qactions; names << "add sibling containment" << "configure shortcuts" << "lock widgets"; foreach (const QString &name, names) { QAction *a = actions->action(name); @@ -399,7 +399,7 @@ KConfigGroup *AppletPrivate::mainConfigGroup() } if (q->isContainment()) { - Corona *corona = static_cast(q)->corona(); + Corona *corona = static_cast(q)->corona(); KConfigGroup containmentConfig; //qDebug() << "got a corona, baby?" << (QObject*)corona << (QObject*)q; @@ -448,7 +448,7 @@ void AppletPrivate::resetConfigurationObject() if (!q->containment()) { return; } - Corona * corona = q->containment()->corona(); + Corona *corona = q->containment()->corona(); if (corona) { corona->requireConfigSync(); } diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index a9a2e4c8c..f31f02e39 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -1,23 +1,23 @@ - /* - * Copyright 2005 by Aaron Seigo - * Copyright 2007 by Riccardo Iaconelli - * Copyright 2008 by Ménard Alexis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library 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. - */ +/* +* Copyright 2005 by Aaron Seigo +* Copyright 2007 by Riccardo Iaconelli +* Copyright 2008 by Ménard Alexis +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU Library General Public License as +* published by the Free Software Foundation; either version 2, 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 Library 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. +*/ #ifndef PLASMA_APPLET_P_H #define PLASMA_APPLET_P_H @@ -67,7 +67,7 @@ public: void propagateConfigChanged(); void setUiReady(); - static KActionCollection* defaultActions(QObject *parent); + static KActionCollection *defaultActions(QObject *parent); void requestConfiguration(); diff --git a/src/plasma/private/associatedapplicationmanager.cpp b/src/plasma/private/associatedapplicationmanager.cpp index 9e02f733e..213dd61d7 100644 --- a/src/plasma/private/associatedapplicationmanager.cpp +++ b/src/plasma/private/associatedapplicationmanager.cpp @@ -64,13 +64,12 @@ public: class AssociatedApplicationManagerSingleton { - public: - AssociatedApplicationManager self; +public: + AssociatedApplicationManager self; }; Q_GLOBAL_STATIC(AssociatedApplicationManagerSingleton, privateAssociatedApplicationManagerSelf) - AssociatedApplicationManager::AssociatedApplicationManager(QObject *parent) : QObject(parent), d(new AssociatedApplicationManagerPrivate()) @@ -144,7 +143,6 @@ bool AssociatedApplicationManager::appletHasValidAssociatedApplication(const Pla return (d->applicationNames.contains(applet) || d->urlLists.contains(applet)); } - } // namespace Plasma #include diff --git a/src/plasma/private/authorizationmanager_p.h b/src/plasma/private/authorizationmanager_p.h index 51c0a1a1d..125ca4625 100644 --- a/src/plasma/private/authorizationmanager_p.h +++ b/src/plasma/private/authorizationmanager_p.h @@ -38,12 +38,12 @@ class QByteArray; namespace KWallet { - class Wallet; +class Wallet; } // namespace KWallet namespace Jolie { - class Server; +class Server; } // namespace Jolie namespace Plasma @@ -55,37 +55,37 @@ class Credentials; class AuthorizationManagerPrivate { - public: - AuthorizationManagerPrivate(AuthorizationManager *manager); - ~AuthorizationManagerPrivate(); +public: + AuthorizationManagerPrivate(AuthorizationManager *manager); + ~AuthorizationManagerPrivate(); - void prepareForServiceAccess(); - void prepareForServicePublication(); - void slotWalletOpened(); - void slotLoadRules(); - AuthorizationRule *matchingRule(const QString &serviceName, const Credentials &key) const; - Credentials getCredentials(const QString &id = QString()); - void addCredentials(const Credentials &identity); - void saveRules(); + void prepareForServiceAccess(); + void prepareForServicePublication(); + void slotWalletOpened(); + void slotLoadRules(); + AuthorizationRule *matchingRule(const QString &serviceName, const Credentials &key) const; + Credentials getCredentials(const QString &id = QString()); + void addCredentials(const Credentials &identity); + void saveRules(); #if ENABLE_REMOTE_WIDGETS - QCA::Initializer initializer; + QCA::Initializer initializer; #endif - AuthorizationManager *q; - Jolie::Server *server; - AuthorizationManager::AuthorizationPolicy - authorizationPolicy; - AuthorizationInterface *authorizationInterface; - AuthorizationInterface *customAuthorizationInterface; - KWallet::Wallet *wallet; + AuthorizationManager *q; + Jolie::Server *server; + AuthorizationManager::AuthorizationPolicy + authorizationPolicy; + AuthorizationInterface *authorizationInterface; + AuthorizationInterface *customAuthorizationInterface; + KWallet::Wallet *wallet; - Credentials myCredentials; - QMap identities; - QList rules; - KConfigGroup identitiesConfig; - KConfigGroup rulesConfig; - bool locked; + Credentials myCredentials; + QMap identities; + QList rules; + KConfigGroup identitiesConfig; + KConfigGroup rulesConfig; + bool locked; }; } diff --git a/src/plasma/private/componentinstaller.cpp b/src/plasma/private/componentinstaller.cpp index 571d98a12..8fbef24ad 100644 --- a/src/plasma/private/componentinstaller.cpp +++ b/src/plasma/private/componentinstaller.cpp @@ -31,16 +31,16 @@ namespace Plasma class ComponentInstallerPrivate { - public: +public: #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT - QSet alreadyPrompted; + QSet alreadyPrompted; #endif }; class ComponentInstallerSingleton { - public: - ComponentInstaller self; +public: + ComponentInstaller self; }; Q_GLOBAL_STATIC(ComponentInstallerSingleton, privateComponentInstallerSelf) @@ -61,8 +61,8 @@ ComponentInstaller::~ComponentInstaller() } void ComponentInstaller::installMissingComponent(const QString &type, - const QString &name, - QWidget *parent, bool force) + const QString &name, + QWidget *parent, bool force) { #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT QString searchString = type + '-' + name; diff --git a/src/plasma/private/componentinstaller_p.h b/src/plasma/private/componentinstaller_p.h index f85cbb6b2..1902bfe16 100644 --- a/src/plasma/private/componentinstaller_p.h +++ b/src/plasma/private/componentinstaller_p.h @@ -44,49 +44,49 @@ class ComponentInstallerPrivate; */ class ComponentInstaller { - public: - /** - * Singleton pattern accessor. - */ - static ComponentInstaller *self(); +public: + /** + * Singleton pattern accessor. + */ + static ComponentInstaller *self(); - /** - * Installs a missing component asynchronously. - * - * By default, this method will cache requested components and not - * prompt again for the same engine in the same session. The force - * parameter can be used to disable this mechanism, e.g. when the user - * just installed a new widget written in a scripting language, and so - * is likely to want the script engine installed after all. - * - * In the case of on-demand installation, this will unfortunately not - * allow the call which triggered the missing component lookup to - * succeed, but we cannot afford to block all of Plasma until the - * mechanism is done installing the service. - * - * This function does nothing if PackageKit integration was disabled at - * compile time. - * - * @param type the type of the component, should be "scriptengine" or - * "dataengine" - * @param name the name of the component - * @param parent a parent widget, used to set the wid for PackageKit - * @param force whether to always prompt, even if recently prompted - */ - void installMissingComponent(const QString &type, const QString &name, - QWidget *parent = 0, bool force = false); + /** + * Installs a missing component asynchronously. + * + * By default, this method will cache requested components and not + * prompt again for the same engine in the same session. The force + * parameter can be used to disable this mechanism, e.g. when the user + * just installed a new widget written in a scripting language, and so + * is likely to want the script engine installed after all. + * + * In the case of on-demand installation, this will unfortunately not + * allow the call which triggered the missing component lookup to + * succeed, but we cannot afford to block all of Plasma until the + * mechanism is done installing the service. + * + * This function does nothing if PackageKit integration was disabled at + * compile time. + * + * @param type the type of the component, should be "scriptengine" or + * "dataengine" + * @param name the name of the component + * @param parent a parent widget, used to set the wid for PackageKit + * @param force whether to always prompt, even if recently prompted + */ + void installMissingComponent(const QString &type, const QString &name, + QWidget *parent = 0, bool force = false); - private: - /** - * Default constructor. The singleton method self() is the - * preferred access mechanism. - */ - ComponentInstaller(); - ~ComponentInstaller(); +private: + /** + * Default constructor. The singleton method self() is the + * preferred access mechanism. + */ + ComponentInstaller(); + ~ComponentInstaller(); - ComponentInstallerPrivate *const d; + ComponentInstallerPrivate *const d; - friend class ComponentInstallerSingleton; + friend class ComponentInstallerSingleton; }; } // namespace Plasma diff --git a/src/plasma/private/configloader_p.h b/src/plasma/private/configloader_p.h index e429d9e68..25bb6b8ee 100644 --- a/src/plasma/private/configloader_p.h +++ b/src/plasma/private/configloader_p.h @@ -27,199 +27,198 @@ namespace Plasma class ConfigLoaderPrivate { - public: - ConfigLoaderPrivate() - : saveDefaults(false) - { - } +public: + ConfigLoaderPrivate() + : saveDefaults(false) + { + } - ~ConfigLoaderPrivate() - { - clearData(); - } + ~ConfigLoaderPrivate() + { + clearData(); + } - void clearData() - { - qDeleteAll(bools); - qDeleteAll(strings); - qDeleteAll(stringlists); - qDeleteAll(colors); - qDeleteAll(fonts); - qDeleteAll(ints); - qDeleteAll(uints); - qDeleteAll(urls); - qDeleteAll(dateTimes); - qDeleteAll(doubles); - qDeleteAll(intlists); - qDeleteAll(longlongs); - qDeleteAll(points); - qDeleteAll(rects); - qDeleteAll(sizes); - qDeleteAll(ulonglongs); - qDeleteAll(urllists); - } + void clearData() + { + qDeleteAll(bools); + qDeleteAll(strings); + qDeleteAll(stringlists); + qDeleteAll(colors); + qDeleteAll(fonts); + qDeleteAll(ints); + qDeleteAll(uints); + qDeleteAll(urls); + qDeleteAll(dateTimes); + qDeleteAll(doubles); + qDeleteAll(intlists); + qDeleteAll(longlongs); + qDeleteAll(points); + qDeleteAll(rects); + qDeleteAll(sizes); + qDeleteAll(ulonglongs); + qDeleteAll(urllists); + } - bool *newBool() - { - bool *v = new bool; - bools.append(v); - return v; - } + bool *newBool() + { + bool *v = new bool; + bools.append(v); + return v; + } - QString *newString() - { - QString *v = new QString; - strings.append(v); - return v; - } + QString *newString() + { + QString *v = new QString; + strings.append(v); + return v; + } - QStringList *newStringList() - { - QStringList *v = new QStringList; - stringlists.append(v); - return v; - } + QStringList *newStringList() + { + QStringList *v = new QStringList; + stringlists.append(v); + return v; + } - QColor *newColor() - { - QColor *v = new QColor; - colors.append(v); - return v; - } + QColor *newColor() + { + QColor *v = new QColor; + colors.append(v); + return v; + } - QFont *newFont() - { - QFont *v = new QFont; - fonts.append(v); - return v; - } + QFont *newFont() + { + QFont *v = new QFont; + fonts.append(v); + return v; + } - qint32 *newInt() - { - qint32 *v = new qint32; - ints.append(v); - return v; - } + qint32 *newInt() + { + qint32 *v = new qint32; + ints.append(v); + return v; + } - quint32 *newUint() - { - quint32 *v = new quint32; - uints.append(v); - return v; - } + quint32 *newUint() + { + quint32 *v = new quint32; + uints.append(v); + return v; + } - QUrl *newUrl() - { - QUrl *v = new QUrl; - urls.append(v); - return v; - } + QUrl *newUrl() + { + QUrl *v = new QUrl; + urls.append(v); + return v; + } - QDateTime *newDateTime() - { - QDateTime *v = new QDateTime; - dateTimes.append(v); - return v; - } + QDateTime *newDateTime() + { + QDateTime *v = new QDateTime; + dateTimes.append(v); + return v; + } - double *newDouble() - { - double *v = new double; - doubles.append(v); - return v; - } + double *newDouble() + { + double *v = new double; + doubles.append(v); + return v; + } - QList* newIntList() - { - QList *v = new QList; - intlists.append(v); - return v; - } + QList *newIntList() + { + QList *v = new QList; + intlists.append(v); + return v; + } - qint64 *newLongLong() - { - qint64 *v = new qint64; - longlongs.append(v); - return v; - } + qint64 *newLongLong() + { + qint64 *v = new qint64; + longlongs.append(v); + return v; + } - QPoint *newPoint() - { - QPoint *v = new QPoint; - points.append(v); - return v; - } + QPoint *newPoint() + { + QPoint *v = new QPoint; + points.append(v); + return v; + } - QRect *newRect() - { - QRect *v = new QRect; - rects.append(v); - return v; - } + QRect *newRect() + { + QRect *v = new QRect; + rects.append(v); + return v; + } - QSize *newSize() - { - QSize *v = new QSize; - sizes.append(v); - return v; - } + QSize *newSize() + { + QSize *v = new QSize; + sizes.append(v); + return v; + } - quint64 *newULongLong() - { - quint64 *v = new quint64; - ulonglongs.append(v); - return v; - } + quint64 *newULongLong() + { + quint64 *v = new quint64; + ulonglongs.append(v); + return v; + } - QList *newUrlList() - { - QList *v = new QList(); - urllists.append(v); - return v; - } + QList *newUrlList() + { + QList *v = new QList(); + urllists.append(v); + return v; + } - void parse(ConfigLoader *loader, QIODevice *xml); + void parse(ConfigLoader *loader, QIODevice *xml); - /** - * Whether or not to write out default values. - * - * @param writeDefaults true if defaults should be written out - */ - void setWriteDefaults(bool writeDefaults) - { - saveDefaults = writeDefaults; - } + /** + * Whether or not to write out default values. + * + * @param writeDefaults true if defaults should be written out + */ + void setWriteDefaults(bool writeDefaults) + { + saveDefaults = writeDefaults; + } - /** - * @return true if default values will also be written out - */ - bool writeDefaults() const - { - return saveDefaults; - } + /** + * @return true if default values will also be written out + */ + bool writeDefaults() const + { + return saveDefaults; + } - - QList bools; - QList strings; - QList stringlists; - QList colors; - QList fonts; - QList ints; - QList uints; - QList urls; - QList dateTimes; - QList doubles; - QList *> intlists; - QList longlongs; - QList points; - QList rects; - QList sizes; - QList ulonglongs; - QList *> urllists; - QString baseGroup; - QStringList groups; - QHash keysToNames; - bool saveDefaults; + QList bools; + QList strings; + QList stringlists; + QList colors; + QList fonts; + QList ints; + QList uints; + QList urls; + QList dateTimes; + QList doubles; + QList *> intlists; + QList longlongs; + QList points; + QList rects; + QList sizes; + QList ulonglongs; + QList *> urllists; + QString baseGroup; + QStringList groups; + QHash keysToNames; + bool saveDefaults; }; } // namespace Plasma diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index 5ea94ef81..9e673829e 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -22,7 +22,6 @@ #include "private/containment_p.h" - #include #include #include @@ -37,7 +36,6 @@ #include "private/applet_p.h" - namespace Plasma { @@ -48,7 +46,7 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme actions->setConfigGroup("Shortcuts-Containment"); //adjust applet actions - QAction *appAction = qobject_cast(actions->action("remove")); + QAction *appAction = qobject_cast(actions->action("remove")); appAction->setShortcut(QKeySequence("alt+d, alt+r")); if (c && c->d->isPanelContainment()) { appAction->setText(i18n("Remove this Panel")); @@ -56,7 +54,7 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme appAction->setText(i18n("Remove this Activity")); } - appAction = qobject_cast(actions->action("configure")); + appAction = qobject_cast(actions->action("configure")); if (appAction) { appAction->setShortcut(QKeySequence("alt+d, alt+s")); appAction->setText(i18n("Activity Settings")); diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index 1dfff383a..24049c716 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -29,12 +29,11 @@ #include "corona.h" #include "containmentactions.h" - class KJob; namespace KIO { - class Job; +class Job; } namespace Plasma @@ -75,7 +74,7 @@ public: bool isPanelContainment() const; void setLockToolText(); - void appletDeleted(Applet*); + void appletDeleted(Applet *); void configChanged(); Applet *createApplet(const QString &name, const QVariantList &args = QVariantList(), uint id = 0); @@ -99,7 +98,7 @@ public: //Applets still considered not ready QSet loadingApplets; QString wallpaper; - QHash localActionPlugins; + QHash localActionPlugins; int lastScreen; QString activityId; Types::ContainmentType type; diff --git a/src/plasma/private/containmentactions_p.h b/src/plasma/private/containmentactions_p.h index fb6ee2b41..0c9801eb8 100644 --- a/src/plasma/private/containmentactions_p.h +++ b/src/plasma/private/containmentactions_p.h @@ -20,7 +20,6 @@ #ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H #define PLASMA_CONTAINMENTACTIONSPRIVATE_H - namespace Plasma { diff --git a/src/plasma/private/corona_p.h b/src/plasma/private/corona_p.h index f978351be..bf3280e08 100644 --- a/src/plasma/private/corona_p.h +++ b/src/plasma/private/corona_p.h @@ -55,7 +55,7 @@ public: QString configName; KSharedConfigPtr config; QTimer *configSyncTimer; - QList containments; + QList containments; KActionCollection actions; int containmentsStarting; }; diff --git a/src/plasma/private/datacontainer_p.cpp b/src/plasma/private/datacontainer_p.cpp index 31f1fba14..d9d33d77f 100644 --- a/src/plasma/private/datacontainer_p.cpp +++ b/src/plasma/private/datacontainer_p.cpp @@ -24,16 +24,16 @@ namespace Plasma { SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, QObject *visualization, - uint pollingInterval, - Plasma::Types::IntervalAlignment align, - bool immediateUpdate) + uint pollingInterval, + Plasma::Types::IntervalAlignment align, + bool immediateUpdate) { QMap::const_iterator relayIt = relays.constFind(pollingInterval); SignalRelay *relay = 0; //FIXME what if we have two applets with the same interval and different alignment? if (relayIt == relays.constEnd()) { - relay = new SignalRelay(const_cast(dc), this, + relay = new SignalRelay(const_cast(dc), this, pollingInterval, align, immediateUpdate); relays[pollingInterval] = relay; } else { @@ -97,7 +97,7 @@ void SignalRelay::checkAlignment() int seconds = t.second(); if (minutes > 1 || seconds > 10) { newTime = ((60 - minutes) * 1000 * 60) + - ((60 - seconds) * 1000) + 500; + ((60 - seconds) * 1000) + 500; } } @@ -166,6 +166,4 @@ void SignalRelay::timerEvent(QTimerEvent *event) } // Plasma namespace - - #include "moc_datacontainer_p.cpp" diff --git a/src/plasma/private/datacontainer_p.h b/src/plasma/private/datacontainer_p.h index a4760dcda..92ac7d17a 100644 --- a/src/plasma/private/datacontainer_p.h +++ b/src/plasma/private/datacontainer_p.h @@ -67,7 +67,7 @@ public: bool hasUpdates(); /** - * Deletes the store member of DataContainerPrivate if + * Deletes the store member of DataContainerPrivate if * there are no more references to it. */ void storeJobFinished(KJob *job); @@ -86,7 +86,7 @@ public: QMap relayObjects; QMap relays; QTime updateTs; - Storage* storage; + Storage *storage; QBasicTimer storageTimer; QBasicTimer checkUsageTimer; QWeakPointer model; diff --git a/src/plasma/private/dataengine_p.h b/src/plasma/private/dataengine_p.h index d8ade83af..3dad942d0 100644 --- a/src/plasma/private/dataengine_p.h +++ b/src/plasma/private/dataengine_p.h @@ -33,77 +33,77 @@ class Service; class DataEnginePrivate { - public: - DataEnginePrivate(DataEngine *e, const KPluginInfo &info); - ~DataEnginePrivate(); - DataContainer *source(const QString &sourceName, bool createWhenMissing = true); - void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment align, bool immediateCall = true); - DataContainer *requestSource(const QString &sourceName, bool *newSource = 0); - void internalUpdateSource(DataContainer*); - void setupScriptSupport(); +public: + DataEnginePrivate(DataEngine *e, const KPluginInfo &info); + ~DataEnginePrivate(); + DataContainer *source(const QString &sourceName, bool createWhenMissing = true); + void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, + Plasma::Types::IntervalAlignment align, bool immediateCall = true); + DataContainer *requestSource(const QString &sourceName, bool *newSource = 0); + void internalUpdateSource(DataContainer *); + void setupScriptSupport(); - /** - * Reference counting method. Calling this method increases the count - * by one. - **/ - void ref(); + /** + * Reference counting method. Calling this method increases the count + * by one. + **/ + void ref(); - /** - * Reference counting method. Calling this method decreases the count - * by one. - **/ - void deref(); + /** + * Reference counting method. Calling this method decreases the count + * by one. + **/ + void deref(); - /** - * Reference counting method. Used to determine if this DataEngine is - * used. - * @return true if the reference count is non-zero - **/ - bool isUsed() const; + /** + * Reference counting method. Used to determine if this DataEngine is + * used. + * @return true if the reference count is non-zero + **/ + bool isUsed() const; - /** - * a datacontainer has been destroyed, clean up stuff - */ - void sourceDestroyed(QObject *object); + /** + * a datacontainer has been destroyed, clean up stuff + */ + void sourceDestroyed(QObject *object); - /** - * stores the source - * @param sourceName the name of the source to store - */ - void storeSource(DataContainer *source) const; + /** + * stores the source + * @param sourceName the name of the source to store + */ + void storeSource(DataContainer *source) const; - /** - * stores all sources marked for storage - */ - void storeAllSources(); + /** + * stores all sources marked for storage + */ + void storeAllSources(); - /** - * retrieves source data - * @param the data container to populate - */ - void retrieveStoredData(DataContainer *s); + /** + * retrieves source data + * @param the data container to populate + */ + void retrieveStoredData(DataContainer *s); - /** - * Call this method when you call setData directly on a DataContainer instead - * of using the DataEngine::setData methods. - * If this method is not called, no dataUpdated(..) signals will be emitted! - */ - void scheduleSourcesUpdated(); + /** + * Call this method when you call setData directly on a DataContainer instead + * of using the DataEngine::setData methods. + * If this method is not called, no dataUpdated(..) signals will be emitted! + */ + void scheduleSourcesUpdated(); - DataEngine *q; - KPluginInfo dataEngineDescription; - int refCount; - int checkSourcesTimerId; - int updateTimerId; - int minPollingInterval; - QTime updateTimestamp; - DataEngine::SourceDict sources; - bool valid; - DataEngineScript *script; - QString serviceName; - Package *package; - QString waitingSourceRequest; + DataEngine *q; + KPluginInfo dataEngineDescription; + int refCount; + int checkSourcesTimerId; + int updateTimerId; + int minPollingInterval; + QTime updateTimestamp; + DataEngine::SourceDict sources; + bool valid; + DataEngineScript *script; + QString serviceName; + Package *package; + QString waitingSourceRequest; }; } // Plasma namespace diff --git a/src/plasma/private/dataengineconsumer_p.h b/src/plasma/private/dataengineconsumer_p.h index 8ee5f1aa0..1f1e09b8c 100644 --- a/src/plasma/private/dataengineconsumer_p.h +++ b/src/plasma/private/dataengineconsumer_p.h @@ -40,7 +40,7 @@ class DataEngineConsumerPrivate : public QObject public: QSet loadedEngines; - QMap engineNameForService; + QMap engineNameForService; public Q_SLOTS: void slotJobFinished(Plasma::ServiceJob *job); diff --git a/src/plasma/private/dataenginemanager.cpp b/src/plasma/private/dataenginemanager.cpp index cb8b8285f..b9c5d8efa 100644 --- a/src/plasma/private/dataenginemanager.cpp +++ b/src/plasma/private/dataenginemanager.cpp @@ -39,50 +39,50 @@ namespace Plasma class NullEngine : public DataEngine { - public: - NullEngine(QObject *parent = 0) - : DataEngine(KPluginInfo(), parent) - { - setValid(false); +public: + NullEngine(QObject *parent = 0) + : DataEngine(KPluginInfo(), parent) + { + setValid(false); - // ref() ourselves to ensure we never get deleted - d->ref(); - } + // ref() ourselves to ensure we never get deleted + d->ref(); + } }; class DataEngineManagerPrivate { - public: - DataEngineManagerPrivate() - : nullEng(0) - {} +public: + DataEngineManagerPrivate() + : nullEng(0) + {} - ~DataEngineManagerPrivate() - { - foreach (Plasma::DataEngine *engine, engines) { - delete engine; - } - engines.clear(); - delete nullEng; + ~DataEngineManagerPrivate() + { + foreach (Plasma::DataEngine *engine, engines) { + delete engine; + } + engines.clear(); + delete nullEng; + } + + DataEngine *nullEngine() + { + if (!nullEng) { + nullEng = new NullEngine; } - DataEngine *nullEngine() - { - if (!nullEng) { - nullEng = new NullEngine; - } + return nullEng; + } - return nullEng; - } - - DataEngine::Dict engines; - DataEngine *nullEng; + DataEngine::Dict engines; + DataEngine *nullEng; }; class DataEngineManagerSingleton { - public: - DataEngineManager self; +public: + DataEngineManager self; }; Q_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf) @@ -173,7 +173,7 @@ void DataEngineManager::timerEvent(QTimerEvent *) QTextStream out(&f); - QHashIterator it(d->engines); + QHashIterator it(d->engines); out << "================================== " << QLocale().toString(QDateTime::currentDateTime()) << endl; while (it.hasNext()) { it.next(); @@ -212,5 +212,4 @@ void DataEngineManager::timerEvent(QTimerEvent *) } // namespace Plasma - #include "moc_dataenginemanager_p.cpp" diff --git a/src/plasma/private/dataenginemanager_p.h b/src/plasma/private/dataenginemanager_p.h index e35b5ff87..c55a055f0 100644 --- a/src/plasma/private/dataenginemanager_p.h +++ b/src/plasma/private/dataenginemanager_p.h @@ -42,56 +42,55 @@ class DataEngineManagerPrivate; class PLASMA_EXPORT DataEngineManager: public QObject { Q_OBJECT - public: - /** - * Singleton pattern accessor. - */ - static DataEngineManager *self(); +public: + /** + * Singleton pattern accessor. + */ + static DataEngineManager *self(); - /** - * Returns a data engine object if one is loaded and available. - * On failure, the fallback NullEngine (which does nothing and - * !isValid()) is returned. - * - * @param name the name of the engine - */ - Plasma::DataEngine *engine(const QString &name) const; + /** + * Returns a data engine object if one is loaded and available. + * On failure, the fallback NullEngine (which does nothing and + * !isValid()) is returned. + * + * @param name the name of the engine + */ + Plasma::DataEngine *engine(const QString &name) const; - /** - * Loads a data engine and increases the reference count on it. - * This should be called once per object (or set of objects) using the - * DataEngine. Afterwards, dataEngine should be used or the return - * value cached. Call unloadDataEngine when finished with the engine. - * - * @param name the name of the engine - * @return the data engine that was loaded, or the NullEngine on failure. - */ - Plasma::DataEngine *loadEngine(const QString &name); + /** + * Loads a data engine and increases the reference count on it. + * This should be called once per object (or set of objects) using the + * DataEngine. Afterwards, dataEngine should be used or the return + * value cached. Call unloadDataEngine when finished with the engine. + * + * @param name the name of the engine + * @return the data engine that was loaded, or the NullEngine on failure. + */ + Plasma::DataEngine *loadEngine(const QString &name); - /** - * Decreases the reference count on the engine. If the count reaches - * zero, then the engine is deleted to save resources. - */ - void unloadEngine(const QString &name); + /** + * Decreases the reference count on the engine. If the count reaches + * zero, then the engine is deleted to save resources. + */ + void unloadEngine(const QString &name); +protected: + /** + * Reimplemented from QObject + **/ + void timerEvent(QTimerEvent *event); - protected: - /** - * Reimplemented from QObject - **/ - void timerEvent(QTimerEvent *event); +private: + /** + * Default constructor. The singleton method self() is the + * preferred access mechanism. + */ + DataEngineManager(); + ~DataEngineManager(); - private: - /** - * Default constructor. The singleton method self() is the - * preferred access mechanism. - */ - DataEngineManager(); - ~DataEngineManager(); + DataEngineManagerPrivate *const d; - DataEngineManagerPrivate *const d; - - friend class DataEngineManagerSingleton; + friend class DataEngineManagerSingleton; }; } // namespace Plasma diff --git a/src/plasma/private/effectwatcher.cpp b/src/plasma/private/effectwatcher.cpp index f9b11f357..25b48e2d9 100644 --- a/src/plasma/private/effectwatcher.cpp +++ b/src/plasma/private/effectwatcher.cpp @@ -26,7 +26,7 @@ namespace Plasma { -EffectWatcher::EffectWatcher(const QString& property, QObject *parent) +EffectWatcher::EffectWatcher(const QString &property, QObject *parent) : QObject(parent), m_property(XCB_ATOM_NONE), m_isX11(QX11Info::isPlatformX11()) @@ -59,17 +59,19 @@ void EffectWatcher::init(const QString &property) } } -bool EffectWatcher::nativeEventFilter(const QByteArray& eventType, void *message, long *result) +bool EffectWatcher::nativeEventFilter(const QByteArray &eventType, void *message, long *result) { Q_UNUSED(result); - if (eventType != "xcb_generic_event_t") + if (eventType != "xcb_generic_event_t") { return false; - xcb_generic_event_t* event = reinterpret_cast(message); + } + xcb_generic_event_t *event = reinterpret_cast(message); uint response_type = event->response_type & ~0x80; - if (response_type != XCB_PROPERTY_NOTIFY || m_property == XCB_ATOM_NONE) + if (response_type != XCB_PROPERTY_NOTIFY || m_property == XCB_ATOM_NONE) { return false; + } - xcb_property_notify_event_t* prop_event = reinterpret_cast(event); + xcb_property_notify_event_t *prop_event = reinterpret_cast(event); if (prop_event->atom == m_property) { bool nowEffectActive = isEffectActive(); if (m_effectActive != nowEffectActive) { diff --git a/src/plasma/private/effectwatcher_p.h b/src/plasma/private/effectwatcher_p.h index ad0196001..b315ac659 100644 --- a/src/plasma/private/effectwatcher_p.h +++ b/src/plasma/private/effectwatcher_p.h @@ -34,12 +34,12 @@ class EffectWatcher: public QObject, public QAbstractNativeEventFilter Q_OBJECT public: - EffectWatcher(const QString& property, QObject *parent = 0); + EffectWatcher(const QString &property, QObject *parent = 0); protected: bool isEffectActive() const; - bool nativeEventFilter(const QByteArray& eventType, void *message, long *result) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; Q_SIGNALS: void effectChanged(bool on); diff --git a/src/plasma/private/framesvg_p.h b/src/plasma/private/framesvg_p.h index 055fcf343..5a22469aa 100644 --- a/src/plasma/private/framesvg_p.h +++ b/src/plasma/private/framesvg_p.h @@ -34,39 +34,39 @@ class FrameData { public: FrameData(FrameSvg *svg) - : enabledBorders(FrameSvg::AllBorders), - frameSize(-1,-1), - topHeight(0), - leftWidth(0), - rightWidth(0), - bottomHeight(0), - topMargin(0), - leftMargin(0), - rightMargin(0), - bottomMargin(0), - noBorderPadding(false), - stretchBorders(false), - tileCenter(false), - composeOverBorder(false) + : enabledBorders(FrameSvg::AllBorders), + frameSize(-1, -1), + topHeight(0), + leftWidth(0), + rightWidth(0), + bottomHeight(0), + topMargin(0), + leftMargin(0), + rightMargin(0), + bottomMargin(0), + noBorderPadding(false), + stretchBorders(false), + tileCenter(false), + composeOverBorder(false) { ref(svg); } FrameData(const FrameData &other, FrameSvg *svg) - : enabledBorders(other.enabledBorders), - frameSize(other.frameSize), - topHeight(0), - leftWidth(0), - rightWidth(0), - bottomHeight(0), - topMargin(0), - leftMargin(0), - rightMargin(0), - bottomMargin(0), - noBorderPadding(false), - stretchBorders(false), - tileCenter(false), - composeOverBorder(false) + : enabledBorders(other.enabledBorders), + frameSize(other.frameSize), + topHeight(0), + leftWidth(0), + rightWidth(0), + bottomHeight(0), + topMargin(0), + leftMargin(0), + rightMargin(0), + bottomMargin(0), + noBorderPadding(false), + stretchBorders(false), + tileCenter(false), + composeOverBorder(false) { ref(svg); } @@ -126,10 +126,10 @@ class FrameSvgPrivate { public: FrameSvgPrivate(FrameSvg *psvg) - : q(psvg), - theme(new Plasma::Theme(q)), - cacheAll(false), - overlayPos(0,0) + : q(psvg), + theme(new Plasma::Theme(q)), + cacheAll(false), + overlayPos(0, 0) { } @@ -155,7 +155,7 @@ public: bool cacheAll : 1; QPoint overlayPos; - QHash frames; + QHash frames; static QHash s_sharedFrames; }; diff --git a/src/plasma/private/package_p.h b/src/plasma/private/package_p.h index ba4ead970..d902eb11c 100644 --- a/src/plasma/private/package_p.h +++ b/src/plasma/private/package_p.h @@ -33,32 +33,32 @@ namespace Plasma class ContentStructure { - public: - ContentStructure() - : directory(false), - required(false) - { - } +public: + ContentStructure() + : directory(false), + required(false) + { + } - ContentStructure(const ContentStructure &other) - { - paths = other.paths; + ContentStructure(const ContentStructure &other) + { + paths = other.paths; #ifndef PLASMA_NO_PACKAGE_EXTRADATA - name = other.name; - mimeTypes = other.mimeTypes; + name = other.name; + mimeTypes = other.mimeTypes; #endif - directory = other.directory; - required = other.required; - } + directory = other.directory; + required = other.required; + } - QString found; - QStringList paths; + QString found; + QStringList paths; #ifndef PLASMA_NO_PACKAGE_EXTRADATA - QString name; - QStringList mimeTypes; + QString name; + QStringList mimeTypes; #endif - bool directory : 1; - bool required : 1; + bool directory : 1; + bool required : 1; }; class PackagePrivate : public QSharedData diff --git a/src/plasma/private/packagejob.cpp b/src/plasma/private/packagejob.cpp index 4890e07e2..e0cf60f79 100644 --- a/src/plasma/private/packagejob.cpp +++ b/src/plasma/private/packagejob.cpp @@ -25,21 +25,22 @@ namespace Plasma { -class PackageJobPrivate { +class PackageJobPrivate +{ public: PackageJobThread *thread; QString installPath; }; -PackageJob::PackageJob(const QString &servicePrefix, QObject* parent) : +PackageJob::PackageJob(const QString &servicePrefix, QObject *parent) : KJob(parent) { d = new PackageJobPrivate; d->thread = new PackageJobThread(servicePrefix, this); - connect(d->thread, SIGNAL(finished(bool, const QString&)), - SLOT(slotFinished(bool, const QString&)), Qt::QueuedConnection); - connect(d->thread, SIGNAL(installPathChanged(const QString&)), - SIGNAL(installPathChanged(const QString&)), Qt::QueuedConnection); + connect(d->thread, SIGNAL(finished(bool,QString)), + SLOT(slotFinished(bool,QString)), Qt::QueuedConnection); + connect(d->thread, SIGNAL(installPathChanged(QString)), + SIGNAL(installPathChanged(QString)), Qt::QueuedConnection); } PackageJob::~PackageJob() @@ -64,12 +65,12 @@ void PackageJob::start() d->thread->start(); } -void PackageJob::install(const QString& src, const QString &dest) +void PackageJob::install(const QString &src, const QString &dest) { d->thread->install(src, dest); } -void PackageJob::uninstall(const QString& installationPath) +void PackageJob::uninstall(const QString &installationPath) { d->thread->uninstall(installationPath); } diff --git a/src/plasma/private/packagejob_p.h b/src/plasma/private/packagejob_p.h index 5c246698b..08c66dd1c 100644 --- a/src/plasma/private/packagejob_p.h +++ b/src/plasma/private/packagejob_p.h @@ -22,7 +22,6 @@ #include "kjob.h" - namespace Plasma { @@ -32,26 +31,26 @@ class PackageJob : public KJob { Q_OBJECT - public: - PackageJob(const QString &servicePrefix, QObject* parent = 0); - ~PackageJob(); +public: + PackageJob(const QString &servicePrefix, QObject *parent = 0); + ~PackageJob(); - virtual void start(); + virtual void start(); - void install(const QString& src, const QString& dest); - void uninstall(const QString &installationPath); + void install(const QString &src, const QString &dest); + void uninstall(const QString &installationPath); - Q_SIGNALS: - void installPathChanged(const QString &path); +Q_SIGNALS: + void installPathChanged(const QString &path); // Q_SIGNALS: // void finished(bool success); - private Q_SLOTS: - void slotFinished(bool ok, const QString &err); +private Q_SLOTS: + void slotFinished(bool ok, const QString &err); - private: - PackageJobPrivate* d; +private: + PackageJobPrivate *d; }; } diff --git a/src/plasma/private/packagejobthread.cpp b/src/plasma/private/packagejobthread.cpp index b86c0f68c..c6950ff47 100644 --- a/src/plasma/private/packagejobthread.cpp +++ b/src/plasma/private/packagejobthread.cpp @@ -20,7 +20,6 @@ #include "private/packagejobthread_p.h" - #include "package.h" #include "config-plasma.h" @@ -86,8 +85,9 @@ bool copyFolder(QString sourcePath, QString targetPath) bool removeFolder(QString folderPath) { QDir folder(folderPath); - if(!folder.exists()) + if (!folder.exists()) { return false; + } foreach (const QString &fileName, folder.entryList(QDir::Files)) { if (!QFile::remove(folderPath + QDir::separator() + fileName)) { @@ -106,18 +106,16 @@ bool removeFolder(QString folderPath) return folder.rmdir(folderName); } - -class PackageJobThreadPrivate { +class PackageJobThreadPrivate +{ public: QString installPath; QString errorMessage; QString servicePrefix; }; - - -PackageJobThread::PackageJobThread(const QString &servicePrefix, QObject* parent) : -QThread(parent) +PackageJobThread::PackageJobThread(const QString &servicePrefix, QObject *parent) : + QThread(parent) { d = new PackageJobThreadPrivate; d->servicePrefix = servicePrefix; @@ -128,7 +126,7 @@ PackageJobThread::~PackageJobThread() delete d; } -bool PackageJobThread::install(const QString& src, const QString &dest) +bool PackageJobThread::install(const QString &src, const QString &dest) { bool ok = installPackage(src, dest); emit installPathChanged(d->installPath); @@ -136,7 +134,7 @@ bool PackageJobThread::install(const QString& src, const QString &dest) return ok; } -bool PackageJobThread::installPackage(const QString& src, const QString &dest) +bool PackageJobThread::installPackage(const QString &src, const QString &dest) { QString packageRoot = dest; QDir root(dest); @@ -173,7 +171,7 @@ bool PackageJobThread::installPackage(const QString& src, const QString &dest) if (mimetype.inherits("application/zip")) { archive = new KZip(src); } else if (mimetype.inherits("application/x-compressed-tar") || - mimetype.inherits("application/x-tar")|| mimetype.inherits("application/x-bzip-compressed-tar") || + mimetype.inherits("application/x-tar") || mimetype.inherits("application/x-bzip-compressed-tar") || mimetype.inherits("application/x-xz") || mimetype.inherits("application/x-lzma")) { archive = new KTar(src); } else { @@ -329,19 +327,20 @@ bool PackageJobThread::uninstall(const QString &packagePath) return ok; } -bool PackageJobThread::uninstallPackage(const QString& packagePath) +bool PackageJobThread::uninstallPackage(const QString &packagePath) { if (!QFile::exists(packagePath)) { d->errorMessage = i18n("%1 does not exist", packagePath); return false; } QString pkg; - { // FIXME: remove, pass in packageroot, type and pluginName separately? + { + // FIXME: remove, pass in packageroot, type and pluginName separately? QString _path = packagePath; QStringList ps = packagePath.split('/'); - int ix = ps.count()-1; + int ix = ps.count() - 1; if (packagePath.endsWith('/')) { - ix = ps.count()-2; + ix = ps.count() - 2; } pkg = ps[ix]; } @@ -367,8 +366,6 @@ bool PackageJobThread::uninstallPackage(const QString& packagePath) return true; } - - } // namespace Plasma #include "moc_packagejobthread_p.cpp" diff --git a/src/plasma/private/packagejobthread_p.h b/src/plasma/private/packagejobthread_p.h index 62bcecd86..4a990aa36 100644 --- a/src/plasma/private/packagejobthread_p.h +++ b/src/plasma/private/packagejobthread_p.h @@ -33,23 +33,23 @@ class PackageJobThread : public QThread { Q_OBJECT - public: - PackageJobThread(const QString &servicePrefix, QObject* parent = 0); - virtual ~PackageJobThread(); +public: + PackageJobThread(const QString &servicePrefix, QObject *parent = 0); + virtual ~PackageJobThread(); - bool install(const QString &src, const QString &dest); - bool uninstall(const QString &packagePath); + bool install(const QString &src, const QString &dest); + bool uninstall(const QString &packagePath); - Q_SIGNALS: - void finished(bool success, const QString &errorMessage = QString()); - void percentChanged(int percent); - void error(const QString &errorMessage); - void installPathChanged(const QString &installPath); +Q_SIGNALS: + void finished(bool success, const QString &errorMessage = QString()); + void percentChanged(int percent); + void error(const QString &errorMessage); + void installPathChanged(const QString &installPath); - private: - bool installPackage(const QString &src, const QString &dest); - bool uninstallPackage(const QString &packagePath); - PackageJobThreadPrivate* d; +private: + bool installPackage(const QString &src, const QString &dest); + bool uninstallPackage(const QString &packagePath); + PackageJobThreadPrivate *d; }; } diff --git a/src/plasma/private/packages.cpp b/src/plasma/private/packages.cpp index 43e24a596..d2ead6432 100644 --- a/src/plasma/private/packages.cpp +++ b/src/plasma/private/packages.cpp @@ -143,90 +143,90 @@ void ThemePackage::initPackage(Package *package) { package->addDirectoryDefinition("dialogs", "dialogs/", i18n("Images for dialogs")); package->addFileDefinition("dialogs/background", "dialogs/background.svg", - i18n("Generic dialog background")); + i18n("Generic dialog background")); package->addFileDefinition("dialogs/background", "dialogs/background.svgz", - i18n("Generic dialog background")); + i18n("Generic dialog background")); package->addFileDefinition("dialogs/shutdowndialog", "dialogs/shutdowndialog.svg", - i18n("Theme for the logout dialog")); + i18n("Theme for the logout dialog")); package->addFileDefinition("dialogs/shutdowndialog", "dialogs/shutdowndialog.svgz", - i18n("Theme for the logout dialog")); + i18n("Theme for the logout dialog")); package->addDirectoryDefinition("wallpapers", "wallpapers/", i18n("Wallpaper packages")); package->addDirectoryDefinition("widgets", "widgets/", i18n("Images for widgets")); package->addFileDefinition("widgets/background", "widgets/background.svg", - i18n("Background image for widgets")); + i18n("Background image for widgets")); package->addFileDefinition("widgets/background", "widgets/background.svgz", - i18n("Background image for widgets")); + i18n("Background image for widgets")); package->addFileDefinition("widgets/clock", "widgets/clock.svg", - i18n("Analog clock face")); + i18n("Analog clock face")); package->addFileDefinition("widgets/clock", "widgets/clock.svgz", - i18n("Analog clock face")); + i18n("Analog clock face")); package->addFileDefinition("widgets/panel-background", "widgets/panel-background.svg", - i18n("Background image for panels")); + i18n("Background image for panels")); package->addFileDefinition("widgets/panel-background", "widgets/panel-background.svgz", - i18n("Background image for panels")); + i18n("Background image for panels")); package->addFileDefinition("widgets/plot-background", "widgets/plot-background.svg", - i18n("Background for graphing widgets")); + i18n("Background for graphing widgets")); package->addFileDefinition("widgets/plot-background", "widgets/plot-background.svgz", - i18n("Background for graphing widgets")); + i18n("Background for graphing widgets")); package->addFileDefinition("widgets/tooltip", "widgets/tooltip.svg", - i18n("Background image for tooltips")); + i18n("Background image for tooltips")); package->addFileDefinition("widgets/tooltip", "widgets/tooltip.svgz", - i18n("Background image for tooltips")); + i18n("Background image for tooltips")); package->addDirectoryDefinition("opaque/dialogs", "opaque/dialogs/", i18n("Opaque images for dialogs")); package->addFileDefinition("opaque/dialogs/background", "opaque/dialogs/background.svg", - i18n("Opaque generic dialog background")); + i18n("Opaque generic dialog background")); package->addFileDefinition("opaque/dialogs/background", "opaque/dialogs/background.svgz", - i18n("Opaque generic dialog background")); + i18n("Opaque generic dialog background")); package->addFileDefinition("opaque/dialogs/shutdowndialog", "opaque/dialogs/shutdowndialog.svg", - i18n("Opaque theme for the logout dialog")); + i18n("Opaque theme for the logout dialog")); package->addFileDefinition("opaque/dialogs/shutdowndialog", "opaque/dialogs/shutdowndialog.svgz", - i18n("Opaque theme for the logout dialog")); + i18n("Opaque theme for the logout dialog")); package->addDirectoryDefinition("opaque/widgets", "opaque/widgets/", i18n("Opaque images for widgets")); package->addFileDefinition("opaque/widgets/panel-background", "opaque/widgets/panel-background.svg", - i18n("Opaque background image for panels")); + i18n("Opaque background image for panels")); package->addFileDefinition("opaque/widgets/panel-background", "opaque/widgets/panel-background.svgz", - i18n("Opaque background image for panels")); + i18n("Opaque background image for panels")); package->addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svg", - i18n("Opaque background image for tooltips")); + i18n("Opaque background image for tooltips")); package->addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svgz", - i18n("Opaque background image for tooltips")); + i18n("Opaque background image for tooltips")); package->addDirectoryDefinition("locolor/dialogs", "locolor/dialogs/", - i18n("Low color images for dialogs")); + i18n("Low color images for dialogs")); package->addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svg", - i18n("Low color generic dialog background")); + i18n("Low color generic dialog background")); package->addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svgz", - i18n("Low color generic dialog background")); + i18n("Low color generic dialog background")); package->addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svg", - i18n("Low color theme for the logout dialog")); + i18n("Low color theme for the logout dialog")); package->addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svgz", - i18n("Low color theme for the logout dialog")); + i18n("Low color theme for the logout dialog")); package->addDirectoryDefinition("locolor/widgets", "locolor/widgets/", i18n("Images for widgets")); package->addFileDefinition("locolor/widgets/background", "locolor/widgets/background.svg", - i18n("Low color background image for widgets")); + i18n("Low color background image for widgets")); package->addFileDefinition("locolor/widgets/background", "locolor/widgets/background.svgz", - i18n("Low color background image for widgets")); + i18n("Low color background image for widgets")); package->addFileDefinition("locolor/widgets/clock", "locolor/widgets/clock.svg", - i18n("Low color analog clock face")); + i18n("Low color analog clock face")); package->addFileDefinition("locolor/widgets/clock", "locolor/widgets/clock.svgz", - i18n("Low color analog clock face")); + i18n("Low color analog clock face")); package->addFileDefinition("locolor/widgets/panel-background", "locolor/widgets/panel-background.svg", - i18n("Low color background image for panels")); + i18n("Low color background image for panels")); package->addFileDefinition("locolor/widgets/panel-background", "locolor/widgets/panel-background.svgz", - i18n("Low color background image for panels")); + i18n("Low color background image for panels")); package->addFileDefinition("locolor/widgets/plot-background", "locolor/widgets/plot-background.svg", - i18n("Low color background for graphing widgets")); + i18n("Low color background for graphing widgets")); package->addFileDefinition("locolor/widgets/plot-background", "locolor/widgets/plot-background.svgz", - i18n("Low color background for graphing widgets")); + i18n("Low color background for graphing widgets")); package->addFileDefinition("locolor/widgets/tooltip", "locolor/widgets/tooltip.svg", - i18n("Low color background image for tooltips")); + i18n("Low color background image for tooltips")); package->addFileDefinition("locolor/widgets/tooltip", "locolor/widgets/tooltip.svgz", - i18n("Low color background image for tooltips")); + i18n("Low color background image for tooltips")); package->addFileDefinition("colors", "colors", i18n("KColorScheme configuration file")); @@ -275,7 +275,6 @@ void ShellPackage::initPackage(Plasma::Package *package) //Widget explorer package->addFileDefinition("widgetexplorer", "explorer/WidgetExplorer.qml", i18n("Widgets explorer UI")); - //package->setRequired("mainscript", true); } diff --git a/src/plasma/private/packages_p.h b/src/plasma/private/packages_p.h index 788997291..0833a4ed1 100644 --- a/src/plasma/private/packages_p.h +++ b/src/plasma/private/packages_p.h @@ -78,7 +78,6 @@ public: void initPackage(Plasma::Package *package); }; - } // namespace Plasma #endif // LIBS_PLASMA_PACKAGES_P_H diff --git a/src/plasma/private/service_p.h b/src/plasma/private/service_p.h index 8fbdb9b55..3a703928d 100644 --- a/src/plasma/private/service_p.h +++ b/src/plasma/private/service_p.h @@ -74,7 +74,7 @@ class ServicePrivate public: ServicePrivate(Service *service) : q(service) - { + { } ~ServicePrivate() diff --git a/src/plasma/private/sharedtimer_p.h b/src/plasma/private/sharedtimer_p.h index 36ac7f8c9..cc5f0f70a 100644 --- a/src/plasma/private/sharedtimer_p.h +++ b/src/plasma/private/sharedtimer_p.h @@ -44,7 +44,7 @@ private: explicit TimerDrive(QObject *parent = 0); ~TimerDrive(); class Private; - Private * const d; + Private *const d; }; } // namespace Plasma diff --git a/src/plasma/private/storage.cpp b/src/plasma/private/storage.cpp index aeb1d5570..bc6992e3d 100644 --- a/src/plasma/private/storage.cpp +++ b/src/plasma/private/storage.cpp @@ -38,10 +38,9 @@ #include "dataengine.h" #include "storagethread_p.h" - -StorageJob::StorageJob(const QString& destination, - const QString& operation, - const QVariantMap& parameters, +StorageJob::StorageJob(const QString &destination, + const QString &operation, + const QVariantMap ¶meters, QObject *parent) : ServiceJob(destination, operation, parameters, parent), m_clientName(destination) @@ -71,7 +70,6 @@ QString StorageJob::clientName() const return m_clientName; } - void StorageJob::start() { //FIXME: QHASH @@ -84,13 +82,13 @@ void StorageJob::start() QWeakPointer me(this); if (operationName() == "save") { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "save", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), "save", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap &, params)); } else if (operationName() == "retrieve") { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap &, params)); } else if (operationName() == "delete") { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap &, params)); } else if (operationName() == "expire") { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap &, params)); } else { setError(true); setResult(false); @@ -107,7 +105,7 @@ void StorageJob::resultSlot(StorageJob *job, const QVariant &result) } } -Plasma::ServiceJob* Storage::createJob(const QString &operation, QVariantMap ¶meters) +Plasma::ServiceJob *Storage::createJob(const QString &operation, QVariantMap ¶meters) { if (m_clientName.isEmpty()) { return 0; @@ -117,7 +115,7 @@ Plasma::ServiceJob* Storage::createJob(const QString &operation, QVariantMap &pa } //Storage implementation -Storage::Storage(QObject* parent) +Storage::Storage(QObject *parent) : Plasma::Service(parent), m_clientName("data") { diff --git a/src/plasma/private/storage_p.h b/src/plasma/private/storage_p.h index 6ec80c4d8..9cef17c6b 100644 --- a/src/plasma/private/storage_p.h +++ b/src/plasma/private/storage_p.h @@ -35,9 +35,9 @@ class StorageJob : public Plasma::ServiceJob Q_PROPERTY(QVariantMap data READ data WRITE setData) public: - StorageJob(const QString& destination, - const QString& operation, - const QVariantMap& parameters, + StorageJob(const QString &destination, + const QString &operation, + const QVariantMap ¶meters, QObject *parent = 0); ~StorageJob(); void setData(const QVariantMap &data); @@ -66,11 +66,10 @@ public: ~Storage(); protected: - Plasma::ServiceJob* createJob(const QString &operation, QVariantMap ¶meters); + Plasma::ServiceJob *createJob(const QString &operation, QVariantMap ¶meters); private: QString m_clientName; }; - #endif //PLASMA_STORAGE_H diff --git a/src/plasma/private/storagethread.cpp b/src/plasma/private/storagethread.cpp index 82d364503..07e2153b0 100644 --- a/src/plasma/private/storagethread.cpp +++ b/src/plasma/private/storagethread.cpp @@ -30,7 +30,6 @@ #include #include - namespace Plasma { @@ -41,7 +40,7 @@ public: { } - StorageThread self; + StorageThread self; }; Q_GLOBAL_STATIC(StorageThreadSingleton, privateStorageThreadSelf) @@ -156,23 +155,23 @@ void StorageThread::save(QWeakPointer wcaller, const QVariantMap &pa QString field; bool binary = false; switch (QMetaType::Type(it.value().type())) { - case QVariant::String: - field = ":txt"; - break; - case QVariant::Int: - field = ":int"; - break; - case QVariant::Double: - case QMetaType::Float: - field = ":float"; - break; - case QVariant::ByteArray: - binary = true; - field = ":binary"; - break; - default: - continue; - break; + case QVariant::String: + field = ":txt"; + break; + case QVariant::Int: + field = ":int"; + break; + case QVariant::Double: + case QMetaType::Float: + field = ":float"; + break; + case QVariant::ByteArray: + binary = true; + field = ":binary"; + break; + default: + continue; + break; } if (binary) { diff --git a/src/plasma/private/storagethread_p.h b/src/plasma/private/storagethread_p.h index 1afbb1b29..2746810a2 100644 --- a/src/plasma/private/storagethread_p.h +++ b/src/plasma/private/storagethread_p.h @@ -20,7 +20,6 @@ #ifndef STORAGETHREAD_H #define STORAGETHREAD_H - #include #include #include @@ -50,10 +49,10 @@ public Q_SLOTS: void expire(QWeakPointer caller, const QVariantMap ¶meters); Q_SIGNALS: - void newResult(StorageJob* caller, const QVariant &result); + void newResult(StorageJob *caller, const QVariant &result); private: - void initializeDb(StorageJob* caller); + void initializeDb(StorageJob *caller); QSqlDatabase m_db; }; diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h index 9614500dc..4e9b8a3e5 100644 --- a/src/plasma/private/svg_p.h +++ b/src/plasma/private/svg_p.h @@ -32,27 +32,27 @@ class Svg; class SharedSvgRenderer : public QSvgRenderer, public QSharedData { - public: - typedef QExplicitlySharedDataPointer Ptr; +public: + typedef QExplicitlySharedDataPointer Ptr; - SharedSvgRenderer(QObject *parent = 0); - SharedSvgRenderer( - const QString &filename, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent = 0); + SharedSvgRenderer(QObject *parent = 0); + SharedSvgRenderer( + const QString &filename, + const QString &styleSheet, + QHash &interestingElements, + QObject *parent = 0); - SharedSvgRenderer( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent = 0); + SharedSvgRenderer( + const QByteArray &contents, + const QString &styleSheet, + QHash &interestingElements, + QObject *parent = 0); - private: - bool load( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements); +private: + bool load( + const QByteArray &contents, + const QString &styleSheet, + QHash &interestingElements); }; class SvgPrivate diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index 84bfbc41d..6fd7382ea 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -43,10 +43,9 @@ EffectWatcher *ThemePrivate::s_blurEffectWatcher = 0; ThemePrivate *ThemePrivate::globalTheme = 0; QAtomicInt ThemePrivate::globalThemeRefCount = QAtomicInt(); -QHash ThemePrivate::themes = QHash(); +QHash ThemePrivate::themes = QHash(); QHash ThemePrivate::themesRefCount = QHash(); - ThemePrivate::ThemePrivate(QObject *parent) : QObject(parent), colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)), @@ -109,26 +108,25 @@ ThemePrivate::~ThemePrivate() } KConfigGroup &ThemePrivate::config() - { - if (!cfg.isValid()) { - QString groupName = QStringLiteral("Theme"); +{ + if (!cfg.isValid()) { + QString groupName = QStringLiteral("Theme"); - if (!useGlobal) { - QString app = QCoreApplication::applicationName(); + if (!useGlobal) { + QString app = QCoreApplication::applicationName(); - if (!app.isEmpty()) { + if (!app.isEmpty()) { #ifndef NDEBUG - // qDebug() << "using theme for app" << app; + // qDebug() << "using theme for app" << app; #endif - groupName.append("-").append(app); - } + groupName.append("-").append(app); } - cfg = KConfigGroup(KSharedConfig::openConfig(themeRcFile), groupName); } - - return cfg; + cfg = KConfigGroup(KSharedConfig::openConfig(themeRcFile), groupName); } + return cfg; +} bool ThemePrivate::useCache() { @@ -150,7 +148,6 @@ bool ThemePrivate::useCache() } themeMetadataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % themeName % QLatin1Literal("/metadata.desktop")); - if (isRegularTheme) { const QString cacheFileBase = cacheFile + QStringLiteral("*.kcache"); @@ -177,7 +174,7 @@ bool ThemePrivate::useCache() // now we check for, and remove if necessary, old caches foreach (const QString &file, QStandardPaths::locateAll(QStandardPaths::CacheLocation, cacheFileBase)) { if (currentCacheFileName.isEmpty() || - !file.endsWith(currentCacheFileName)) { + !file.endsWith(currentCacheFileName)) { QFile::remove(file); } } @@ -406,7 +403,7 @@ const QString ThemePrivate::processStyleSheet(const QString &css) QHash::const_iterator it = elements.constBegin(); QHash::const_iterator itEnd = elements.constEnd(); - for ( ; it != itEnd; ++it) { + for (; it != itEnd; ++it) { stylesheet.replace(it.key(), it.value()); } return stylesheet; @@ -464,44 +461,44 @@ void ThemePrivate::settingsChanged() QColor ThemePrivate::color(Theme::ColorRole role) const { switch (role) { - case Theme::TextColor: - return colorScheme.foreground(KColorScheme::NormalText).color(); + case Theme::TextColor: + return colorScheme.foreground(KColorScheme::NormalText).color(); - case Theme::HighlightColor: - return colorScheme.decoration(KColorScheme::HoverColor).color(); + case Theme::HighlightColor: + return colorScheme.decoration(KColorScheme::HoverColor).color(); - case Theme::BackgroundColor: - return colorScheme.background(KColorScheme::NormalBackground).color(); + case Theme::BackgroundColor: + return colorScheme.background(KColorScheme::NormalBackground).color(); - case Theme::ButtonTextColor: - return buttonColorScheme.foreground(KColorScheme::NormalText).color(); + case Theme::ButtonTextColor: + return buttonColorScheme.foreground(KColorScheme::NormalText).color(); - case Theme::ButtonBackgroundColor: - return buttonColorScheme.background(KColorScheme::NormalBackground).color(); + case Theme::ButtonBackgroundColor: + return buttonColorScheme.background(KColorScheme::NormalBackground).color(); - case Theme::ButtonHoverColor: - return buttonColorScheme.decoration(KColorScheme::HoverColor).color(); + case Theme::ButtonHoverColor: + return buttonColorScheme.decoration(KColorScheme::HoverColor).color(); - case Theme::ButtonFocusColor: - return buttonColorScheme.decoration(KColorScheme::FocusColor).color(); + case Theme::ButtonFocusColor: + return buttonColorScheme.decoration(KColorScheme::FocusColor).color(); - case Theme::ViewTextColor: - return viewColorScheme.foreground(KColorScheme::NormalText).color(); + case Theme::ViewTextColor: + return viewColorScheme.foreground(KColorScheme::NormalText).color(); - case Theme::ViewBackgroundColor: - return viewColorScheme.background(KColorScheme::NormalBackground).color(); + case Theme::ViewBackgroundColor: + return viewColorScheme.background(KColorScheme::NormalBackground).color(); - case Theme::ViewHoverColor: - return viewColorScheme.decoration(KColorScheme::HoverColor).color(); + case Theme::ViewHoverColor: + return viewColorScheme.decoration(KColorScheme::HoverColor).color(); - case Theme::ViewFocusColor: - return viewColorScheme.decoration(KColorScheme::FocusColor).color(); + case Theme::ViewFocusColor: + return viewColorScheme.decoration(KColorScheme::FocusColor).color(); - case Theme::LinkColor: - return viewColorScheme.foreground(KColorScheme::LinkText).color(); + case Theme::LinkColor: + return viewColorScheme.foreground(KColorScheme::LinkText).color(); - case Theme::VisitedLinkColor: - return viewColorScheme.foreground(KColorScheme::VisitedText).color(); + case Theme::VisitedLinkColor: + return viewColorScheme.foreground(KColorScheme::VisitedText).color(); } return QColor(); @@ -530,7 +527,7 @@ void ThemePrivate::processWallpaperSettings(KConfigBase *metadata) defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT); } -void ThemePrivate::processContrastSettings(KConfigBase* metadata) +void ThemePrivate::processContrastSettings(KConfigBase *metadata) { KConfigGroup cg; if (metadata->hasGroup("ContrastEffect")) { @@ -538,21 +535,21 @@ void ThemePrivate::processContrastSettings(KConfigBase* metadata) backgroundContrastEnabled = cg.readEntry(QStringLiteral("enabled"), false); //if (backgroundContrastEnabled) { - // Make up sensible default values, based on the background color - // This works for a light theme -- lighting up the background - qreal _contrast = 0.3; - qreal _intensity = 1.9; - qreal _saturation = 1.7; + // Make up sensible default values, based on the background color + // This works for a light theme -- lighting up the background + qreal _contrast = 0.3; + qreal _intensity = 1.9; + qreal _saturation = 1.7; - // If we're using a dark background color, darken the background - if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) { - _contrast = 0.45; - _intensity = 0.45; - _saturation = 1.7; - } - backgroundContrast = cg.readEntry(QStringLiteral("contrast"), _contrast); - backgroundIntensity = cg.readEntry(QStringLiteral("intensity"), _intensity); - backgroundSaturation = cg.readEntry(QStringLiteral("saturation"), _saturation); + // If we're using a dark background color, darken the background + if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) { + _contrast = 0.45; + _intensity = 0.45; + _saturation = 1.7; + } + backgroundContrast = cg.readEntry(QStringLiteral("contrast"), _contrast); + backgroundIntensity = cg.readEntry(QStringLiteral("intensity"), _intensity); + backgroundSaturation = cg.readEntry(QStringLiteral("saturation"), _saturation); //} } else { backgroundContrastEnabled = false; @@ -597,7 +594,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings // load the color scheme config const QString colorsFile = realTheme ? QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/colors")) - : QString(); + : QString(); //qDebug() << "we're going for..." << colorsFile << "*******************"; diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 291ce33a6..d0335d5ec 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -61,7 +61,7 @@ enum CacheType { }; Q_DECLARE_FLAGS(CacheTypes, CacheType) Q_DECLARE_OPERATORS_FOR_FLAGS(CacheTypes) - + class ThemePrivate : public QObject { Q_OBJECT diff --git a/src/plasma/scripting/appletscript.cpp b/src/plasma/scripting/appletscript.cpp index b3fc82f9e..42c0395f7 100644 --- a/src/plasma/scripting/appletscript.cpp +++ b/src/plasma/scripting/appletscript.cpp @@ -62,9 +62,9 @@ void AppletScript::constraintsEvent(Plasma::Types::Constraints constraints) Q_UNUSED(constraints); } -QList AppletScript::contextualActions() +QList AppletScript::contextualActions() { - return QList(); + return QList(); } void AppletScript::setHasConfigurationInterface(bool hasInterface) @@ -139,5 +139,4 @@ void AppletScript::setContainmentType(Plasma::Types::ContainmentType type) } // Plasma namespace - #include "moc_appletscript.cpp" diff --git a/src/plasma/scripting/appletscript.h b/src/plasma/scripting/appletscript.h index 616139579..fd514a0eb 100644 --- a/src/plasma/scripting/appletscript.h +++ b/src/plasma/scripting/appletscript.h @@ -89,7 +89,7 @@ public: * @return A list of actions. The default implementation returns an * empty list. */ - virtual QList contextualActions(); + virtual QList contextualActions(); /** * Sets whether or not this script has a configuration interface or not @@ -113,17 +113,17 @@ public: */ void configNeedsSaving() const; - /** - * @see Containment - * @since 4.7 - */ - Plasma::Types::ContainmentType containmentType() const; + /** + * @see Containment + * @since 4.7 + */ + Plasma::Types::ContainmentType containmentType() const; - /** - * @see Containment - * @since 4.7 - */ - void setContainmentType(Plasma::Types::ContainmentType type); + /** + * @see Containment + * @since 4.7 + */ + void setContainmentType(Plasma::Types::ContainmentType type); Q_SIGNALS: /** @@ -168,7 +168,7 @@ private: }; #define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) + K_PLUGIN_FACTORY(factory, registerPlugin();) } //Plasma namespace diff --git a/src/plasma/scripting/dataenginescript.cpp b/src/plasma/scripting/dataenginescript.cpp index ac45e4a48..bf3013c07 100644 --- a/src/plasma/scripting/dataenginescript.cpp +++ b/src/plasma/scripting/dataenginescript.cpp @@ -197,5 +197,4 @@ void DataEngineScript::forceImmediateUpdateOfAllVisualizations() } // Plasma namespace - #include "moc_dataenginescript.cpp" diff --git a/src/plasma/scripting/dataenginescript.h b/src/plasma/scripting/dataenginescript.h index 4618eacc0..5d4492be4 100644 --- a/src/plasma/scripting/dataenginescript.h +++ b/src/plasma/scripting/dataenginescript.h @@ -68,7 +68,7 @@ public: * the default implementation provides) or not is up to the * DataEngine to decide. By default, this returns dataEngine()->sources() */ - virtual QStringList sources() const; + virtual QStringList sources() const; /** * Called when the script should create a source that does not currently @@ -144,7 +144,7 @@ private: }; #define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) + K_PLUGIN_FACTORY(factory, registerPlugin();) } //Plasma namespace diff --git a/src/plasma/scripting/scriptengine.cpp b/src/plasma/scripting/scriptengine.cpp index e84c4e3ea..30fbb6ba6 100644 --- a/src/plasma/scripting/scriptengine.cpp +++ b/src/plasma/scripting/scriptengine.cpp @@ -149,15 +149,15 @@ ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QOb ScriptEngine *engine = 0; foreach (const KService::Ptr &service, offers) { switch (type) { - case Types::AppletComponent: - engine = service->createInstance(parent, args, &error); - break; - case Types::DataEngineComponent: - engine = service->createInstance(parent, args, &error); - break; - default: - return 0; - break; + case Types::AppletComponent: + engine = service->createInstance(parent, args, &error); + break; + case Types::DataEngineComponent: + engine = service->createInstance(parent, args, &error); + break; + default: + return 0; + break; } if (engine) { @@ -179,7 +179,7 @@ ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QOb AppletScript *loadScriptEngine(const QString &language, Applet *applet) { AppletScript *engine = - static_cast(loadEngine(language, Types::AppletComponent, applet)); + static_cast(loadEngine(language, Types::AppletComponent, applet)); if (engine) { engine->setApplet(applet); @@ -191,7 +191,7 @@ AppletScript *loadScriptEngine(const QString &language, Applet *applet) DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine) { DataEngineScript *engine = - static_cast(loadEngine(language, Types::DataEngineComponent, dataEngine)); + static_cast(loadEngine(language, Types::DataEngineComponent, dataEngine)); if (engine) { engine->setDataEngine(dataEngine); diff --git a/src/plasma/service.cpp b/src/plasma/service.cpp index ec79e145c..1b3cbaf23 100644 --- a/src/plasma/service.cpp +++ b/src/plasma/service.cpp @@ -225,7 +225,7 @@ ServiceJob *Service::startOperationCall(const QVariantMap &description, QObject } } else { #ifndef NDEBUG - // qDebug() << op << "is not a valid group; valid groups are:" << d->operationsMap.keys(); + // qDebug() << op << "is not a valid group; valid groups are:" << d->operationsMap.keys(); #endif } @@ -319,6 +319,4 @@ void Service::registerOperationsScheme() } // namespace Plasma - - #include "moc_service.cpp" diff --git a/src/plasma/service.h b/src/plasma/service.h index eff3aacd1..b5d9b5a26 100644 --- a/src/plasma/service.h +++ b/src/plasma/service.h @@ -215,7 +215,7 @@ protected: void setOperationEnabled(const QString &operation, bool enable); private: - ServicePrivate * const d; + ServicePrivate *const d; friend class DataEnginePrivate; friend class PluginLoader; @@ -229,8 +229,8 @@ Q_DECLARE_METATYPE(Plasma::Service *) * Register a service when it is contained in a loadable module */ #define K_EXPORT_PLASMA_SERVICE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) + K_PLUGIN_FACTORY(factory, registerPlugin();) \ + K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/servicejob.cpp b/src/plasma/servicejob.cpp index 858169d7c..f1fc5c223 100644 --- a/src/plasma/servicejob.cpp +++ b/src/plasma/servicejob.cpp @@ -28,11 +28,11 @@ namespace Plasma ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, const QString &op, const QVariantMap ¶ms) - : q(owner), - destination(dest), - operation(op), - parameters(params), - m_allowAutoStart(true) + : q(owner), + destination(dest), + operation(op), + parameters(params), + m_allowAutoStart(true) { } @@ -101,6 +101,4 @@ void ServiceJob::start() } // namespace Plasma - - #include "moc_servicejob.cpp" diff --git a/src/plasma/servicejob.h b/src/plasma/servicejob.h index fa3b34635..56b7577c7 100644 --- a/src/plasma/servicejob.h +++ b/src/plasma/servicejob.h @@ -56,7 +56,6 @@ class PLASMA_EXPORT ServiceJob : public KJob Q_PROPERTY(QString operationName READ operationName) Q_PROPERTY(QVariant result READ result) - public: /** * Default constructor @@ -118,7 +117,7 @@ private: Q_PRIVATE_SLOT(d, void autoStart()) Q_PRIVATE_SLOT(d, void preventAutoStart()) - ServiceJobPrivate * const d; + ServiceJobPrivate *const d; }; } // namespace Plasma diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp index 23c79c817..4e825c458 100644 --- a/src/plasma/svg.cpp +++ b/src/plasma/svg.cpp @@ -88,7 +88,7 @@ bool SharedSvgRenderer::load( QDomNode defs = svg.elementsByTagName("defs").item(0); for (QDomElement style = defs.firstChildElement("style"); !style.isNull(); - style = style.nextSiblingElement("style")) { + style = style.nextSiblingElement("style")) { if (style.attribute("id") == "current-color-scheme") { QDomElement colorScheme = svg.createElement("style"); colorScheme.setAttribute("type", "text/css"); @@ -96,7 +96,7 @@ bool SharedSvgRenderer::load( defs.replaceChild(colorScheme, style); colorScheme.appendChild(svg.createCDATASection(styleSheet)); - interestingElements.insert("current-color-scheme", QRect(0,0,1,1)); + interestingElements.insert("current-color-scheme", QRect(0, 0, 1, 1)); break; } @@ -174,8 +174,8 @@ bool SvgPrivate::setImagePath(const QString &imagePath) // lets check to see if we're already set to this file if (isThemed == themed && - ((themed && themePath == imagePath) || - (!themed && path == imagePath))) { + ((themed && themePath == imagePath) || + (!themed && path == imagePath))) { return false; } @@ -224,7 +224,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath) createRenderer(); naturalSize = renderer->defaultSize() * devicePixelRatio; //qDebug() << "natural size for" << path << "from renderer is" << naturalSize; - cacheAndColorsTheme()->insertIntoRectsCache(path, "_Natural", QRectF(QPointF(0,0), naturalSize)); + cacheAndColorsTheme()->insertIntoRectsCache(path, "_Natural", QRectF(QPointF(0, 0), naturalSize)); //qDebug() << "natural size for" << path << "from cache is" << naturalSize; } } @@ -300,11 +300,11 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF &s) if (!elementSizeHints.isEmpty()) { QSize bestFit(-1, -1); - Q_FOREACH(const QSize &hint, elementSizeHints) { + Q_FOREACH (const QSize &hint, elementSizeHints) { if (hint.width() >= s.width() && hint.height() >= s.height() && - (!bestFit.isValid() || - (bestFit.width() * bestFit.height()) > (hint.width() * hint.height()))) { + (!bestFit.isValid() || + (bestFit.width() * bestFit.height()) > (hint.width() * hint.height()))) { bestFit = hint; } } @@ -351,7 +351,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, const QSizeF &s) createRenderer(); - QRectF finalRect = makeUniform(renderer->boundsOnElement(actualElementId), QRect(QPoint(0,0), size)); + QRectF finalRect = makeUniform(renderer->boundsOnElement(actualElementId), QRect(QPoint(0, 0), size)); //don't alter the pixmap size or it won't match up properly to, e.g., FrameSvg elements //makeUniform should never change the size so much that it gains or loses a whole pixel @@ -390,7 +390,7 @@ void SvgPrivate::createRenderer() //qDebug() << kBacktrace(); if (themed && path.isEmpty() && !themeFailed) { - Applet *applet = qobject_cast(q->parent()); + Applet *applet = qobject_cast(q->parent()); //FIXME: this maybe could be more efficient if we knew if the package was empty, e.g. for //C++; however, I'm not sure this has any real world runtime impact. something to measure //for. @@ -570,9 +570,9 @@ bool Svg::eventFilter(QObject *watched, QEvent *event) qreal SvgPrivate::closestDistance(qreal to, qreal from) { qreal a = to - from; - if (qFuzzyCompare(to, from)) + if (qFuzzyCompare(to, from)) { return 0; - else if ( to > from ) { + } else if (to > from) { qreal b = to - from - 1; return (qAbs(a) > qAbs(b)) ? b : a; } else { @@ -599,7 +599,7 @@ QRectF SvgPrivate::makeUniform(const QRectF &orig, const QRectF &dst) qreal rem_orig = orig.x() - (floor(orig.x())); qreal rem_dst = dst.x() - (floor(dst.x())); qreal offset = closestDistance(rem_dst, rem_orig); - res.translate(offset + offset*div_w, 0); + res.translate(offset + offset * div_w, 0); res.setWidth(res.width() + offset); } //vertical snap @@ -607,7 +607,7 @@ QRectF SvgPrivate::makeUniform(const QRectF &orig, const QRectF &dst) qreal rem_orig = orig.y() - (floor(orig.y())); qreal rem_dst = dst.y() - (floor(dst.y())); qreal offset = closestDistance(rem_dst, rem_orig); - res.translate(0, offset + offset*div_h); + res.translate(0, offset + offset * div_h); res.setHeight(res.height() + offset); } @@ -688,7 +688,7 @@ QPixmap Svg::pixmap(const QString &elementID) } } -QImage Svg::image(const QSize& size, const QString& elementID) +QImage Svg::image(const QSize &size, const QString &elementID) { QPixmap pix(d->findInCache(elementID, size)); return pix.toImage(); @@ -697,7 +697,7 @@ QImage Svg::image(const QSize& size, const QString& elementID) void Svg::paint(QPainter *painter, const QPointF &point, const QString &elementID) { QPixmap pix((elementID.isNull() || d->multipleImages) ? d->findInCache(elementID, size()) : - d->findInCache(elementID)); + d->findInCache(elementID)); if (pix.isNull()) { return; @@ -740,7 +740,7 @@ void Svg::resize(qreal width, qreal height) void Svg::resize(const QSizeF &size) { if (qFuzzyCompare(size.width(), d->size.width()) && - qFuzzyCompare(size.height(), d->size.height())) { + qFuzzyCompare(size.height(), d->size.height())) { return; } @@ -752,7 +752,7 @@ void Svg::resize(const QSizeF &size) void Svg::resize() { if (qFuzzyCompare(d->naturalSize.width(), d->size.width()) && - qFuzzyCompare(d->naturalSize.height(), d->size.height())) { + qFuzzyCompare(d->naturalSize.height(), d->size.height())) { return; } @@ -810,7 +810,7 @@ void Svg::setImagePath(const QString &svgFilePath) QString Svg::imagePath() const { - return d->themed ? d->themePath : d->path; + return d->themed ? d->themePath : d->path; } void Svg::setUsingRenderingCache(bool useCache) @@ -845,6 +845,4 @@ Theme *Svg::theme() const } // Plasma namespace - - #include "moc_svg.cpp" diff --git a/src/plasma/svg.h b/src/plasma/svg.h index e8bfe294b..1c53c6b43 100644 --- a/src/plasma/svg.h +++ b/src/plasma/svg.h @@ -62,353 +62,352 @@ class PLASMA_EXPORT Svg : public QObject Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged) Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache) - public: - /** - * Constructs an SVG object that implicitly shares and caches rendering. - * - * Unlike QSvgRenderer, which this class uses internally, - * Plasma::Svg represents an image generated from an SVG. As such, it - * has a related size and transform matrix (the latter being provided - * by the painter used to paint the image). - * - * The size is initialized to be the SVG's native size. - * - * @param parent options QObject to parent this to - * - * @related Plasma::Theme - */ - explicit Svg(QObject *parent = 0); - ~Svg(); +public: + /** + * Constructs an SVG object that implicitly shares and caches rendering. + * + * Unlike QSvgRenderer, which this class uses internally, + * Plasma::Svg represents an image generated from an SVG. As such, it + * has a related size and transform matrix (the latter being provided + * by the painter used to paint the image). + * + * The size is initialized to be the SVG's native size. + * + * @param parent options QObject to parent this to + * + * @related Plasma::Theme + */ + explicit Svg(QObject *parent = 0); + ~Svg(); - /** - * Set the device pixel ratio for the Svg. This is the ratio between - * image pixels and device-independent pixels. - * The default value is 1.0. - * Setting it to something more, will make all the elements of this svg appear bigger. - */ - void setDevicePixelRatio(qreal ratio); + /** + * Set the device pixel ratio for the Svg. This is the ratio between + * image pixels and device-independent pixels. + * The default value is 1.0. + * Setting it to something more, will make all the elements of this svg appear bigger. + */ + void setDevicePixelRatio(qreal ratio); - /** - * @return the device pixel ratio for this Svg. - */ - qreal devicePixelRatio(); + /** + * @return the device pixel ratio for this Svg. + */ + qreal devicePixelRatio(); - /** - * Returns a pixmap of the SVG represented by this object. - * - * The size of the pixmap will be the size of this Svg object (size()) - * if containsMultipleImages is @c true; otherwise, it will be the - * size of the requested element after the whole SVG has been scaled - * to size(). - * - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - * @return a QPixmap of the rendered SVG - */ - Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString()); + /** + * Returns a pixmap of the SVG represented by this object. + * + * The size of the pixmap will be the size of this Svg object (size()) + * if containsMultipleImages is @c true; otherwise, it will be the + * size of the requested element after the whole SVG has been scaled + * to size(). + * + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + * @return a QPixmap of the rendered SVG + */ + Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString()); - /** - * Returns an image of the SVG represented by this object. - * - * The size of the image will be the size of this Svg object (size()) - * if containsMultipleImages is @c true; otherwise, it will be the - * size of the requested element after the whole SVG has been scaled - * to size(). - * - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - * @return a QPixmap of the rendered SVG - */ - Q_INVOKABLE QImage image(const QSize &size, const QString &elementID = QString()); + /** + * Returns an image of the SVG represented by this object. + * + * The size of the image will be the size of this Svg object (size()) + * if containsMultipleImages is @c true; otherwise, it will be the + * size of the requested element after the whole SVG has been scaled + * to size(). + * + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + * @return a QPixmap of the rendered SVG + */ + Q_INVOKABLE QImage image(const QSize &size, const QString &elementID = QString()); + /** + * Paints all or part of the SVG represented by this object + * + * The size of the painted area will be the size of this Svg object + * (size()) if containsMultipleImages is @c true; otherwise, it will + * be the size of the requested element after the whole SVG has been + * scaled to size(). + * + * @param painter the QPainter to use + * @param point the position to start drawing; the entire svg will be + * drawn starting at this point. + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, const QPointF &point, + const QString &elementID = QString()); - /** - * Paints all or part of the SVG represented by this object - * - * The size of the painted area will be the size of this Svg object - * (size()) if containsMultipleImages is @c true; otherwise, it will - * be the size of the requested element after the whole SVG has been - * scaled to size(). - * - * @param painter the QPainter to use - * @param point the position to start drawing; the entire svg will be - * drawn starting at this point. - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - */ - Q_INVOKABLE void paint(QPainter *painter, const QPointF &point, - const QString &elementID = QString()); + /** + * Paints all or part of the SVG represented by this object + * + * The size of the painted area will be the size of this Svg object + * (size()) if containsMultipleImages is @c true; otherwise, it will + * be the size of the requested element after the whole SVG has been + * scaled to size(). + * + * @param painter the QPainter to use + * @param x the horizontal coordinate to start painting from + * @param y the vertical coordinate to start painting from + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, int x, int y, + const QString &elementID = QString()); - /** - * Paints all or part of the SVG represented by this object - * - * The size of the painted area will be the size of this Svg object - * (size()) if containsMultipleImages is @c true; otherwise, it will - * be the size of the requested element after the whole SVG has been - * scaled to size(). - * - * @param painter the QPainter to use - * @param x the horizontal coordinate to start painting from - * @param y the vertical coordinate to start painting from - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - */ - Q_INVOKABLE void paint(QPainter *painter, int x, int y, - const QString &elementID = QString()); + /** + * Paints all or part of the SVG represented by this object + * + * @param painter the QPainter to use + * @param rect the rect to draw into; if smaller than the current size + * the drawing is starting at this point. + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, + const QString &elementID = QString()); - /** - * Paints all or part of the SVG represented by this object - * - * @param painter the QPainter to use - * @param rect the rect to draw into; if smaller than the current size - * the drawing is starting at this point. - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - */ - Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, - const QString &elementID = QString()); + /** + * Paints all or part of the SVG represented by this object + * + * @param painter the QPainter to use + * @param x the horizontal coordinate to start painting from + * @param y the vertical coordinate to start painting from + * @param width the width of the element to draw + * @param height the height of the element do draw + * @param elementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, + int height, const QString &elementID = QString()); - /** - * Paints all or part of the SVG represented by this object - * - * @param painter the QPainter to use - * @param x the horizontal coordinate to start painting from - * @param y the vertical coordinate to start painting from - * @param width the width of the element to draw - * @param height the height of the element do draw - * @param elementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - */ - Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, - int height, const QString &elementID = QString()); + /** + * The size of the SVG. + * + * If the SVG has been resized with resize(), that size will be + * returned; otherwise, the natural size of the SVG will be returned. + * + * If containsMultipleImages is @c true, each element of the SVG + * will be rendered at this size by default. + * + * @return the current size of the SVG + **/ + QSize size() const; - /** - * The size of the SVG. - * - * If the SVG has been resized with resize(), that size will be - * returned; otherwise, the natural size of the SVG will be returned. - * - * If containsMultipleImages is @c true, each element of the SVG - * will be rendered at this size by default. - * - * @return the current size of the SVG - **/ - QSize size() const; + /** + * Resizes the rendered image. + * + * Rendering will actually take place on the next call to paint. + * + * If containsMultipleImages is @c true, each element of the SVG + * will be rendered at this size by default; otherwise, the entire + * image will be scaled to this size and each element will be + * scaled appropriately. + * + * @param width the new width + * @param height the new height + **/ + Q_INVOKABLE void resize(qreal width, qreal height); - /** - * Resizes the rendered image. - * - * Rendering will actually take place on the next call to paint. - * - * If containsMultipleImages is @c true, each element of the SVG - * will be rendered at this size by default; otherwise, the entire - * image will be scaled to this size and each element will be - * scaled appropriately. - * - * @param width the new width - * @param height the new height - **/ - Q_INVOKABLE void resize(qreal width, qreal height); + /** + * Resizes the rendered image. + * + * Rendering will actually take place on the next call to paint. + * + * If containsMultipleImages is @c true, each element of the SVG + * will be rendered at this size by default; otherwise, the entire + * image will be scaled to this size and each element will be + * scaled appropriately. + * + * @param size the new size of the image + **/ + Q_INVOKABLE void resize(const QSizeF &size); - /** - * Resizes the rendered image. - * - * Rendering will actually take place on the next call to paint. - * - * If containsMultipleImages is @c true, each element of the SVG - * will be rendered at this size by default; otherwise, the entire - * image will be scaled to this size and each element will be - * scaled appropriately. - * - * @param size the new size of the image - **/ - Q_INVOKABLE void resize(const QSizeF &size); + /** + * Resizes the rendered image to the natural size of the SVG. + * + * Rendering will actually take place on the next call to paint. + **/ + Q_INVOKABLE void resize(); - /** - * Resizes the rendered image to the natural size of the SVG. - * - * Rendering will actually take place on the next call to paint. - **/ - Q_INVOKABLE void resize(); + /** + * Find the size of a given element. + * + * This is the size of the element with ID @p elementId after the SVG + * has been scaled (see resize()). Note that this is unaffected by + * the containsMultipleImages property. + * + * @param elementId the id of the element to check + * @return the size of a given element, given the current size of the SVG + **/ + Q_INVOKABLE QSize elementSize(const QString &elementId) const; - /** - * Find the size of a given element. - * - * This is the size of the element with ID @p elementId after the SVG - * has been scaled (see resize()). Note that this is unaffected by - * the containsMultipleImages property. - * - * @param elementId the id of the element to check - * @return the size of a given element, given the current size of the SVG - **/ - Q_INVOKABLE QSize elementSize(const QString &elementId) const; + /** + * The bounding rect of a given element. + * + * This is the bounding rect of the element with ID @p elementId after + * the SVG has been scaled (see resize()). Note that this is + * unaffected by the containsMultipleImages property. + * + * @param elementId the id of the element to check + * @return the current rect of a given element, given the current size of the SVG + **/ + Q_INVOKABLE QRectF elementRect(const QString &elementId) const; - /** - * The bounding rect of a given element. - * - * This is the bounding rect of the element with ID @p elementId after - * the SVG has been scaled (see resize()). Note that this is - * unaffected by the containsMultipleImages property. - * - * @param elementId the id of the element to check - * @return the current rect of a given element, given the current size of the SVG - **/ - Q_INVOKABLE QRectF elementRect(const QString &elementId) const; + /** + * Check whether an element exists in the loaded SVG. + * + * @param elementId the id of the element to check for + * @return @c true if the element is defined in the SVG, otherwise @c false + **/ + Q_INVOKABLE bool hasElement(const QString &elementId) const; - /** - * Check whether an element exists in the loaded SVG. - * - * @param elementId the id of the element to check for - * @return @c true if the element is defined in the SVG, otherwise @c false - **/ - Q_INVOKABLE bool hasElement(const QString &elementId) const; + /** + * Check whether this object is backed by a valid SVG file. + * + * This method can be expensive as it causes disk access. + * + * @return @c true if the SVG file exists and the document is valid, + * otherwise @c false. + **/ + Q_INVOKABLE bool isValid() const; - /** - * Check whether this object is backed by a valid SVG file. - * - * This method can be expensive as it causes disk access. - * - * @return @c true if the SVG file exists and the document is valid, - * otherwise @c false. - **/ - Q_INVOKABLE bool isValid() const; + /** + * Set whether the SVG contains a single image or multiple ones. + * + * If this is set to @c true, the SVG will be treated as a + * collection of related images, rather than a consistent + * drawing. + * + * In particular, when individual elements are rendered, this + * affects whether the elements are resized to size() by default. + * See paint() and pixmap(). + * + * @param multiple true if the svg contains multiple images + */ + void setContainsMultipleImages(bool multiple); - /** - * Set whether the SVG contains a single image or multiple ones. - * - * If this is set to @c true, the SVG will be treated as a - * collection of related images, rather than a consistent - * drawing. - * - * In particular, when individual elements are rendered, this - * affects whether the elements are resized to size() by default. - * See paint() and pixmap(). - * - * @param multiple true if the svg contains multiple images - */ - void setContainsMultipleImages(bool multiple); + /** + * Whether the SVG contains multiple images. + * + * If this is @c true, the SVG will be treated as a + * collection of related images, rather than a consistent + * drawing. + * + * @return @c true if the SVG will be treated as containing + * multiple images, @c false if it will be treated + * as a coherent image. + */ + bool containsMultipleImages() const; - /** - * Whether the SVG contains multiple images. - * - * If this is @c true, the SVG will be treated as a - * collection of related images, rather than a consistent - * drawing. - * - * @return @c true if the SVG will be treated as containing - * multiple images, @c false if it will be treated - * as a coherent image. - */ - bool containsMultipleImages() const; + /** + * Set the SVG file to render. + * + * Relative paths are looked for in the current Plasma theme, + * and should not include the file extension (.svg and .svgz + * files will be searched for). See Theme::imagePath(). + * + * If the parent object of this Svg is a Plasma::Applet, + * relative paths will be searched for in the applet's package + * first. + * + * @param svgFilePath either an absolute path to an SVG file, or + * an image name + */ + virtual void setImagePath(const QString &svgFilePath); - /** - * Set the SVG file to render. - * - * Relative paths are looked for in the current Plasma theme, - * and should not include the file extension (.svg and .svgz - * files will be searched for). See Theme::imagePath(). - * - * If the parent object of this Svg is a Plasma::Applet, - * relative paths will be searched for in the applet's package - * first. - * - * @param svgFilePath either an absolute path to an SVG file, or - * an image name - */ - virtual void setImagePath(const QString &svgFilePath); + /** + * The SVG file to render. + * + * If this SVG is themed, this will be a relative path, and will not + * include a file extension. + * + * @return either an absolute path to an SVG file, or an image name + * @see Theme::imagePath() + */ + QString imagePath() const; - /** - * The SVG file to render. - * - * If this SVG is themed, this will be a relative path, and will not - * include a file extension. - * - * @return either an absolute path to an SVG file, or an image name - * @see Theme::imagePath() - */ - QString imagePath() const; + /** + * Sets whether or not to cache the results of rendering to pixmaps. + * + * If the SVG is resized and re-rendered often (and does not keep using the + * same small set of pixmap dimensions), then it may be less efficient to do + * disk caching. A good example might be a progress meter that uses an Svg + * object to paint itself: the meter will be changing often enough, with + * enough unpredictability and without re-use of the previous pixmaps to + * not get a gain from caching. + * + * Most Svg objects should use the caching feature, however. + * Therefore, the default is to use the render cache. + * + * @param useCache true to cache rendered pixmaps + * @since 4.3 + */ + void setUsingRenderingCache(bool useCache); - /** - * Sets whether or not to cache the results of rendering to pixmaps. - * - * If the SVG is resized and re-rendered often (and does not keep using the - * same small set of pixmap dimensions), then it may be less efficient to do - * disk caching. A good example might be a progress meter that uses an Svg - * object to paint itself: the meter will be changing often enough, with - * enough unpredictability and without re-use of the previous pixmaps to - * not get a gain from caching. - * - * Most Svg objects should use the caching feature, however. - * Therefore, the default is to use the render cache. - * - * @param useCache true to cache rendered pixmaps - * @since 4.3 - */ - void setUsingRenderingCache(bool useCache); + /** + * Whether the rendering cache is being used. + * + * @return @c true if the Svg object is using caching for rendering results + * @since 4.3 + */ + bool isUsingRenderingCache() const; - /** - * Whether the rendering cache is being used. - * - * @return @c true if the Svg object is using caching for rendering results - * @since 4.3 - */ - bool isUsingRenderingCache() const; + /** + * Sets the Plasma::Theme to use with this Svg object. + * + * By default, Svg objects use Plasma::Theme::default(). + * + * This determines how relative image paths are interpreted. + * + * @param theme the theme object to use + * @since 4.3 + */ + void setTheme(Plasma::Theme *theme); - /** - * Sets the Plasma::Theme to use with this Svg object. - * - * By default, Svg objects use Plasma::Theme::default(). - * - * This determines how relative image paths are interpreted. - * - * @param theme the theme object to use - * @since 4.3 - */ - void setTheme(Plasma::Theme *theme); + /** + * The Plasma::Theme used by this Svg object. + * + * This determines how relative image paths are interpreted. + * + * @return the theme used by this Svg + */ + Theme *theme() const; - /** - * The Plasma::Theme used by this Svg object. - * - * This determines how relative image paths are interpreted. - * - * @return the theme used by this Svg - */ - Theme *theme() const; +Q_SIGNALS: + /** + * Emitted whenever the SVG data has changed in such a way that a repaint is required. + * Any usage of an Svg object that does the painting itself must connect to this signal + * and respond by updating the painting. Note that connected to Theme::themeChanged is + * incorrect in such a use case as the Svg itself may not be updated yet nor may theme + * change be the only case when a repaint is needed. Also note that classes or QML code + * which take Svg objects as parameters for their own painting all respond to this signal + * so that in those cases manually responding to the signal is unnecessary; ONLY when + * direct, manual painting with an Svg object is done in application code is this signal + * used. + */ + void repaintNeeded(); - Q_SIGNALS: - /** - * Emitted whenever the SVG data has changed in such a way that a repaint is required. - * Any usage of an Svg object that does the painting itself must connect to this signal - * and respond by updating the painting. Note that connected to Theme::themeChanged is - * incorrect in such a use case as the Svg itself may not be updated yet nor may theme - * change be the only case when a repaint is needed. Also note that classes or QML code - * which take Svg objects as parameters for their own painting all respond to this signal - * so that in those cases manually responding to the signal is unnecessary; ONLY when - * direct, manual painting with an Svg object is done in application code is this signal - * used. - */ - void repaintNeeded(); + /** + * Emitted whenever the size of the Svg is changed. @see resize() + */ + void sizeChanged(); - /** - * Emitted whenever the size of the Svg is changed. @see resize() - */ - void sizeChanged(); + /** + * Emitted whenever the image path of the Svg is changed. + */ + void imagePathChanged(); - /** - * Emitted whenever the image path of the Svg is changed. - */ - void imagePathChanged(); +private: + SvgPrivate *const d; + bool eventFilter(QObject *watched, QEvent *event); - private: - SvgPrivate *const d; - bool eventFilter(QObject *watched, QEvent *event); + Q_PRIVATE_SLOT(d, void themeChanged()) + Q_PRIVATE_SLOT(d, void colorsChanged()) - Q_PRIVATE_SLOT(d, void themeChanged()) - Q_PRIVATE_SLOT(d, void colorsChanged()) - - friend class SvgPrivate; - friend class FrameSvgPrivate; - friend class FrameSvg; + friend class SvgPrivate; + friend class FrameSvgPrivate; + friend class FrameSvg; }; } // Plasma namespace diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index aba84d58b..a3c27b9bb 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -190,9 +190,9 @@ QString Theme::imagePath(const QString &name) const /* if (path.isEmpty()) { -#ifndef NDEBUG + #ifndef NDEBUG // qDebug() << "Theme says: bad image path " << name; -#endif + #endif } */ @@ -322,14 +322,14 @@ bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModif return false; } -void Theme::insertIntoCache(const QString& key, const QPixmap& pix) +void Theme::insertIntoCache(const QString &key, const QPixmap &pix) { if (d->useCache()) { d->pixmapCache->insertPixmap(key, pix); } } -void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const QString& id) +void Theme::insertIntoCache(const QString &key, const QPixmap &pix, const QString &id) { if (d->useCache()) { d->pixmapsToCache.insert(id, pix); @@ -402,7 +402,7 @@ QStringList Theme::listCachedRectKeys(const QString &image) const return keys; } -void Theme::insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect) +void Theme::insertIntoRectsCache(const QString &image, const QString &element, const QRectF &rect) { if (!d->useCache()) { return; @@ -425,7 +425,7 @@ void Theme::insertIntoRectsCache(const QString& image, const QString &element, c } } -void Theme::invalidateRectsCache(const QString& image) +void Theme::invalidateRectsCache(const QString &image) { if (d->useCache()) { KConfigGroup imageGroup(d->svgElementsCache, image); @@ -560,7 +560,6 @@ qreal Theme::backgroundSaturation() const return d->backgroundSaturation; } - } #include "moc_theme.cpp" diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 42677fb1b..0bf88989e 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -81,433 +81,432 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY(QColor viewHoverColor READ viewHoverColor NOTIFY themeChanged) Q_PROPERTY(QColor viewFocusColor READ viewFocusColor NOTIFY themeChanged) - public: - enum ColorRole { - TextColor = 0, /**< the text color to be used by items resting on the background */ - HighlightColor = 1, /**< the text highlight color to be used by items resting +public: + enum ColorRole { + TextColor = 0, /**< the text color to be used by items resting on the background */ + HighlightColor = 1, /**< the text highlight color to be used by items resting on the background */ - BackgroundColor = 2, /**< the default background color */ - ButtonTextColor = 4, /** text color for buttons */ - ButtonBackgroundColor = 8, /** background color for buttons*/ - LinkColor = 16, /** color for clickable links */ - VisitedLinkColor = 32, /** color visited clickable links */ - ButtonHoverColor = 64, /** color for hover effect on buttons */ - ButtonFocusColor = 128, /** color for focus effect on buttons */ - ViewTextColor = 256, /** text color for views */ - ViewBackgroundColor = 512, /** background color for views */ - ViewHoverColor = 1024, /** color for hover effect on view */ - ViewFocusColor = 2048 /** color for focus effect on view */ - }; + BackgroundColor = 2, /**< the default background color */ + ButtonTextColor = 4, /** text color for buttons */ + ButtonBackgroundColor = 8, /** background color for buttons*/ + LinkColor = 16, /** color for clickable links */ + VisitedLinkColor = 32, /** color visited clickable links */ + ButtonHoverColor = 64, /** color for hover effect on buttons */ + ButtonFocusColor = 128, /** color for focus effect on buttons */ + ViewTextColor = 256, /** text color for views */ + ViewBackgroundColor = 512, /** background color for views */ + ViewHoverColor = 1024, /** color for hover effect on view */ + ViewFocusColor = 2048 /** color for focus effect on view */ + }; - /** - * Default constructor. It will be the global theme configured in plasmarc - * @param parent the parent object - */ - explicit Theme(QObject *parent = 0); + /** + * Default constructor. It will be the global theme configured in plasmarc + * @param parent the parent object + */ + explicit Theme(QObject *parent = 0); - /** - * Construct a theme. It will be a custom theme instance of themeName. - * @param themeName the name of the theme to create - * @param parent the parent object - * @since 4.3 - */ - explicit Theme(const QString &themeName, QObject *parent = 0); + /** + * Construct a theme. It will be a custom theme instance of themeName. + * @param themeName the name of the theme to create + * @param parent the parent object + * @since 4.3 + */ + explicit Theme(const QString &themeName, QObject *parent = 0); - ~Theme(); + ~Theme(); - /** - * Sets the current theme being used. - */ - void setThemeName(const QString &themeName); + /** + * Sets the current theme being used. + */ + void setThemeName(const QString &themeName); - /** - * @return the name of the theme. - */ - QString themeName() const; + /** + * @return the name of the theme. + */ + QString themeName() const; - /** - * Retrieve the path for an SVG image in the current theme. - * - * @param name the name of the file in the theme directory (without the - * ".svg" part or a leading slash) - * @return the full path to the requested file for the current theme - */ - QString imagePath(const QString &name) const; + /** + * Retrieve the path for an SVG image in the current theme. + * + * @param name the name of the file in the theme directory (without the + * ".svg" part or a leading slash) + * @return the full path to the requested file for the current theme + */ + QString imagePath(const QString &name) const; - /** - * Retrieves the default wallpaper associated with this theme. - * - * @param size the target height and width of the wallpaper; if an invalid size - * is passed in, then a default size will be provided instead. - * @return the full path to the wallpaper image - */ - QString wallpaperPath(const QSize &size = QSize()) const; + /** + * Retrieves the default wallpaper associated with this theme. + * + * @param size the target height and width of the wallpaper; if an invalid size + * is passed in, then a default size will be provided instead. + * @return the full path to the wallpaper image + */ + QString wallpaperPath(const QSize &size = QSize()) const; - Q_INVOKABLE QString wallpaperPathForSize(int width=-1, int height=-1) const; + Q_INVOKABLE QString wallpaperPathForSize(int width = -1, int height = -1) const; - /** - * Checks if this theme has an image named in a certain way - * - * @param name the name of the file in the theme directory (without the - * ".svg" part or a leading slash) - * @return true if the image exists for this theme - */ - bool currentThemeHasImage(const QString &name) const; + /** + * Checks if this theme has an image named in a certain way + * + * @param name the name of the file in the theme directory (without the + * ".svg" part or a leading slash) + * @return true if the image exists for this theme + */ + bool currentThemeHasImage(const QString &name) const; - /** - * Returns the color scheme configurationthat goes along this theme. - * This can be used with KStatefulBrush and KColorScheme to determine - * the proper colours to use along with the visual elements in this theme. - */ - KSharedConfigPtr colorScheme() const; + /** + * Returns the color scheme configurationthat goes along this theme. + * This can be used with KStatefulBrush and KColorScheme to determine + * the proper colours to use along with the visual elements in this theme. + */ + KSharedConfigPtr colorScheme() const; - /** - * Returns the text color to be used by items resting on the background - * - * @param role which role (usage pattern) to get the color for - */ - QColor color(ColorRole role) const; + /** + * Returns the text color to be used by items resting on the background + * + * @param role which role (usage pattern) to get the color for + */ + QColor color(ColorRole role) const; - /** - * Tells the theme whether to follow the global settings or use application - * specific settings - * - * @param useGlobal pass in true to follow the global settings - */ - void setUseGlobalSettings(bool useGlobal); + /** + * Tells the theme whether to follow the global settings or use application + * specific settings + * + * @param useGlobal pass in true to follow the global settings + */ + void setUseGlobalSettings(bool useGlobal); - /** - * @return true if the global settings are followed, false if application - * specific settings are used. - */ - bool useGlobalSettings() const; + /** + * @return true if the global settings are followed, false if application + * specific settings are used. + */ + bool useGlobalSettings() const; - /** - * Provides a Plasma::Theme-themed stylesheet for hybrid (web / native Plasma) widgets. - * - * You can use this method to retrieve a basic default stylesheet, or to theme your - * custom stylesheet you use for example in Plasma::WebView. The QString you can pass - * into this method does not have to be a valid stylesheet, in fact you can use this - * method to replace color placeholders with the theme's color in any QString. - * - * In order to use this method with a custom stylesheet, just put for example %textcolor - * in your QString and it will be replaced with the theme's text (or foreground) color. - * - * Just like in many other methods for retrieving theme information, do not forget to - * update your stylesheet upon the themeChanged() signal. - * - * The following tags will be replaced by corresponding colors from Plasma::Theme: - * - * %textcolor - * %backgroundcolor - * %buttonbackgroundcolor - * - * %link - * %activatedlink - * %hoveredlink - * %visitedlink - * - * %fontfamily - * %fontsize - * %smallfontsize - * - * @param css a stylesheet to theme, leave empty for a default stylesheet containing - * theming for some commonly used elements, body text and links, for example. - * - * @return a piece of CSS that sets the most commonly used style elements to a theme - * matching Plasma::Theme. - * - * @since 4.5 - */ - QString styleSheet(const QString &css = QString()) const; + /** + * Provides a Plasma::Theme-themed stylesheet for hybrid (web / native Plasma) widgets. + * + * You can use this method to retrieve a basic default stylesheet, or to theme your + * custom stylesheet you use for example in Plasma::WebView. The QString you can pass + * into this method does not have to be a valid stylesheet, in fact you can use this + * method to replace color placeholders with the theme's color in any QString. + * + * In order to use this method with a custom stylesheet, just put for example %textcolor + * in your QString and it will be replaced with the theme's text (or foreground) color. + * + * Just like in many other methods for retrieving theme information, do not forget to + * update your stylesheet upon the themeChanged() signal. + * + * The following tags will be replaced by corresponding colors from Plasma::Theme: + * + * %textcolor + * %backgroundcolor + * %buttonbackgroundcolor + * + * %link + * %activatedlink + * %hoveredlink + * %visitedlink + * + * %fontfamily + * %fontsize + * %smallfontsize + * + * @param css a stylesheet to theme, leave empty for a default stylesheet containing + * theming for some commonly used elements, body text and links, for example. + * + * @return a piece of CSS that sets the most commonly used style elements to a theme + * matching Plasma::Theme. + * + * @since 4.5 + */ + QString styleSheet(const QString &css = QString()) const; + /** + * This is an overloaded member provided to check with file timestamp + * where cache is still valid. + * + * @param key the name to use in the cache for this image + * @param pix the pixmap object to populate with the resulting data if found + * @param lastModified if non-zero, the time stamp is also checked on the file, + * and must be newer than the timestamp to be loaded + * + * @return true when pixmap was found and loaded from cache, false otherwise + * @since 4.3 + **/ + bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified = 0); - /** - * This is an overloaded member provided to check with file timestamp - * where cache is still valid. - * - * @param key the name to use in the cache for this image - * @param pix the pixmap object to populate with the resulting data if found - * @param lastModified if non-zero, the time stamp is also checked on the file, - * and must be newer than the timestamp to be loaded - * - * @return true when pixmap was found and loaded from cache, false otherwise - * @since 4.3 - **/ - bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified = 0); + /** + * Insert specified pixmap into the cache. + * If the cache already contains pixmap with the specified key then it is + * overwritten. + * + * @param key the name to use in the cache for this pixmap + * @param pix the pixmap data to store in the cache + **/ + void insertIntoCache(const QString &key, const QPixmap &pix); - /** - * Insert specified pixmap into the cache. - * If the cache already contains pixmap with the specified key then it is - * overwritten. - * - * @param key the name to use in the cache for this pixmap - * @param pix the pixmap data to store in the cache - **/ - void insertIntoCache(const QString& key, const QPixmap& pix); + /** + * Insert specified pixmap into the cache. + * If the cache already contains pixmap with the specified key then it is + * overwritten. + * The actual insert is delayed for optimization reasons and the id + * parameter is used to discard repeated inserts in the delay time, useful + * when for instance the graphics to inser comes from a quickly resizing + * object: the frames between the start and destination sizes aren't + * useful in the cache and just cause overhead. + * + * @param key the name to use in the cache for this pixmap + * @param pix the pixmap data to store in the cache + * @param id a name that identifies the caller class of this function in an unique fashion. + * This is needed to limit disk writes of the cache. + * If an image with the same id changes quickly, + * only the last size where insertIntoCache was called is actually stored on disk + * @since 4.3 + **/ + void insertIntoCache(const QString &key, const QPixmap &pix, const QString &id); - /** - * Insert specified pixmap into the cache. - * If the cache already contains pixmap with the specified key then it is - * overwritten. - * The actual insert is delayed for optimization reasons and the id - * parameter is used to discard repeated inserts in the delay time, useful - * when for instance the graphics to inser comes from a quickly resizing - * object: the frames between the start and destination sizes aren't - * useful in the cache and just cause overhead. - * - * @param key the name to use in the cache for this pixmap - * @param pix the pixmap data to store in the cache - * @param id a name that identifies the caller class of this function in an unique fashion. - * This is needed to limit disk writes of the cache. - * If an image with the same id changes quickly, - * only the last size where insertIntoCache was called is actually stored on disk - * @since 4.3 - **/ - void insertIntoCache(const QString& key, const QPixmap& pix, const QString& id); + /** + * Sets the maximum size of the cache (in kilobytes). If cache gets bigger + * the limit then some entries are removed + * Setting cache limit to 0 disables automatic cache size limiting. + * + * Note that the cleanup might not be done immediately, so the cache might + * temporarily (for a few seconds) grow bigger than the limit. + **/ + void setCacheLimit(int kbytes); - /** - * Sets the maximum size of the cache (in kilobytes). If cache gets bigger - * the limit then some entries are removed - * Setting cache limit to 0 disables automatic cache size limiting. - * - * Note that the cleanup might not be done immediately, so the cache might - * temporarily (for a few seconds) grow bigger than the limit. - **/ - void setCacheLimit(int kbytes); + /** + * Tries to load the rect of a sub element from a disk cache + * + * @param image path of the image we want to check + * @param element sub element we want to retrieve + * @param rect output parameter of the element rect found in cache + * if not found or if we are sure it doesn't exist it will be QRect() + * @return true if the element was found in cache or if we are sure the element doesn't exist + **/ + bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const; - /** - * Tries to load the rect of a sub element from a disk cache - * - * @param image path of the image we want to check - * @param element sub element we want to retrieve - * @param rect output parameter of the element rect found in cache - * if not found or if we are sure it doesn't exist it will be QRect() - * @return true if the element was found in cache or if we are sure the element doesn't exist - **/ - bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const; + /** + * Returns a list of all keys of cached rects for the given image. + * + * @param image path of the image for which the keys should be returned + * + * @return a QStringList whose elements are the entry keys in the rects cache + * + * @since 4.6 + */ + QStringList listCachedRectKeys(const QString &image) const; - /** - * Returns a list of all keys of cached rects for the given image. - * - * @param image path of the image for which the keys should be returned - * - * @return a QStringList whose elements are the entry keys in the rects cache - * - * @since 4.6 - */ - QStringList listCachedRectKeys(const QString &image) const; + /** + * Inserts a rectangle of a sub element of an image into a disk cache + * + * @param image path of the image we want to insert information + * @param element sub element we want insert the rect + * @param rect element rectangle + **/ + void insertIntoRectsCache(const QString &image, const QString &element, const QRectF &rect); - /** - * Inserts a rectangle of a sub element of an image into a disk cache - * - * @param image path of the image we want to insert information - * @param element sub element we want insert the rect - * @param rect element rectangle - **/ - void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect); + /** + * Discards all the information about a given image from the rectangle disk cache + * + * @param image the path to the image the cache is assoiated with + **/ + void invalidateRectsCache(const QString &image); - /** - * Discards all the information about a given image from the rectangle disk cache - * - * @param image the path to the image the cache is assoiated with - **/ - void invalidateRectsCache(const QString &image); + /** + * Frees up memory used by cached information for a given image without removing + * the permenant record of it on disk. + * @see invalidateRectsCache + * + * @param image the path to the image the cache is assoiated with + */ + void releaseRectsCache(const QString &image); - /** - * Frees up memory used by cached information for a given image without removing - * the permenant record of it on disk. - * @see invalidateRectsCache - * - * @param image the path to the image the cache is assoiated with - */ - void releaseRectsCache(const QString &image); + /** + * @return plugin info for this theme, with informations such as + * name, description, author, website etc + * @since 5.0 + */ + KPluginInfo pluginInfo() const; - /** - * @return plugin info for this theme, with informations such as - * name, description, author, website etc - * @since 5.0 - */ - KPluginInfo pluginInfo() const; + /** + * @return The default application font + * @since 5.0 + */ + QFont defaultFont() const; - /** - * @return The default application font - * @since 5.0 - */ - QFont defaultFont() const; + /** + * @return The smallest readable font + * @since 5.0 + */ + QFont smallestFont() const; - /** - * @return The smallest readable font - * @since 5.0 - */ - QFont smallestFont() const; + /** + * @return The theme's colorscheme's text color + * @since 5.0 + */ + QColor textColor() const; - /** - * @return The theme's colorscheme's text color - * @since 5.0 - */ - QColor textColor() const; + /** + * @return The theme's colorscheme's highlight color + * @since 5.0 + */ + QColor highlightColor() const; - /** - * @return The theme's colorscheme's highlight color - * @since 5.0 - */ - QColor highlightColor() const; + /** + * @return The theme's colorscheme's background color + * @since 5.0 + */ + QColor backgroundColor() const; - /** - * @return The theme's colorscheme's background color - * @since 5.0 - */ - QColor backgroundColor() const; + /** + * @return The theme's colorscheme's color for text on buttons + * @since 5.0 + */ + QColor buttonTextColor() const; - /** - * @return The theme's colorscheme's color for text on buttons - * @since 5.0 - */ - QColor buttonTextColor() const; + /** + * @return The theme's colorscheme's background color color of buttons + * @since 5.0 + */ + QColor buttonBackgroundColor() const; - /** - * @return The theme's colorscheme's background color color of buttons - * @since 5.0 - */ - QColor buttonBackgroundColor() const; + /** + * @return The theme's colorscheme's link color + * @since 5.0 + */ + QColor linkColor() const; - /** - * @return The theme's colorscheme's link color - * @since 5.0 - */ - QColor linkColor() const; + /** + * @return The theme's colorscheme's text color for visited links + * @since 5.0 + */ + QColor visitedLinkColor() const; - /** - * @return The theme's colorscheme's text color for visited links - * @since 5.0 - */ - QColor visitedLinkColor() const; + /** + * @return The theme's colorscheme's color of hovered buttons + * @since 5.0 + */ + QColor buttonHoverColor() const; - /** - * @return The theme's colorscheme's color of hovered buttons - * @since 5.0 - */ - QColor buttonHoverColor() const; + /** + * @return The theme's colorscheme's color of focused buttons + * @since 5.0 + */ + QColor buttonFocusColor() const; - /** - * @return The theme's colorscheme's color of focused buttons - * @since 5.0 - */ - QColor buttonFocusColor() const; + /** + * @return The theme's colorscheme's text color in views + * @since 5.0 + */ + QColor viewTextColor() const; - /** - * @return The theme's colorscheme's text color in views - * @since 5.0 - */ - QColor viewTextColor() const; + /** + * @return The theme's colorscheme's background color of views + * @since 5.0 + */ + QColor viewBackgroundColor() const; - /** - * @return The theme's colorscheme's background color of views - * @since 5.0 - */ - QColor viewBackgroundColor() const; + /** + * @return The theme's colorscheme's color of hovered views + * @since 5.0 + */ + QColor viewHoverColor() const; - /** - * @return The theme's colorscheme's color of hovered views - * @since 5.0 - */ - QColor viewHoverColor() const; + /** + * @return The theme's colorscheme's color of focused views + * @since 5.0 + */ + QColor viewFocusColor() const; - /** - * @return The theme's colorscheme's color of focused views - * @since 5.0 - */ - QColor viewFocusColor() const; + /** This method allows Plasma to enable and disable the background + * contrast effect for a given theme, improving readability. The + * value is read from the "enabled" key in the "ContrastEffect" + * group in the Theme's metadata file. + * The configuration in the metadata.desktop file of the theme + * could look like this (for a lighter background): + * \code + * [ContrastEffect] + * enabled=true + * contrast=0.45 + * intensity=0.45 + * saturation=1.7 + * \endcode + * @return Whether or not to enable the contrasteffect + * @since 5.0 + */ + bool backgroundContrastEnabled() const; - /** This method allows Plasma to enable and disable the background - * contrast effect for a given theme, improving readability. The - * value is read from the "enabled" key in the "ContrastEffect" - * group in the Theme's metadata file. - * The configuration in the metadata.desktop file of the theme - * could look like this (for a lighter background): - * \code - * [ContrastEffect] - * enabled=true - * contrast=0.45 - * intensity=0.45 - * saturation=1.7 - * \endcode - * @return Whether or not to enable the contrasteffect - * @since 5.0 - */ - bool backgroundContrastEnabled() const; + /** This method allows Plasma to set a background contrast effect + * for a given theme, improving readability. The value is read + * from the "contrast" key in the "ContrastEffect" group in the + * Theme's metadata file. + * @return The contrast provided to the contrasteffect + * @since 5.0 + * @see backgroundContrastEnabled + */ + qreal backgroundContrast() const; - /** This method allows Plasma to set a background contrast effect - * for a given theme, improving readability. The value is read - * from the "contrast" key in the "ContrastEffect" group in the - * Theme's metadata file. - * @return The contrast provided to the contrasteffect - * @since 5.0 - * @see backgroundContrastEnabled - */ - qreal backgroundContrast() const; + /** This method allows Plasma to set a background contrast effect + * for a given theme, improving readability. The value is read + * from the "intensity" key in the "ContrastEffect" group in the + * Theme's metadata file. + * @return The intensity provided to the contrasteffect + * @since 5.0 + * @see backgroundContrastEnabled + */ + qreal backgroundIntensity() const; - /** This method allows Plasma to set a background contrast effect - * for a given theme, improving readability. The value is read - * from the "intensity" key in the "ContrastEffect" group in the - * Theme's metadata file. - * @return The intensity provided to the contrasteffect - * @since 5.0 - * @see backgroundContrastEnabled - */ - qreal backgroundIntensity() const; + /** This method allows Plasma to set a background contrast effect + * for a given theme, improving readability. The value is read + * from the "saturation" key in the "ContrastEffect" group in the + * Theme's metadata file. + * @return The saturation provided to the contrasteffect + * @since 5.0 + * @see backgroundContrastEnabled + */ + qreal backgroundSaturation() const; - /** This method allows Plasma to set a background contrast effect - * for a given theme, improving readability. The value is read - * from the "saturation" key in the "ContrastEffect" group in the - * Theme's metadata file. - * @return The saturation provided to the contrasteffect - * @since 5.0 - * @see backgroundContrastEnabled - */ - qreal backgroundSaturation() const; + /** + * Returns the size of the letter "M" as rendered on the screen with the given font. + * This values gives you a base size that: + * * scales dependent on the DPI of the screen + * * Scales with the default font as set by the user + * You can use it like this in QML Items: + * \code + * Item { + * width: theme.mSize(theme.defaultFont).height + * height: width + * } + * \endcode + * This allows you to dynamically scale elements of your user interface with different font settings and + * different physical outputs (with different DPI). + * @param font The font to use for the metrics. + * @return The size of the letter "M" as rendered on the screen with the given font. + * @since 5.0 + */ + Q_INVOKABLE QSizeF mSize(const QFont &font = QApplication::font()) const; - /** - * Returns the size of the letter "M" as rendered on the screen with the given font. - * This values gives you a base size that: - * * scales dependent on the DPI of the screen - * * Scales with the default font as set by the user - * You can use it like this in QML Items: - * \code - * Item { - * width: theme.mSize(theme.defaultFont).height - * height: width - * } - * \endcode - * This allows you to dynamically scale elements of your user interface with different font settings and - * different physical outputs (with different DPI). - * @param font The font to use for the metrics. - * @return The size of the letter "M" as rendered on the screen with the given font. - * @since 5.0 - */ - Q_INVOKABLE QSizeF mSize(const QFont &font = QApplication::font()) const; +Q_SIGNALS: + /** + * Emitted when the user changes the theme. Stylesheet usage, colors, etc. should + * be updated at this point. However, SVGs should *not* be repainted in response + * to this signal; connect to Svg::repaintNeeded() instead for that, as Svg objects + * need repainting not only when themeChanged() is emitted; moreover Svg objects + * connect to and respond appropriately to themeChanged() internally, emitting + * Svg::repaintNeeded() at an appropriate time. + */ + void themeChanged(); - Q_SIGNALS: - /** - * Emitted when the user changes the theme. Stylesheet usage, colors, etc. should - * be updated at this point. However, SVGs should *not* be repainted in response - * to this signal; connect to Svg::repaintNeeded() instead for that, as Svg objects - * need repainting not only when themeChanged() is emitted; moreover Svg objects - * connect to and respond appropriately to themeChanged() internally, emitting - * Svg::repaintNeeded() at an appropriate time. - */ - void themeChanged(); + /** Notifier for change of defaultFont property */ + void defaultFontChanged(); + /** Notifier for change of smallestFont property */ + void smallestFontChanged(); - /** Notifier for change of defaultFont property */ - void defaultFontChanged(); - /** Notifier for change of smallestFont property */ - void smallestFontChanged(); - - private: - friend class SvgPrivate; - friend class ThemePrivate; - ThemePrivate *d; +private: + friend class SvgPrivate; + friend class ThemePrivate; + ThemePrivate *d; }; } // Plasma namespace diff --git a/src/plasmapkg/main.cpp b/src/plasmapkg/main.cpp index 72dcc9469..f96e33f8e 100644 --- a/src/plasmapkg/main.cpp +++ b/src/plasmapkg/main.cpp @@ -18,7 +18,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - /** * plasmapkg2 exit codes used in this program @@ -57,11 +56,11 @@ int main(int argc, char **argv) parser.addOption(QCommandLineOption(QStringList() << "hash", i18nc("Do not translate ", "Generate a SHA1 hash for the package at "), "path")); parser.addOption(QCommandLineOption(QStringList() << "g" << "global", i18n("For install or remove, operates on packages installed for all users."))); parser.addOption(QCommandLineOption(QStringList() << "t" << "type", - i18nc("theme, wallpaper, etc. are keywords, but they may be translated, as both versions " - "are recognized by the application " - "(if translated, should be same as messages with 'package type' context below)", - "The type of package, e.g. theme, wallpaper, plasmoid, dataengine, runner, layout-template, etc."), - "type", "plasmoid")); + i18nc("theme, wallpaper, etc. are keywords, but they may be translated, as both versions " + "are recognized by the application " + "(if translated, should be same as messages with 'package type' context below)", + "The type of package, e.g. theme, wallpaper, plasmoid, dataengine, runner, layout-template, etc."), + "type", "plasmoid")); parser.addOption(QCommandLineOption(QStringList() << "i" << "install", i18nc("Do not translate ", "Install the package at "), "path")); parser.addOption(QCommandLineOption(QStringList() << "s" << "show", i18nc("Do not translate ", "Show information of package "), "name")); parser.addOption(QCommandLineOption(QStringList() << "u" << "upgrade", i18nc("Do not translate ", "Upgrade the package at "), "path")); diff --git a/src/plasmapkg/plasmapkg.cpp b/src/plasmapkg/plasmapkg.cpp index 414b9d843..870420cf3 100644 --- a/src/plasmapkg/plasmapkg.cpp +++ b/src/plasmapkg/plasmapkg.cpp @@ -49,7 +49,8 @@ static QTextStream cout(stdout); namespace Plasma { -class PlasmaPkgPrivate { +class PlasmaPkgPrivate +{ public: QString packageRoot; QString packageFile; @@ -62,7 +63,7 @@ public: QString installPath; void output(const QString &msg); void runKbuildsycoca(); - QStringList packages(const QStringList& types); + QStringList packages(const QStringList &types); void renderTypeTable(const QMap &plugins); void listTypes(); void coutput(const QString &msg); @@ -70,7 +71,7 @@ public: }; -PlasmaPkg::PlasmaPkg(int& argc, char** argv, QCommandLineParser *parser) : +PlasmaPkg::PlasmaPkg(int &argc, char **argv, QCommandLineParser *parser) : QCoreApplication(argc, argv) { d = new PlasmaPkgPrivate; @@ -85,7 +86,7 @@ PlasmaPkg::~PlasmaPkg() void PlasmaPkg::runMain() { - Plasma::PackageStructure* structure = new Plasma::PackageStructure; + Plasma::PackageStructure *structure = new Plasma::PackageStructure; if (d->parser->isSet("hash")) { const QString path = d->parser->value("hash"); Plasma::Package package(structure); @@ -133,8 +134,8 @@ void PlasmaPkg::runMain() } if (!d->packageFile.isEmpty() && (!d->parser->isSet("type") || - type.compare(i18nc("package type", "wallpaper"), Qt::CaseInsensitive) == 0 || - type.compare("wallpaper", Qt::CaseInsensitive) == 0)) { + type.compare(i18nc("package type", "wallpaper"), Qt::CaseInsensitive) == 0 || + type.compare("wallpaper", Qt::CaseInsensitive) == 0)) { // Check type for common plasma packages Plasma::Package package(structure); QString serviceType; @@ -149,8 +150,8 @@ void PlasmaPkg::runMain() if (!serviceType.isEmpty()) { if (serviceType.contains("Plasma/Applet") || - //serviceType.contains("Plasma/PopupApplet") || - serviceType.contains("Plasma/Containment")) { + //serviceType.contains("Plasma/PopupApplet") || + serviceType.contains("Plasma/Containment")) { type = "plasmoid"; } else if (serviceType == "Plasma/Generic") { type = "package"; @@ -187,7 +188,7 @@ void PlasmaPkg::runMain() } if (type.compare(i18nc("package type", "plasmoid"), Qt::CaseInsensitive) == 0 || - type.compare("plasmoid", Qt::CaseInsensitive) == 0) { + type.compare("plasmoid", Qt::CaseInsensitive) == 0) { d->packageRoot = "plasma/plasmoids/"; d->servicePrefix = "plasma-applet-"; d->pluginTypes << "Plasma/Applet"; @@ -251,7 +252,7 @@ void PlasmaPkg::runMain() d->packageRoot = "kwin/scripts/"; d->servicePrefix = "kwin-script-"; d->pluginTypes << "KWin/Script"; - } else /* if (KSycoca::isAvailable()) */ { + } else { /* if (KSycoca::isAvailable()) */ const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(type); KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint); if (offers.isEmpty()) { @@ -267,7 +268,7 @@ void PlasmaPkg::runMain() if (!d->installer) { d->coutput(i18n("Could not load installer for package of type %1. Error reported was: %2", - d->parser->value("type"), error)); + d->parser->value("type"), error)); return; } @@ -388,11 +389,11 @@ void PlasmaPkgPrivate::runKbuildsycoca() } } -QStringList PlasmaPkgPrivate::packages(const QStringList& types) +QStringList PlasmaPkgPrivate::packages(const QStringList &types) { QStringList result; - foreach (const QString& type, types) { + foreach (const QString &type, types) { if (type.compare("Plasma/Generic", Qt::CaseInsensitive) == 0) { const QStringList &packs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "plasma/packages/", QStandardPaths::LocateDirectory); @@ -401,7 +402,7 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types) const QStringList &entries = cd.entryList(QDir::Dirs); foreach (const QString pack, entries) { if ((pack != "." && pack != "..") && - (QFile::exists(ppath+'/'+pack+"/metadata.desktop"))) { + (QFile::exists(ppath + '/' + pack + "/metadata.desktop"))) { result << pack; } @@ -416,7 +417,7 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types) const QStringList &entries = cd.entryList(QDir::Dirs); foreach (const QString pack, entries) { if ((pack != "." && pack != "..") && - (QFile::exists(ppath+'/'+pack+"/metadata.desktop"))) { + (QFile::exists(ppath + '/' + pack + "/metadata.desktop"))) { result << pack; } @@ -431,7 +432,7 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types) const QStringList &entries = cd.entryList(QDir::Dirs); foreach (const QString pack, entries) { if ((pack != "." && pack != "..") && - (QFile::exists(ppath+'/'+pack+"/metadata.desktop"))) { + (QFile::exists(ppath + '/' + pack + "/metadata.desktop"))) { result << pack; } @@ -451,7 +452,7 @@ QStringList PlasmaPkgPrivate::packages(const QStringList& types) return result; } -void PlasmaPkg::showPackageInfo(const QString& pluginName) +void PlasmaPkg::showPackageInfo(const QString &pluginName) { QString type = QStringLiteral("Plasma/Applet"); if (!d->pluginTypes.contains(type) && d->pluginTypes.count() > 0) { @@ -482,7 +483,7 @@ void PlasmaPkg::showPackageInfo(const QString& pluginName) exit(0); } -QString PlasmaPkg::findPackageRoot(const QString& pluginName, const QString& prefix) +QString PlasmaPkg::findPackageRoot(const QString &pluginName, const QString &prefix) { QString packageRoot; if (d->parser->isSet("packageroot") && d->parser->isSet("global")) { @@ -499,11 +500,11 @@ QString PlasmaPkg::findPackageRoot(const QString& pluginName, const QString& pre return packageRoot; } -void PlasmaPkg::listPackages(const QStringList& types) +void PlasmaPkg::listPackages(const QStringList &types) { QStringList list = d->packages(types); list.sort(); - foreach (const QString& package, list) { + foreach (const QString &package, list) { d->coutput(package); } exit(0); @@ -615,7 +616,7 @@ void PlasmaPkgPrivate::listTypes() foreach (const QString &file, desktopFiles) { // extract the type KConfig config(file, KConfig::SimpleConfig); - #warning "read config here" +#warning "read config here" // structure.read(&config); // get the name based on the rc file name, just as Plasma::PackageStructure does const QString name = file.left(file.length() - 2); diff --git a/src/plasmapkg/plasmapkg.h b/src/plasmapkg/plasmapkg.h index d4411dff1..3383980db 100644 --- a/src/plasmapkg/plasmapkg.h +++ b/src/plasmapkg/plasmapkg.h @@ -35,21 +35,21 @@ class PlasmaPkg : public QCoreApplication { Q_OBJECT - public: - PlasmaPkg(int& argc, char** argv, QCommandLineParser *parser); - virtual ~PlasmaPkg(); +public: + PlasmaPkg(int &argc, char **argv, QCommandLineParser *parser); + virtual ~PlasmaPkg(); - void listPackages(const QStringList &types); - void showPackageInfo(const QString &pluginName); - QString findPackageRoot(const QString &pluginName, const QString &prefix); + void listPackages(const QStringList &types); + void showPackageInfo(const QString &pluginName); + QString findPackageRoot(const QString &pluginName, const QString &prefix); - private Q_SLOTS: - void runMain(); - void packageInstalled(KJob *job); - void packageUninstalled(KJob *job); +private Q_SLOTS: + void runMain(); + void packageInstalled(KJob *job); + void packageUninstalled(KJob *job); - private: - PlasmaPkgPrivate* d; +private: + PlasmaPkgPrivate *d; }; } diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index fbdc88dea..0dd552ed3 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -67,10 +67,10 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) foreach (QObject *child, item->children()) { //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && + child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && + child->property("fillWidth").isValid() && child->property("fillHeight").isValid() + ) { layout = child; } } @@ -97,10 +97,10 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) foreach (QObject *child, q->children()) { //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && + child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && + child->property("fillWidth").isValid() && child->property("fillHeight").isValid() + ) { ownLayout = child; } } @@ -121,24 +121,24 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) //Here we can't use the new connect syntax because we can't link against QtQuick layouts QObject::connect(layout, SIGNAL(minimumWidthChanged()), - q, SLOT(minimumWidthChanged())); + q, SLOT(minimumWidthChanged())); QObject::connect(layout, SIGNAL(minimumHeightChanged()), - q, SLOT(minimumHeightChanged())); + q, SLOT(minimumHeightChanged())); QObject::connect(layout, SIGNAL(preferredWidthChanged()), - q, SLOT(preferredWidthChanged())); + q, SLOT(preferredWidthChanged())); QObject::connect(layout, SIGNAL(preferredHeightChanged()), - q, SLOT(preferredHeightChanged())); + q, SLOT(preferredHeightChanged())); QObject::connect(layout, SIGNAL(maximumWidthChanged()), - q, SLOT(maximumWidthChanged())); + q, SLOT(maximumWidthChanged())); QObject::connect(layout, SIGNAL(maximumHeightChanged()), - q, SLOT(maximumHeightChanged())); + q, SLOT(maximumHeightChanged())); QObject::connect(layout, SIGNAL(fillWidthChanged()), - q, SLOT(fillWidthChanged())); + q, SLOT(fillWidthChanged())); QObject::connect(layout, SIGNAL(fillHeightChanged()), - q, SLOT(fillHeightChanged())); + q, SLOT(fillHeightChanged())); representationLayout = layout; AppletQuickItemPrivate::ownLayout = ownLayout; @@ -191,17 +191,16 @@ QObject *AppletQuickItemPrivate::createFullRepresentationItem() emit q->fullRepresentationChanged(fullRepresentation.data()); } - if (!fullRepresentationItem) { return 0; } QQuickItem *graphicsObj = qobject_cast(fullRepresentationItem.data()); - QObject::connect (graphicsObj, &QQuickItem::widthChanged, [=]() { + QObject::connect(graphicsObj, &QQuickItem::widthChanged, [ = ]() { fullRepresentationResizeTimer.start(); }); - QObject::connect (graphicsObj, &QQuickItem::heightChanged, [=]() { + QObject::connect(graphicsObj, &QQuickItem::heightChanged, [ = ]() { fullRepresentationResizeTimer.start(); }); @@ -246,20 +245,20 @@ void AppletQuickItemPrivate::compactRepresentationCheck() } else { if (switchWidth > 0 && switchHeight > 0) { full = q->width() > switchWidth && q->height() > switchHeight; - //if a size to switch wasn't set, determine what representation to always chose + //if a size to switch wasn't set, determine what representation to always chose } else { //preferred representation set? if (preferredRepresentation) { full = preferredRepresentation.data() == fullRepresentation.data(); - //Otherwise, base on FormFactor + //Otherwise, base on FormFactor } else { full = (applet->formFactor() != Plasma::Types::Horizontal && applet->formFactor() != Plasma::Types::Vertical); } } if ((full && fullRepresentationItem && fullRepresentationItem.data() == currentRepresentationItem.data()) || - (!full && compactRepresentationItem && compactRepresentationItem.data() == currentRepresentationItem.data()) - ) { + (!full && compactRepresentationItem && compactRepresentationItem.data() == currentRepresentationItem.data()) + ) { return; } } @@ -294,7 +293,7 @@ void AppletQuickItemPrivate::compactRepresentationCheck() emit q->expandedChanged(true); } - //Icon + //Icon } else { QQuickItem *compactItem = qobject_cast(createCompactRepresentationItem()); QQuickItem *compactExpanderItem = qobject_cast(createCompactRepresentationExpanderItem()); @@ -321,7 +320,7 @@ void AppletQuickItemPrivate::compactRepresentationCheck() currentRepresentationItem = compactItem; connectLayoutAttached(compactItem); - + expanded = false; emit q->expandedChanged(false); } @@ -368,9 +367,6 @@ void AppletQuickItemPrivate::fillHeightChanged() propagateSizeHint("fillHeight"); } - - - AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent) : QQuickItem(parent), d(new AppletQuickItemPrivate(applet, this)) @@ -384,23 +380,21 @@ AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent) d->compactRepresentationCheckTimer.setSingleShot(true); d->compactRepresentationCheckTimer.setInterval(250); - connect (&d->compactRepresentationCheckTimer, SIGNAL(timeout()), - this, SLOT(compactRepresentationCheck())); + connect(&d->compactRepresentationCheckTimer, SIGNAL(timeout()), + this, SLOT(compactRepresentationCheck())); d->compactRepresentationCheckTimer.start(); d->fullRepresentationResizeTimer.setSingleShot(true); d->fullRepresentationResizeTimer.setInterval(250); - connect (&d->fullRepresentationResizeTimer, &QTimer::timeout, - [=]() { - if (!d->applet->isContainment()) { - KConfigGroup cg = d->applet->config(); - cg = KConfigGroup(&cg, "PopupApplet"); - cg.writeEntry("DialogWidth", d->fullRepresentationItem.data()->property("width").toInt()); - cg.writeEntry("DialogHeight", d->fullRepresentationItem.data()->property("height").toInt()); - } - }); - - + connect(&d->fullRepresentationResizeTimer, &QTimer::timeout, + [ = ]() { + if (!d->applet->isContainment()) { + KConfigGroup cg = d->applet->config(); + cg = KConfigGroup(&cg, "PopupApplet"); + cg.writeEntry("DialogWidth", d->fullRepresentationItem.data()->property("width").toInt()); + cg.writeEntry("DialogHeight", d->fullRepresentationItem.data()->property("height").toInt()); + } + }); d->qmlObject = new KDeclarative::QmlObject(this); d->qmlObject->setInitializationDelayed(true); @@ -420,7 +414,7 @@ AppletQuickItem::~AppletQuickItem() AppletQuickItemPrivate::s_rootObjects.remove(d->qmlObject->engine()); } - AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object) +AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object) { //at the moment of the attached object creation, the root item is the only one that hasn't a parent //only way to avoid creation of this attached for everybody but the root item @@ -461,7 +455,7 @@ void AppletQuickItem::init() QString reason; if (d->applet->package().isValid()) { foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) { - reason += error.toString()+'\n'; + reason += error.toString() + '\n'; } reason = i18n("Error loading QML file: %1", reason); } else { @@ -496,10 +490,10 @@ void AppletQuickItem::init() if (d->qmlObject->rootObject()) { QQuickItem *graphicsObj = qobject_cast(d->fullRepresentationItem.data()); - QObject::connect (graphicsObj, &QQuickItem::widthChanged, [=]() { + QObject::connect(graphicsObj, &QQuickItem::widthChanged, [ = ]() { d->fullRepresentationResizeTimer.start(); }); - QObject::connect (graphicsObj, &QQuickItem::heightChanged, [=]() { + QObject::connect(graphicsObj, &QQuickItem::heightChanged, [ = ]() { d->fullRepresentationResizeTimer.start(); }); } @@ -586,7 +580,6 @@ void AppletQuickItem::setCompactRepresentation(QQmlComponent *component) emit compactRepresentationChanged(component); } - QQmlComponent *AppletQuickItem::fullRepresentation() { return d->fullRepresentation.data(); @@ -637,8 +630,8 @@ void AppletQuickItem::setExpanded(bool expanded) if (expanded) { d->createFullRepresentationItem(); if (!d->applet->isContainment() && - (!d->preferredRepresentation || - d->preferredRepresentation.data() != d->fullRepresentation.data())) { + (!d->preferredRepresentation || + d->preferredRepresentation.data() != d->fullRepresentation.data())) { d->createCompactRepresentationExpanderItem(); } @@ -664,7 +657,6 @@ void AppletQuickItem::setExpanded(bool expanded) ////////////Internals - KDeclarative::QmlObject *AppletQuickItem::qmlObject() { return d->qmlObject; diff --git a/src/plasmaquick/appletquickitem.h b/src/plasmaquick/appletquickitem.h index 54249dfa2..269a7f7be 100644 --- a/src/plasmaquick/appletquickitem.h +++ b/src/plasmaquick/appletquickitem.h @@ -41,16 +41,18 @@ // We mean it. // -namespace Plasma { - class Applet; +namespace Plasma +{ +class Applet; } -namespace KDeclarative { - class QmlObject; +namespace KDeclarative +{ +class QmlObject; } - -namespace PlasmaQuick { +namespace PlasmaQuick +{ class AppletQuickItemPrivate; @@ -67,7 +69,6 @@ class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem Q_PROPERTY(QQmlComponent *fullRepresentation READ fullRepresentation WRITE setFullRepresentation NOTIFY fullRepresentationChanged) Q_PROPERTY(QObject *fullRepresentationItem READ fullRepresentationItem NOTIFY fullRepresentationItemChanged) - /** * this is supposed to be either one between compactRepresentation or fullRepresentation */ @@ -105,7 +106,6 @@ public: int switchHeight() const; void setSwitchHeight(int width); - QQmlComponent *compactRepresentation(); void setCompactRepresentation(QQmlComponent *component); @@ -121,7 +121,6 @@ public: ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static AppletQuickItem *qmlAttachedProperties(QObject *object); - Q_SIGNALS: //Property signals void switchWidthChanged(int width); @@ -143,8 +142,6 @@ protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); virtual void itemChange(ItemChange change, const ItemChangeData &value); - - private: AppletQuickItemPrivate *const d; @@ -163,5 +160,4 @@ private: QML_DECLARE_TYPEINFO(PlasmaQuick::AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES) - #endif diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index 26a8fba29..a452144d1 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -38,7 +38,8 @@ #include #include -namespace PlasmaQuick { +namespace PlasmaQuick +{ //////////////////////////////ConfigModel @@ -49,7 +50,7 @@ public: ~ConfigModelPrivate(); ConfigModel *q; - QList categories; + QList categories; QWeakPointer appletInterface; void appendCategory(ConfigCategory *c); @@ -153,7 +154,6 @@ QVariant ConfigModelPrivate::get(int row) const return value; } - ConfigModel::ConfigModel(QObject *parent) : QAbstractListModel(parent), d(new ConfigModelPrivate(this)) @@ -180,7 +180,7 @@ int ConfigModel::rowCount(const QModelIndex &index) const return d->categories.count(); } -QVariant ConfigModel::data(const QModelIndex& index, int role) const +QVariant ConfigModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= d->categories.count()) { return QVariant(); @@ -237,9 +237,9 @@ Plasma::Applet *ConfigModel::applet() const QQmlListProperty ConfigModel::categories() { return QQmlListProperty(this, 0, ConfigModelPrivate::categories_append, - ConfigModelPrivate::categories_count, - ConfigModelPrivate::categories_at, - ConfigModelPrivate::categories_clear); + ConfigModelPrivate::categories_count, + ConfigModelPrivate::categories_at, + ConfigModelPrivate::categories_clear); } diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index 7ac1a6e2a..3e0ddd093 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -20,7 +20,6 @@ #ifndef CONFIGMODEL_H #define CONFIGMODEL_H - #include #include @@ -37,8 +36,9 @@ // We mean it. // -namespace Plasma { - class Applet; +namespace Plasma +{ +class Applet; } namespace PlasmaQuick @@ -65,7 +65,7 @@ class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel public: enum Roles { - NameRole = Qt::UserRole+1, + NameRole = Qt::UserRole + 1, IconRole, SourceRole, PluginNameRole @@ -88,9 +88,12 @@ public: void setApplet(Plasma::Applet *interface); Plasma::Applet *applet() const; - int count() {return rowCount();} + int count() + { + return rowCount(); + } virtual int rowCount(const QModelIndex &index = QModelIndex()) const; - virtual QVariant data(const QModelIndex&, int) const; + virtual QVariant data(const QModelIndex &, int) const; /** * @param row the row for which the data will be returned diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index 11b1e0230..727291c0e 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -38,7 +38,6 @@ #include #include - namespace PlasmaQuick { @@ -76,14 +75,12 @@ void ConfigViewPrivate::init() q->setColor(Qt::transparent); q->setTitle(i18n("%1 Settings", applet.data()->title())); - if (!applet.data()->containment()->corona()->package().isValid()) { qWarning() << "Invalid home screen package"; } q->setResizeMode(QQuickView::SizeViewToRootObject); - //config model local of the applet QQmlComponent *component = new QQmlComponent(q->engine(), QUrl::fromLocalFile(applet.data()->package().filePath("configmodel")), q); QObject *object = component->beginCreate(q->engine()->rootContext()); @@ -94,14 +91,12 @@ void ConfigViewPrivate::init() delete object; } - q->engine()->rootContext()->setContextProperty("plasmoid", applet.data()->property("_plasma_graphicObject").value()); + q->engine()->rootContext()->setContextProperty("plasmoid", applet.data()->property("_plasma_graphicObject").value()); q->engine()->rootContext()->setContextProperty("configDialog", q); component->completeCreate(); delete component; } - - ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent) : QQuickView(parent), d(new ConfigViewPrivate(applet, this)) diff --git a/src/plasmaquick/configview.h b/src/plasmaquick/configview.h index b3bbffd3b..dccbf3cc8 100644 --- a/src/plasmaquick/configview.h +++ b/src/plasmaquick/configview.h @@ -20,7 +20,6 @@ #ifndef CONFIGVIEW_H #define CONFIGVIEW_H - #include #include @@ -36,8 +35,9 @@ // We mean it. // -namespace Plasma { - class Applet; +namespace Plasma +{ +class Applet; } namespace PlasmaQuick @@ -75,8 +75,8 @@ Q_SIGNALS: void appletGlobalShortcutChanged(); protected: - void hideEvent(QHideEvent *ev); - void resizeEvent(QResizeEvent *re); + void hideEvent(QHideEvent *ev); + void resizeEvent(QResizeEvent *re); private: ConfigViewPrivate *const d; diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index ffa63fc79..61997d022 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -51,7 +51,8 @@ namespace PlasmaQuick { -class DialogPrivate { +class DialogPrivate +{ public: DialogPrivate(Dialog *dialog) : q(dialog), @@ -70,7 +71,7 @@ public: Window }; - QScreen* screenForItem(QQuickItem *item) const; + QScreen *screenForItem(QQuickItem *item) const; void updateInputShape(); //SLOTS @@ -107,10 +108,10 @@ public: }; //find the screen which contains the item -QScreen* DialogPrivate::screenForItem(QQuickItem* item) const +QScreen *DialogPrivate::screenForItem(QQuickItem *item) const { const QPoint globalPosition = item->window()->mapToGlobal(item->position().toPoint()); - foreach(QScreen *screen, QGuiApplication::screens()) { + foreach (QScreen *screen, QGuiApplication::screens()) { if (screen->geometry().contains(globalPosition)) { return screen; } @@ -128,7 +129,7 @@ void DialogPrivate::syncBorders() // says it's at. QRect avail; QPoint pos = q->position(); - Q_FOREACH(QScreen *screen, q->screen()->virtualSiblings()) { + Q_FOREACH (QScreen *screen, q->screen()->virtualSiblings()) { if (screen->availableGeometry().contains(pos)) { avail = screen->availableGeometry(); break; @@ -164,10 +165,10 @@ void DialogPrivate::syncBorders() void DialogPrivate::updateContrast() { KWindowEffects::enableBackgroundContrast(q->winId(), theme.backgroundContrastEnabled(), - theme.backgroundContrast(), - theme.backgroundIntensity(), - theme.backgroundSaturation(), - frameSvgItem->frameSvg()->mask()); + theme.backgroundContrast(), + theme.backgroundIntensity(), + theme.backgroundSaturation(), + frameSvgItem->frameSvg()->mask()); } void DialogPrivate::updateVisibility(bool visible) @@ -212,7 +213,7 @@ void DialogPrivate::updateVisibility(bool visible) case Plasma::Types::BottomEdge: slideLocation = KWindowEffects::BottomEdge; break; - //no edge, no slide + //no edge, no slide default: break; } @@ -226,7 +227,7 @@ void DialogPrivate::updateVisibility(bool visible) if (type != Dialog::Normal) { KWindowSystem::setType(q->winId(), (NET::WindowType)type); } else { - q->setFlags(Qt::FramelessWindowHint|q->flags()); + q->setFlags(Qt::FramelessWindowHint | q->flags()); } if (type == Dialog::Dock) { KWindowSystem::setOnAllDesktops(q->winId(), true); @@ -405,9 +406,6 @@ void DialogPrivate::requestSizeSync(bool delayed) } } - - - Dialog::Dialog(QQuickItem *parent) : QQuickWindow(parent ? parent->window() : 0), d(new DialogPrivate(this)) @@ -423,16 +421,16 @@ Dialog::Dialog(QQuickItem *parent) d->syncTimer->setSingleShot(true); d->syncTimer->setInterval(0); connect(d->syncTimer, &QTimer::timeout, - [=]() { - if (d->resizeOrigin == DialogPrivate::MainItem) { - d->syncToMainItemSize(); - } else { - d->syncMainItemToSize(); - } - d->resizeOrigin = DialogPrivate::Undefined; - }); + [ = ]() { + if (d->resizeOrigin == DialogPrivate::MainItem) { + d->syncToMainItemSize(); + } else { + d->syncMainItemToSize(); + } + d->resizeOrigin = DialogPrivate::Undefined; + }); - connect(this, &QWindow::xChanged, [=]() { + connect(this, &QWindow::xChanged, [ = ]() { //Tooltips always have all the borders // floating windows have all borders if (!(flags() & Qt::ToolTip) && d->location != Plasma::Types::Floating) { @@ -440,7 +438,7 @@ Dialog::Dialog(QQuickItem *parent) d->requestSizeSync(true); } }); - connect(this, &QWindow::yChanged, [=]() { + connect(this, &QWindow::yChanged, [ = ]() { //Tooltips always have all the borders // floating windows have all borders if (!(flags() & Qt::ToolTip) && d->location != Plasma::Types::Floating) { @@ -490,13 +488,13 @@ void Dialog::setMainItem(QQuickItem *mainItem) mainItem->setProperty("parent", QVariant::fromValue(contentItem())); if (mainItem->metaObject()->indexOfSignal("widthChanged")) { - connect(mainItem, &QQuickItem::widthChanged, [=]() { + connect(mainItem, &QQuickItem::widthChanged, [ = ]() { d->resizeOrigin = DialogPrivate::MainItem; d->syncTimer->start(0); }); } if (mainItem->metaObject()->indexOfSignal("heightChanged")) { - connect(mainItem, &QQuickItem::heightChanged, [=]() { + connect(mainItem, &QQuickItem::heightChanged, [ = ]() { d->resizeOrigin = DialogPrivate::MainItem; d->syncTimer->start(0); }); @@ -512,10 +510,10 @@ void Dialog::setMainItem(QQuickItem *mainItem) foreach (QObject *child, mainItem->children()) { //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && + child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && + child->property("fillWidth").isValid() && child->property("fillHeight").isValid() + ) { layout = child; } } @@ -572,20 +570,20 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) switch (d->location) { case Plasma::Types::TopEdge: - return QPoint(screen->availableGeometry().center().x() - size.width()/2, screen->availableGeometry().y()); + return QPoint(screen->availableGeometry().center().x() - size.width() / 2, screen->availableGeometry().y()); break; case Plasma::Types::LeftEdge: - return QPoint(screen->availableGeometry().x(), screen->availableGeometry().center().y() - size.height()/2); + return QPoint(screen->availableGeometry().x(), screen->availableGeometry().center().y() - size.height() / 2); break; case Plasma::Types::RightEdge: - return QPoint(screen->availableGeometry().right() - size.width(), screen->availableGeometry().center().y() - size.height()/2); + return QPoint(screen->availableGeometry().right() - size.width(), screen->availableGeometry().center().y() - size.height() / 2); break; case Plasma::Types::BottomEdge: - return QPoint(screen->availableGeometry().center().x() - size.width()/2, screen->availableGeometry().bottom() -size.height()); + return QPoint(screen->availableGeometry().center().x() - size.width() / 2, screen->availableGeometry().bottom() - size.height()); break; - //Default center in the screen + //Default center in the screen default: - return screen->geometry().center() - QPoint(size.width()/2, size.height()/2); + return screen->geometry().center() - QPoint(size.width() / 2, size.height() / 2); } } else { return QPoint(); @@ -611,16 +609,16 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) parentGeometryBounds = QRect(pos.toPoint(), QSize(item->width(), item->height())); } - const QPoint topPoint(pos.x() + (item->boundingRect().width() - size.width())/2, - parentGeometryBounds.top() - size.height()); - const QPoint bottomPoint(pos.x() + (item->boundingRect().width() - size.width())/2, + const QPoint topPoint(pos.x() + (item->boundingRect().width() - size.width()) / 2, + parentGeometryBounds.top() - size.height()); + const QPoint bottomPoint(pos.x() + (item->boundingRect().width() - size.width()) / 2, parentGeometryBounds.bottom()); const QPoint leftPoint(parentGeometryBounds.left() - size.width(), - pos.y() + (item->boundingRect().height() - size.height())/2); + pos.y() + (item->boundingRect().height() - size.height()) / 2); const QPoint rightPoint(parentGeometryBounds.right(), - pos.y() + (item->boundingRect().height() - size.height())/2); + pos.y() + (item->boundingRect().height() - size.height()) / 2); QPoint dialogPos; if (d->location == Plasma::Types::TopEdge) { @@ -709,7 +707,6 @@ void Dialog::setLocation(Plasma::Types::Location location) d->requestSizeSync(); } - QObject *Dialog::margins() const { return d->frameSvgItem->margins(); @@ -717,7 +714,7 @@ QObject *Dialog::margins() const void Dialog::setFramelessFlags(Qt::WindowFlags flags) { - setFlags(Qt::FramelessWindowHint|flags); + setFlags(Qt::FramelessWindowHint | flags); emit flagsChanged(); } @@ -746,7 +743,7 @@ void Dialog::setType(WindowType type) if (d->type != Normal) { KWindowSystem::setType(winId(), (NET::WindowType)type); } else { - setFlags(Qt::FramelessWindowHint|flags()); + setFlags(Qt::FramelessWindowHint | flags()); } if (type == Tooltip) { @@ -777,7 +774,7 @@ void Dialog::focusInEvent(QFocusEvent *ev) void Dialog::focusOutEvent(QFocusEvent *ev) { if (d->hideOnWindowDeactivate) { - qDebug( ) << "DIALOG: hiding dialog."; + qDebug() << "DIALOG: hiding dialog."; setVisible(false); } QQuickWindow::focusOutEvent(ev); diff --git a/src/plasmaquick/dialog.h b/src/plasmaquick/dialog.h index 71ce8582a..1e39177a5 100644 --- a/src/plasmaquick/dialog.h +++ b/src/plasmaquick/dialog.h @@ -47,8 +47,8 @@ class QQuickItem; class QScreen; - -namespace PlasmaQuick { +namespace PlasmaQuick +{ class DialogPrivate; diff --git a/src/plasmaquick/dialogshadows.cpp b/src/plasmaquick/dialogshadows.cpp index 0a19df6db..db408aed6 100644 --- a/src/plasmaquick/dialogshadows.cpp +++ b/src/plasmaquick/dialogshadows.cpp @@ -2,7 +2,7 @@ * Copyright 2011 by Aaron Seigo * * This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU Library General Public License version 2, +* it under the terms of the GNU Library General Public License version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -39,8 +39,8 @@ public: Private(DialogShadows *shadows) : q(shadows) #if HAVE_X11 - ,_connection( 0x0 ), - _gc( 0x0 ) + , _connection(0x0), + _gc(0x0) , m_isX11(QX11Info::isPlatformX11()) #endif { @@ -56,7 +56,7 @@ public: void freeX11Pixmaps(); void clearPixmaps(); void setupPixmaps(); - Qt::HANDLE createPixmap(const QPixmap& source); + Qt::HANDLE createPixmap(const QPixmap &source); void initPixmap(const QString &element); QPixmap initEmptyPixmap(const QSize &size); void updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders); @@ -78,7 +78,7 @@ public: #if HAVE_X11 //! xcb connection - xcb_connection_t* _connection; + xcb_connection_t *_connection; //! graphical context xcb_gcontext_t _gc; @@ -96,7 +96,7 @@ public: { } - DialogShadows self; + DialogShadows self; }; Q_GLOBAL_STATIC(DialogShadowsSingleton, privateDialogShadowsSelf) @@ -164,11 +164,13 @@ void DialogShadows::Private::updateShadows() } } -Qt::HANDLE DialogShadows::Private::createPixmap(const QPixmap& source) +Qt::HANDLE DialogShadows::Private::createPixmap(const QPixmap &source) { // do nothing for invalid pixmaps - if( source.isNull() ) return 0; + if (source.isNull()) { + return 0; + } /* in some cases, pixmap handle is invalid. This is the case notably @@ -176,51 +178,52 @@ Qt::HANDLE DialogShadows::Private::createPixmap(const QPixmap& source) explicitly and draw the source pixmap on it. */ - #if HAVE_X11 +#if HAVE_X11 if (!m_isX11) { return 0; } - - // check connection - if( !_connection ) _connection = QX11Info::connection(); - - const int width( source.width() ); - const int height( source.height() ); + + // check connection + if (!_connection) { + _connection = QX11Info::connection(); + } + + const int width(source.width()); + const int height(source.height()); // create X11 pixmap - Pixmap pixmap = XCreatePixmap( QX11Info::display(), QX11Info::appRootWindow(), width, height, 32 ); + Pixmap pixmap = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), width, height, 32); // check gc - if( !_gc ) - { - _gc = xcb_generate_id( _connection ); - xcb_create_gc( _connection, _gc, pixmap, 0, 0x0 ); + if (!_gc) { + _gc = xcb_generate_id(_connection); + xcb_create_gc(_connection, _gc, pixmap, 0, 0x0); } - + // // create explicitly shared QPixmap from it // QPixmap dest( QPixmap::fromX11Pixmap( pixmap, QPixmap::ExplicitlyShared ) ); -// +// // // create surface for pixmap // { // QPainter painter( &dest ); // painter.setCompositionMode( QPainter::CompositionMode_Source ); // painter.drawPixmap( 0, 0, source ); // } -// -// +// +// // return pixmap; - QImage image( source.toImage() ); + QImage image(source.toImage()); xcb_put_image( _connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap, _gc, image.width(), image.height(), 0, 0, - 0, 32, + 0, 32, image.byteCount(), image.constBits()); - + return (Qt::HANDLE)pixmap; - - #else + +#else return 0; - #endif +#endif } @@ -258,7 +261,7 @@ void DialogShadows::Private::setupPixmaps() initPixmap("shadow-left"); initPixmap("shadow-topleft"); - m_emptyCornerPix = initEmptyPixmap(QSize(1,1)); + m_emptyCornerPix = initEmptyPixmap(QSize(1, 1)); m_emptyCornerLeftPix = initEmptyPixmap(QSize(q->elementSize("shadow-topleft").width(), 1)); m_emptyCornerTopPix = initEmptyPixmap(QSize(1, q->elementSize("shadow-topleft").height())); m_emptyCornerRightPix = initEmptyPixmap(QSize(q->elementSize("shadow-bottomright").width(), 1)); @@ -268,7 +271,6 @@ void DialogShadows::Private::setupPixmaps() } - void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders) { #if HAVE_X11 @@ -284,7 +286,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB //shadow-topright if (enabledBorders & Plasma::FrameSvg::TopBorder && - enabledBorders & Plasma::FrameSvg::RightBorder) { + enabledBorders & Plasma::FrameSvg::RightBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_shadowPixmaps[1])); } else if (enabledBorders & Plasma::FrameSvg::TopBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_emptyCornerTopPix)); @@ -303,7 +305,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB //shadow-bottomright if (enabledBorders & Plasma::FrameSvg::BottomBorder && - enabledBorders & Plasma::FrameSvg::RightBorder) { + enabledBorders & Plasma::FrameSvg::RightBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_shadowPixmaps[3])); } else if (enabledBorders & Plasma::FrameSvg::BottomBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_emptyCornerBottomPix)); @@ -322,7 +324,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB //shadow-bottomleft if (enabledBorders & Plasma::FrameSvg::BottomBorder && - enabledBorders & Plasma::FrameSvg::LeftBorder) { + enabledBorders & Plasma::FrameSvg::LeftBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_shadowPixmaps[5])); } else if (enabledBorders & Plasma::FrameSvg::BottomBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_emptyCornerBottomPix)); @@ -341,7 +343,7 @@ void DialogShadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledB //shadow-topleft if (enabledBorders & Plasma::FrameSvg::TopBorder && - enabledBorders & Plasma::FrameSvg::LeftBorder) { + enabledBorders & Plasma::FrameSvg::LeftBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_shadowPixmaps[7])); } else if (enabledBorders & Plasma::FrameSvg::TopBorder) { data[enabledBorders] << reinterpret_cast(createPixmap(m_emptyCornerTopPix)); @@ -500,7 +502,7 @@ void DialogShadows::Private::clearShadow(const QWindow *window) bool DialogShadows::enabled() const { - return hasElement("shadow-left"); + return hasElement("shadow-left"); } #include "moc_dialogshadows_p.cpp" diff --git a/src/plasmaquick/dialogshadows_p.h b/src/plasmaquick/dialogshadows_p.h index d12869bfb..7e17c1208 100644 --- a/src/plasmaquick/dialogshadows_p.h +++ b/src/plasmaquick/dialogshadows_p.h @@ -2,7 +2,7 @@ * Copyright 2011 by Aaron Seigo * * This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU Library General Public License version 2, +* it under the terms of the GNU Library General Public License version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -24,7 +24,6 @@ #include "plasma/framesvg.h" #include "plasma/svg.h" - class DialogShadows : public Plasma::Svg { Q_OBJECT @@ -42,7 +41,7 @@ public: private: class Private; - Private * const d; + Private *const d; Q_PRIVATE_SLOT(d, void updateShadows()) Q_PRIVATE_SLOT(d, void windowDestroyed(QObject *deletedObject)) diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index 3cf4020c4..6355e7c7c 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -69,7 +69,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept } //TODO: security: permission for remote urls - if (!path.isLocalFile() ) { + if (!path.isLocalFile()) { return path; } @@ -85,9 +85,9 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept //tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml QString relativePath; foreach (const QString &prefix, m_package.contentsPrefixPaths()) { - if (path.path().startsWith(m_package.path()+prefix)) { + if (path.path().startsWith(m_package.path() + prefix)) { //obtain a string in the form ui/foo/bar/baz.qml - relativePath = path.path().mid(QString(m_package.path()+prefix).length()); + relativePath = path.path().mid(QString(m_package.path() + prefix).length()); break; } } @@ -105,7 +105,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept //qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename)); return QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename)); - //forbid to load random absolute paths + //forbid to load random absolute paths } else { foreach (const QString &allowed, m_allowedPaths) { //It's a private import @@ -128,7 +128,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept //qDebug() << "Trying" << platform; //search for a platformqml/ path sibling of this allowed path - const QString &platformPath = allowed+QStringLiteral("/../platformqml/")+platform+path.path().mid(allowed.length()); + const QString &platformPath = allowed + QStringLiteral("/../platformqml/") + platform + path.path().mid(allowed.length()); const QFile f(platformPath); //qDebug() << "Found a platform specific file:" << QUrl::fromLocalFile(platformPath)< #include -namespace PlasmaQuick { +namespace PlasmaQuick +{ ///////////////////////ConfigCategory @@ -65,7 +66,6 @@ void ConfigCategory::setName(const QString &name) emit nameChanged(); } - QString ConfigCategory::icon() const { return m_icon; @@ -81,7 +81,6 @@ void ConfigCategory::setIcon(const QString &icon) emit iconChanged(); } - QString ConfigCategory::source() const { return m_source; diff --git a/src/plasmaquick/private/configcategory_p.h b/src/plasmaquick/private/configcategory_p.h index 0d9f1e66f..23ea26ab2 100644 --- a/src/plasmaquick/private/configcategory_p.h +++ b/src/plasmaquick/private/configcategory_p.h @@ -33,10 +33,11 @@ // We mean it. // -namespace PlasmaQuick { +namespace PlasmaQuick +{ //This class represents a single row item of the ConfigModel model in a QML friendly manner. -//the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments +//the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments class ConfigCategory : public QObject { Q_OBJECT diff --git a/src/plasmaquick/private/packages.cpp b/src/plasmaquick/private/packages.cpp index cec78cfe6..92216ff64 100644 --- a/src/plasmaquick/private/packages.cpp +++ b/src/plasmaquick/private/packages.cpp @@ -27,7 +27,6 @@ #include - void LookAndFeelPackage::initPackage(Plasma::Package *package) { // http://community.kde.org/Plasma/lookAndFeelPackage# @@ -86,7 +85,6 @@ void QmlWallpaperPackage::initPackage(Plasma::Package *package) //FIXME: why setting it required doesn't work? //package->setRequired("mainscript", true); - QStringList platform = KDeclarative::KDeclarative::runtimePlatform(); if (!platform.isEmpty()) { QMutableStringListIterator it(platform); diff --git a/src/plasmaquick/private/packages.h b/src/plasmaquick/private/packages.h index 949af772f..7498832d0 100644 --- a/src/plasmaquick/private/packages.h +++ b/src/plasmaquick/private/packages.h @@ -25,8 +25,6 @@ #include #include - - class LookAndFeelPackage : public Plasma::PackageStructure { public: @@ -45,5 +43,4 @@ public: void initPackage(Plasma::Package *package); }; - #endif // LOOKANDFEELPACKAGE_H diff --git a/src/plasmaquick/shellpluginloader.cpp b/src/plasmaquick/shellpluginloader.cpp index 3d8d0a845..4f27c9bf6 100644 --- a/src/plasmaquick/shellpluginloader.cpp +++ b/src/plasmaquick/shellpluginloader.cpp @@ -21,7 +21,6 @@ #include "private/packages.h" - #include ShellPluginLoader::ShellPluginLoader() diff --git a/src/plasmaquick/view.cpp b/src/plasmaquick/view.cpp index 9932cae9f..fce5cedc4 100644 --- a/src/plasmaquick/view.cpp +++ b/src/plasmaquick/view.cpp @@ -94,18 +94,17 @@ void ViewPrivate::setContainment(Plasma::Containment *cont) if (cont) { cont->reactToScreenChange(); QObject::connect(cont, &Plasma::Containment::locationChanged, - q, &View::locationChanged); + q, &View::locationChanged); QObject::connect(cont, &Plasma::Containment::formFactorChanged, - q, &View::formFactorChanged); + q, &View::formFactorChanged); QObject::connect(cont, &Plasma::Containment::configureRequested, - q, &View::showConfigurationInterface); + q, &View::showConfigurationInterface); } else { return; } QQuickItem *graphicObject = qobject_cast(containment.data()->property("_plasma_graphicObject").value()); - if (graphicObject) { qDebug() << "using as graphic containment" << graphicObject << containment.data(); @@ -156,9 +155,6 @@ void ViewPrivate::showConfigurationInterface(Plasma::Applet *applet) configView.data()->show(); } - - - View::View(Plasma::Corona *corona, QWindow *parent) : QQuickView(parent), d(new ViewPrivate(corona, this)) @@ -169,9 +165,8 @@ View::View(Plasma::Corona *corona, QWindow *parent) setFormat(format); setColor(Qt::transparent); - QObject::connect(screen(), &QScreen::geometryChanged, - this, &View::screenGeometryChanged); + this, &View::screenGeometryChanged); if (!corona->package().isValid()) { qWarning() << "Invalid home screen package"; @@ -180,7 +175,7 @@ View::View(Plasma::Corona *corona, QWindow *parent) setResizeMode(View::SizeRootObjectToView); QObject::connect(corona, &Plasma::Corona::packageChanged, - this, &View::coronaPackageChanged); + this, &View::coronaPackageChanged); } View::~View() diff --git a/src/platformstatus/platformstatus.cpp b/src/platformstatus/platformstatus.cpp index f01acbce6..6c3e02598 100644 --- a/src/platformstatus/platformstatus.cpp +++ b/src/platformstatus/platformstatus.cpp @@ -35,8 +35,8 @@ void PlatformStatus::findShellPackage(bool sendSignal) const QString package = group.readEntry("shellPackage", defaultPackage); const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - "plasma/shells/" + package + '/', - QStandardPaths::LocateDirectory); + "plasma/shells/" + package + '/', + QStandardPaths::LocateDirectory); if (path.isEmpty()) { if (package != defaultPackage) { group.deleteEntry("ShellPackage"); diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index dfa1c6d16..f36270c87 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -48,9 +48,7 @@ #include #include - - -Q_DECLARE_METATYPE(AppletInterface*) +Q_DECLARE_METATYPE(AppletInterface *) AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent) : AppletQuickItem(script->applet(), parent), @@ -146,12 +144,12 @@ void AppletInterface::init() applet()->updateConstraints(Plasma::Types::UiReadyConstraint); connect(applet(), &Plasma::Applet::activated, - [=] () { - setExpanded(true); - if (QQuickItem *i = qobject_cast(fullRepresentationItem())) { - i->forceActiveFocus(Qt::ShortcutFocusReason); - } - }); + [ = ]() { + setExpanded(true); + if (QQuickItem *i = qobject_cast(fullRepresentationItem())) { + i->forceActiveFocus(Qt::ShortcutFocusReason); + } + }); } Plasma::Types::FormFactor AppletInterface::formFactor() const @@ -173,7 +171,7 @@ QString AppletInterface::currentActivity() const } } -QObject* AppletInterface::configuration() const +QObject *AppletInterface::configuration() const { return m_configuration; } @@ -315,9 +313,9 @@ QString AppletInterface::file(const QString &fileType, const QString &filePath) return appletScript()->filePath(fileType, filePath); } -QList AppletInterface::contextualActions() const +QList AppletInterface::contextualActions() const { - QList actions; + QList actions; Plasma::Applet *a = applet(); if (a->failedToLaunch()) { return actions; @@ -426,7 +424,6 @@ int AppletInterface::apiVersion() const return offers.first()->property("X-KDE-PluginInfo-Version", QVariant::Int).toInt(); } - void AppletInterface::setAssociatedApplication(const QString &string) { applet()->setAssociatedApplication(string); @@ -474,7 +471,7 @@ QKeySequence AppletInterface::globalShortcut() const return applet()->globalShortcut(); } -void AppletInterface::setGlobalShortcut(const QKeySequence& sequence) +void AppletInterface::setGlobalShortcut(const QKeySequence &sequence) { applet()->setGlobalShortcut(sequence); } @@ -501,13 +498,13 @@ QStringList AppletInterface::downloadedFiles() const void AppletInterface::executeAction(const QString &name) { if (qmlObject()->rootObject()) { - const QMetaObject *metaObj = qmlObject()->rootObject()->metaObject(); - QString actionMethodName = QString("action_" + name); - if (metaObj->indexOfMethod(QMetaObject::normalizedSignature((actionMethodName + "()").toLatin1())) != -1){ - QMetaObject::invokeMethod(qmlObject()->rootObject(), actionMethodName.toLatin1(), Qt::DirectConnection); - }else{ - QMetaObject::invokeMethod(qmlObject()->rootObject(), "actionTriggered", Qt::DirectConnection, Q_ARG(QVariant, name)); - } + const QMetaObject *metaObj = qmlObject()->rootObject()->metaObject(); + QString actionMethodName = QString("action_" + name); + if (metaObj->indexOfMethod(QMetaObject::normalizedSignature((actionMethodName + "()").toLatin1())) != -1) { + QMetaObject::invokeMethod(qmlObject()->rootObject(), actionMethodName.toLatin1(), Qt::DirectConnection); + } else { + QMetaObject::invokeMethod(qmlObject()->rootObject(), "actionTriggered", Qt::DirectConnection, Q_ARG(QVariant, name)); + } } } diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 31da8ec7e..2510b11e7 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -39,14 +39,15 @@ class QSizeF; class ConfigView; -namespace KDeclarative { - class ConfigPropertyMap; - class QmlObject; +namespace KDeclarative +{ +class ConfigPropertyMap; +class QmlObject; } namespace Plasma { - class ConfigLoader; +class ConfigLoader; } // namespace Plasma class AppletInterface : public PlasmaQuick::AppletQuickItem @@ -112,7 +113,7 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem /** * Configuration object: each config key will be a writable property of this object. property bindings work. */ - Q_PROPERTY(QObject* configuration READ configuration CONSTANT) + Q_PROPERTY(QObject *configuration READ configuration CONSTANT) /** * When true the plasmoid is busy. The containment may graphically indicate that drawing for instance a spinner busy widget over it @@ -140,7 +141,7 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem Q_PROPERTY(Plasma::Types::ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) /** - * Sets the associated application of this plasmoid, if the plasmoid is representing the "compact" view for some application or for some document type. + * Sets the associated application of this plasmoid, if the plasmoid is representing the "compact" view for some application or for some document type. * TODO: a way to set associated application urls. */ Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication) @@ -175,7 +176,7 @@ public: DeclarativeAppletScript *appletScript() const; - QList contextualActions() const; + QList contextualActions() const; void executeAction(const QString &name); @@ -259,7 +260,7 @@ public: QString currentActivity() const; - QObject* configuration() const; + QObject *configuration() const; bool isBusy() const; void setBusy(bool busy); @@ -300,7 +301,6 @@ Q_SIGNALS: */ void activated(); - //PROPERTY change notifiers-------------- void iconChanged(); void titleChanged(); @@ -332,7 +332,6 @@ private: //UI-specific members ------------------ - QString m_toolTipMainText; QString m_toolTipSubText; Plasma::Types::BackgroundHints m_backgroundHints; diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 56ce9fbaf..481855899 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -66,23 +66,23 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) connect(containment(), &Plasma::Containment::activityChanged, this, &ContainmentInterface::activityChanged); connect(containment(), &Plasma::Containment::activityChanged, - [=]() { - delete m_activityInfo; - m_activityInfo = new KActivities::Info(containment()->activity(), this); - connect(m_activityInfo, &KActivities::Info::nameChanged, - this, &ContainmentInterface::activityNameChanged); - emit activityNameChanged(); - }); + [ = ]() { + delete m_activityInfo; + m_activityInfo = new KActivities::Info(containment()->activity(), this); + connect(m_activityInfo, &KActivities::Info::nameChanged, + this, &ContainmentInterface::activityNameChanged); + emit activityNameChanged(); + }); connect(containment(), &Plasma::Containment::wallpaperChanged, this, &ContainmentInterface::loadWallpaper); connect(containment(), &Plasma::Containment::containmentTypeChanged, this, &ContainmentInterface::containmentTypeChanged); - if (containment()->corona()) { - connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, - this, &ContainmentInterface::availableScreenRegionChanged); - connect(containment()->corona(), &Plasma::Corona::availableScreenRectChanged, - this, &ContainmentInterface::availableScreenRectChanged); + if (containment()->corona()) { + connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, + this, &ContainmentInterface::availableScreenRegionChanged); + connect(containment()->corona(), &Plasma::Corona::availableScreenRectChanged, + this, &ContainmentInterface::availableScreenRectChanged); } if (!m_appletInterfaces.isEmpty()) { @@ -216,7 +216,6 @@ Plasma::Applet *ContainmentInterface::addApplet(const QString &plugin, const QVa blockSignals(true); Plasma::Applet *applet = containment()->createApplet(plugin, args); - if (applet) { QObject *appletGraphicObject = applet->property("_plasma_graphicObject").value(); @@ -224,8 +223,9 @@ Plasma::Applet *ContainmentInterface::addApplet(const QString &plugin, const QVa emit appletAdded(appletGraphicObject, pos.x(), pos.y()); emit appletsChanged(); - } else + } else { blockSignals(false); + } return applet; } @@ -278,16 +278,14 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) KIO::MimetypeJob *job = KIO::mimetype(url, flags); m_dropPoints[job] = QPoint(x, y); - QObject::connect(job, SIGNAL(result(KJob*)), this, SLOT(dropJobResult(KJob*))); QObject::connect(job, SIGNAL(mimetype(KIO::Job*,QString)), - this, SLOT(mimeTypeRetrieved(KIO::Job*,QString))); + this, SLOT(mimeTypeRetrieved(KIO::Job*,QString))); QMenu *choices = new QMenu("Content dropped"); choices->addAction(QIcon::fromTheme("process-working"), i18n("Fetching file type...")); choices->popup(window() ? window()->mapToGlobal(QPoint(x, y)) : QPoint(x, y)); - m_dropMenus[job] = choices; #endif } @@ -360,7 +358,7 @@ void ContainmentInterface::clearDataForMimeJob(KIO::Job *job) void ContainmentInterface::dropJobResult(KJob *job) { #ifndef PLASMA_NO_KIO - KIO::TransferJob* tjob = dynamic_cast(job); + KIO::TransferJob *tjob = dynamic_cast(job); if (!tjob) { qDebug() << "job is not a KIO::TransferJob, won't handle the drop..."; clearDataForMimeJob(tjob); @@ -379,7 +377,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet { #ifndef PLASMA_NO_KIO qDebug() << "Mimetype Job returns." << mimetype; - KIO::TransferJob* tjob = dynamic_cast(job); + KIO::TransferJob *tjob = dynamic_cast(job); if (!tjob) { qDebug() << "job should be a TransferJob, but isn't"; clearDataForMimeJob(job); @@ -409,7 +407,6 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet return; } - qDebug() << "Creating menu for:" << mimetype << posi; appletList << Plasma::PluginLoader::self()->listAppletInfoForMimeType(mimetype); @@ -495,8 +492,6 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet #endif // PLASMA_NO_KIO } - - void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) { if (!applet) { @@ -536,7 +531,7 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) void ContainmentInterface::loadWallpaper() { if (containment()->containmentType() != Plasma::Types::DesktopContainment && - containment()->containmentType() != Plasma::Types::CustomContainment) { + containment()->containmentType() != Plasma::Types::CustomContainment) { return; } @@ -575,12 +570,12 @@ QString ContainmentInterface::activityName() const return m_activityInfo->name(); } -QList ContainmentInterface::actions() const +QList ContainmentInterface::actions() const { //FIXME: giving directly a QList crashes //use a multimap to sort by action type - QMultiMap actions; + QMultiMap actions; foreach (QAction *a, containment()->actions()->actions()) { if (a->isEnabled()) { actions.insert(a->data().toInt(), a); @@ -601,9 +596,6 @@ QList ContainmentInterface::actions() const return actions.values(); } - - - //PROTECTED-------------------- void ContainmentInterface::mousePressEvent(QMouseEvent *event) @@ -621,7 +613,6 @@ void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event) return; } - //the plugin can be a single action or a context menu //Don't have an action list? execute as single action //and set the event position as action data @@ -657,7 +648,7 @@ void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event) //this is a workaround where Qt now creates the menu widget //in .exec before oxygen can polish it and set the following attribute - desktopMenu.setAttribute( Qt::WA_TranslucentBackground ); + desktopMenu.setAttribute(Qt::WA_TranslucentBackground); //end workaround desktopMenu.exec(event->globalPos()); @@ -680,8 +671,6 @@ void ContainmentInterface::wheelEvent(QWheelEvent *event) } } - - void ContainmentInterface::addAppletActions(QMenu &desktopMenu, Plasma::Applet *applet, QEvent *event) { foreach (QAction *action, applet->contextualActions()) { @@ -747,7 +736,7 @@ void ContainmentInterface::addAppletActions(QMenu &desktopMenu, Plasma::Applet * void ContainmentInterface::addContainmentActions(QMenu &desktopMenu, QEvent *event) { if (containment()->corona()->immutability() != Plasma::Types::Mutable && - !KAuthorized::authorizeKAction("plasma/containment_actions")) { + !KAuthorized::authorizeKAction("plasma/containment_actions")) { //qDebug() << "immutability"; return; } @@ -770,22 +759,20 @@ void ContainmentInterface::addContainmentActions(QMenu &desktopMenu, QEvent *eve plugin->restore(pluginConfig); } - - QList actions = plugin->contextualActions(); + QList actions = plugin->contextualActions(); if (actions.isEmpty()) { //it probably didn't bother implementing the function. give the user a chance to set //a better plugin. note that if the user sets no-plugin this won't happen... if ((containment()->containmentType() != Plasma::Types::PanelContainment && - containment()->containmentType() != Plasma::Types::CustomPanelContainment) && - containment()->actions()->action("configure")) { + containment()->containmentType() != Plasma::Types::CustomPanelContainment) && + containment()->actions()->action("configure")) { desktopMenu.addAction(containment()->actions()->action("configure")); } } else { desktopMenu.addActions(actions); } - return; } diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 4339af793..cca5cfb04 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -30,12 +30,14 @@ class QmlObject; class WallpaperInterface; -namespace KIO { - class Job; +namespace KIO +{ +class Job; } -namespace KActivities { - class Info; +namespace KActivities +{ +class Info; } class ContainmentInterface : public AppletInterface @@ -46,7 +48,7 @@ class ContainmentInterface : public AppletInterface * List of applets this containment has: the containments */ Q_PROPERTY(QList applets READ applets NOTIFY appletsChanged) - + /** * Type of this containment TODO: notify */ @@ -65,14 +67,20 @@ class ContainmentInterface : public AppletInterface /** * Actions associated to this containment or corona */ - Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) + Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) public: ContainmentInterface(DeclarativeAppletScript *parent); //Not for QML - Plasma::Containment *containment() const { return static_cast(appletScript()->applet()->containment()); } + Plasma::Containment *containment() const + { + return static_cast(appletScript()->applet()->containment()); + } - inline WallpaperInterface *wallpaperInterface() const { return m_wallpaperInterface;} + inline WallpaperInterface *wallpaperInterface() const + { + return m_wallpaperInterface; + } //For QML use QList applets(); @@ -83,7 +91,7 @@ public: QString activity() const; QString activityName() const; - QList actions() const; + QList actions() const; /** * FIXME: either a property or not accessible at all. Lock or unlock widgets @@ -168,8 +176,8 @@ private: WallpaperInterface *m_wallpaperInterface; QList m_appletInterfaces; - QHash m_dropPoints; - QHash m_dropMenus; + QHash m_dropPoints; + QHash m_dropMenus; KActivities::Info *m_activityInfo; }; diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index 89fecdd2d..765e958bf 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -46,10 +46,8 @@ #include #include - K_EXPORT_PLASMA_APPLETSCRIPTENGINE(declarativeappletscript, DeclarativeAppletScript) - DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args) : Plasma::AppletScript(parent), m_interface(0) @@ -59,12 +57,12 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant /*qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Plasmoid", QLatin1String("Do not create objects of type Plasmoid"));*/ qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Plasmoid", - QLatin1String("Do not create objects of type Plasmoid")); + QLatin1String("Do not create objects of type Plasmoid")); qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Containment", - QLatin1String("Do not create objects of type Containment")); + QLatin1String("Do not create objects of type Containment")); qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Wallpaper", - QLatin1String("Do not create objects of type Wallpaper")); + QLatin1String("Do not create objects of type Wallpaper")); qmlRegisterType(); Q_UNUSED(args); @@ -86,7 +84,7 @@ bool DeclarativeAppletScript::init() if (pc && pc->isContainment()) { m_interface = new ContainmentInterface(this); - //fail? so it's a normal Applet + //fail? so it's a normal Applet } else { m_interface = new AppletInterface(this); } @@ -121,7 +119,7 @@ void DeclarativeAppletScript::executeAction(const QString &name) m_interface->executeAction(name); } -QList DeclarativeAppletScript::contextualActions() +QList DeclarativeAppletScript::contextualActions() { if (!m_interface) { return QList(); @@ -130,6 +128,5 @@ QList DeclarativeAppletScript::contextualActions() return m_interface->contextualActions(); } - #include "declarativeappletscript.moc" diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.h b/src/scriptengines/qml/plasmoid/declarativeappletscript.h index c24e186ce..b139023d4 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.h +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.h @@ -38,7 +38,7 @@ public: QString filePath(const QString &type, const QString &file) const; - QList contextualActions(); + QList contextualActions(); void constraintsEvent(Plasma::Types::Constraints constraints); @@ -61,5 +61,4 @@ private: friend class ContainmentInterface; }; - #endif diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 7177b033b..a3a9b5134 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -111,7 +111,7 @@ Plasma::ConfigLoader *WallpaperInterface::configScheme() void WallpaperInterface::syncWallpaperPackage() { if (m_wallpaperPlugin == m_containmentInterface->containment()->wallpaper() && - m_qmlObject->rootObject()) { + m_qmlObject->rootObject()) { return; } @@ -144,8 +144,8 @@ void WallpaperInterface::syncWallpaperPackage() m_qmlObject->completeInitialization(); if (m_qmlObject->mainComponent() && - m_qmlObject->rootObject() && - !m_qmlObject->mainComponent()->isError()) { + m_qmlObject->rootObject() && + !m_qmlObject->mainComponent()->isError()) { m_qmlObject->rootObject()->setProperty("z", -1000); m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this)); @@ -168,7 +168,7 @@ void WallpaperInterface::syncWallpaperPackage() emit configurationChanged(); } -QList WallpaperInterface::contextualActions() const +QList WallpaperInterface::contextualActions() const { return m_actions->actions(); } @@ -183,7 +183,7 @@ bool WallpaperInterface::supportsMimetype(const QString &mimetype) const void WallpaperInterface::setUrl(const QUrl &url) { if (m_qmlObject->rootObject()) { - QMetaObject::invokeMethod(m_qmlObject->rootObject(), QString("setUrl").toLatin1(), Qt::DirectConnection, Q_ARG(QVariant, QVariant::fromValue(url))); + QMetaObject::invokeMethod(m_qmlObject->rootObject(), QString("setUrl").toLatin1(), Qt::DirectConnection, Q_ARG(QVariant, QVariant::fromValue(url))); } } @@ -243,7 +243,7 @@ QAction *WallpaperInterface::action(QString name) const void WallpaperInterface::executeAction(const QString &name) { if (m_qmlObject->rootObject()) { - QMetaObject::invokeMethod(m_qmlObject->rootObject(), QString("action_" + name).toLatin1(), Qt::DirectConnection); + QMetaObject::invokeMethod(m_qmlObject->rootObject(), QString("action_" + name).toLatin1(), Qt::DirectConnection); } } diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.h b/src/scriptengines/qml/plasmoid/wallpaperinterface.h index 58ec477de..bd70aa363 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.h +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.h @@ -25,8 +25,9 @@ #include -namespace Plasma { - class ConfigLoader; +namespace Plasma +{ +class ConfigLoader; } class KActionCollection; @@ -34,12 +35,12 @@ class KActionCollection; class ContainmentInterface; class QSignalMapper; -namespace KDeclarative { - class ConfigPropertyMap; - class QmlObject; +namespace KDeclarative +{ +class ConfigPropertyMap; +class QmlObject; } - class WallpaperInterface : public QQuickItem { Q_OBJECT @@ -58,7 +59,7 @@ public: * @return list of wallpapers */ static KPluginInfo::List listWallpaperInfoForMimetype(const QString &mimetype, - const QString &formFactor = QString()); + const QString &formFactor = QString()); Plasma::Package package() const; @@ -68,7 +69,7 @@ public: Plasma::ConfigLoader *configScheme(); - QList contextualActions() const; + QList contextualActions() const; bool supportsMimetype(const QString &mimetype) const; diff --git a/tests/dpi/dpitest.cpp b/tests/dpi/dpitest.cpp index 5c9137119..da1457e65 100644 --- a/tests/dpi/dpitest.cpp +++ b/tests/dpi/dpitest.cpp @@ -29,16 +29,16 @@ #include #include - namespace Plasma { -class DPITestPrivate { +class DPITestPrivate +{ public: QString pluginName; QCommandLineParser *parser; }; -DPITest::DPITest(int& argc, char** argv, QCommandLineParser *parser) : +DPITest::DPITest(int &argc, char **argv, QCommandLineParser *parser) : QApplication(argc, argv) { d = new DPITestPrivate; diff --git a/tests/dpi/dpitest.h b/tests/dpi/dpitest.h index a15a13fe6..469420586 100644 --- a/tests/dpi/dpitest.h +++ b/tests/dpi/dpitest.h @@ -34,15 +34,15 @@ class DPITest : public QApplication { Q_OBJECT - public: - DPITest(int& argc, char** argv, QCommandLineParser *parser); - virtual ~DPITest(); +public: + DPITest(int &argc, char **argv, QCommandLineParser *parser); + virtual ~DPITest(); - public Q_SLOTS: - void runMain(); +public Q_SLOTS: + void runMain(); - private: - DPITestPrivate* d; +private: + DPITestPrivate *d; }; } diff --git a/tests/kplugins/plugintest.cpp b/tests/kplugins/plugintest.cpp index ce424087e..f04781498 100644 --- a/tests/kplugins/plugintest.cpp +++ b/tests/kplugins/plugintest.cpp @@ -48,16 +48,16 @@ #include #include - namespace Plasma { -class PluginTestPrivate { +class PluginTestPrivate +{ public: QString pluginName; QCommandLineParser *parser; }; -PluginTest::PluginTest(int& argc, char** argv, QCommandLineParser *parser) : +PluginTest::PluginTest(int &argc, char **argv, QCommandLineParser *parser) : QApplication(argc, argv) { d = new PluginTestPrivate; @@ -95,7 +95,7 @@ bool PluginTest::loadKPlugin() QCoreApplication::addLibraryPath(pluginPath); //QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this); QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/plugins/kf5/kplugins/libplasma_engine_time.so", this); - KPluginFactory *factory = qobject_cast(loader.instance()); + KPluginFactory *factory = qobject_cast(loader.instance()); //QObject *factory = loader.instance(); if (factory) { qDebug() << "loaded successfully and cast"; @@ -132,7 +132,7 @@ bool PluginTest::loadFromKService(const QString &name) // load the engine, add it to the engines QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name); KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", - constraint); + constraint); QString error; if (offers.isEmpty()) { @@ -156,7 +156,6 @@ bool PluginTest::loadFromKService(const QString &name) return engine != 0; } - bool PluginTest::loadFromPlasma() { bool ok = false; @@ -176,7 +175,6 @@ bool PluginTest::loadFromPlasma() return ok; } - void PluginTest::loadKQPlugin() { qDebug() << "Load KQPlugin"; @@ -185,7 +183,7 @@ void PluginTest::loadKQPlugin() QCoreApplication::addLibraryPath(pluginPath); //QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this); QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/plugins/kf5/kplugins/libplasma_engine_time.so", this); - KPluginFactory *factory = qobject_cast(loader.instance()); + KPluginFactory *factory = qobject_cast(loader.instance()); //QObject *factory = loader.instance(); if (factory) { qDebug() << "loaded successfully and cast"; @@ -224,7 +222,7 @@ bool PluginTest::loadKService(const QString &name) QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name); constraint = QString(); KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", - constraint); + constraint); QString error; if (offers.isEmpty()) { diff --git a/tests/kplugins/plugintest.h b/tests/kplugins/plugintest.h index 1ad4aa988..c1af9fdbf 100644 --- a/tests/kplugins/plugintest.h +++ b/tests/kplugins/plugintest.h @@ -36,23 +36,23 @@ class PluginTest : public QApplication { Q_OBJECT - public: - PluginTest(int& argc, char** argv, QCommandLineParser *parser); - virtual ~PluginTest(); +public: + PluginTest(int &argc, char **argv, QCommandLineParser *parser); + virtual ~PluginTest(); - void showPackageInfo(const QString &pluginName); + void showPackageInfo(const QString &pluginName); - public Q_SLOTS: - void runMain(); - bool loadKPlugin(); - bool loadFromKService(const QString &name = "time"); - bool loadFromPlasma(); - void loadKQPlugin(); - bool loadKService(const QString &name = QString()); - void dataUpdated(QString s, Plasma::DataEngine::Data d); +public Q_SLOTS: + void runMain(); + bool loadKPlugin(); + bool loadFromKService(const QString &name = "time"); + bool loadFromPlasma(); + void loadKQPlugin(); + bool loadKService(const QString &name = QString()); + void dataUpdated(QString s, Plasma::DataEngine::Data d); - private: - PluginTestPrivate* d; +private: + PluginTestPrivate *d; }; } diff --git a/tests/testcontainmentactionsplugin/test.cpp b/tests/testcontainmentactionsplugin/test.cpp index f6302a7ef..182a37a68 100644 --- a/tests/testcontainmentactionsplugin/test.cpp +++ b/tests/testcontainmentactionsplugin/test.cpp @@ -32,11 +32,11 @@ ContextTest::ContextTest(QObject *parent, const QVariantList &args) { } -QList ContextTest::contextualActions() +QList ContextTest::contextualActions() { Plasma::Containment *c = containment(); Q_ASSERT(c); - QList actions; + QList actions; actions << c->actions()->action("configure"); return actions; @@ -57,7 +57,7 @@ void ContextTest::init(const KConfigGroup &config) m_text = config.readEntry("test-text", QString()); } -QWidget* ContextTest::createConfigurationInterface(QWidget* parent) +QWidget *ContextTest::createConfigurationInterface(QWidget *parent) { //m_currentText = m_text; QWidget *widget = new QWidget(parent); diff --git a/tests/testcontainmentactionsplugin/test.h b/tests/testcontainmentactionsplugin/test.h index c2e8761da..7c8a87a6b 100644 --- a/tests/testcontainmentactionsplugin/test.h +++ b/tests/testcontainmentactionsplugin/test.h @@ -27,24 +27,23 @@ class ContextTest : public Plasma::ContainmentActions { Q_OBJECT - public: - ContextTest(QObject* parent, const QVariantList& args); +public: + ContextTest(QObject *parent, const QVariantList &args); - void init(const KConfigGroup &config); + void init(const KConfigGroup &config); - QList contextualActions(); + QList contextualActions(); - void performNextAction(); - void performPreviousAction(); - - QWidget* createConfigurationInterface(QWidget* parent); - void configurationAccepted(); - void save(KConfigGroup &config); + void performNextAction(); + void performPreviousAction(); - private: - Ui::Config m_ui; - QString m_text; + QWidget *createConfigurationInterface(QWidget *parent); + void configurationAccepted(); + void save(KConfigGroup &config); + +private: + Ui::Config m_ui; + QString m_text; }; - #endif diff --git a/tests/testengine/testengine.cpp b/tests/testengine/testengine.cpp index 0a55c8bce..76947c36d 100644 --- a/tests/testengine/testengine.cpp +++ b/tests/testengine/testengine.cpp @@ -17,7 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - #include "testengine.h" #include @@ -34,25 +33,21 @@ #include #include - Q_DECLARE_METATYPE(TestEngine::MyUserType) - TestEngine::TestEngine(QObject *parent, const QVariantList &args) : Plasma::DataEngine(parent, args) { } // ctor() - TestEngine::~TestEngine() { } // dtor() - void TestEngine::init() { QString dsn("TestEngine"); - + // QVariant::Invalid // QVariant::BitArray setData(dsn, "QBitArray", QVariant(QBitArray(97, false))); @@ -64,7 +59,7 @@ void TestEngine::init() setData(dsn, "QBrush", QVariant(QBrush(Qt::SolidPattern))); // QVariant::ByteArray QByteArray byteArray; - for (int i=0; i<256; ++i) { + for (int i = 0; i < 256; ++i) { byteArray.append(i); } setData(dsn, "QByteArray1", QVariant(byteArray)); @@ -88,7 +83,7 @@ void TestEngine::init() // QVariant::Image setData(dsn, "QImage", QVariant(QImage(56, 78, QImage::Format_Mono))); // QVariant::Int - setData(dsn, "int", QVariant((int)-4321)); + setData(dsn, "int", QVariant((int) - 4321)); // QVariant::KeySequence (???) // QVariant::Line setData(dsn, "QLine", QVariant(QLine(12, 34, 56, 78))); @@ -101,10 +96,10 @@ void TestEngine::init() // QVariant::Locale setData(dsn, "QLocale", QVariant(QLocale("fr_FR"))); // QVariant::LongLong - setData(dsn, "qlonglong", QVariant((qlonglong)-4321)); + setData(dsn, "qlonglong", QVariant((qlonglong) - 4321)); // QVariant::Map QMap map; - for (int i=0; i<123; ++i) { + for (int i = 0; i < 123; ++i) { QString key = QString("key%1").arg(i); QString val = QString("value%1").arg(i); map[key] = val; @@ -166,7 +161,6 @@ void TestEngine::init() setData(dsn, "UserType", v); } // init() - bool TestEngine::sourceRequestEvent(const QString &source) { // Nothing to do... diff --git a/tests/testengine/testengine.h b/tests/testengine/testengine.h index 51f765989..b3b239044 100644 --- a/tests/testengine/testengine.h +++ b/tests/testengine/testengine.h @@ -24,10 +24,8 @@ #ifndef __TESTDATAENGINE_H__ #define __TESTDATAENGINE_H__ - #include "plasma/dataengine.h" - class TestEngine : public Plasma::DataEngine { Q_OBJECT @@ -46,7 +44,4 @@ protected: bool sourceRequestEvent(const QString &source); }; - - - #endif // __TESTDATAENGINE_H__