Author: tgoettlicher Date: Wed Feb 6 16:11:51 2008 New Revision: 44201 URL: http://svn.opensuse.org/viewcvs/yast?rev=44201&view=rev Log: menu works!! Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/CMakeLists.txt branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.h branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.h branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.cpp branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.h Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/CMakeLists.txt (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/CMakeLists.txt Wed Feb 6 16:11:51 2008 @@ -12,6 +12,8 @@ moduleiconitem.cpp kcategorizedview.cpp kcategorydrawer.cpp + yservice.cpp + kcmoduleproxy.cpp ) Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmodulemodel.cpp Wed Feb 6 16:11:51 2008 @@ -24,10 +24,10 @@ #include <QList> #include <KDebug> #include <KIcon> -#include <KServiceTypeTrader> #include "kcategorizedsortfilterproxymodel.h" #include "menuitem.h" +#include "yservice.h" Q_DECLARE_METATYPE(MenuItem *) @@ -70,9 +70,9 @@ } } -int weightOfService( const KService::Ptr service ) +int weightOfService( const YService::Ptr service ) { - QVariant tmp = service->property( "X-KDE-Weight", QVariant::Int ); + QVariant tmp = service->weight; int weight = tmp.isValid() ? tmp.toInt() : 100; return weight; } Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.cpp Wed Feb 6 16:11:51 2008 @@ -203,7 +203,7 @@ void KCMultiWidget::addModule(const KCModuleInfo& moduleinfo) { if( !moduleinfo.service() ) { - kWarning() << "ModuleInfo has no associated KService" ; + kWarning() << "ModuleInfo has no associated YService" ; return; } @@ -217,6 +217,7 @@ } KCModuleProxy * module; QScrollArea * moduleScrollArea; +#ifdef tg if( m_orphanModules.contains( moduleinfo.service() ) ) { // the KCModule already exists - it was removed from the dialog in @@ -234,6 +235,7 @@ } else { +#endif moduleScrollArea = new QScrollArea( this ); module = new KCModuleProxy( moduleinfo, moduleScrollArea ); moduleScrollArea->setWidget( module ); @@ -247,8 +249,12 @@ parentComponents ); connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); +#ifdef tg } +#endif + +#ifdef tg CreatedModule cm; cm.kcm = module; cm.service = moduleinfo.service(); @@ -274,6 +280,9 @@ KPageWidgetItem* page = addPage(moduleScrollArea, moduleinfo.moduleName()); page->setIcon( KIcon(moduleinfo.icon()) ); page->setHeader(moduleinfo.comment()); + +#endif + } KCModuleProxy* KCMultiWidget::currentModule() Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.h (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/kcmultiwidget.h Wed Feb 6 16:11:51 2008 @@ -29,7 +29,8 @@ // KDE #include <kpagedialog.h> -#include <kservice.h> +//#include <kservice.h> +#include "yservice.h" class KCModuleProxy; class KCModuleInfo; @@ -207,14 +208,14 @@ struct CreatedModule { KCModuleProxy * kcm; - KService::Ptr service; + YService::Ptr service; bool adminmode; int buttons; }; typedef QList<CreatedModule> ModuleList; ModuleList m_modules; - typedef QMap<KService::Ptr, KCModuleProxy*> OrphanMap; + typedef QMap<YService::Ptr, KCModuleProxy*> OrphanMap; OrphanMap m_orphanModules; QHash<KCModuleProxy*,QStringList> moduleParentComponents; Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp Wed Feb 6 16:11:51 2008 @@ -38,7 +38,7 @@ #include <KLineEdit> #include <KLocale> #include <KMenuBar> -#include <KServiceTypeTrader> +//#include <KServiceTypeTrader> #include <KStandardAction> #include <KTabWidget> #include <KToggleAction> @@ -52,12 +52,14 @@ #include "kcmultiwidget.h" #include "menuitem.h" #include "moduleiconitem.h" +#include "yservice.h" Q_DECLARE_METATYPE(MenuItem *) MainWindow::MainWindow(QWidget *parent) : - KXmlGuiWindow(parent), categories( KServiceTypeTrader::self()->query("SystemSettingsCategory") ), - modules( KServiceTypeTrader::self()->query("KCModule") ), + KXmlGuiWindow(parent), +// categories( KServiceTypeTrader::self()->query("SystemSettingsCategory") ), +// modules( KServiceTypeTrader::self()->query("KCModule") ), rootItem(new MenuItem( true, 0 )), groupWidget(NULL), selectedPage(0) { @@ -95,42 +97,64 @@ current = current->parent; } + // tg new menu + + + YService* entry = new YService; + entry->_name = "Thomas"; + + MenuItem * menuItem = new MenuItem(true,parent); + menuItem->name = "new"; + menuItem->service = entry; + + + + MenuItem * menuItem2 = new MenuItem(false,menuItem); + menuItem2->name = "new"; + menuItem2->service = entry; + + MenuItem * menuItem3 = new MenuItem(false,menuItem2); + menuItem3->name = "new"; + menuItem3->service = entry; + + + // tg new menu + + + QString space; space.fill( ' ', depth * 2 ); kDebug() << space << "Looking for children in '" << parent->name << "'"; for (int i = 0; i < categories.size(); ++i) { - KService::Ptr entry = categories.at(i); + YService::Ptr entry = categories.at(i); QString parentCategory = entry->property("X-KDE-System-Settings-Parent-Category").toString(); QString category = entry->property("X-KDE-System-Settings-Category").toString(); - //kDebug() << "Examining category " << parentCategory << "/" << category; + kDebug() << "Examining category " << parentCategory << "/" << category; if ( parentCategory == parent->name ) { - KCModuleInfo module( entry->entryPath() ); - MenuItem * menuItem = new MenuItem(true, parent); menuItem->name = category; menuItem->service = entry; - menuItem->item = module; readMenu( menuItem ); } } // scan for any modules at this level and add them for (int i = 0; i < modules.size(); ++i) { - KService::Ptr entry = modules.at(i); + YService::Ptr entry = modules.at(i); QString category = entry->property("X-KDE-System-Settings-Parent-Category").toString(); - //kDebug() << "Examining module " << category; + kDebug() << "Examining module " << category; if(!parent->name.isEmpty() && category == parent->name ) { - kDebug() << space << "found module '" << entry->name() << "' " << entry->desktopEntryPath(); - // Add the module info to the menu - KCModuleInfo module(entry->entryPath()); - kDebug() << space << "filename is " << module.fileName(); - //append(module); +// kDebug() << space << "found module '" << entry->name() << "' " << entry->desktopEntryPath(); MenuItem * infoItem = new MenuItem(false, parent); infoItem->name = category; infoItem->service = entry; - infoItem->item = module; + + + } } + + } void MainWindow::closeEvent ( QCloseEvent * ) @@ -182,8 +206,11 @@ moduleTabs->addTab(tv, item->service->name() ); // record the index of the newly added tab so that we can later update the label showing // number of search hits +#ifdef tg modelToTabHash.insert( kcsfpm, moduleTabs->count() - 1 ); +#endif } + windowStack->addWidget(moduleTabs); windowStack->setCurrentWidget(moduleTabs); setCentralWidget(windowStack); @@ -279,24 +306,6 @@ actionCollection()->addAction( "search", searchAction ); searchAction->setShortcutConfigurable( false ); hbox->setWhatsThis( i18n("Search Bar<p>Enter a search term.</p>") ); -#if 0 - // Now it's time to draw our display - foreach( const MenuItem &item , menu->menuList() ) { - if( item.menu ) { - KServiceGroup::Ptr group = KServiceGroup::group( item.subMenu ); - if ( !group ){ - kDebug() << "Invalid Group "" << item.subMenu << "". Check your installation."; - continue; - } - - KToggleAction *newAction = new KToggleAction( KIcon(group->icon()), group->caption(), this); - connect(newAction, SIGNAL(toggled(bool)), this, SLOT(slotTopPage())); - - pageActions.append(newAction); - kDebug() << "relpath is :" << group->relPath(); - } - } -#endif } void MainWindow::aboutCurrentModule() @@ -352,49 +361,6 @@ } else { kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString(); } - // Because some KCMultiWidgets take an age to load, it is possible - // for the user to click another ModuleIconItem while loading. - // This causes execution to return here while the first groupWidget is shown - if ( groupWidget ) - return; - - groupWidget = moduleItemToWidgetDict[mItem->service]; - - if( !groupWidget ) { - groupWidget = new KCMultiWidget(windowStack, Qt::NonModal); // THAT ZERO IS NEW (actually the 0 can go, jr) - windowStack->addWidget(groupWidget); - moduleItemToWidgetDict.insert(mItem->service,groupWidget); - - connect(groupWidget, SIGNAL(aboutToShow( KCModuleProxy * )), this, SLOT(updateModuleHelp( KCModuleProxy * ))); - connect(groupWidget, SIGNAL(finished()), this, SLOT(groupModulesFinished())); - connect(groupWidget, SIGNAL(close()), this, SLOT(showAllModules())); - - if ( ! mItem->menu ) { - groupWidget->addModule( mItem->item ); - } else { - foreach ( MenuItem * i, mItem->children ) { - kDebug() << "adding " , i->item.fileName(); - groupWidget->addModule( i->item ); - } - } - } - - // calling this with a shown KCMultiWidget sets groupWidget to 0 - // which makes the show() call below segfault. The groupWidget test - // above should prevent execution reaching here while the KCMultiWidget is - // visible - windowStack->setCurrentWidget( groupWidget ); - - setCaption( mItem->service->name() ); - showAllAction->setEnabled(true); - searchText->setEnabled(false); - search->setEnabled(false); - searchAction->setEnabled(false); - - KToggleAction *currentRadioAction; - foreach ( currentRadioAction, pageActions ) { - currentRadioAction->setEnabled(false); - } } void MainWindow::updateModuleHelp( KCModuleProxy *currentModule ) { @@ -443,6 +409,7 @@ void MainWindow::updateSearchHits() { +#ifdef tg // if the search lineedit is empty, clear the search labels if ( search->text().isEmpty() ) { generalHitLabel->setText(QString()); @@ -464,6 +431,7 @@ } } } +#endif } void MainWindow::slotSearchHits(const QString &query, int *hitList, int length) { Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.h (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.h Wed Feb 6 16:11:51 2008 @@ -23,7 +23,7 @@ #define MAINWINDOW_H // KDE -#include <KService> +#include "yservice.h" #include <KXmlGuiWindow> class QAbstractItemModel; @@ -71,8 +71,8 @@ void readMenu( MenuItem * ); KCModuleModel *model; - KService::List categories; - KService::List modules; + YService::List categories; + YService::List modules; MenuItem * rootItem; QStackedWidget *windowStack; KTabWidget *moduleTabs; @@ -80,9 +80,10 @@ KCMultiWidget *groupWidget; QScrollArea *scrollView; - - QHashKService::Ptr,KCMultiWidget* moduleItemToWidgetDict; +#ifdef tg + QHashYService::Ptr,KCMultiWidget* moduleItemToWidgetDict; QHash<const QAbstractItemModel *,int> modelToTabHash; +#endif QList<KToggleAction*> pageActions; QList<QScrollArea*> overviewPages; Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/menuitem.h Wed Feb 6 16:11:51 2008 @@ -23,7 +23,7 @@ #include <QList> #include <QString> #include <KCModuleInfo> -#include <KService> // for KService::Ptr +#include "yservice.h" /** * A menu consists of menu items. An item is either another menu or a module. @@ -38,7 +38,7 @@ bool menu; QString name; QString caption; - KService::Ptr service; + YService::Ptr service; KCModuleInfo item; }; Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.cpp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.cpp (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.cpp Wed Feb 6 16:11:51 2008 @@ -37,7 +37,7 @@ { this->rootMenu = rootMenu; this->menuPath = menuPath; - this->categories = KServiceTypeTrader::self()->query("SystemSettingsCategory"); + this->categories = YServiceTypeTrader::self()->query("SystemSettingsCategory"); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( KDialog::marginHint() ); @@ -100,7 +100,7 @@ QString categoryName = parentPath.section('/', -2, -2); QString iconName; for (int i = 0; i < categories.size(); ++i) { - const KService* entry = categories.at(i).data(); + const YService* entry = categories.at(i).data(); if (entry->name() == categoryName) { iconName = entry->icon(); break; @@ -159,7 +159,7 @@ QString categoryCaption = (*it).caption; QString iconFile; for (int i = 0; i < categories.size(); ++i) { - const KService* entry = categories.at(i).data(); + const YService* entry = categories.at(i).data(); if (entry->name() == categoryCaption) { iconFile = entry->icon(); break; Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rew... ============================================================================== --- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.h (original) +++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/modulesview.h Wed Feb 6 16:11:51 2008 @@ -26,7 +26,7 @@ #include <QListWidget> #include <QList> -#include <KService> +#include "yservice" /** * Overloaded to give a larger default size that fits with text of two lines. */ @@ -103,7 +103,7 @@ QList<RowIconView*> groups; KCModuleMenu *rootMenu; QString menuPath; - KService::List categories; + YService::List categories; void createRow( const QString &parentPath, QBoxLayout *layout ); }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org