Order of files and order of tabs #696
Replies: 4 comments 4 replies
-
There's no problem to solve. Please read #503 (comment) In short: Use the side-pane mode if the order is important to you. |
Beta Was this translation helpful? Give feedback.
-
The side pane does not solve the problem of the order because:
The attached code sorts the tabs according to the order of the files passed on the command line. |
Beta Was this translation helpful? Give feedback.
-
It seems that the tab order is important to multiple users as several requests have been made for such a feature: #267, #503 and this discussion. So I would not say that this has no practical value. |
Beta Was this translation helpful? Give feedback.
-
Sorry to insist, but I still don't understand why you completely reject a feature which has been requested by several users and effectively has some practical value for these users (but maybe not for you). |
Beta Was this translation helpful? Give feedback.
-
Hello.
When FeatherPad is launched with multiple files, the order of the tabs does not reflect the order of the files passed on the command line. For example:
% featherpad file1 file2 file3 file4
I would expect the order of the tabs to be: file1 file2 file3 file4
However, the order of the tabs seems to be more or less random.
FeatherPad creates one thread per file to load, and the resulting order of the tabs reflects the order of the end of the execution of the threads, which is unpredictable.
Attached is an attempt to solve this problem and to keep the order of the files in the order of the tabs:
load_order_in_tabs.tar.gz
The general idea is to create an object with the ordered list of files while loading the files and use this list to open each new tab at the right position.
In FPsingleton::newWin(), a LoadMultipleFilesOperation object is created. This is basically an ordered list of LoadFileOperation objects. Each LoadFileOperation object will contain a pointer to the corresponding TabPage. A pointer to each LoadFileOperation object is passed through the loading of each file until the FPwin::addText() function. When the loading of a file is completed, the tabs are put in the right order using the LoadMultipleFilesOperation object.
The LoadMultipleFilesOperation is supposed to be deleted when all the files are loaded. This is done in FPwin::addText() with a call to LoadMultipleFilesOperation::destroyIfCompleted(). However, the loading process is complex and there are many possible cases of errors. In such situation, I'm not sure if FPwin::addText() is called and thus if the LoadMultipleFilesOperation is deleted. That's why I added a garbage collector mechanism (see class LoadMultipleFilesOperationGarbageCollector): in worst case, the LoadMultipleFilesOperation objects are deleted at exit.
This tab ordering mechanism is used when loading files from the command line, from the file dialog and when restoring the files from a previous session. There are probably other cases where it could be used, for example with the drag and drop of files from another application.
There might be some issues with the order of the tabs in some (rare) cases. For example when several files are loaded while other files are still being loaded (and the operation is not completed).
And I did not try with Qt 6.
Please review the attached code and let me know what you think.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions