From d2d73b6391fbc7f743199f48387d13e887bbac1e Mon Sep 17 00:00:00 2001 From: harlekin Date: Fri, 20 Sep 2002 20:19:14 +0000 Subject: fixed the crash when closing config dialog and also sorting of the plugins is working now --- (limited to 'core/pim/today') diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 7537631..d8b427d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -108,16 +108,12 @@ void Today::setOwnerField( QString &message ) { * Init stuff needed for today. Reads the config file. */ void Today::init() { - - QDate date = QDate::currentDate(); - QString time = ( tr( date.toString() ) ); - - DateLabel->setText( QString( "" + time + "" ) ); - // read config Config cfg( "today" ); - cfg.setGroup( "Applets" ); + cfg.setGroup( "Plugins" ); + m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); + m_allApplets = cfg.readListEntry( "AllApplets", ',' ); } @@ -133,13 +129,15 @@ void Today::loadPlugins() { } pluginList.clear(); - QString path = QPEApplication::qpeDir() + "/plugins/today"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; + + QMap tempList; + for ( it = list.begin(); it != list.end(); ++it ) { TodayPluginInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); @@ -164,12 +162,10 @@ void Today::loadPlugins() { // package the whole thing into a qwidget so it can be shown and hidden plugin.guiBox = new QWidget( this ); QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); - QPixmap plugPix; plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( 18, 18 ), 0 ); - OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); + OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); - // a scrollview for each plugin QScrollView* sv = new QScrollView( plugin.guiBox ); QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); @@ -178,20 +174,36 @@ void Today::loadPlugins() { sv->setHScrollBarMode( QScrollView::AlwaysOff ); sv->setFrameShape( QFrame::NoFrame ); sv->addChild( plugWidget ); - // make sure the icon is on the top alligned boxLayout->addWidget( plugIcon, 0, AlignTop ); boxLayout->addWidget( sv, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); boxLayout->setStretchFactor( sv, 9 ); - layout->addWidget( plugin.guiBox ); + // "prebuffer" it in one more list, to get the sorting done + tempList.insert( plugin.name, plugin ); - pluginList.append( plugin ); + // on first start the list is off course empty + if ( m_allApplets.isEmpty() ) { + layout->addWidget( plugin.guiBox ); + pluginList.append( plugin ); + } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; } } + + if ( !m_allApplets.isEmpty() ) { + TodayPlugin tempPlugin; + QStringList::Iterator stringit; + for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { + tempPlugin = ( tempList.find( *stringit ) ).data(); + if ( !( (tempPlugin.name).isEmpty() ) ) { + layout->addWidget( tempPlugin.guiBox ); + pluginList.append( tempPlugin ); + } + } + } } @@ -227,8 +239,7 @@ void Today::draw() { noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } - //layout->addStretch(0); - //layout->addItem( new QSpacerItem( 1,1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); + layout->addStretch(0); } @@ -241,12 +252,13 @@ void Today::startConfig() { TodayPlugin plugin; QList configWidgetList; - for ( uint i = 0; i < pluginList.count(); i++ ) { + + for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { plugin = pluginList[i]; // load the config widgets in the tabs if ( plugin.guiPart->configWidget( this ) != 0l ) { - ConfigWidget* widget = plugin.guiPart->configWidget( this ); + ConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); configWidgetList.append( widget ); conf.TabWidget3->insertTab( widget, plugin.guiPart->appName() ); } @@ -274,6 +286,12 @@ void Today::startConfig() { void Today::refresh() { init(); + // set the date in top label + QDate date = QDate::currentDate(); + QString time = ( tr( date.toString() ) ); + + DateLabel->setText( QString( "" + time + "" ) ); + if ( layout ) { delete layout; } diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 672adc4..b35c9b1 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -34,6 +34,7 @@ class QVBoxLayout; + class Today : public TodayBase { Q_OBJECT @@ -55,13 +56,13 @@ private: void loadPlugins(); void draw(); - private slots: void channelReceived(const QCString &msg, const QByteArray & data); private: TodayConfig *conf; QStringList m_excludeApplets; + QStringList m_allApplets; // QString m_autoStartTimer; int m_newStart; diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 4f23471..532d126 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp @@ -35,7 +35,6 @@ class ToolButton : public QToolButton { public: ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) : QToolButton( parent, name ) { - // setTextLabel( name ); setPixmap( Resource::loadPixmap( icon ) ); setAutoRaise( TRUE ); setFocusPolicy( QWidget::NoFocus ); @@ -69,29 +68,24 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags m_appletListView = new QListView( hbox1 ); m_appletListView->addColumn( "PluginList" ); m_appletListView->header()->hide(); + m_appletListView->setSorting( -1 ); QVBox *vbox1 = new QVBox( hbox1 ); new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", this , SLOT( moveSelectedUp() ) ); new ToolButton( vbox1, tr( "Move Down" ),"opieplayer/down", this , SLOT( moveSelectedDown() ) ); tab2Layout->addWidget( hbox1 ); - TabWidget3->insertTab( tab_2, tr( "active/order" ) ); + tab_3 = new QWidget( TabWidget3, "tab_3" ); QVBoxLayout *tab3Layout = new QVBoxLayout( tab_3 ); - QHBox *hbox_clip = new QHBox( tab_3 ); - TextLabel1 = new QLabel( hbox_clip, "TextLabel1" ); - TextLabel1->setText( tr( "Clip after how\n" - "many letters" ) ); - SpinBox7 = new QSpinBox( hbox_clip, "SpinBox7" ); - SpinBox7->setMaxValue( 80 ); + tab3Layout->setMargin( 20 ); QHBox *hbox_auto = new QHBox( tab_3 ); TextLabel2 = new QLabel( hbox_auto, "AutoStart" ); - TextLabel2->setText( tr( "autostart on \nresume? (Opie only)" ) ); + TextLabel2->setText( tr( "autostart on \nresume?\n (Opie only)" ) ); CheckBoxAuto = new QCheckBox( hbox_auto, "CheckBoxAuto" ); QHBox *hbox_inactive = new QHBox( tab_3 ); TimeLabel = new QLabel( hbox_inactive , "TimeLabel" ); TimeLabel->setText( tr( "minutes inactive" ) ); - SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner"); - tab3Layout->addWidget( hbox_clip ); + SpinBoxTime = new QSpinBox( hbox_inactive, "TimeSpinner" ); tab3Layout->addWidget( hbox_auto ); tab3Layout->addWidget( hbox_inactive ); TabWidget3->insertTab( tab_3, tr( "Misc" ) ); @@ -112,7 +106,7 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal, WFlags void TodayConfig::setAutoStart() { Config cfg( "today" ); cfg.setGroup( "Autostart" ); - int autostart = cfg.readNumEntry( "autostart", 1); + int autostart = cfg.readNumEntry( "autostart", 1 ); if ( autostart ) { QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); e << QString( "add" ); @@ -136,7 +130,7 @@ void TodayConfig::readConfig() { m_autoStartTimer = cfg.readEntry( "autostartdelay", "0" ); SpinBoxTime->setValue( m_autoStartTimer.toInt() ); - cfg.setGroup( "Applets" ); + cfg.setGroup( "Plugins" ); m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); } @@ -145,25 +139,36 @@ void TodayConfig::readConfig() { */ void TodayConfig::writeConfig() { Config cfg( "today" ); - cfg. setGroup ( "Applets" ); + cfg.setGroup( "Plugins" ); if ( m_applets_changed ) { QStringList exclude; QStringList include; - QMap ::Iterator it; - for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { - if ( !(*it)-> isOn () ) { - exclude << it.key(); - } else { - include << it.key(); + QStringList all_applets; + + QListViewItemIterator list_it( m_appletListView ); + + // this makes sure the names get saved in the order selected + for ( ; list_it.current(); ++list_it ) { + QMap ::Iterator it; + for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { + if ( list_it.current() == (*it) && !(*it)-> isOn () ) { + exclude << it.key(); + } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ + include << it.key(); + } + if ( list_it.current() == (*it) ) { + all_applets << it.key(); + } } } cfg.writeEntry( "ExcludeApplets", exclude, ',' ); cfg.writeEntry( "IncludeApplets", include, ',' ); + cfg.writeEntry( "AllApplets", all_applets, ',' ); } cfg.setGroup( "Autostart" ); m_autoStart = CheckBoxAuto->isChecked(); - cfg.writeEntry( "autostart", m_autoStart ); + cfg.writeEntry( "autostart", m_autoStart ); m_autoStartTimer = SpinBoxTime->value(); cfg.readEntry( "autostartdelay", m_autoStartTimer ); } @@ -171,7 +176,7 @@ void TodayConfig::writeConfig() { void TodayConfig::moveSelectedUp() { QListViewItem *item = m_appletListView->selectedItem(); - if ( item && item->itemAbove() ) { + if ( item && item->itemAbove() ) { item->itemAbove()->moveItem( item ); } } @@ -197,10 +202,10 @@ void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon item->setPixmap( 0, icon ); } - qDebug (" SUCHNAME: " + name ); if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { item->setOn( TRUE ); } + m_applets[libName] = item; } -- cgit v0.9.0.2