Author: tgoettlicher
Date: Thu Feb 7 17:21:58 2008
New Revision: 44254
URL: http://svn.opensuse.org/viewcvs/yast?rev=44254&view=rev
Log:
added search widgets to ui
Modified:
branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp
Modified: branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp?rev=44254&r1=44253&r2=44254&view=diff
==============================================================================
--- branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp (original)
+++ branches/tmp/tgoettlicher/yast2_2nd_rewrite/systemsettings/mainwindow.cpp Thu Feb 7 17:21:58 2008
@@ -1,121 +1,62 @@
-/**
- * This file is part of the System Settings package
- * Copyright (C) 2005 Benjamin C Meyer (ben+systempreferences at meyerhome dot net)
- * (C) 2007 Will Stephenson
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-
-
-#define SINGLECLICK true
-
#include "mainwindow.h"
-
-#include <QApplication>
-#include <QLabel>
-#include <QLayout>
-#include <QScrollArea>
-#include <QStackedWidget>
-
-//#include <KAboutApplicationDialog>
-//#include <KActionCollection>
-//#include <KCModuleInfo>
#include "kcmoduleproxy.h"
-//#include <KDebug>
-//#include <KDialog> // for spacing
-//#include <KGlobalSettings>
-//#include <KIconLoader>
-#include <QLineEdit>
-//#include <KLocale>
-//#include <KMenuBar>
-//#include <KServiceTypeTrader>
-//#include <KStandardAction>
-//#include <KTabWidget>
-//#include <KToggleAction>
-//#include <KToggleToolBarAction>
-//#include <KToolBarSpacerAction>
#include "kcategorizedsortfilterproxymodel.h"
#include "kcategorizedview.h"
#include "kcategorydrawer.h"
-
#include "kcmodulemodel.h"
#include "kcmultiwidget.h"
#include "menuitem.h"
#include "moduleiconitem.h"
#include "yservice.h"
-#include <iostream>
+#include <QApplication>
+#include <QLabel>
+#include <QLayout>
+#include <QScrollArea>
+#include <QStackedWidget>
+#include <QLineEdit>
#include <QAction>
+#include <QPushButton>
+
+#include <iostream>
+
+#define SINGLECLICK true
Q_DECLARE_METATYPE(MenuItem *)
MainWindow::MainWindow(QWidget *parent)
-// KXmlGuiWindow(parent),
- : QMainWindow(parent)
-// , categories( KServiceTypeTrader::self()->query("SystemSettingsCategory") )
-// , modules( KServiceTypeTrader::self()->query("KCModule") )
- , rootItem(new MenuItem( true, 0 ))
- , groupWidget(NULL)
- , selectedPage(0)
-
-{
- // Load the menu structure in from disk.
-
- readMenu( rootItem );
- qStableSort( rootItem->children.begin(), rootItem->children.end(), pageLessThan ); // sort tabs by weight
-// moduleTabs = new KTabWidget(this, QTabWidget::North|QTabWidget::Rounded);
- moduleTabs = new QTabWidget(this);
- moduleTabs->setTabPosition(QTabWidget::North);
- moduleTabs->setTabShape(QTabWidget::Rounded);
- buildActions();
- buildMainWidget();
- std::cerr << "here" << std::endl;
-// setupGUI(ToolBar|Save|Create,QString());
- //widgetChange();
-// menuBar()->hide();
+ : QMainWindow(parent)
+ , rootItem(new MenuItem( true, 0 ))
+ , groupWidget(NULL)
+ , selectedPage(0)
- connect(moduleTabs, SIGNAL(currentChanged(int)), SLOT(widgetChange()));
+{
+ readMenu( rootItem );
+ qStableSort( rootItem->children.begin(), rootItem->children.end(), pageLessThan ); // sort tabs by weight
+
+ moduleTabs = new QTabWidget(this);
+ moduleTabs->setTabPosition(QTabWidget::North);
+ moduleTabs->setTabShape(QTabWidget::Rounded);
+ buildActions();
+ buildMainWidget();
+
+ connect(moduleTabs, SIGNAL(currentChanged(int)), SLOT(widgetChange()));
}
MainWindow::~MainWindow()
{
- delete moduleTabs;
- delete rootItem;
+ delete moduleTabs;
+ delete rootItem;
}
QSize MainWindow::sizeHint() const
{
- return QSize(780, 580);
+ return QSize(780, 580);
}
void MainWindow::readMenu( MenuItem * parent )
{
- // look for any categories inside this level, and recurse into them
- int depth = 0;
- MenuItem * current = parent;
- while ( current && current->parent ) {
- depth++;
- current = current->parent;
- }
-
- // tg new menu
-
-
YService* entry = new YService;
entry->_name = "The World";
@@ -191,48 +132,6 @@
MenuItem * menuItema = new MenuItem(true,parent);
menuItema->name = "new";
menuItema->service = entrya;
-
-
-
-
- // tg new menu
-
-#ifdef tg
-
-
- QString space;
- space.fill( ' ', depth * 2 );
-// kDebug() << space << "Looking for children in '" << parent->name << "'";
- for (int i = 0; i < categories.size(); ++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;
- if ( parentCategory == parent->name ) {
- MenuItem * menuItem = new MenuItem(true, parent);
- menuItem->name = category;
- menuItem->service = entry;
- readMenu( menuItem );
- }
- }
-
- // scan for any modules at this level and add them
- for (int i = 0; i < modules.size(); ++i) {
- YService::Ptr entry = modules.at(i);
- QString category = entry->property("X-KDE-System-Settings-Parent-Category").toString();
-// kDebug() << "Examining module " << category;
- if(!parent->name.isEmpty() && category == parent->name ) {
-// kDebug() << space << "found module '" << entry->name() << "' " << entry->desktopEntryPath();
- MenuItem * infoItem = new MenuItem(false, parent);
- infoItem->name = category;
- infoItem->service = entry;
-
-
-
- }
- }
-
-#endif
}
void MainWindow::closeEvent ( QCloseEvent * )
@@ -244,6 +143,29 @@
void MainWindow::buildMainWidget()
{
+ QWidget *centralWidget = new QWidget();
+ setCentralWidget(centralWidget);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ centralWidget->setLayout(layout);
+
+
+ // create searchbox
+ QWidget *searchBox = new QWidget(this);
+
+ search = new QLineEdit(searchBox);
+ QPushButton* searchButton = new QPushButton("Search",searchBox);
+
+ QHBoxLayout *searchLayout = new QHBoxLayout;
+ searchLayout->addWidget(search);
+ searchLayout->addWidget(searchButton);
+ searchBox->setLayout(searchLayout);
+
+ layout->addWidget(searchBox);
+
+
+ // create icon widget
+
windowStack = new QStackedWidget(this);
// Top level pages.
@@ -254,7 +176,6 @@
KCategoryDrawer * drawer = new KCategoryDrawer;
KCategorizedView * tv = new KCategorizedView( this );
tv->setSelectionMode(QAbstractItemView::SingleSelection);
-//tg FIXME tv->setSpacing(KDialog::spacingHint());
tv->setSpacing(8);
tv->setCategoryDrawer( drawer );
tv->setViewMode( QListView::IconMode );
@@ -280,8 +201,11 @@
connect( tv, SIGNAL(doubleClicked(const QModelIndex&)),
SLOT(selectionChanged(const QModelIndex&)));
}
+
+
//tg FIXME connect( search, SIGNAL(textChanged(const QString&)),
//tg FIXME kcsfpm, SLOT(setFilterRegExp(const QString&)));
+
connect( kcsfpm, SIGNAL(layoutChanged()),
SLOT(updateSearchHits()) );
moduleTabs->addTab(tv, item->service->name() );
@@ -294,7 +218,8 @@
windowStack->addWidget(moduleTabs);
windowStack->setCurrentWidget(moduleTabs);
- setCentralWidget(windowStack);
+// setCentralWidget(windowStack);
+ layout->addWidget(windowStack);
}
void MainWindow::buildActions()
@@ -354,12 +279,12 @@
// Search edit box and result labels
QWidget *hbox = new QWidget( this );
- search = new KLineEdit( hbox );
+ search = new QLineEdit( hbox );
search->setObjectName(QLatin1String("search"));
- search->setClearButtonShown( true );
+// search->setClearButtonShown( true );
search->setFocusPolicy( Qt::StrongFocus );
- searchLabel->setBuddy( search );
- connect(searchText, SIGNAL(triggered()), search, SLOT(setFocus()));
+// searchLabel->setBuddy( search );
+// connect(searchText, SIGNAL(triggered()), search, SLOT(setFocus()));
QWidget* vbox = new QWidget(hbox);
// Set a non empty content to prevent the toolbar from getting taller when
@@ -384,11 +309,11 @@
hlayout->setStretchFactor(vbox,1);
hbox->setLayout(hlayout);
- searchAction = new KAction( "none", this );
- searchAction->setDefaultWidget(hbox);
- actionCollection()->addAction( "search", searchAction );
- searchAction->setShortcutConfigurable( false );
- hbox->setWhatsThis( i18n("Search Bar<p>Enter a search term.</p>") );
+// searchAction = new KAction( "none", this );
+// searchAction->setDefaultWidget(hbox);
+// actionCollection()->addAction( "search", searchAction );
+// searchAction->setShortcutConfigurable( false );
+// hbox->setWhatsThis( i18n("Search Bar<p>Enter a search term.</p>") );
#endif
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org