OSDN Git Service

Maemo: Improve file selection dialog for publishing.
authorChristian Kandeler <christian.kandeler@nokia.com>
Fri, 17 Dec 2010 12:17:35 +0000 (13:17 +0100)
committerChristian Kandeler <christian.kandeler@nokia.com>
Fri, 17 Dec 2010 14:56:22 +0000 (15:56 +0100)
- Make sure file names are completely visible.
- Show hidden files.
- Pre-unselect files of types unlikely to be included in the package.

src/plugins/qt4projectmanager/qt-maemo/maemopublishedprojectmodel.cpp
src/plugins/qt4projectmanager/qt-maemo/maemopublishedprojectmodel.h
src/plugins/qt4projectmanager/qt-maemo/maemopublishingfileselectiondialog.cpp

index 66750ae..625f3e6 100644 (file)
@@ -40,6 +40,8 @@
 ****************************************************************************/
 #include "maemopublishedprojectmodel.h"
 
+#include <QtCore/QFileInfo>
+
 namespace Qt4ProjectManager {
 namespace Internal {
 namespace {
@@ -49,6 +51,32 @@ const int IncludeColumn = 2;
 MaemoPublishedProjectModel::MaemoPublishedProjectModel(QObject *parent)
     : QFileSystemModel(parent)
 {
+    setFilter(filter() | QDir::Hidden | QDir::System);
+}
+
+void MaemoPublishedProjectModel::initFilesToExclude()
+{
+    initFilesToExclude(rootPath());
+}
+
+void MaemoPublishedProjectModel::initFilesToExclude(const QString &filePath)
+{
+    QFileInfo fi(filePath);
+    if (fi.isDir()) {
+        const QStringList fileNames = QDir(filePath).entryList(QDir::Files
+            | QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden);
+        foreach (const QString &fileName, fileNames)
+            initFilesToExclude(filePath + QLatin1Char('/') + fileName);
+    } else {
+        const QString &fileName = fi.fileName();
+        if (fi.isHidden() || fileName.endsWith(QLatin1String(".o"))
+                || fileName == QLatin1String("Makefile")
+                || fileName.contains(QLatin1String(".pro.user"))
+                || fileName.contains(QLatin1String(".so"))
+                || fileName.endsWith(QLatin1String(".a"))) {
+            m_filesToExclude.insert(filePath);
+        }
+    }
 }
 
 int MaemoPublishedProjectModel::columnCount(const QModelIndex &parent) const
index e0b4cb6..51de90c 100644 (file)
@@ -53,6 +53,7 @@ class MaemoPublishedProjectModel : public QFileSystemModel
     Q_OBJECT
 public:
     explicit MaemoPublishedProjectModel(QObject *parent = 0);
+    void initFilesToExclude();
     QStringList filesToExclude() const { return m_filesToExclude.toList(); }
 
 private:
@@ -65,6 +66,8 @@ private:
         int role);
     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 
+    void initFilesToExclude(const QString &filePath);
+
     QSet<QString> m_filesToExclude;
 };
 
index 5bc2256..ed123a7 100644 (file)
@@ -54,8 +54,10 @@ MaemoPublishingFileSelectionDialog::MaemoPublishingFileSelectionDialog(const QSt
     ui->setupUi(this);
     m_projectModel = new MaemoPublishedProjectModel(this);
     const QModelIndex rootIndex = m_projectModel->setRootPath(projectPath);
+    m_projectModel->initFilesToExclude();
     ui->projectView->setModel(m_projectModel);
     ui->projectView->setRootIndex(rootIndex);
+    ui->projectView->header()->setResizeMode(0, QHeaderView::ResizeToContents);
 }
 
 MaemoPublishingFileSelectionDialog::~MaemoPublishingFileSelectionDialog()