Skip to content

Commit bd8a605

Browse files
committed
[kuroneko] subclass QTabWidget to expose tab re-order signal
1 parent 63599a4 commit bd8a605

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

ide/mainwindow.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,13 @@ void MainWindow::changeTab(int index)
16241624
setProject();
16251625
}
16261626

1627+
void MainWindow::movedTab(int from, int to)
1628+
{
1629+
Editor *E = editors->at(from);
1630+
editors->remove(from);
1631+
editors->insert(to, E);
1632+
}
1633+
16271634
void MainWindow::addToolButton(QToolBar *bar, QToolButton *btn, QString imgfile)
16281635
{
16291636
const QSize buttonSize(24, 24);
@@ -2163,11 +2170,12 @@ void MainWindow::setupProjectTools(QSplitter *vsplit)
21632170
editors = new QVector<Editor*>();
21642171

21652172
/* project editor tabs */
2166-
editorTabs = new QTabWidget(this);
2173+
editorTabs = new pIDE_QTabWidget(this);
21672174
editorTabs->setTabsClosable(true);
21682175
editorTabs->setMovable(true);
21692176
connect(editorTabs,SIGNAL(tabCloseRequested(int)),this,SLOT(closeTab(int)));
21702177
connect(editorTabs,SIGNAL(currentChanged(int)),this,SLOT(changeTab(int)));
2178+
connect(editorTabs->pIDE_tabBar(),SIGNAL(tabMoved(int,int)),this,SLOT(movedTab(int,int)));
21712179
rightSplit->addWidget(editorTabs);
21722180

21732181
QList<int> rsizes;

ide/mainwindow.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ QT_BEGIN_NAMESPACE
7070
class QTextEdit;
7171
QT_END_NAMESPACE
7272

73+
class pIDE_QTabWidget : public QTabWidget
74+
{
75+
public:
76+
pIDE_QTabWidget(QWidget *parent = 0) : QTabWidget(parent) {}
77+
QTabBar *pIDE_tabBar() { return tabBar(); /* protected */ }
78+
};
79+
7380
//! [0]
7481
class MainWindow : public QMainWindow
7582
{
@@ -131,6 +138,7 @@ public slots:
131138
void referenceTreeClicked(QModelIndex index);
132139
void closeTab(int index = 0);
133140
void changeTab(int index);
141+
void movedTab(int from, int to);
134142
void setCurrentPort(int index);
135143
void connectButton(bool show = true);
136144
void terminalClosed();
@@ -253,7 +261,7 @@ public slots:
253261
int findPosition;
254262
int wasClicked;
255263

256-
QTabWidget *editorTabs;
264+
pIDE_QTabWidget *editorTabs;
257265
QVector<Editor*> *editors;
258266
QFont editorFont;
259267
bool fileChangeDisable;

0 commit comments

Comments
 (0)