Commit ecebb704 authored by Laurent Montel's avatar Laurent Montel 😁

Fix remove all tab without current index

parent 45aaae0d
......@@ -77,8 +77,8 @@ MainWindow::MainWindow()
setCentralWidget( tabPosts );
connect(tabPosts,SIGNAL(createNewPost()),SLOT(slotCreateNewPost()));
connect(tabPosts,SIGNAL(closeTabClicked()),SLOT(slotCloseTabClicked()));
connect(tabPosts, SIGNAL(tabCloseRequested(int)), this, SLOT(slotRemovePostEntry(int)));
connect(tabPosts,SIGNAL(tabCloseRequested(int)), this, SLOT(slotRemovePostEntry(int)));
connect(tabPosts,SIGNAL(tabRemoveAllExclude(int)), this, SLOT(slotRemoveAllExclude(int)));
toolbox = new Toolbox( this );
toolboxDock = new QDockWidget( i18n( "Toolbox" ), this );
......@@ -470,6 +470,30 @@ void MainWindow::slotPublishPost()
activePost->submitPost( mCurrentBlogId, *activePost->currentPost() );
}
void MainWindow::slotRemoveAllExclude(int pos)
{
for(int i = tabPosts->count()-1; i >=0; --i) {
if (i == pos) {
continue;
}
PostEntry *widget = qobject_cast<PostEntry*>( tabPosts->widget( i ) );
if( !widget ) {
if( activePost )
widget = activePost;
else
return;
}
DBMan::self()->removeTempEntry( *widget->currentPost() );
tabPosts->removePage(widget);
widget->close();
}
if( tabPosts->count() < 1 ) {
activePost = 0;
toolbox->resetFields();
// actionCollection()->action("publish_post")->setEnabled( false );
}
}
void MainWindow::slotRemovePostEntry( int pos )
{
kDebug();
......
......@@ -103,6 +103,7 @@ private slots:
void slotDialogDestroyed( QObject *win );
void slotCloseTabClicked();
void slotRemoveAllExclude(int);
protected:
void keyPressEvent( QKeyEvent * event );
......
......@@ -23,6 +23,7 @@
#include <QToolButton>
#include <QTabBar>
#include <QDebug>
PostsTabWidget::PostsTabWidget(QWidget *parent)
: KTabWidget(parent)
......@@ -83,23 +84,11 @@ void PostsTabWidget::slotTabContextMenuRequest( const QPoint &pos )
QAction *action = menu.exec( mapToGlobal( pos ) );
if ( action == allOther ) { // Close all other tabs
/*
QList<Widget *> widgets;
const int index = q->indexOf( w );
for ( int i=0; i<q->count(); i++ ) {
if ( i==index) continue; // Skip the current one
Widget *other = qobject_cast<Widget *>( q->widget( i ) );
widgets << other;
}
foreach ( Widget *other, widgets ) {
delete other;
}
*/
Q_EMIT tabRemoveAllExclude(indexBar);
} else if (action == closeTab) {
Q_EMIT tabCloseRequested(indexBar);
}
}
#include "poststabwidget.moc"
......@@ -31,6 +31,7 @@ public:
Q_SIGNALS:
void createNewPost();
void closeTabClicked();
void tabRemoveAllExclude(int);
private Q_SLOTS:
void slotTabContextMenuRequest(const QPoint&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment