On 12/22/2014 12:29 AM, Juha Manninen wrote:
On Sun, Dec 21, 2014 at 5:27 PM, zeljko <zel...@holobit.net> wrote:
What could be exact bug with Qt ? Any example project ?
What is exactly affected ?
My main suspect now is line :
TabControl.Pages.Move(TabIndex, Pal.fVisiblePageIndex);
in TComponentPage.InsertVisiblePage. It moves an exising tab to its
new position.
I noticed that the missing tabs are always the ones that existed
before doing import. Thus they are not inserted but moved.
New tabs are inserted :
TabControl.Pages.Insert(Pal.fVisiblePageIndex, PageName);
but it apparently causes no problems.
hmm...it works fine here, but anyway, I've changed tabMove a bit, patch
is attached, so pls test if it's ok now.
zeljko
Index: lcl/interfaces/qt/qtpagecontrol.inc
===================================================================
--- lcl/interfaces/qt/qtpagecontrol.inc (revision 47233)
+++ lcl/interfaces/qt/qtpagecontrol.inc (working copy)
@@ -314,11 +314,9 @@
TabWidget.BeginUpdate;
TabWidget.setUpdatesEnabled(false);
- TabWidget.removeTab(Index);
- TabWidget.insertTab(NewIndex, Page.Widget, Page.getIcon, Page.getText);
+ QTabBar_moveTab(QTabBarH(TabWidget.TabBar.Widget), Index, NewIndex);
+ // DebugLn('TQtWSCustomTabControl.MovePage from Index=',dbgs(Index),' to ',dbgs(NewIndex),' finished.');
TabWidget.setUpdatesEnabled(true);
- if TabWidget.getCurrentIndex <> NewIndex then
- TabWidget.setCurrentWidget(Page, True);
TabWidget.EndUpdate;
end;
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas (revision 47233)
+++ lcl/interfaces/qt/qtwidgets.pas (working copy)
@@ -903,12 +903,14 @@
private
FSavedIndexOnPageChanging: Integer; // used to handle OnPageChanging AllowChange param
FTabBarChangedHook: QTabBar_hookH;
+ FTabBarMovedHook: QTabBar_hookH;
public
procedure AttachEvents; override;
procedure DetachEvents; override;
function GetTabRect(const AIndex: integer): TRect;
// under some themes tabs doesn't start at 0,0 (eg. MacOSX)
function TabBarOffset: TPoint;
+ procedure SignalTabBarMoved(fromIndex: integer; toIndex: Integer); cdecl;
procedure SignalTabBarCurrentChanged(Index: Integer); cdecl;
function SlotTabBarMouse(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
@@ -9375,11 +9377,18 @@
begin
inherited AttachEvents;
FTabBarChangedHook := QTabBar_hook_create(QTabBarH(Widget));
+ FTabBarMovedHook := QTabBar_hook_create(QTabBarH(Widget));
QTabBar_hook_hook_currentChanged(FTabBarChangedHook, @SignalTabBarCurrentChanged);
+ QTabBar_hook_hook_tabMoved(FTabBarMovedHook, @SignalTabBarMoved);
end;
procedure TQtTabBar.DetachEvents;
begin
+ if FTabBarMovedHook <> nil then
+ begin
+ QTabBar_hook_destroy(FTabBarMovedHook);
+ FTabBarMovedHook := nil;
+ end;
if FTabBarChangedHook <> nil then
begin
QTabBar_hook_destroy(FTabBarChangedHook);
@@ -9427,6 +9436,21 @@
end;
end;
+procedure TQtTabBar.SignalTabBarMoved(fromIndex: integer; toIndex: Integer);
+ cdecl;
+var
+ ANewIndex: Integer;
+begin
+ if LCLObject = nil then
+ Exit;
+ // DebugLn('TQtTabBar.SignalTabBarMoved From=',dbgs(fromIndex),' to ',dbgs(toIndex),' FSavedIndexOnPageChanging=',dbgs(FSavedIndexOnPageChanging));
+ if Assigned(FOwner) and not (FOwner.ChildOfComplexWidget = ccwTTabControl) then
+ begin
+ ANewIndex := TQtTabWidget(FOwner).GetLCLPageIndex(toIndex);
+ TQtTabWidget(FOwner).setCurrentWidget(TQtWidget(TCustomTabControl(LCLObject).Page[ANewIndex].Handle), True);
+ end;
+end;
+
procedure TQtTabBar.SignalTabBarCurrentChanged(Index: Integer); cdecl;
var
Msg: TLMNotify;
@@ -9437,7 +9461,6 @@
if TQtTabWidget(LCLObject.Handle).InUpdate then
exit;
-
FillChar(Msg{%H-}, SizeOf(Msg), 0);
Msg.Msg := LM_NOTIFY;
FillChar(Hdr{%H-}, SizeOf(Hdr), 0);
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus