From 73cda7874a27bd72bf47159645bdf5190568fea2 Mon Sep 17 00:00:00 2001 From: Mailson Menezes Date: Mon, 2 Apr 2012 15:48:51 -0300 Subject: Remove unused code from UiFileSystemModel Change-Id: I0bda4c1fc086ec3f10e6de7a4aa818a814421b42 Reviewed-by: Daker Fernandes Pinheiro Reviewed-by: Anselmo L. S. Melo --- src/models/uifileinfogatherer.cpp | 12 ---- src/models/uifileinfogatherer_p.h | 8 --- src/models/uifilesystemmodel.cpp | 69 +--------------------- src/models/uifilesystemmodel.h | 9 --- src/models/uifilesystemmodel_p.h | 19 ------ .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 2 - 6 files changed, 1 insertion(+), 118 deletions(-) diff --git a/src/models/uifileinfogatherer.cpp b/src/models/uifileinfogatherer.cpp index 57d333e..cfbd046 100644 --- a/src/models/uifileinfogatherer.cpp +++ b/src/models/uifileinfogatherer.cpp @@ -118,17 +118,6 @@ bool UiFileInfoGatherer::resolveSymlinks() const return m_resolveSymlinks; } -//void UiFileInfoGatherer::setIconProvider(QFileIconProvider *provider) -//{ -// QMutexLocker locker(&mutex); -// m_iconProvider = provider; -//} - -//QFileIconProvider *UiFileInfoGatherer::iconProvider() const -//{ -// return m_iconProvider; -//} - /*! Fetch extended information for all \a files in \a path @@ -230,7 +219,6 @@ void UiFileInfoGatherer::run() UiExtendedInformation UiFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const { UiExtendedInformation info(fileInfo); -// info.icon = m_iconProvider->icon(fileInfo); info.displayType = _type(fileInfo); #ifndef QT_NO_FILESYSTEMWATCHER // ### Not ready to listen all modifications diff --git a/src/models/uifileinfogatherer_p.h b/src/models/uifileinfogatherer_p.h index 57dbcfc..9b6d628 100644 --- a/src/models/uifileinfogatherer_p.h +++ b/src/models/uifileinfogatherer_p.h @@ -57,7 +57,6 @@ #include #include #include -//#include #include #include #include @@ -137,14 +136,11 @@ public: } QString displayType; -// QIcon icon; private : QFileInfo mFileInfo; }; -//class QFileIconProvider; - #ifndef QT_NO_FILESYSTEMMODEL class Q_AUTOTEST_EXPORT UiFileInfoGatherer : public QThread @@ -171,8 +167,6 @@ public Q_SLOTS: void updateFile(const QString &path); void setResolveSymlinks(bool enable); bool resolveSymlinks() const; -// void setIconProvider(QFileIconProvider *provider); -// QFileIconProvider *iconProvider() const; protected: void run(); @@ -228,8 +222,6 @@ private: QFileSystemWatcher *watcher; #endif bool m_resolveSymlinks; -// QFileIconProvider *m_iconProvider; -// QFileIconProvider defaultProvider; #ifndef Q_OS_WIN uint userId; uint groupId; diff --git a/src/models/uifilesystemmodel.cpp b/src/models/uifilesystemmodel.cpp index 3af0262..7f8f4e0 100644 --- a/src/models/uifilesystemmodel.cpp +++ b/src/models/uifilesystemmodel.cpp @@ -45,8 +45,6 @@ #include #include #include -#include -#include #ifdef Q_OS_WIN # include @@ -59,7 +57,6 @@ QT_BEGIN_NAMESPACE_UIHELPERS /*! \enum UiFileSystemModel::Roles - \value FileIconRole \value FilePathRole \value FileNameRole \value FilePermissions @@ -141,19 +138,12 @@ QT_BEGIN_NAMESPACE_UIHELPERS */ /*! - \fn QIcon UiFileSystemModel::fileName(const QModelIndex &index) const + \fn QString UiFileSystemModel::fileName(const QModelIndex &index) const Returns the file name for the item stored in the model under the given \a index. */ -/*! - \fn QIcon UiFileSystemModel::fileIcon(const QModelIndex &index) const - - Returns the icon for the item stored in the model under the given - \a index. -*/ - /*! \fn QFileInfo UiFileSystemModel::fileInfo(const QModelIndex &index) const @@ -670,9 +660,6 @@ QVariant UiFileSystemModel::myComputer(int role) const switch (role) { case Qt::DisplayRole: return d->myComputer(); -// case Qt::DecorationRole: -// QImage pixmap(16, 1, QImage::Format_Mono); -// return pixmap; //d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); } return QVariant(); } @@ -703,20 +690,6 @@ QVariant UiFileSystemModel::data(const QModelIndex &index, int role) const return filePath(index); case FileNameRole: return d->name(index); - case Qt::DecorationRole: - if (index.column() == 0) { - QImage icon(16, 1, QImage::Format_Mono); - return icon; -// QIcon icon = d->icon(index); -// if (icon.isNull()) { -// if (d->node(index)->isDir()) -// icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder); -// else -// icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File); -// } -// return icon; - } - break; case Qt::TextAlignmentRole: if (index.column() == 1) return Qt::AlignRight; @@ -824,16 +797,6 @@ QString UiFileSystemModelPrivate::displayName(const QModelIndex &index) const return name(index); } -/*! - \internal -*/ -//QIcon UiFileSystemModelPrivate::icon(const QModelIndex &index) const -//{ -// if (!index.isValid()) -// return QIcon(); -// return node(index)->icon(); -//} - /*! \reimp */ @@ -900,16 +863,6 @@ bool UiFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, i QVariant UiFileSystemModel::headerData(int section, Qt::Orientation orientation, int role) const { switch (role) { - case Qt::DecorationRole: - if (section == 0) { - // ### TODO oh man this is ugly and doesn't even work all the way! - // it is still 2 pixels off - QImage pixmap(16, 1, QImage::Format_Mono); - pixmap.fill(0); - pixmap.setAlphaChannel(pixmap.createAlphaMask()); - return pixmap; - } - break; case Qt::TextAlignmentRole: return Qt::AlignLeft; } @@ -1449,25 +1402,6 @@ QDir UiFileSystemModel::rootDirectory() const return dir; } -/*! - Sets the \a provider of file icons for the directory model. -*/ -//void UiFileSystemModel::setIconProvider(QFileIconProvider *provider) -//{ -// Q_D(UiFileSystemModel); -// d->fileInfoGatherer.setIconProvider(provider); -// d->root.updateIcon(provider, QString()); -//} - -///*! -// Returns the file icon provider for this directory model. -//*/ -//QFileIconProvider *UiFileSystemModel::iconProvider() const -//{ -// Q_D(const UiFileSystemModel); -// return d->fileInfoGatherer.iconProvider(); -//} - /*! Sets the directory model's filter to that specified by \a filters. @@ -1929,7 +1863,6 @@ void UiFileSystemModelPrivate::init() q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); QHash roles = q->roleNames(); -// roles.insertMulti(UiFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration roles.insert(UiFileSystemModel::FilePathRole, "filePath"); roles.insert(UiFileSystemModel::FileNameRole, "fileName"); roles.insert(UiFileSystemModel::FilePermissions, "filePermissions"); diff --git a/src/models/uifilesystemmodel.h b/src/models/uifilesystemmodel.h index d9b4982..85bb5ec 100644 --- a/src/models/uifilesystemmodel.h +++ b/src/models/uifilesystemmodel.h @@ -46,7 +46,6 @@ #include #include #include -//#include #include QT_BEGIN_HEADER @@ -58,7 +57,6 @@ QT_BEGIN_NAMESPACE_UIHELPERS //class ExtendedInformation; class UiFileSystemModelPrivate; -//class QFileIconProvider; class UIHELPERS_EXPORT UiFileSystemModel : public QAbstractItemModel { @@ -74,7 +72,6 @@ Q_SIGNALS: public: enum Roles { -// FileIconRole = Qt::DecorationRole, FilePathRole = Qt::UserRole + 1, FileNameRole = Qt::UserRole + 2, FilePermissions = Qt::UserRole + 3 @@ -114,9 +111,6 @@ public: QString rootPath() const; QDir rootDirectory() const; -// void setIconProvider(QFileIconProvider *provider); -// QFileIconProvider *iconProvider() const; - void setFilter(QDir::Filters filters); QDir::Filters filter() const; @@ -141,7 +135,6 @@ public: QModelIndex mkdir(const QModelIndex &parent, const QString &name); bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const inline QString fileName(const QModelIndex &index) const; -// inline QIcon fileIcon(const QModelIndex &index) const; QFile::Permissions permissions(const QModelIndex &index) const; inline QFileInfo fileInfo(const QModelIndex &index) const; bool remove(const QModelIndex &index) const; @@ -165,8 +158,6 @@ private: inline QString UiFileSystemModel::fileName(const QModelIndex &aindex) const { return aindex.data(Qt::DisplayRole).toString(); } -//inline QIcon UiFileSystemModel::fileIcon(const QModelIndex &aindex) const -//{ return qvariant_cast(aindex.data(Qt::DecorationRole)); } inline QFileInfo UiFileSystemModel::fileInfo(const QModelIndex &aindex) const { return QFileInfo(filePath(aindex)); } diff --git a/src/models/uifilesystemmodel_p.h b/src/models/uifilesystemmodel_p.h index aade471..5ffd92b 100644 --- a/src/models/uifilesystemmodel_p.h +++ b/src/models/uifilesystemmodel_p.h @@ -117,7 +117,6 @@ public: inline bool isHidden() const { if (info) return info->isHidden(); return false; } inline bool isSymLink() const { if (info) return info->isSymLink(); return false; } inline bool caseSensitive() const { if (info) return info->isCaseSensitive(); return false; } -// inline QIcon icon() const { if (info) return info->icon; return QIcon(); } inline bool operator <(const QFileSystemNode &node) const { if (caseSensitive() || node.caseSensitive()) @@ -158,23 +157,6 @@ public: inline int visibleLocation(QString childName) { return visibleChildren.indexOf(childName); } -// void updateIcon(QFileIconProvider *iconProvider, const QString &path) { -// if (info) -// info->icon = iconProvider->icon(QFileInfo(path)); -// QHash::const_iterator iterator; -// for (iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) { -// //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/) -// if (!path.isEmpty()) { -// if (path.endsWith(QLatin1Char('/'))) -// iterator.value()->updateIcon(iconProvider, path + iterator.value()->fileName); -// else -// iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName); -// } else -// iterator.value()->updateIcon(iconProvider, iterator.value()->fileName); -// } -// } - - // void retranslateStrings(const QString &path) { // //if (info) @@ -278,7 +260,6 @@ public: return QString::compare(s1.fileName, s2.fileName, Qt::CaseInsensitive) < 0; } -// QIcon icon(const QModelIndex &index) const; QString name(const QModelIndex &index) const; QString displayName(const QModelIndex &index) const; QString filePath(const QModelIndex &index) const; diff --git a/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp index fec947a..92ef33d 100644 --- a/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/models/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -969,9 +969,7 @@ void tst_UiFileSystemModel::roleNames_data() { QTest::addColumn("role"); QTest::addColumn("roleName"); - QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration"); QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display"); - //QTest::newRow("fileIcon") << int(UiFileSystemModel::FileIconRole) << QByteArray("fileIcon"); QTest::newRow("filePath") << int(UiFileSystemModel::FilePathRole) << QByteArray("filePath"); QTest::newRow("fileName") << int(UiFileSystemModel::FileNameRole) << QByteArray("fileName"); QTest::newRow("filePermissions") << int(UiFileSystemModel::FilePermissions) << QByteArray("filePermissions"); -- cgit v1.2.3