[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/k3b/src
From: Michal Malek <michalm () jabster ! pl>
Date: 2010-01-03 18:26:25
Message-ID: 1262543185.049537.13981.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1069552 by mmalek:
* If one try to open an already opened project, the tab with this project will be \
activated
* Overall interface cleanup of ProjectTabWidget: removed redundant methods, more \
consistent method names
M +14 -18 k3b.cpp
M +49 -57 k3bprojecttabwidget.cpp
M +15 -22 k3bprojecttabwidget.h
--- trunk/extragear/multimedia/k3b/src/k3b.cpp #1069551:1069552
@@ -227,9 +227,9 @@
d->welcomeWidget->loadConfig( grp );
// fill the tabs action menu
- m_documentTab->insertAction( actionFileSave );
- m_documentTab->insertAction( actionFileSaveAs );
- m_documentTab->insertAction( actionFileClose );
+ m_documentTab->addAction( actionFileSave );
+ m_documentTab->addAction( actionFileSaveAs );
+ m_documentTab->addAction( actionFileClose );
// /////////////////////////////////////////////////////////////////
// disable actions at startup
@@ -494,7 +494,7 @@
documentHullLayout->addWidget( m_documentTab, 1, 0 );
connect( m_documentTab, SIGNAL(currentChanged(int)), this, \
SLOT(slotCurrentDocChanged()) );
- connect( m_documentTab, SIGNAL(docCloseRequested(Doc*)), this, \
SLOT(slotFileClose(Doc*)) ); + connect( m_documentTab, \
SIGNAL(tabCloseRequested(Doc*)), this, SLOT(slotFileClose(Doc*)) );
d->welcomeWidget = new K3b::WelcomeWidget( this, d->documentStack );
d->documentStack->addWidget( d->welcomeWidget );
@@ -587,8 +587,8 @@
doc->setView( view );
view->setWindowTitle( doc->URL().fileName() );
- m_documentTab->insertTab( doc );
- m_documentTab->setCurrentWidget( view );
+ m_documentTab->addTab( doc );
+ m_documentTab->setCurrentTab( doc );
if( m_documentDock->isHidden() )
m_documentDock->show();
@@ -600,9 +600,8 @@
K3b::View* K3b::MainWindow::activeView() const
{
- QWidget* w = m_documentTab->currentWidget();
- if( K3b::View* view = dynamic_cast<K3b::View*>(w) )
- return view;
+ if( Doc* doc = activeDoc() )
+ return qobject_cast<View*>( doc->view() );
else
return 0;
}
@@ -610,10 +609,7 @@
K3b::Doc* K3b::MainWindow::activeDoc() const
{
- if( activeView() )
- return activeView()->getDocument();
- else
- return 0;
+ return m_documentTab->currentTab();
}
@@ -640,7 +636,7 @@
// check, if document already open. If yes, set the focus to the first \
view
K3b::Doc* doc = k3bappcore->projectManager()->findByUrl( url );
if( doc ) {
- doc->view()->setFocus();
+ m_documentTab->setCurrentTab( doc );
return doc;
}
@@ -1089,7 +1085,7 @@
}
// remove the doc from the project tab
- m_documentTab->removePage( doc );
+ m_documentTab->removeTab( doc );
// remove the project from the manager
k3bappcore->projectManager()->removeProject( doc );
@@ -1435,7 +1431,7 @@
void K3b::MainWindow::slotDataImportSession()
{
if( activeView() ) {
- if( K3b::DataView* view = dynamic_cast<K3b::DataView*>(activeView()) ) {
+ if( K3b::DataView* view = qobject_cast<K3b::DataView*>(activeView()) ) {
view->importSession();
}
}
@@ -1445,7 +1441,7 @@
void K3b::MainWindow::slotDataClearImportedSession()
{
if( activeView() ) {
- if( K3b::DataView* view = dynamic_cast<K3b::DataView*>(activeView()) ) {
+ if( K3b::DataView* view = qobject_cast<K3b::DataView*>(activeView()) ) {
view->clearImportedSession();
}
}
@@ -1455,7 +1451,7 @@
void K3b::MainWindow::slotEditBootImages()
{
if( activeView() ) {
- if( K3b::DataView* view = dynamic_cast<K3b::DataView*>(activeView()) ) {
+ if( K3b::DataView* view = qobject_cast<K3b::DataView*>(activeView()) ) {
view->editBootImages();
}
}
--- trunk/extragear/multimedia/k3b/src/k3bprojecttabwidget.cpp #1069551:1069552
@@ -1,7 +1,7 @@
/*
*
* Copyright (C) 2003-2008 Sebastian Trueg <trueg@k3b.org>
- * (C) 2009 Michal Malek <michalm@jabster.pl>
+ * Copyright (C) 2009-2010 Michal Malek <michalm@jabster.pl>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2008 Sebastian Trueg <trueg@k3b.org>
@@ -91,43 +91,8 @@
}
-void K3b::ProjectTabWidget::addTab( QWidget* child, const QString& label )
+void K3b::ProjectTabWidget::addTab( Doc* doc )
{
- QTabWidget::addTab( child, label );
-}
-
-
-void K3b::ProjectTabWidget::addTab( QWidget* child, const QIcon& iconset, const \
QString& label )
-{
- QTabWidget::addTab( child, iconset, label );
-}
-
-void K3b::ProjectTabWidget::tabInserted ( int index )
-{
- QTabWidget::tabInserted ( index );
-}
-
-void K3b::ProjectTabWidget::insertTab( QWidget* child, const QString& label, int \
index )
-{
- QTabWidget::insertTab( index, child, label );
-}
-
-
-void K3b::ProjectTabWidget::insertTab( QWidget* child, const QIcon& iconset, const \
QString& label, int index )
-{
- QTabWidget::insertTab( index, child, iconset, label );
-}
-
-void K3b::ProjectTabWidget::removePage( Doc* doc )
-{
- if( doc != 0 ) {
- QTabWidget::removeTab( indexOf( doc->view() ) );
- }
-}
-
-
-void K3b::ProjectTabWidget::insertTab( Doc* doc )
-{
QTabWidget::addTab( doc->view(), doc->URL().fileName() );
connect( k3bappcore->projectManager(), SIGNAL(projectSaved(K3b::Doc*)), this, \
SLOT(slotDocSaved(K3b::Doc*)) );
connect( doc, SIGNAL(changed(K3b::Doc*)), this, SLOT(slotDocChanged(K3b::Doc*)) \
); @@ -141,38 +106,36 @@
}
-void K3b::ProjectTabWidget::insertAction( KAction* action )
+void K3b::ProjectTabWidget::removeTab( Doc* doc )
{
- d->projectActionMenu->addAction( action );
+ if( doc != 0 ) {
+ QTabWidget::removeTab( indexOf( doc->view() ) );
+ }
}
-void K3b::ProjectTabWidget::slotDocChanged( K3b::Doc* doc )
+void K3b::ProjectTabWidget::setCurrentTab( Doc* doc )
{
- // we need to cache the icon changes since the changed() signal will be emitted \
very often
- if( !d->projectDataMap[doc].modified ) {
- setTabIcon( indexOf( doc->view() ), KIcon( "document-save" ) );
- d->projectDataMap[doc].modified = true;
-
- // we need this one for the session management
- setTabText( indexOf( doc->view() ), doc->URL().fileName() );
+ if( doc != 0 ) {
+ setCurrentWidget( doc->view() );
+ doc->view()->setFocus();
}
}
-void K3b::ProjectTabWidget::slotDocSaved( K3b::Doc* doc )
+K3b::Doc* K3b::ProjectTabWidget::currentTab() const
{
- setTabIcon( indexOf( doc->view() ), QIcon() );
- setTabText( indexOf( doc->view() ), doc->URL().fileName() );
+ QWidget* widget = currentWidget();
+ if( K3b::View* view = qobject_cast<K3b::View*>(widget) )
+ return view->doc();
+ else
+ return 0;
}
-void K3b::ProjectTabWidget::slotTabCloseRequested( int index )
+void K3b::ProjectTabWidget::addAction( KAction* action )
{
- QWidget* w = widget( index );
- if( View* view = dynamic_cast<View*>(w) ) {
- emit docCloseRequested( view->doc() );
- }
+ d->projectActionMenu->addAction( action );
}
@@ -182,7 +145,7 @@
if( tabPos != -1 )
{
QWidget *w = widget(tabPos);
- if(View* view = dynamic_cast<View*>(w) )
+ if(View* view = qobject_cast<View*>(w) )
return view->doc();
}
return 0;
@@ -227,7 +190,7 @@
Q_FOREACH( const QUrl& url, de->mimeData()->urls() ) {
urls.append( url );
}
- dynamic_cast<View*>(doc->view())->addUrls( urls );
+ qobject_cast<View*>(doc->view())->addUrls( urls );
}
}
return true;
@@ -237,5 +200,34 @@
return QTabWidget::eventFilter( o, e );
}
+
+void K3b::ProjectTabWidget::slotDocChanged( K3b::Doc* doc )
+{
+ // we need to cache the icon changes since the changed() signal will be emitted \
very often + if( !d->projectDataMap[doc].modified ) {
+ setTabIcon( indexOf( doc->view() ), KIcon( "document-save" ) );
+ d->projectDataMap[doc].modified = true;
+
+ // we need this one for the session management
+ setTabText( indexOf( doc->view() ), doc->URL().fileName() );
+ }
+}
+
+
+void K3b::ProjectTabWidget::slotDocSaved( K3b::Doc* doc )
+{
+ setTabIcon( indexOf( doc->view() ), QIcon() );
+ setTabText( indexOf( doc->view() ), doc->URL().fileName() );
+}
+
+
+void K3b::ProjectTabWidget::slotTabCloseRequested( int index )
+{
+ QWidget* w = widget( index );
+ if( View* view = qobject_cast<View*>(w) ) {
+ emit tabCloseRequested( view->doc() );
+ }
+}
+
#include "k3bprojecttabwidget.moc"
--- trunk/extragear/multimedia/k3b/src/k3bprojecttabwidget.h #1069551:1069552
@@ -1,6 +1,7 @@
/*
*
* Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
+ * Copyright (C) 2009-2010 Michal Malek <michalm@jabster.pl>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
@@ -26,8 +27,7 @@
/**
- * An enhanced Tab Widget that hides the tabbar in case only one page has been \
inserted
- * and shows a context menu fpr K3b projects.
+ * An enhanced Tab Widget that shows a context menu fpr K3b projects.
*
* @author Sebastian Trueg
*/
@@ -40,35 +40,28 @@
ProjectTabWidget( QWidget *parent = 0 );
~ProjectTabWidget();
- void insertTab( Doc* );
+ void addTab( Doc* doc );
+ void removeTab( Doc* doc );
+ void setCurrentTab( Doc* doc );
+ Doc* currentTab() const;
- void addTab( QWidget * child, const QString & label );
- void addTab( QWidget * child, const QIcon & iconset, const QString & label \
);
- void insertTab( QWidget * child, const QString & label, int index = -1 );
- void insertTab( QWidget * child, const QIcon & iconset, const QString & \
label, int index = -1 );
-
/**
+ * adds the given action into the popup menu for the tabs
+ */
+ void addAction( KAction* action );
+
+ Q_SIGNALS:
+ void tabCloseRequested( Doc* doc );
+
+ protected:
+ /**
* \return the project for the tab at position \p pos or 0 in case the tab \
is
* not a project tab.
*/
Doc* projectAt( const QPoint& pos ) const;
- /**
- * inserts the given action into the popup menu for the tabs
- */
- void insertAction( KAction* );
-
bool eventFilter( QObject* o, QEvent* e );
-
- Q_SIGNALS:
- void docCloseRequested( Doc* doc );
- protected:
- virtual void tabInserted ( int index );
-
- public Q_SLOTS:
- void removePage( Doc* doc );
-
private Q_SLOTS:
void slotDocChanged( K3b::Doc* );
void slotDocSaved( K3b::Doc* );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic