Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/designer/src/lib/shared/qtresourceview.cpp

    r372 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the Qt Designer of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include "qtresourceeditordialog_p.h"
    4646#include "iconloader_p.h"
     47
    4748
    4849#include <QtDesigner/QDesignerFormEditorInterface>
     
    149150    void slotCopyResourcePath();
    150151    void slotListWidgetContextMenuRequested(const QPoint &pos);
     152
    151153    void createPaths();
    152154    QTreeWidgetItem *createPath(const QString &path, QTreeWidgetItem *parent);
     
    157159    void saveSettings();
    158160    void updateActions();
     161
    159162
    160163    QPixmap makeThumbnail(const QPixmap &pix) const;
     
    163166    QtResourceModel *m_resourceModel;
    164167    QToolBar *m_toolBar;
     168
    165169    QTreeWidget *m_treeWidget;
    166170    QListWidget *m_listWidget;
    167171    QSplitter *m_splitter;
    168     QMap<QString, QStringList>       m_pathToContents; // full path to contents file names
     172    QMap<QString, QStringList>       m_pathToContents; // full path to contents file names (full path to its resource filenames)
     173    QMap<QString, QString>           m_pathToParentPath; // full path to full parent path
     174    QMap<QString, QStringList>       m_pathToSubPaths; // full path to full sub paths
    169175    QMap<QString, QTreeWidgetItem *> m_pathToItem;
    170176    QMap<QTreeWidgetItem *, QString> m_itemToPath;
     
    180186    QString m_settingsKey;
    181187    bool m_resourceEditingEnabled;
     188
    182189};
    183190
     
    256263}
    257264
     265
     266
     267
     268
     269
     270
    258271void QtResourceViewPrivate::storeExpansionState()
    259272{
     
    299312    m_editResourcesAction->setEnabled(resourceActive);
    300313    m_reloadResourcesAction->setEnabled(resourceActive);
     314
    301315}
    302316
     
    312326    m_treeWidget->clear();
    313327    m_pathToContents.clear();
     328
     329
    314330    m_pathToItem.clear();
    315331    m_itemToPath.clear();
     
    325341    else if (!currentPath.isEmpty())
    326342        q_ptr->selectResource(currentPath);
     343
    327344}
    328345
     
    366383
    367384    const QString root(QLatin1Char(':'));
    368 
    369     QMap<QString, QString> pathToParentPath; // full path to full parent path
    370     QMap<QString, QStringList> pathToSubPaths; // full path to full sub paths
    371385
    372386    QMap<QString, QString> contents = m_resourceModel->contents();
     
    377391        QString dirPath = fi.absolutePath();
    378392        m_pathToContents[dirPath].append(fi.fileName());
    379         while (!pathToParentPath.contains(dirPath) && dirPath != root) {
     393        while (!
    380394            const QFileInfo fd(dirPath);
    381395            const QString parentDirPath = fd.absolutePath();
    382             pathToParentPath[dirPath] = parentDirPath;
    383             pathToSubPaths[parentDirPath].append(dirPath);
     396            pathToParentPath[dirPath] = parentDirPath;
     397            pathToSubPaths[parentDirPath].append(dirPath);
    384398            dirPath = parentDirPath;
    385399        }
     
    392406        const QString path = pathToParentItem.first;
    393407        QTreeWidgetItem *item = createPath(path, pathToParentItem.second);
    394         QStringList subPaths = pathToSubPaths.value(path);
     408        QStringList subPaths = pathToSubPaths.value(path);
    395409        QStringListIterator itSubPaths(subPaths);
    396410        while (itSubPaths.hasNext())
    397411            pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item));
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
    398525    }
    399526}
     
    422549void QtResourceViewPrivate::createResources(const QString &path)
    423550{
     551
     552
    424553    QDir dir(path);
    425     QStringList files = m_pathToContents.value(path);
    426     QStringListIterator it(files);
     554    QStringList files = m_pathToContents.value(path);
     555    QStringListIterator it(files);
    427556    while (it.hasNext()) {
    428         QString file = it.next();
    429         QString filePath = dir.absoluteFilePath(file);
    430         QFileInfo fi(filePath);
    431         if (fi.isFile()) {
    432             QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget);
    433             const QPixmap pix = QPixmap(filePath);
    434             if (pix.isNull()) {
    435                 item->setToolTip(filePath);
    436             } else {
    437                 item->setIcon(QIcon(makeThumbnail(pix)));
    438                 const QSize size = pix.size();
    439                 item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath));
     557        QString fileName = it.next();
     558        const bool showProperty = matchAll || fileName.contains(m_filterPattern, Qt::CaseInsensitive);
     559        if (showProperty) {
     560            QString filePath = dir.absoluteFilePath(fileName);
     561            QFileInfo fi(filePath);
     562            if (fi.isFile()) {
     563                QListWidgetItem *item = new QListWidgetItem(fi.fileName(), m_listWidget);
     564                const QPixmap pix = QPixmap(filePath);
     565                if (pix.isNull()) {
     566                    item->setToolTip(filePath);
     567                } else {
     568                    item->setIcon(QIcon(makeThumbnail(pix)));
     569                    const QSize size = pix.size();
     570                    item->setToolTip(QtResourceView::tr("Size: %1 x %2\n%3").arg(size.width()).arg(size.height()).arg(filePath));
     571                }
     572                item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
     573                item->setData(Qt::UserRole, filePath);
     574                m_itemToResource[item] = filePath;
     575                m_resourceToItem[filePath] = item;
    440576            }
    441             item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
    442             item->setData(Qt::UserRole, filePath);
    443             m_itemToResource[item] = filePath;
    444             m_resourceToItem[filePath] = item;
    445577        }
    446578    }
     
    455587    d_ptr->q_ptr = this;
    456588
    457     d_ptr->m_editResourcesAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("edit.png")), tr("Edit Resources..."), this);
     589    QIcon editIcon = QIcon::fromTheme("document-properties", qdesigner_internal::createIconSet(QLatin1String("edit.png")));
     590    d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this);
    458591    d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction);
    459592    connect(d_ptr->m_editResourcesAction, SIGNAL(triggered()), this, SLOT(slotEditResources()));
    460593    d_ptr->m_editResourcesAction->setEnabled(false);
    461594
    462     d_ptr->m_reloadResourcesAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("reload.png")), tr("Reload"), this);
     595    QIcon refreshIcon = QIcon::fromTheme("view-refresh", qdesigner_internal::createIconSet(QLatin1String("reload.png")));
     596    d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this);
     597
    463598    d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction);
    464599    connect(d_ptr->m_reloadResourcesAction, SIGNAL(triggered()), this, SLOT(slotReloadResources()));
    465600    d_ptr->m_reloadResourcesAction->setEnabled(false);
    466601
    467     d_ptr->m_copyResourcePathAction = new QAction(qdesigner_internal::createIconSet(QLatin1String("editcopy.png")), tr("Copy Path"), this);
     602    QIcon copyIcon = QIcon::fromTheme("edit-copy", qdesigner_internal::createIconSet(QLatin1String("editcopy.png")));
     603    d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this);
    468604    connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath()));
    469605    d_ptr->m_copyResourcePathAction->setEnabled(false);
     606
     607
     608
     609
     610
    470611
    471612    d_ptr->m_splitter = new QSplitter;
     
    489630    d_ptr->m_listWidget->setGridSize(QSize(64, 64));
    490631
    491     connect(d_ptr->m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
    492                     this, SLOT(slotCurrentPathChanged(QTreeWidgetItem *)));
    493     connect(d_ptr->m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
    494                     this, SLOT(slotCurrentResourceChanged(QListWidgetItem *)));
    495     connect(d_ptr->m_listWidget, SIGNAL(itemActivated(QListWidgetItem *)),
    496                     this, SLOT(slotResourceActivated(QListWidgetItem *)));
     632    connect(d_ptr->m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*)),
     633                    this, SLOT(slotCurrentPathChanged(QTreeWidgetItem*)));
     634    connect(d_ptr->m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*)),
     635                    this, SLOT(slotCurrentResourceChanged(QListWidgetItem*)));
     636    connect(d_ptr->m_listWidget, SIGNAL(itemActivated(QListWidgetItem*)),
     637                    this, SLOT(slotResourceActivated(QListWidgetItem*)));
    497638    d_ptr->m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    498639    connect(d_ptr->m_listWidget, SIGNAL(customContextMenuRequested(QPoint)),
     
    504645    if (!d_ptr->m_settingsKey.isEmpty())
    505646        d_ptr->saveSettings();
    506 
    507     delete d_ptr;
    508647}
    509648
     
    576715{
    577716    if (d_ptr->m_resourceModel) {
    578         disconnect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSet *, bool)),
    579                     this, SLOT(slotResourceSetActivated(QtResourceSet *)));
     717        disconnect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSetbool)),
     718                    this, SLOT(slotResourceSetActivated(QtResourceSet*)));
    580719    }
    581720
     
    589728        return;
    590729
    591     connect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSet *, bool)),
    592             this, SLOT(slotResourceSetActivated(QtResourceSet *)));
     730    connect(d_ptr->m_resourceModel, SIGNAL(resourceSetActivated(QtResourceSetbool)),
     731            this, SLOT(slotResourceSetActivated(QtResourceSet*)));
    593732
    594733    // fill new here
     
    746885
    747886    settings->endGroup();
    748 
    749     delete d_ptr;
    750887}
    751888
Note: See TracChangeset for help on using the changeset viewer.