Changeset 14196 for trunk/qt/file-tree.cc
- Timestamp:
- Sep 8, 2013, 7:03:25 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/file-tree.cc
r14185 r14196 381 381 } 382 382 383 QString 384 FileTreeItem :: path () const 385 { 386 QString itemPath; 387 const FileTreeItem * item = this; 388 389 while (item != NULL && !item->name().isEmpty()) 390 { 391 if (itemPath.isEmpty()) 392 itemPath = item->name(); 393 else 394 itemPath = item->name() + "/" + itemPath; 395 item = item->parent (); 396 } 397 398 return itemPath; 399 } 400 401 bool 402 FileTreeItem :: isComplete () const 403 { 404 return myHaveSize == totalSize (); 405 } 406 383 407 /*** 384 408 **** … … 436 460 if (role == Qt::EditRole) 437 461 { 438 QString oldpath;439 462 FileTreeItem * item = itemFromIndex (index); 440 463 441 while (item && !item->name().isEmpty()) 442 { 443 if (oldpath.isEmpty()) 444 oldpath = item->name(); 445 else 446 oldpath = item->name() + "/" + oldpath; 447 item = item->parent (); 448 } 449 450 emit pathEdited (oldpath, newname.toString()); 464 emit pathEdited (item->path (), newname.toString ()); 451 465 } 452 466 … … 738 752 subtreeChanged(index, column); 739 753 } 754 } 755 756 void 757 FileTreeModel :: doubleClicked (const QModelIndex& index) 758 { 759 if (!index.isValid()) 760 return; 761 762 const int column (index.column()); 763 if (column == COL_WANTED || column == COL_PRIORITY) 764 return; 765 766 FileTreeItem * item = itemFromIndex (index); 767 768 if (item->childCount () == 0 && item->isComplete ()) 769 emit openRequested (item->path ()); 740 770 } 741 771 … … 897 927 this, SLOT(onClicked(const QModelIndex&))); 898 928 929 connect (this, SIGNAL(doubleClicked(const QModelIndex&)), 930 this, SLOT(onDoubleClicked(const QModelIndex&))); 931 899 932 connect (&myModel, SIGNAL(priorityChanged(const QSet<int>&, int)), 900 933 this, SIGNAL(priorityChanged(const QSet<int>&, int))); … … 905 938 connect (&myModel, SIGNAL(pathEdited(const QString&, const QString&)), 906 939 this, SIGNAL(pathEdited(const QString&, const QString&))); 940 941 connect (&myModel, SIGNAL (openRequested (const QString&)), 942 this, SLOT (onOpenRequested (const QString&)), 943 Qt::QueuedConnection); 907 944 } 908 945 … … 917 954 const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex); 918 955 myModel.clicked (modelIndex); 956 } 957 958 void 959 FileTreeView :: onDoubleClicked (const QModelIndex& proxyIndex) 960 { 961 const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex); 962 myModel.doubleClicked (modelIndex); 963 } 964 965 void 966 FileTreeView :: onOpenRequested (const QString& path) 967 { 968 if (state () == EditingState) 969 return; 970 971 emit openRequested (path); 919 972 } 920 973
Note: See TracChangeset
for help on using the changeset viewer.