Changeset 561 for trunk/tools/designer/src/lib/shared/qtresourceview.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/designer/src/lib/shared/qtresourceview.cpp
r372 r561 2 2 ** 3 3 ** 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]) 5 6 ** 6 7 ** This file is part of the Qt Designer of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 45 45 #include "qtresourceeditordialog_p.h" 46 46 #include "iconloader_p.h" 47 47 48 48 49 #include <QtDesigner/QDesignerFormEditorInterface> … … 149 150 void slotCopyResourcePath(); 150 151 void slotListWidgetContextMenuRequested(const QPoint &pos); 152 151 153 void createPaths(); 152 154 QTreeWidgetItem *createPath(const QString &path, QTreeWidgetItem *parent); … … 157 159 void saveSettings(); 158 160 void updateActions(); 161 159 162 160 163 QPixmap makeThumbnail(const QPixmap &pix) const; … … 163 166 QtResourceModel *m_resourceModel; 164 167 QToolBar *m_toolBar; 168 165 169 QTreeWidget *m_treeWidget; 166 170 QListWidget *m_listWidget; 167 171 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 169 175 QMap<QString, QTreeWidgetItem *> m_pathToItem; 170 176 QMap<QTreeWidgetItem *, QString> m_itemToPath; … … 180 186 QString m_settingsKey; 181 187 bool m_resourceEditingEnabled; 188 182 189 }; 183 190 … … 256 263 } 257 264 265 266 267 268 269 270 258 271 void QtResourceViewPrivate::storeExpansionState() 259 272 { … … 299 312 m_editResourcesAction->setEnabled(resourceActive); 300 313 m_reloadResourcesAction->setEnabled(resourceActive); 314 301 315 } 302 316 … … 312 326 m_treeWidget->clear(); 313 327 m_pathToContents.clear(); 328 329 314 330 m_pathToItem.clear(); 315 331 m_itemToPath.clear(); … … 325 341 else if (!currentPath.isEmpty()) 326 342 q_ptr->selectResource(currentPath); 343 327 344 } 328 345 … … 366 383 367 384 const QString root(QLatin1Char(':')); 368 369 QMap<QString, QString> pathToParentPath; // full path to full parent path370 QMap<QString, QStringList> pathToSubPaths; // full path to full sub paths371 385 372 386 QMap<QString, QString> contents = m_resourceModel->contents(); … … 377 391 QString dirPath = fi.absolutePath(); 378 392 m_pathToContents[dirPath].append(fi.fileName()); 379 while (! pathToParentPath.contains(dirPath) && dirPath != root) {393 while (! 380 394 const QFileInfo fd(dirPath); 381 395 const QString parentDirPath = fd.absolutePath(); 382 pathToParentPath[dirPath] = parentDirPath;383 pathToSubPaths[parentDirPath].append(dirPath);396 pathToParentPath[dirPath] = parentDirPath; 397 pathToSubPaths[parentDirPath].append(dirPath); 384 398 dirPath = parentDirPath; 385 399 } … … 392 406 const QString path = pathToParentItem.first; 393 407 QTreeWidgetItem *item = createPath(path, pathToParentItem.second); 394 QStringList subPaths = pathToSubPaths.value(path);408 QStringList subPaths = pathToSubPaths.value(path); 395 409 QStringListIterator itSubPaths(subPaths); 396 410 while (itSubPaths.hasNext()) 397 411 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 398 525 } 399 526 } … … 422 549 void QtResourceViewPrivate::createResources(const QString &path) 423 550 { 551 552 424 553 QDir dir(path); 425 QStringList file s = m_pathToContents.value(path);426 QStringListIterator it(file s);554 QStringList files = m_pathToContents.value(path); 555 QStringListIterator it(files); 427 556 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; 440 576 } 441 item->setFlags(item->flags() | Qt::ItemIsDragEnabled);442 item->setData(Qt::UserRole, filePath);443 m_itemToResource[item] = filePath;444 m_resourceToItem[filePath] = item;445 577 } 446 578 } … … 455 587 d_ptr->q_ptr = this; 456 588 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); 458 591 d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction); 459 592 connect(d_ptr->m_editResourcesAction, SIGNAL(triggered()), this, SLOT(slotEditResources())); 460 593 d_ptr->m_editResourcesAction->setEnabled(false); 461 594 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 463 598 d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction); 464 599 connect(d_ptr->m_reloadResourcesAction, SIGNAL(triggered()), this, SLOT(slotReloadResources())); 465 600 d_ptr->m_reloadResourcesAction->setEnabled(false); 466 601 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); 468 604 connect(d_ptr->m_copyResourcePathAction, SIGNAL(triggered()), this, SLOT(slotCopyResourcePath())); 469 605 d_ptr->m_copyResourcePathAction->setEnabled(false); 606 607 608 609 610 470 611 471 612 d_ptr->m_splitter = new QSplitter; … … 489 630 d_ptr->m_listWidget->setGridSize(QSize(64, 64)); 490 631 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*))); 497 638 d_ptr->m_listWidget->setContextMenuPolicy(Qt::CustomContextMenu); 498 639 connect(d_ptr->m_listWidget, SIGNAL(customContextMenuRequested(QPoint)), … … 504 645 if (!d_ptr->m_settingsKey.isEmpty()) 505 646 d_ptr->saveSettings(); 506 507 delete d_ptr;508 647 } 509 648 … … 576 715 { 577 716 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*))); 580 719 } 581 720 … … 589 728 return; 590 729 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*))); 593 732 594 733 // fill new here … … 746 885 747 886 settings->endGroup(); 748 749 delete d_ptr;750 887 } 751 888
Note:
See TracChangeset
for help on using the changeset viewer.