Skip to content

Commit 8563601

Browse files
committed
TabId define removed, uint64_t -> qulonglong (should fix Linux build)
1 parent a6be0ff commit 8563601

6 files changed

Lines changed: 45 additions & 47 deletions

File tree

file-commander-core/src/ccontroller.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ void CController::attachListenersToTab(Panel p, CPanel& tab)
128128
tab.addCurrentItemChangeListener(listener);
129129
}
130130

131-
TabId CController::addTab(Panel p, const QString& path, bool activate)
131+
qulonglong CController::addTab(Panel p, const QString& path, bool activate)
132132
{
133133
CPanel& tab = createTab(p);
134134
tab.setPath(path, refreshCauseOther); // Fires onCurrentPathChanged -> logs the new tab's path to the visited-locations list
135-
const TabId newId = tab.id();
135+
const qulonglong newId = tab.id();
136136

137137
if (activate)
138138
switchActiveTab(p, newId);
@@ -143,7 +143,7 @@ TabId CController::addTab(Panel p, const QString& path, bool activate)
143143
return newId;
144144
}
145145

146-
void CController::closeTab(Panel p, TabId tabId)
146+
void CController::closeTab(Panel p, qulonglong tabId)
147147
{
148148
auto& tabList = _panels[(size_t)p];
149149
if (tabList.tabs.size() == 1)
@@ -169,7 +169,7 @@ void CController::closeTab(Panel p, TabId tabId)
169169
savePanelState(p);
170170
}
171171

172-
void CController::setActiveTab(Panel p, TabId tabId)
172+
void CController::setActiveTab(Panel p, qulonglong tabId)
173173
{
174174
auto& tabList = _panels[(size_t)p];
175175
if (tabList.tabs[tabList.activeTab]->id() == tabId)
@@ -179,7 +179,7 @@ void CController::setActiveTab(Panel p, TabId tabId)
179179
savePanelState(p);
180180
}
181181

182-
void CController::switchActiveTab(Panel p, TabId tabId)
182+
void CController::switchActiveTab(Panel p, qulonglong tabId)
183183
{
184184
auto& tabList = _panels[(size_t)p];
185185
const auto idx = tabIndexById(p, tabId);
@@ -190,7 +190,7 @@ void CController::switchActiveTab(Panel p, TabId tabId)
190190
tabList.tabs[tabList.activeTab]->setActive(true);
191191
}
192192

193-
void CController::moveTabPosition(Panel p, TabId tabId, size_t newPosition)
193+
void CController::moveTabPosition(Panel p, qulonglong tabId, size_t newPosition)
194194
{
195195
auto& tabList = _panels[(size_t)p];
196196
const auto idx = tabIndexById(p, tabId);
@@ -216,7 +216,7 @@ void CController::moveTabPosition(Panel p, TabId tabId, size_t newPosition)
216216
savePanelState(p);
217217
}
218218

219-
std::optional<size_t> CController::tabIndexById(Panel p, TabId tabId) const
219+
std::optional<size_t> CController::tabIndexById(Panel p, qulonglong tabId) const
220220
{
221221
const auto& tabList = _panels[(size_t)p];
222222
for (size_t i = 0; i < tabList.tabs.size(); ++i)
@@ -230,31 +230,31 @@ int CController::tabCount(Panel p) const
230230
return (int)_panels[(size_t)p].tabs.size();
231231
}
232232

233-
TabId CController::activeTabId(Panel p) const
233+
qulonglong CController::activeTabId(Panel p) const
234234
{
235235
const auto& tabList = _panels[(size_t)p];
236236
return tabList.tabs[tabList.activeTab]->id();
237237
}
238238

239-
std::vector<TabId> CController::tabIds(Panel p) const
239+
std::vector<qulonglong> CController::tabIds(Panel p) const
240240
{
241241
const auto& tabList = _panels[(size_t)p];
242-
std::vector<TabId> ids;
242+
std::vector<qulonglong> ids;
243243
ids.reserve(tabList.tabs.size());
244244
for (const auto& tab : tabList.tabs)
245245
ids.push_back(tab->id());
246246
return ids;
247247
}
248248

249-
QString CController::tabPath(Panel p, TabId tabId) const
249+
QString CController::tabPath(Panel p, qulonglong tabId) const
250250
{
251251
const auto& tabList = _panels[(size_t)p];
252252
const auto idx = tabIndexById(p, tabId);
253253
assert_and_return_r(idx.has_value(), QString());
254254
return tabList.tabs[*idx]->currentDirPathPosix();
255255
}
256256

257-
QString CController::tabName(Panel p, TabId tabId) const
257+
QString CController::tabName(Panel p, qulonglong tabId) const
258258
{
259259
const auto& tabList = _panels[(size_t)p];
260260
const auto idx = tabIndexById(p, tabId);

file-commander-core/src/ccontroller.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ class CController final : public CVolumeEnumerator::IVolumeListObserver, public
4545
// Updates the list of files in the current directory this panel is viewing, and send the new state to UI
4646
void refreshPanelContents(Panel p);
4747
// Tab management. A tab is an independent CPanel; panel(p) returns the active tab's CPanel for side p.
48-
// Tabs are identified by TabId, not by position: the underlying tab list may be reordered/resized freely
48+
// Tabs are identified by tab ID, not by position: the underlying tab list may be reordered/resized freely
4949
// without invalidating an id a caller is holding onto.
5050
// Creates a new tab for side p showing 'path' and returns its id. Active by default; pass activate=false
5151
// to leave the currently active tab as is (e. g. for a background tab opened via middle-click).
52-
TabId addTab(Panel p, const QString& path, bool activate = true);
52+
qulonglong addTab(Panel p, const QString& path, bool activate = true);
5353
// Closes the tab with id. Never removes the last tab (a panel always keeps >= 1 tab).
54-
void closeTab(Panel p, TabId tabId);
54+
void closeTab(Panel p, qulonglong tabId);
5555
// Makes tabId the active tab for side p (deactivates the previously active tab, activates the new one).
56-
void setActiveTab(Panel p, TabId tabId);
56+
void setActiveTab(Panel p, qulonglong tabId);
5757
// Moves the tab with id to newPosition within side p's tab list (e. g. to mirror a drag-reorder in the UI).
5858
// No-op if tabId is already at newPosition. newPosition must be a valid index (same semantics as QTabBar::tabMoved's 'to').
59-
void moveTabPosition(Panel p, TabId tabId, size_t newPosition);
59+
void moveTabPosition(Panel p, qulonglong tabId, size_t newPosition);
6060
[[nodiscard]] int tabCount(Panel p) const;
61-
[[nodiscard]] TabId activeTabId(Panel p) const;
62-
[[nodiscard]] std::vector<TabId> tabIds(Panel p) const; // Tab ids in display order, for the UI to (re)build its tab strip
63-
[[nodiscard]] QString tabPath(Panel p, TabId tabId) const;
64-
[[nodiscard]] QString tabName(Panel p, TabId tabId) const; // The tab's folder name, for the tab label
61+
[[nodiscard]] qulonglong activeTabId(Panel p) const;
62+
[[nodiscard]] std::vector<qulonglong> tabIds(Panel p) const; // Tab ids in display order, for the UI to (re)build its tab strip
63+
[[nodiscard]] QString tabPath(Panel p, qulonglong tabId) const;
64+
[[nodiscard]] QString tabName(Panel p, qulonglong tabId) const; // The tab's folder name, for the tab label
6565
// Indicates that an item was activated and appropriate action should be taken. Returns error message, if any
6666
FileOperationResultCode itemActivated(qulonglong itemHash, Panel p);
6767
// A current volume has been switched
@@ -151,9 +151,9 @@ class CController final : public CVolumeEnumerator::IVolumeListObserver, public
151151
void attachListenersToTab(Panel p, CPanel& tab);
152152
// Deactivates the currently active tab and activates tabId. Shared by addTab and setActiveTab; callers are
153153
// responsible for skipping the call when tabId is already the active tab.
154-
void switchActiveTab(Panel p, TabId tabId);
154+
void switchActiveTab(Panel p, qulonglong tabId);
155155
// Returns tabId's position within side p's tab list, or nullopt if not found (should never happen for a live id).
156-
[[nodiscard]] std::optional<size_t> tabIndexById(Panel p, TabId tabId) const;
156+
[[nodiscard]] std::optional<size_t> tabIndexById(Panel p, qulonglong tabId) const;
157157

158158
// Persistence (centralized here; CPanel no longer touches settings).
159159
void restorePanelState(Panel p); // Rebuilds side p's tabs from settings (with migration from the legacy single-path keys)
@@ -170,7 +170,7 @@ class CController final : public CVolumeEnumerator::IVolumeListObserver, public
170170
// Shared worker pool for all panel tabs. Declared before _panels so it outlives the CPanels that post tasks to it.
171171
CWorkerThreadPool _panelWorkerPool;
172172
std::array<TabList, 2> _panels;
173-
TabId _nextTabId = 1; // 0 is reserved as "no tab"/invalid
173+
qulonglong _nextTabId = 1; // 0 is reserved as "no tab"/invalid
174174
// Listeners attached to every tab of a side; recorded so tabs created later also get them.
175175
std::array<std::vector<PanelContentsChangedListener*>, 2> _panelContentsListeners;
176176
std::array<std::vector<CursorPositionListener*>, 2> _cursorPositionListeners;

file-commander-core/src/cpanel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum {
2222
ItemDiscoveryProgressNotificationTag
2323
};
2424

25-
CPanel::CPanel(Panel position, CWorkerThreadPool& workerThreadPool, TabId id) :
25+
CPanel::CPanel(Panel position, CWorkerThreadPool& workerThreadPool, qulonglong id) :
2626
_panelPosition(position),
2727
_id(id),
2828
// The panel's own address is a unique, non-zero pool tag. Reuse-safe: ~CPanel retires all of this tag's tasks
@@ -39,7 +39,7 @@ CPanel::~CPanel()
3939
_workerThreadPool.retire(_taskTag);
4040
}
4141

42-
TabId CPanel::id() const noexcept
42+
qulonglong CPanel::id() const noexcept
4343
{
4444
return _id;
4545
}

file-commander-core/src/cpanel.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ enum class Panel
3030
UnknownPanel
3131
};
3232

33-
using TabId = uint64_t; // Stable identifier for a CPanel-as-tab, assigned once by CController when the tab is created
34-
3533
enum FileListRefreshCause
3634
{
3735
refreshCauseForwardNavigation,
@@ -71,10 +69,10 @@ class CPanel final
7169
void addCurrentItemChangeListener(CursorPositionListener * listener);
7270
void addCurrentPathChangedListener(CurrentPathChangedListener * listener);
7371

74-
explicit CPanel(Panel position, CWorkerThreadPool& workerThreadPool, TabId id);
72+
explicit CPanel(Panel position, CWorkerThreadPool& workerThreadPool, qulonglong id);
7573
~CPanel();
7674

77-
[[nodiscard]] TabId id() const noexcept; // Stable per-tab identifier; never changes for this CPanel's lifetime
75+
[[nodiscard]] qulonglong id() const noexcept; // Stable per-tab identifier; never changes for this CPanel's lifetime
7876

7977
// Seeds the navigation history when restoring a tab from saved settings. The controller owns persistence now,
8078
// so CPanel no longer reads or writes QSettings itself.
@@ -146,7 +144,7 @@ class CPanel final
146144
CallbackCaller<CursorPositionListener> _currentItemChangeListener;
147145
CallbackCaller<CurrentPathChangedListener> _currentPathChangedListeners;
148146
const Panel _panelPosition;
149-
const TabId _id; // Stable identity for this tab; assigned by CController. Distinct from _taskTag below.
147+
const qulonglong _id; // Stable identity for this tab; assigned by CController. Distinct from _taskTag below.
150148
const uint64_t _taskTag; // Unique per panel; tags this panel's tasks in the shared pool so they can be retired when the panel is destroyed
151149
CurrentDisplayMode _currentDisplayMode = NormalMode;
152150

qt-app/src/panel/cpanelwidget.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ void CPanelWidget::initPanel(Panel p)
171171
assert_r(connect(ui->_tabBar, &QTabBar::customContextMenuRequested, this, &CPanelWidget::showContextMenuForTab));
172172

173173
// Mirror however many tabs CController restored for this side (usually one, but persisted multi-tab state may have more).
174-
const std::vector<TabId> ids = _controller->tabIds(p);
175-
const TabId activeId = _controller->activeTabId(p);
174+
const std::vector<qulonglong> ids = _controller->tabIds(p);
175+
const qulonglong activeId = _controller->activeTabId(p);
176176
int activeIndex = 0;
177177
{
178178
const QSignalBlocker block(ui->_tabBar);
179-
for (const TabId id : ids)
179+
for (const qulonglong id : ids)
180180
{
181181
PanelTab& tab = _tabs.emplace_back();
182182
populateTriplet(tab);
@@ -299,7 +299,7 @@ void CPanelWidget::tryOpenItemInNewTab(const QModelIndex& sortModelIndex, bool a
299299

300300
void CPanelWidget::openPathInNewTab(const QString& path, bool activate)
301301
{
302-
const TabId id = _controller->addTab(_panelPosition, path, activate);
302+
const qulonglong id = _controller->addTab(_panelPosition, path, activate);
303303

304304
PanelTab& tab = _tabs.emplace_back();
305305
populateTriplet(tab);
@@ -364,7 +364,7 @@ void CPanelWidget::onTabBarCloseRequested(int index)
364364
closeTabById(tabIdAt(index));
365365
}
366366

367-
void CPanelWidget::closeTabById(TabId id)
367+
void CPanelWidget::closeTabById(qulonglong id)
368368
{
369369
if (_tabs.size() <= 1)
370370
return;
@@ -392,7 +392,7 @@ void CPanelWidget::closeTabById(TabId id)
392392
_tabs[(size_t)_activeTab].headerState = ui->_list->header()->saveState();
393393

394394
_controller->closeTab(_panelPosition, id);
395-
const TabId activeId = _controller->activeTabId(_panelPosition); // post-removal active tab
395+
const qulonglong activeId = _controller->activeTabId(_panelPosition); // post-removal active tab
396396

397397
// Detach the view from the closing triplet (via activateTab below) BEFORE deleting it.
398398
const PanelTab closing = _tabs[(size_t)index];
@@ -426,7 +426,7 @@ void CPanelWidget::onTabBarTabMoved(int from, int to)
426426
if (from == to)
427427
return;
428428

429-
// By the time this signal fires, the QTabBar (and the per-tab data carrying its TabId) has already moved
429+
// By the time this signal fires, the QTabBar (and the per-tab data carrying its tab ID) has already moved
430430
// the tab internally -- mirror the same reorder into _tabs, which has no notion of its own beyond position.
431431
PanelTab movedTab = std::move(_tabs[(size_t)from]);
432432
_tabs.erase(_tabs.begin() + from);
@@ -470,16 +470,16 @@ void CPanelWidget::closeAllOtherTabs(int index)
470470
{
471471
assert_and_return_r(index >= 0 && index < (int)_tabs.size(), );
472472

473-
const TabId keepId = tabIdAt(index);
474-
std::vector<TabId> idsToClose;
473+
const qulonglong keepId = tabIdAt(index);
474+
std::vector<qulonglong> idsToClose;
475475
for (int i = 0; i < ui->_tabBar->count(); ++i)
476476
{
477-
const TabId id = tabIdAt(i);
477+
const qulonglong id = tabIdAt(i);
478478
if (id != keepId)
479479
idsToClose.push_back(id);
480480
}
481481

482-
for (const TabId id : idsToClose)
482+
for (const qulonglong id : idsToClose)
483483
closeTabById(id);
484484
}
485485

@@ -494,7 +494,7 @@ void CPanelWidget::updateTabText(int index)
494494
ui->_tabBar->setTabText(index, _controller->tabName(_panelPosition, tabIdAt(index)));
495495
}
496496

497-
TabId CPanelWidget::tabIdAt(int index) const
497+
qulonglong CPanelWidget::tabIdAt(int index) const
498498
{
499499
return ui->_tabBar->tabData(index).toULongLong();
500500
}

qt-app/src/panel/cpanelwidget.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CPanelWidget final : public QWidget,
4949
void initPanel(Panel p);
5050

5151
// Tabs (this side). The QTabBar and the per-tab model triplets (_tabs) are kept position-aligned with each
52-
// other; CController's tabs are addressed by TabId, recovered from a QTabBar position via tabIdAt().
52+
// other; CController's tabs are addressed by tab ID, recovered from a QTabBar position via tabIdAt().
5353
void createNewTab(); // New tab showing the current folder, switched to
5454
void closeCurrentTab(); // Closes the active tab (no-op when it's the only one)
5555
void switchToNextTab();
@@ -122,20 +122,20 @@ private slots:
122122

123123
[[nodiscard]] bool pasteImage(const QImage& image, bool lossyCompression);
124124

125-
// Tab helpers (UI side; _tabs is position-aligned with the QTabBar; CController is addressed by TabId, see tabIdAt())
125+
// Tab helpers (UI side; _tabs is position-aligned with the QTabBar; CController is addressed by tab ID, see tabIdAt())
126126
struct PanelTab {
127127
CFileListModel* model = nullptr;
128128
CFileListSortFilterProxyModel* sortModel = nullptr;
129129
QItemSelectionModel* selectionModel = nullptr;
130130
QByteArray headerState; // This tab's own column widths/order/visibility (sort indicator bits in here are ignored - sortModel owns the sort)
131131
};
132132
void populateTriplet(PanelTab& tab); // Wires a model / sort-proxy / selection-model trio into an already-emplaced tab (not shown yet)
133-
[[nodiscard]] TabId tabIdAt(int index) const; // The TabId stored as this QTabBar position's tab data
133+
[[nodiscard]] qulonglong tabIdAt(int index) const; // The tab ID stored as this QTabBar position's tab data
134134
void activateTab(int index); // Points the shared view at tab 'index's triplet, restoring its own column widths and sort
135135
void onTabBarCurrentChanged(int index);
136136
void onTabBarCloseRequested(int index);
137137
void onTabBarTabMoved(int from, int to); // Drag-reorder: mirrors the QTabBar's move into _tabs and CController
138-
void closeTabById(TabId id); // Closes whichever tab currently holds id (re-resolves its position fresh); shared by onTabBarCloseRequested and closeAllOtherTabs
138+
void closeTabById(qulonglong id); // Closes whichever tab currently holds id (re-resolves its position fresh); shared by onTabBarCloseRequested and closeAllOtherTabs
139139
void updateTabBarVisibility(); // The bar stays hidden while there's only one tab
140140
void updateTabText(int index);
141141
void openPathInNewTab(const QString& path, bool activate = true); // Shared by createNewTab() and openCurrentItemInNewTab()/onItemMiddleClicked(); activate=false keeps the new tab in the background

0 commit comments

Comments
 (0)