]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Krazy fixes
authorPeter Penz <peter.penz19@gmail.com>
Fri, 8 Jun 2012 20:07:59 +0000 (22:07 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 8 Jun 2012 20:08:29 +0000 (22:08 +0200)
14 files changed:
src/dolphinviewcontainer.cpp
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kitemmodelbase.h
src/kitemviews/kstandarditemlistgroupheader.cpp
src/kitemviews/private/kitemlistkeyboardsearchmanager.h
src/kitemviews/private/kitemlistsmoothscroller.h
src/kitemviews/private/knepomukrolesprovider.cpp
src/panels/places/placesitemmodel.cpp
src/panels/terminal/terminalpanel.cpp
src/tests/kfileitemmodeltest.cpp
src/tests/kitemlistcontrollertest.cpp
src/views/dolphinview.cpp
src/views/viewproperties.cpp

index 4d3f1983bc1dcdf6068ad35df6f1c18db769cddb..607cb33a7c9e85e44185499b581753f250f97f8f 100644 (file)
@@ -532,7 +532,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
     } else if (KProtocolManager::isSourceProtocol(url)) {
         QString app = "konqueror";
         if (url.protocol().startsWith(QLatin1String("http"))) {
-            showMessage(i18nc("@info:status",
+            showMessage(i18nc("@info:status", // krazy:exclude=qmethods
                               "Dolphin does not support web pages, the web browser has been launched"),
                         Information);
 
index 7e5d961d69e93008f481c42fd5ef44a08f05b3df..eec90065a4e59447756db5461631897c197631df 100644 (file)
@@ -938,7 +938,7 @@ void KFileItemModel::insertItems(const KFileItemList& items)
             insertedCount = 0;
         }
 
-        // Insert item at the position targetIndex by transfering
+        // Insert item at the position targetIndex by transferring
         // the ownership of the item-data from sortedItems to m_itemData.
         // m_items will be inserted after the loop (see comment below)
         m_itemData.insert(targetIndex, sortedItems.at(sourceIndex));
@@ -1920,7 +1920,7 @@ void KFileItemModel::determineMimeTypes(const KFileItemList& items, int timeout)
 {
     QElapsedTimer timer;
     timer.start();
-    foreach (KFileItem item, items) {
+    foreach (KFileItem item, items) { // krazy:exclude=foreach
         item.determineMimeType();
         if (timer.elapsed() > timeout) {
             // Don't block the user interface, let the remaining items
index bbb01247d1082d4841cd419818b82969ab6e6f46..5418c3f9ce624761188b8801d3e65f980e86ce88 100644 (file)
@@ -1070,10 +1070,10 @@ int KFileItemModelRolesUpdater::subItemsCount(const QString& path) const
 
     int count = -1;
     DIR* dir = ::opendir(QFile::encodeName(path));
-    if (dir) {
+    if (dir) {  // krazy:exclude=syscalls
         count = 0;
         struct dirent *dirEntry = 0;
-        while ((dirEntry = ::readdir(dir))) { // krazy:exclude=syscalls
+        while ((dirEntry = ::readdir(dir))) {
             if (dirEntry->d_name[0] == '.') {
                 if (dirEntry->d_name[1] == '\0' || !countHiddenFiles) {
                     // Skip "." or hidden files
index 129524b31d42e44ed0153b5b65fc2cb2d602c1f5..70f688390951986171a6f9fab75f4e28301f0263 100644 (file)
@@ -63,7 +63,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject
 
 public:
     KItemModelBase(QObject* parent = 0);
-    KItemModelBase(const QByteArray& sortRole, QObject* parent = 0);
+    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = 0);
     virtual ~KItemModelBase();
 
     /** @return The number of items. */
index 3a5ddd94430b8c11cc89a5693c1acb5f8af3b076..1e23c0a56a5a500166258f8d7cab21bf79be1808 100644 (file)
@@ -101,7 +101,7 @@ void KStandardItemListGroupHeader::updateCache()
     const qreal maxWidth = size().width() - 4 * styleOption().padding;
 
     if (role() == "rating") {
-        m_text = QString();
+        m_text = QString(); // krazy:exlude=nullstrassign
 
         const qreal height = styleOption().fontMetrics.ascent();
         const QSizeF pixmapSize(qMin(height * 5, maxWidth), height);
index 3731548c96f802fb3f72203c05dc7f8b9ba5aab6..661178db8b9f05faca14ecd23c83a7333014240c 100644 (file)
@@ -20,8 +20,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef KITEMLISTKEYBOARDMANAGER_H
-#define KITEMLISTKEYBOARDMANAGER_H
+#ifndef KITEMLISTKEYBOARDSEARCHMANAGER_H
+#define KITEMLISTKEYBOARDSEARCHMANAGER_H
 
 #include <libdolphin_export.h>
 
index 252c966c7a15deb4403772f4f044e383d54c68c8..ea56822085aaa1967a936a8db04f2f60bf722fbe 100644 (file)
@@ -38,8 +38,8 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListSmoothScroller : public QObject
     Q_OBJECT
 
 public:
-    KItemListSmoothScroller(QScrollBar* scrollBar,
-                            QObject* parent = 0);
+    explicit KItemListSmoothScroller(QScrollBar* scrollBar,
+                                     QObject* parent = 0);
     virtual ~KItemListSmoothScroller();
 
     void setScrollBar(QScrollBar* scrollBar);
index fffcd216d668f516c6fd0cc6b86ba5148b9aa5a0..0ae9b6bd3edf88ea48c40bb491ef9e57148b8062 100644 (file)
@@ -79,9 +79,9 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res
             // Merge the two Nepomuk properties for width and height
             // as one string into the "imageSize" role
             const QString uri = property.uri().toString();
-            if (uri.endsWith("#width")) {
+            if (uri.endsWith(QLatin1String("#width"))) {
                 width = value.toInt();
-            } else if (uri.endsWith("#height")) {
+            } else if (uri.endsWith(QLatin1String("#height"))) {
                 height = value.toInt();
             }
 
index a0358cb4326517e7f69193288d51bc59aac47019..5d89dfa7febdfc93f28a498827153c8f0610bbe2 100644 (file)
@@ -1082,21 +1082,21 @@ KUrl PlacesItemModel::createTimelineUrl(const KUrl& url)
     KUrl timelineUrl;
 
     const QString path = url.pathOrUrl();
-    if (path.endsWith("yesterday")) {
+    if (path.endsWith(QLatin1String("yesterday"))) {
         const QDate date = QDate::currentDate().addDays(-1);
         const int year = date.year();
         const int month = date.month();
         const int day = date.day();
         timelineUrl = "timeline:/" + timelineDateString(year, month) +
               '/' + timelineDateString(year, month, day);
-    } else if (path.endsWith("thismonth")) {
+    } else if (path.endsWith(QLatin1String("thismonth"))) {
         const QDate date = QDate::currentDate();
         timelineUrl = "timeline:/" + timelineDateString(date.year(), date.month());
-    } else if (path.endsWith("lastmonth")) {
+    } else if (path.endsWith(QLatin1String("lastmonth"))) {
         const QDate date = QDate::currentDate().addMonths(-1);
         timelineUrl = "timeline:/" + timelineDateString(date.year(), date.month());
     } else {
-        Q_ASSERT(path.endsWith("today"));
+        Q_ASSERT(path.endsWith(QLatin1String("today")));
         timelineUrl= url;
     }
 
@@ -1128,14 +1128,14 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
 
 #ifdef HAVE_NEPOMUK
     const QString path = url.pathOrUrl();
-    if (path.endsWith("documents")) {
+    if (path.endsWith(QLatin1String("documents"))) {
         searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Document()));
-    } else if (path.endsWith("images")) {
+    } else if (path.endsWith(QLatin1String("images"))) {
         searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image()));
-    } else if (path.endsWith("audio")) {
+    } else if (path.endsWith(QLatin1String("audio"))) {
         searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
                                                                     Nepomuk::Query::LiteralTerm("audio")));
-    } else if (path.endsWith("videos")) {
+    } else if (path.endsWith(QLatin1String("videos"))) {
         searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
                                                                     Nepomuk::Query::LiteralTerm("video")));
     } else {
index dba67f1b407255f3ae27ae3261c20528dd410c0f..889c07e45fc8e4c5549c90c1926b420af19e83b7 100644 (file)
@@ -74,7 +74,7 @@ void TerminalPanel::dockVisibilityChanged()
         // signal, we have to update m_konsolePartCurrentDirectory manually. If this
         // was not done, showing the panel again might not set the part's working
         // directory correctly.
-        m_konsolePartCurrentDirectory = "/";
+        m_konsolePartCurrentDirectory = '/';
     }
 }
 
index e6bcb906eaa5f708562e28d7efb2ccff40a018a3..65c28ce757fa3d32225a298895a67f2bd41db872 100644 (file)
@@ -419,7 +419,7 @@ void KFileItemModelTest::testExpandItems()
 
     // Store the URLs of all folders in a set.
     QSet<KUrl> allFolders;
-    allFolders << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1");
+    allFolders << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1");
 
     m_model->loadDirectory(m_testDir->url());
     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
@@ -437,7 +437,7 @@ void KFileItemModelTest::testExpandItems()
     QVERIFY(m_model->isExpanded(0));
     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
     QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
-    QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + "a"));
+    QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a'));
 
     QCOMPARE(spyInserted.count(), 1);
     KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
@@ -453,7 +453,7 @@ void KFileItemModelTest::testExpandItems()
     QVERIFY(m_model->isExpanded(1));
     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
     QCOMPARE(m_model->count(), 4);  // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
-    QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + "a") << KUrl(m_testDir->name() + "a/a"));
+    QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a"));
 
     QCOMPARE(spyInserted.count(), 1);
     itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
@@ -482,7 +482,7 @@ void KFileItemModelTest::testExpandItems()
     m_model->setExpanded(0, false);
     QVERIFY(!m_model->isExpanded(0));
     QCOMPARE(m_model->count(), 1);
-    QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + "a"))); // TODO: Make sure that child URLs are also removed
+    QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + 'a'))); // TODO: Make sure that child URLs are also removed
 
     QCOMPARE(spyRemoved.count(), 1);
     itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
@@ -593,7 +593,7 @@ void KFileItemModelTest::testSorting()
     m_model->loadDirectory(m_testDir->url());
     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
 
-    int index = m_model->index(KUrl(m_testDir->url().url() + "c"));
+    int index = m_model->index(KUrl(m_testDir->url().url() + 'c'));
     m_model->setExpanded(index, true);
     QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
 
index 47b2b8b7593a344cfb63345a5e358b982ab697b8..2085dead6143101ad61f3222ace58ef51c0cd969 100644 (file)
@@ -210,7 +210,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
     groupingEnabledList.append(true);
     groupingEnabledNames[true] = "grouping enabled";
 
-    foreach (KFileItemListView::ItemLayout layout, layoutList) {
+    foreach (const KFileItemListView::ItemLayout& layout, layoutList) {
         // The following settings depend on the layout.
         // Note that 'columns' are actually 'rows' in
         // Compact layout.
@@ -249,8 +249,8 @@ void KItemListControllerTest::testKeyboardNavigation_data()
         }
 
         foreach (int columnCount, columnCountList) {
-            foreach (KItemListController::SelectionBehavior selectionBehavior, selectionBehaviorList) {
-                foreach (bool groupingEnabled, groupingEnabledList) {
+            foreach (const KItemListController::SelectionBehavior& selectionBehavior, selectionBehaviorList) {
+                foreach (bool groupingEnabled, groupingEnabledList) { // krazy:exclude=foreach
                     QList<QPair<KeyPress, ViewState> > testList;
 
                     // First, key presses which should have the same effect
index ff5c2988a2b4f37b537e2e9d51e38d3296030d7a..53f9b45bf8f148f67e8a322ea7b7baefb684a6c2 100644 (file)
@@ -1482,7 +1482,7 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const
     KUrl::List urls;
 
     const KFileItemList items = selectedItems();
-    foreach (const KFileItem &item, items) {
+    foreach (const KFileItemitem, items) {
         urls.append(item.url());
     }
 
@@ -1507,7 +1507,7 @@ void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
     KUrl::List destUrls;
     foreach (const KUrl& source, sourceUrls) {
-        KUrl destination(url().url() + "/" + source.fileName());
+        KUrl destination(url().url() + '/' + source.fileName());
         destUrls << destination;
     }
     markUrlsAsSelected(destUrls);
index 96a00dc1dc9939731fdea79c59c141d363018c3a..ff0c274bef5df435174429f5d149b0e8dcf23e0c 100644 (file)
@@ -284,7 +284,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
     roles.append("text");
 
     // Iterate through all stored keys and append all roles that match to
-    // the curren view mode.
+    // the current view mode.
     const QString prefix = viewModePrefix();
     const int prefixLength = prefix.length();
 
@@ -426,7 +426,7 @@ void ViewProperties::convertNameRoleToTextRole()
 {
     QStringList visibleRoles = m_node->visibleRoles();
     for (int i = 0; i < visibleRoles.count(); ++i) {
-        if (visibleRoles[i].endsWith("_name")) {
+        if (visibleRoles[i].endsWith(QLatin1String("_name"))) {
             const int leftLength = visibleRoles[i].length() - 5;
             visibleRoles[i] = visibleRoles[i].left(leftLength) + "_text";
         }