mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
[#136 state:fixed] Add dropped folders to recent added folders list in the folder selection window.
This commit is contained in:
parent
883875e88e
commit
e9bb1c01f7
@ -10,6 +10,8 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
#import "HSOutline.h"
|
||||
#import "PyDirectoryOutline.h"
|
||||
|
||||
#define DGAddedFoldersNotification @"DGAddedFoldersNotification"
|
||||
|
||||
@interface DirectoryOutline : HSOutline {}
|
||||
- (id)initWithPyParent:(id)aPyParent view:(HSOutlineView *)aOutlineView;
|
||||
- (PyDirectoryOutline *)py;
|
||||
|
@ -49,12 +49,15 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
sourceDragMask = [info draggingSourceOperationMask];
|
||||
pboard = [info draggingPasteboard];
|
||||
if ([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
NSArray *foldernames = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
if (!(sourceDragMask & NSDragOperationLink))
|
||||
return NO;
|
||||
for (NSString *filename in filenames) {
|
||||
[[self py] addDirectory:filename];
|
||||
for (NSString *foldername in foldernames) {
|
||||
[[self py] addDirectory:foldername];
|
||||
}
|
||||
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:foldernames forKey:@"foldernames"];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:DGAddedFoldersNotification
|
||||
object:self userInfo:userInfo];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[self refreshRemoveButtonText];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(directorySelectionChanged:)
|
||||
name:NSOutlineViewSelectionDidChangeNotification object:outlineView];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(outlineAddedFolders:)
|
||||
name:DGAddedFoldersNotification object:outline];
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -162,4 +164,12 @@ http://www.hardcoded.net/licenses/bsd_license
|
||||
[self refreshRemoveButtonText];
|
||||
}
|
||||
|
||||
- (void)outlineAddedFolders:(NSNotification *)aNotification
|
||||
{
|
||||
NSArray *foldernames = [[aNotification userInfo] objectForKey:@"foldernames"];
|
||||
for (NSString *foldername in foldernames) {
|
||||
[_recentDirectories addFile:foldername];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -45,6 +45,7 @@ class DirectoriesDialog(QMainWindow):
|
||||
self.app.recentResults.itemsChanged.connect(self._updateLoadResultsButton)
|
||||
self.recentFolders.itemsChanged.connect(self._updateAddButton)
|
||||
self.recentFolders.mustOpenItem.connect(self.app.add_directory)
|
||||
self.directoriesModel.foldersAdded.connect(self.directoriesModelAddedFolders)
|
||||
self.app.willSavePrefs.connect(self.appWillSavePrefs)
|
||||
|
||||
def _setupActions(self):
|
||||
@ -188,6 +189,10 @@ class DirectoriesDialog(QMainWindow):
|
||||
def appWillSavePrefs(self):
|
||||
self.app.prefs.directoriesWindowRect = self.geometry()
|
||||
|
||||
def directoriesModelAddedFolders(self, folders):
|
||||
for folder in folders:
|
||||
self.recentFolders.insertItem(folder)
|
||||
|
||||
def loadResultsTriggered(self):
|
||||
title = trmsg("SelectResultToLoadMsg")
|
||||
files = tr("dupeGuru Results (*.dupeguru)")
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import urllib.parse
|
||||
|
||||
from PyQt4.QtCore import QModelIndex, Qt, QRect, QEvent, QPoint, QUrl
|
||||
from PyQt4.QtCore import pyqtSignal, Qt, QRect, QEvent, QPoint, QUrl
|
||||
from PyQt4.QtGui import (QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush, QStyle,
|
||||
QStyleOptionComboBox, QStyleOptionViewItemV4)
|
||||
|
||||
@ -107,6 +107,7 @@ class DirectoriesModel(TreeModel):
|
||||
paths = [str(QUrl(url).toLocalFile()) for url in urls if url]
|
||||
for path in paths:
|
||||
self.model.add_directory(path)
|
||||
self.foldersAdded.emit(paths)
|
||||
self.reset()
|
||||
return True
|
||||
|
||||
@ -140,6 +141,8 @@ class DirectoriesModel(TreeModel):
|
||||
# work with ActionMove either. So screw that, and accept anything.
|
||||
return Qt.ActionMask
|
||||
|
||||
#--- Signals
|
||||
foldersAdded = pyqtSignal(list)
|
||||
#--- model --> view
|
||||
def refresh(self):
|
||||
self.reset()
|
||||
|
Loading…
x
Reference in New Issue
Block a user