Changeset 14196
- Timestamp:
- Sep 8, 2013, 7:03:25 PM (9 years ago)
- Location:
- trunk/qt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/details.cc
r14185 r14196 18 18 #include <QComboBox> 19 19 #include <QDateTime> 20 #include <QDesktopServices> 20 21 #include <QDialogButtonBox> 21 22 #include <QDoubleSpinBox> … … 1395 1396 this, SLOT (onPathEdited (const QString&, const QString&))); 1396 1397 1398 connect (myFileTreeView, SIGNAL (openRequested (const QString&)), 1399 this, SLOT (onOpenRequested (const QString&))); 1400 1397 1401 return myFileTreeView; 1398 1402 } … … 1435 1439 mySession.torrentRenamePath (myIds, oldpath, newname); 1436 1440 } 1441 1442 void 1443 Details :: onOpenRequested (const QString& path) 1444 { 1445 if (!mySession.isLocal ()) 1446 return; 1447 1448 foreach (const int id, myIds) 1449 { 1450 const Torrent * const tor = myModel.getTorrentFromId (id); 1451 if (tor == NULL) 1452 continue; 1453 1454 const QString localFilePath = tor->getPath () + "/" + path; 1455 if (!QFile::exists (localFilePath)) 1456 continue; 1457 1458 if (QDesktopServices::openUrl (QUrl::fromLocalFile (localFilePath))) 1459 break; 1460 } 1461 } -
trunk/qt/details.h
r14180 r14196 143 143 void onFileWantedChanged (const QSet<int>& fileIndices, bool); 144 144 void onPathEdited (const QString& oldpath, const QString& newname); 145 void onOpenRequested (const QString& path); 145 146 void onHonorsSessionLimitsToggled (bool); 146 147 void onDownloadLimitedToggled (bool); -
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 -
trunk/qt/file-tree.h
r14185 r14196 69 69 int fileIndex () const { return myFileIndex; } 70 70 uint64_t totalSize () const { return myTotalSize; } 71 QString path () const; 72 bool isComplete () const; 71 73 72 74 private: … … 116 118 void wantedChanged (const QSet<int>& fileIndices, bool); 117 119 void pathEdited (const QString& oldpath, const QString& newname); 120 void openRequested (const QString& path); 118 121 119 122 public: … … 139 142 public slots: 140 143 void clicked (const QModelIndex & index); 144 void doubleClicked (const QModelIndex & index); 141 145 }; 142 146 … … 168 172 void wantedChanged (const QSet<int>& fileIndices, bool wanted); 169 173 void pathEdited (const QString& oldpath, const QString& newname); 174 void openRequested (const QString& path); 170 175 171 176 protected: … … 179 184 public slots: 180 185 void onClicked (const QModelIndex& index); 186 void onDoubleClicked (const QModelIndex& index); 187 void onOpenRequested (const QString& path); 181 188 }; 182 189
Note: See TracChangeset
for help on using the changeset viewer.