@@ -905,7 +905,6 @@ QuickFolders.Interface = {
905905 model = QuickFolders . Model ;
906906 let cat = this . CategoryMenu ,
907907 showToolIcon = prefs . isShowToolIcon && ! QuickFolders . FilterWorker . FilterMode ;
908- if ( prefs . isDebugOption ( "categories" ) ) debugger ;
909908 if ( cat ) {
910909 // don't show if ALWAYS and NEVER are the only ones that are references by tabs
911910 let catArray = model . Categories ,
@@ -918,10 +917,17 @@ QuickFolders.Interface = {
918917 }
919918 cat . style . display = ( showToolIcon || isCustomCat ) ? '-moz-inline-box' : 'none' ;
920919 cat . collapsed = ( ! isCustomCat ) ;
921- if ( this . currentActiveCategories && ! catArray . includes ( this . currentActiveCategories ) ) {
922- // make sure all tabs are visible in case we delete the last category!
923- this . selectCategory ( FCat . ALL ) ;
924- }
920+
921+ if ( this . currentActiveCategories ) {
922+ if ( this . currentActiveCategories == FCat . UNCATEGORIZED ) // [issue 72] Category "_Uncategorized" will show all categories after moving a folder to another
923+ this . selectCategory ( FCat . UNCATEGORIZED ) ;
924+ else {
925+ if ( ! catArray . includes ( this . currentActiveCategories ) ) {
926+ // make sure all tabs are visible in case we delete the last category!
927+ this . selectCategory ( FCat . ALL ) ;
928+ }
929+ }
930+ }
925931
926932
927933 if ( prefs . getBoolPref ( 'collapseCategories' ) )
@@ -952,7 +958,8 @@ QuickFolders.Interface = {
952958 try {
953959 if ( lCatCount > 0 && menuList && menuPopup ) {
954960 let activeCatsList = this . currentActiveCategories ,
955- cats = activeCatsList ? activeCatsList . split ( '|' ) : [ ] ;
961+ cats = activeCatsList ? activeCatsList . split ( '|' ) : [ ] ,
962+ isMultiCategories = prefs . getBoolPref ( 'premium.categories.multiSelect' ) ;
956963 util . clearChildren ( menuPopup , true ) ;
957964
958965 menuPopup . appendChild ( this . createMenuItem (
@@ -964,12 +971,13 @@ QuickFolders.Interface = {
964971 if ( category != FCat . ALWAYS && category != FCat . NEVER ) {
965972 let menuItem = this . createMenuItem ( category , category , 'menuitem-iconic' ) ;
966973 // add checkbox for multiple category selection
967- if ( prefs . getBoolPref ( 'premium.categories.multiSelect' ) ) {
974+ if ( isMultiCategories ) {
968975 // multi selection
969- if ( cats . includes ( category ) )
976+ if ( cats . includes ( category ) ) {
970977 menuItem . setAttribute ( "checked" , true ) ;
971- if ( isPostbox )
972- menuItem . setAttribute ( "type" , "checkbox" ) ;
978+ if ( isPostbox )
979+ menuItem . setAttribute ( "type" , "checkbox" ) ;
980+ }
973981 }
974982 menuPopup . appendChild ( menuItem ) ;
975983 }
@@ -991,8 +999,14 @@ QuickFolders.Interface = {
991999 menuPopup . appendChild ( this . createIconicElement ( 'menuseparator' , '*' ) ) ;
9921000 }
9931001 if ( isUncat ) {
994- let s = this . getUIstring ( "qfUncategorized" , "(Uncategorized)" ) ;
995- menuPopup . appendChild ( this . createMenuItem ( FCat . UNCATEGORIZED , s , 'menuitem-iconic' ) ) ;
1002+ let s = this . getUIstring ( "qfUncategorized" , "(Uncategorized)" ) ,
1003+ itemUncat = this . createMenuItem ( FCat . UNCATEGORIZED , s , 'menuitem-iconic' ) ;
1004+ menuPopup . appendChild ( itemUncat ) ;
1005+ if ( cats . includes ( FCat . UNCATEGORIZED ) && isMultiCategories ) {
1006+ itemUncat . setAttribute ( "checked" , true ) ;
1007+ if ( isPostbox )
1008+ menuItem . setAttribute ( "type" , "checkbox" ) ;
1009+ }
9961010 }
9971011 if ( isNever ) {
9981012 let s = this . getUIstring ( "qfShowNever" , "Never Show (Folder Alias)" ) ;
@@ -1636,13 +1650,24 @@ QuickFolders.Interface = {
16361650 // first let's reset anything in the quickMove if we are in single message mode:
16371651 QuickMove . resetList ( ) ;
16381652 }
1639- let messageUris = util . getSelectedMsgUris ( ) ;
1640- if ( messageUris ) {
1641- let currentFolder = util . CurrentFolder ;
1642- while ( messageUris . length ) {
1643- QuickMove . add ( messageUris . pop ( ) , currentFolder , iscopy ) ;
1653+ // is the folder tree highlighted?
1654+ // [issue 75] support moving folders through quickMove
1655+ if ( eventTarget && eventTarget . getAttribute ( "id" ) == "folderTree" ) {
1656+ let folders = gFolderTreeView . getSelectedFolders ( ) ;
1657+ if ( folders . length ) {
1658+ QuickMove . addFolders ( folders , iscopy ) ;
1659+ QuickMove . update ( ) ;
16441660 }
1645- QuickMove . update ( ) ;
1661+ }
1662+ else {
1663+ let messageUris = util . getSelectedMsgUris ( ) ;
1664+ if ( messageUris ) {
1665+ let currentFolder = util . CurrentFolder ;
1666+ while ( messageUris . length ) {
1667+ QuickMove . add ( messageUris . pop ( ) , currentFolder , iscopy ) ;
1668+ }
1669+ QuickMove . update ( ) ;
1670+ }
16461671 }
16471672 isHandled = true ;
16481673 }
@@ -3106,8 +3131,12 @@ QuickFolders.Interface = {
31063131 }
31073132 folder . updateFolder ( msgWindow ) ;
31083133 if ( isCurrent ) {
3109- if ( typeof ( gFolderDisplay . show ) != 'undefined' )
3110- gFolderDisplay . show ( folder ) ;
3134+ if ( typeof ( gFolderDisplay . show ) != 'undefined' ) {
3135+ setTimeout (
3136+ function ( ) { gFolderDisplay . show ( folder ) ; } ,
3137+ 100
3138+ ) ;
3139+ }
31113140 }
31123141 }
31133142 else { // Postbox / SeaMonkey
@@ -5522,7 +5551,7 @@ QuickFolders.Interface = {
55225551
55235552 viewChangeOrder : function viewChangeOrder ( ) {
55245553 window . openDialog ( 'chrome://quickfolders/content/change-order.xul' , 'quickfolders-change-order' ,
5525- 'chrome,titlebar,toolbar, centerscreen,resizable,dependent' , QuickFolders ) ; // dependent = modeless
5554+ 'chrome,titlebar,centerscreen,resizable,dependent' , QuickFolders ) ; // dependent = modeless
55265555 } ,
55275556
55285557 lastTabSelected : null ,
@@ -6903,16 +6932,37 @@ QuickFolders.Interface = {
69036932 QuickFolders . FilterWorker . toggle_FilterMode ( active ) ;
69046933 } ,
69056934
6906- moveFolder : function moveFolder ( fromFolder , targetFolder , arrCount ) {
6907- // [Bug 26517] support multiple folder moves - addeed "count" and transmitting URIs
6935+ moveFolders : function moveFolders ( fromFolders , targetFolder ) {
6936+ // [Bug 26517] support multiple folder moves - added "count" and transmitting URIs
69086937 const Cc = Components . classes ,
69096938 Ci = Components . interfaces ,
69106939 util = QuickFolders . Util ;
6911-
6940+ let arrCount = fromFolders . length ;
6941+
6942+ function isChildFolder ( f ) {
6943+ for ( let i = 0 ; i < fromFolders . length ; i ++ ) {
6944+ if ( f == fromFolders [ i ] ) continue ;
6945+ let p = f ;
6946+ while ( p = p . parent ) {
6947+ if ( p == fromFolders [ i ] ) return true ;
6948+ }
6949+ }
6950+ return false ;
6951+ }
6952+ // make sure this is not a child of previous folders!
6953+ // in this case, it will be moved anyway through its parent
6954+ // and may lead to a problem (remaining folders are not moved)
6955+ let newFolders = [ ] ;
6956+ for ( let j = 0 ; j < arrCount ; j ++ ) {
6957+ let fld = fromFolders [ j ] ;
6958+ if ( isChildFolder ( fld ) ) continue ; // skip
6959+ newFolders . push ( fld ) ;
6960+ }
6961+ arrCount = newFolders . length ;
6962+
69126963 let lastFolder ,
69136964 sPrompt = util . getBundleString ( "qfConfirmMoveFolder" , "Really move folder {0} to {1}?" ) ,
6914- whatIsMoved = arrCount ?
6915- ( arrCount == 1 ? fromFolder [ 0 ] . prettyName : "[" + arrCount + " folders]" ) : fromFolder . prettyName ;
6965+ whatIsMoved = ( arrCount == 1 ? newFolders [ 0 ] . prettyName : "[" + arrCount + " folders]" ) ;
69166966
69176967 sPrompt = sPrompt . replace ( "{0}" , whatIsMoved ) ;
69186968 sPrompt = sPrompt . replace ( "{1}" , targetFolder . prettyName ) ;
@@ -6921,13 +6971,14 @@ QuickFolders.Interface = {
69216971
69226972 let cs = Cc [ "@mozilla.org/messenger/messagecopyservice;1" ] . getService ( Ci . nsIMsgCopyService ) ;
69236973 try {
6924- let toCount = arrCount || 1 , // for the moment only support dragging one folder.
6925- ap = util . Application ,
6926- isNewArray = ( ap == 'Thunderbird' || ap == 'SeaMonkey' ) ;
6927- for ( let i = 0 ; i < toCount ; i ++ ) {
6974+ let ap = util . Application ,
6975+ isNewArray = ( ap == 'Thunderbird' || ap == 'SeaMonkey' ) ,
6976+ countChanges = 0 ;
6977+ for ( let i = 0 ; i < newFolders . length ; i ++ ) {
69286978 let folders = new Array ,
6929- fld = arrCount ? fromFolder [ i ] : fromFolder ,
6979+ fld = newFolders [ i ] ,
69306980 fromURI = fld . URI ;
6981+
69316982 lastFolder = fld ; // keep track of last folder in case of a problem.
69326983 folders . push ( fld ) ; // dt.mozGetDataAt("text/x-moz-folder", i).QueryInterface(Ci.nsIMsgFolder)
69336984 let array = isNewArray ?
@@ -6936,6 +6987,9 @@ QuickFolders.Interface = {
69366987
69376988 if ( ! isNewArray )
69386989 array . AppendElement ( fld ) ;
6990+ if ( util . CurrentFolder == fld ) {
6991+ this . goUpFolder ( ) ;
6992+ }
69396993
69406994 // cannot move if the target Folder is in a different account?
69416995 // folders[0]\ == targetFolder.server
@@ -6953,14 +7007,14 @@ QuickFolders.Interface = {
69537007 // get encoded folder Name:
69547008 let slash = fromURI . lastIndexOf ( '/' ) ,
69557009 encName = fromURI . substring ( slash ) ,
6956- newURI = targetFolder . URI + encName ,
6957- countChanges = QuickFolders . Model . moveFolderURI ( fromURI , newURI ) ;
6958- if ( countChanges )
6959- this . updateFolders ( true , true ) ;
7010+ newURI = targetFolder . URI + encName ;
7011+ countChanges += QuickFolders . Model . moveFolderURI ( fromURI , newURI ) ;
69607012
69617013 // Filter Validation!
6962- setTimeout ( function ( ) { QuickFolders . FilterList . validateFilterTargets ( fromURI , newURI ) ; } ) ;
7014+ setTimeout ( function ( ) { QuickFolders . Util . validateFilterTargets ( fromURI , newURI ) ; } ) ;
69637015 }
7016+ if ( countChanges )
7017+ this . updateFolders ( true , true ) ;
69647018 }
69657019 catch ( ex ) {
69667020 sPrompt = util . getBundleString ( "qfCantMoveFolder" , "Folder {0} cannot be moved." ) ;
0 commit comments