Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54922 - in /branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src: YQPkgFilterTab.cc YQPkgFilterTab.h
  • From: sh-sh-sh@xxxxxxxxxxxxxxxx
  • Date: Thu, 22 Jan 2009 17:33:46 -0000
  • Message-id: <E1LQ3R4-0004tg-TC@xxxxxxxxxxxxxxxx>
Author: sh-sh-sh
Date: Thu Jan 22 18:33:46 2009
New Revision: 54922

URL: http://svn.opensuse.org/viewcvs/yast?rev=54922&view=rev
Log:
first version with [New] menu and [Close] button

Modified:
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.cc
branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.h

Modified: branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.cc?rev=54922&r1=54921&r2=54922&view=diff
==============================================================================
--- branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.cc (original)
+++ branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.cc Thu Jan 22
18:33:46 2009
@@ -14,12 +14,19 @@

Author: Stefan Hundhammer <sh@xxxxxxx>

+ Textdomain "qt-pkg"
+
/-*/


#include <vector>
-#include <QStackedWidget>
+
+#include <QAction>
+#include <QHBoxLayout>
+#include <QMenu>
+#include <QPushButton>
#include <QSplitter>
+#include <QStackedWidget>
#include <QTabBar>

#define YUILogComponent "qt-pkg"
@@ -29,14 +36,16 @@
#include "YQPkgFilterTab.h"
#include "YQPkgDiskUsageList.h"
#include "YQSignalBlocker.h"
+#include "YQi18n.h"
#include "utf8.h"

using std::vector;
typedef vector<YQPkgFilterPage *> YQPkgFilterPageVector;

#define MARGIN 5 // inner margin between 3D borders and content
-#define TOP_EXTRA_MARGIN 3
-#define SPLITTER_HALF_SPACING 2
+#define TOP_EXTRA_MARGIN 3
+#define SPLITTER_HALF_SPACING 2
+#define SHOW_ONLY_IMPORTANT_PAGES 1


struct YQPkgFilterTabPrivate
@@ -48,6 +57,8 @@
, filtersWidgetStack(0)
, diskUsageList(0)
, rightPane(0)
+ , newButton(0)
+ , closeButton(0)
{}

QStackedWidget * baseClassWidgetStack;
@@ -56,6 +67,8 @@
QStackedWidget * filtersWidgetStack;
YQPkgDiskUsageList * diskUsageList;
QWidget * rightPane;
+ QPushButton * newButton;
+ QPushButton * closeButton;
YQPkgFilterPageVector pages;
};

@@ -93,6 +106,44 @@
QSizePolicy::Expanding ) );
priv->baseClassWidgetStack->addWidget( priv->outerSplitter );

+
+#if SHOW_ONLY_IMPORTANT_PAGES
+
+ //
+ // "New" and "Close" buttons
+ //
+
+ QWidget * buttonBox = new QWidget( this );
+ YUI_CHECK_NEW( buttonBox );
+ setCornerWidget( buttonBox, Qt::TopRightCorner );
+ buttonBox->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
QSizePolicy::Fixed ) );
+
+ QHBoxLayout * buttonBoxLayout = new QHBoxLayout( buttonBox );
+ YUI_CHECK_NEW( buttonBoxLayout );
+ buttonBox->setLayout( buttonBoxLayout );
+ buttonBoxLayout->setContentsMargins( 0, 0, 0, 0 );
+
+ priv->newButton = new QPushButton( _( "&New" ), buttonBox );
+ YUI_CHECK_NEW( priv->newButton );
+ buttonBoxLayout->addWidget( priv->newButton );
+
+ QMenu * menu = new QMenu();
+ YUI_CHECK_NEW( menu );
+ priv->newButton->setMenu( menu );
+ menu->setTearOffEnabled( true );
+
+ connect( menu, SIGNAL( triggered( QAction * ) ),
+ this, SLOT ( showPage ( QAction * ) ) );
+
+
+ priv->closeButton = new QPushButton( _( "&Close" ), buttonBox );
+ YUI_CHECK_NEW( priv->closeButton );
+ buttonBoxLayout->addWidget( priv->closeButton );
+
+ connect( priv->closeButton, SIGNAL( clicked() ),
+ this, SLOT ( closeCurrentPage() ) );
+#endif
+

//
// Splitter that divides the left pane into upper filters area and disk
usage area
@@ -209,9 +260,22 @@
priv->pages.push_back( page );
priv->filtersWidgetStack->addWidget( pageContent );

- // FIXME: Only add showAlways pages immediately
- yuiWarning() << "Adding " << toUTF8( pageLabel) << endl;
- page->tabIndex = tabBar()->addTab( pageLabel );
+
+ if ( priv->newButton && priv->newButton->menu() )
+ {
+ QAction * action = new QAction( pageLabel, this );
+ YUI_CHECK_NEW( action );
+ action->setData( qVariantFromValue( pageContent ) );
+
+ priv->newButton->menu()->addAction( action );
+ }
+
+#if SHOW_ONLY_IMPORTANT_PAGES
+ if ( showAlways )
+#endif
+ {
+ page->tabIndex = tabBar()->addTab( pageLabel );
+ }
}


@@ -246,6 +310,17 @@


void
+YQPkgFilterTab::showPage( QAction * action )
+{
+ if ( ! action )
+ return;
+
+ QWidget * pageContent = action->data().value<QWidget *>();
+ showPage( pageContent );
+}
+
+
+void
YQPkgFilterTab::showPage( YQPkgFilterPage * page )
{
YUI_CHECK_PTR( page );
@@ -264,6 +339,22 @@
}


+void
+YQPkgFilterTab::closeCurrentPage()
+{
+ if ( tabBar()->count() > 1 )
+ {
+ int currentIndex = tabBar()->currentIndex();
+ YQPkgFilterPage * currentPage = findPage( currentIndex );
+
+ if ( currentPage )
+ currentPage->tabIndex = -1;
+
+ tabBar()->removeTab( currentIndex );
+ }
+}
+
+
YQPkgFilterPage *
YQPkgFilterTab::findPage( QWidget * pageContent )
{

Modified: branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.h
URL:
http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.h?rev=54922&r1=54921&r2=54922&view=diff
==============================================================================
--- branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.h (original)
+++ branches/tmp/sh/tabbed-pkg-browsing/qt-pkg/src/YQPkgFilterTab.h Thu Jan 22
18:33:46 2009
@@ -27,6 +27,7 @@
class YQPkgFilterTabPrivate;
class YQPkgFilterPage;
class YQPkgDiskUsageList;
+class QAction;


/**
@@ -118,6 +119,10 @@
void showPage( QWidget * page );
void showPage( const QString & internalName );

+ /**
+ * Close the current page unless this is the last visible page.
+ **/
+ void closeCurrentPage();

protected slots:

@@ -126,6 +131,11 @@
**/
void showPage( int tabIndex );

+ /**
+ * Show the page with the widget of this action's data().
+ **/
+ void showPage( QAction * action );
+

protected:


--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages