private void AddExcludeDir() { string dir = QFileDialog.GetExistingDirectory(this,"Select path to exclude",PathFinder.HomeDir); if (dir == null) { return; } Console.WriteLine("Excluding '{0}'",dir); // Check if the new dir is already part of some excluded directory in the list bool seen = false; for (int i = 0; i < main.ExcludeDirList.Count; ++i) { if (main.ExcludeDirList.Item(i).Text().StartsWith(dir)) { seen = true; QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK"); } else if (dir.StartsWith(main.ExcludeDirList.Item(i).Text())) { seen = true; QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK"); } } if (!seen) { main.ExcludeDirList.AddItem(dir); } }
private void ShowDirChooser() { string new_root = QFileDialog.GetExistingDirectory(this,"Choose new path for beagle to index","/"); if (new_root == null) { return; } Console.WriteLine("Selected new root '{0}'",new_root); // Check if the new_root is already part of some root in the list bool seen = false; for (int i = 0; i < main.RootsList.Count; ++i) { Console.WriteLine("Checking against {0}",main.RootsList.Item(i).Text()); if (main.RootsList.Item(i).Text().StartsWith(new_root)) { seen = true; QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The list contains a path that is included in the new path.","OK"); } else if (new_root.StartsWith(main.RootsList.Item(i).Text())) { seen = true; QMessageBox.Critical(this,"Invalid directory","The selected path wasn't added. The path is already included in one of the paths in the list.","OK"); } } if (!seen) { main.RootsList.AddItem(new_root); } }