Author: dmacvicar
Date: Tue Dec 16 16:31:26 2008
New Revision: 54193
URL: http://svn.opensuse.org/viewcvs/yast?rev=54193&view=rev
Log:
Move some methods around where they make sense.
we have a dock with groups too
Modified:
branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp
branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.h
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.cpp
branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.h
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp?rev=54193&r1=54192&r2=54193&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.cpp Tue Dec 16 16:31:26 2008
@@ -13,51 +13,125 @@
#include <QLayout>
#include <QLabel>
+#include <QToolBar>
+#include <QLabel>
+#include <QLineEdit>
+#include <QDockWidget>
+#include <QListView>
#include <QDebug>
#include "kcategorizedsortfilterproxymodel.h"
#include "kcategorizedview.h"
#include "kcategorydrawer.h"
#include "yqmodulesproxymodel.h"
+
#include "yqmodulesmodel.h"
+#include "yqmodulegroupsmodel.h"
#include "moduleiconitem.h"
-MainWindow::MainWindow() : QMainWindow()
+class MainWindow::Private
+{
+public:
+ Private()
+ {
+ }
+ ~Private()
+ {
+ }
+
+ YQModulesModel *modmodel;
+ QListView *groupview;
+ KCategorizedView * modview;
+
+};
+
+MainWindow::MainWindow()
+ : QMainWindow()
+ , d(new Private)
{
qDebug();
+ // Tool bar
+ QToolBar *toolbar = new QToolBar(this);
+
+ // Search Widget
+ QWidget *searchWidget = new QWidget(this);
+ QHBoxLayout *searchLayout = new QHBoxLayout(searchWidget);
+ QLabel *searchLabel = new QLabel(searchWidget);
+ searchLabel->setText("Search:");
+ searchLayout->addWidget(searchLabel);
+ QLineEdit *searchField = new QLineEdit(searchWidget);
+ searchLayout->addWidget(searchField);
+
+ // Add search widget to toolbar
+ toolbar->addWidget(searchWidget);
+ addToolBar(toolbar);
+
+ // Central widget
QWidget *centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
-
QHBoxLayout *layout = new QHBoxLayout;
centralWidget->setLayout(layout);
+ // setup central widget
+ d->modview = new KCategorizedView( this );
KCategoryDrawer * drawer = new KCategoryDrawer;
- KCategorizedView * tv = new KCategorizedView( this );
-
- layout->addWidget(tv);
+
+ layout->addWidget(d->modview);
- tv->setSelectionMode(QAbstractItemView::SingleSelection);
+ d->modview->setSelectionMode(QAbstractItemView::SingleSelection);
// tv->setSpacing(KDialog::spacingHint());
- tv->setCategoryDrawer( drawer );
- tv->setViewMode( QListView::IconMode );
- tv->setItemDelegate( new ModuleIconItemDelegate( this ) );
- tv->setMouseTracking( true );
- tv->viewport()->setAttribute( Qt::WA_Hover );
- YQModulesModel *model = new YQModulesModel(this);
+ d->modview->setCategoryDrawer( drawer );
+ d->modview->setViewMode( QListView::IconMode );
+ d->modview->setItemDelegate( new ModuleIconItemDelegate( this ) );
+ d->modview->setMouseTracking( true );
+ d->modview->viewport()->setAttribute( Qt::WA_Hover );
+
+ // init the models
+ d->modmodel = new YQModulesModel(this);
KCategorizedSortFilterProxyModel * kcsfpm = new YQModulesProxyModel( this );
kcsfpm->setCategorizedModel( true );
- kcsfpm->setSourceModel( model );
+ kcsfpm->setSourceModel( d->modmodel );
+
//kcsfpm->setFilterRole( KCModuleModel::UserFilterRole );
//kcsfpm->setFilterCaseSensitivity( Qt::CaseInsensitive );
kcsfpm->sort( 0 );
- tv->setModel( kcsfpm );
+ d->modview->setModel( kcsfpm );
+
+ // Setup Dock Widget with groups
+ QDockWidget *groupdock = new QDockWidget(this);
+ d->groupview = new QListView(groupdock);
+ d->groupview->setModel(d->modmodel->groupsModel());
+
+ groupdock->setWidget(d->groupview);
+
+ addDockWidget(Qt::LeftDockWidgetArea, groupdock);
+
+ connect( d->groupview, SIGNAL( pressed( const QModelIndex & ) ),
+ SLOT( slotGroupPressed( const QModelIndex & ) ) );
+}
+
+void MainWindow::slotGroupPressed( const QModelIndex &index )
+{
+ qDebug() << "Group Click";
+ // scroll to the category in the main view
+ QModelIndex modidx = d->modmodel->firstModuleInGroup(index);
+ qDebug() << "Scroll to :" << d->modmodel->groupsModel()->data(index).toString();
+ qDebug() << " 1st item :" << d->modmodel->data(modidx).toString();
+ if ( modidx.isValid() )
+ d->modview->scrollTo(modidx);
+}
+
+void MainWindow::initActions()
+{
+
}
MainWindow::~MainWindow()
{
+ delete d;
}
#include "main_window.moc"
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.h?rev=54193&r1=54192&r2=54193&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.h (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/main_window.h Tue Dec 16 16:31:26 2008
@@ -32,7 +32,13 @@
MainWindow();
~MainWindow();
-public slots:
+protected slots:
+ void slotGroupPressed( const QModelIndex &index );
+protected:
+ void initActions();
+private:
+ class Private;
+ Private *const d;
};
#endif
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp?rev=54193&r1=54192&r2=54193&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.cpp Tue Dec 16 16:31:26 2008
@@ -22,6 +22,8 @@
YQModuleGroupsModel::YQModuleGroupsModel( QObject * parent )
: YQDesktopFilesModel( GROUPS_DESKTOP_DIR, parent)
{
+ addIconPath("/usr/share/YaST2/theme/current/icons/32x32/apps");
+ addIconPath("/usr/share/icons/hicolor/32x32/apps");
}
YQModuleGroupsModel::~YQModuleGroupsModel()
@@ -33,6 +35,15 @@
return indexForValue( "X-SuSE-YaST-Group", groupid );
}
+QString YQModuleGroupsModel::groupId( const QModelIndex &idx ) const
+{
+ QModelIndex grpid = index( idx.row(), Group);
+ // retrieve the groupid
+ QString groupid = data( grpid, Qt::UserRole ).toString();
+ return groupid;
+}
+
+
QVariant YQModuleGroupsModel::data( const QModelIndex &index, int role ) const
{
return YQDesktopFilesModel::data(index, role);
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h?rev=54193&r1=54192&r2=54193&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulegroupsmodel.h Tue Dec 16 16:31:26 2008
@@ -26,14 +26,6 @@
Q_OBJECT
public:
- enum UserRoleData
- {
- RawName,
- SortKey,
- Hidden,
- LastColumn
- };
-
YQModuleGroupsModel( QObject * parent = 0 );
~YQModuleGroupsModel();
@@ -46,6 +38,12 @@
* the group id, which you may had obtain in the modules model for example.
*/
QModelIndex indexForGroupId( const QString &groupid ) const;
+
+ /**
+ * Returns the group id for a given group
+ */
+ QString groupId( const QModelIndex &idx ) const;
+
};
#endif
Modified: branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.cpp?rev=54193&r1=54192&r2=54193&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.cpp (original)
+++ branches/tmp/tgoettlicher/yast2cc_rewrite/src/yqmodulesmodel.cpp Tue Dec 16 16:31:26 2008
@@ -9,6 +9,8 @@
| |
\---------------------------------------------------------------------*/
+#include <QDebug>
+
#include "yqmodulesmodel.h"
#include "yqmodulesproxymodel.h"
@@ -18,12 +20,19 @@
{
public:
Private()
- {}
+ : groupsModel(new YQModuleGroupsModel)
+ {
+
+ }
+
~Private()
- {}
- YQModuleGroupsModel groupsModel;
+ {
+ delete groupsModel;
+ }
+
+ YQModuleGroupsModel *groupsModel;
QMap