KListBox->K3ListBox

svn path=/branches/work/kwin_composite/; revision=633055
This commit is contained in:
Dirk Mueller 2007-02-13 00:27:24 +00:00
parent a71753e5cd
commit 6883415ff4
5 changed files with 122 additions and 127 deletions

View file

@ -12,7 +12,7 @@ kde4_automoc(kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
kde4_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} )
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KDE3SUPPORT_LIBS} )
install(TARGETS kdeinit_kwin_rules_dialog DESTINATION ${LIB_INSTALL_DIR} )
@ -29,7 +29,7 @@ kde4_add_plugin(kcm_kwinrules ${kcm_kwinrules_PART_SRCS})
kde4_install_libtool_file( ${PLUGIN_INSTALL_DIR} kcm_kwinrules )
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} )
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KDE3SUPPORT_LIBS} )
install(TARGETS kcm_kwinrules DESTINATION ${PLUGIN_INSTALL_DIR} )

View file

@ -18,7 +18,6 @@
#include "ruleslist.h"
#include <klistwidget.h>
#include <kpushbutton.h>
#include <assert.h>
#include <kdebug.h>
@ -29,14 +28,14 @@
namespace KWinInternal
{
KCMRulesList::KCMRulesList( QWidget* parent)
: KCMRulesListBase( parent)
KCMRulesList::KCMRulesList( QWidget* parent, const char* name )
: KCMRulesListBase( parent, name )
{
// connect both current/selected, so that current==selected (stupid QListBox :( )
connect( rules_listbox, SIGNAL( currentChanged( QListWidgetItem* )),
SLOT( activeChanged( QListWidgetItem*)));
connect( rules_listbox, SIGNAL( selectionChanged( QListWidgetItem* )),
SLOT( activeChanged( QListWidgetItem*)));
connect( rules_listbox, SIGNAL( currentChanged( Q3ListBoxItem* )),
SLOT( activeChanged( Q3ListBoxItem*)));
connect( rules_listbox, SIGNAL( selectionChanged( Q3ListBoxItem* )),
SLOT( activeChanged( Q3ListBoxItem*)));
connect( new_button, SIGNAL( clicked()),
SLOT( newClicked()));
connect( modify_button, SIGNAL( clicked()),
@ -47,7 +46,7 @@ KCMRulesList::KCMRulesList( QWidget* parent)
SLOT( moveupClicked()));
connect( movedown_button, SIGNAL( clicked()),
SLOT( movedownClicked()));
connect( rules_listbox, SIGNAL( doubleClicked ( QListWidgetItem * ) ),
connect( rules_listbox, SIGNAL( doubleClicked ( Q3ListBoxItem * ) ),
SLOT( modifyClicked()));
load();
}
@ -61,16 +60,14 @@ KCMRulesList::~KCMRulesList()
rules.clear();
}
void KCMRulesList::activeChanged( QListWidgetItem* item )
void KCMRulesList::activeChanged( Q3ListBoxItem* item )
{
int itemRow = rules_listbox->row(item);
if( item != NULL )
item->setSelected( true ); // make current==selected
rules_listbox->setSelected( item, true ); // make current==selected
modify_button->setEnabled( item != NULL );
delete_button->setEnabled( item != NULL );
moveup_button->setEnabled( item != NULL && itemRow > 0 );
movedown_button->setEnabled( item != NULL && itemRow < (rules_listbox->count()-1) );
moveup_button->setEnabled( item != NULL && item->prev() != NULL );
movedown_button->setEnabled( item != NULL && item->next() != NULL );
}
void KCMRulesList::newClicked()
@ -79,16 +76,16 @@ void KCMRulesList::newClicked()
Rules* rule = dlg.edit( NULL, 0, false );
if( rule == NULL )
return;
int pos = rules_listbox->currentRow() + 1;
rules_listbox->insertItem( pos , rule->description );
rules_listbox->item(pos)->setSelected( true );
int pos = rules_listbox->currentItem() + 1;
rules_listbox->insertItem( rule->description, pos );
rules_listbox->setSelected( pos, true );
rules.insert( rules.begin() + pos, rule );
emit changed( true );
}
void KCMRulesList::modifyClicked()
{
int pos = rules_listbox->currentRow();
int pos = rules_listbox->currentItem();
if ( pos == -1 )
return;
RulesDialog dlg;
@ -97,29 +94,29 @@ void KCMRulesList::modifyClicked()
return;
delete rules[ pos ];
rules[ pos ] = rule;
rules_listbox->item(pos)->setText( rule->description );
rules_listbox->changeItem( rule->description, pos );
emit changed( true );
}
void KCMRulesList::deleteClicked()
{
int pos = rules_listbox->currentRow();
int pos = rules_listbox->currentItem();
assert( pos != -1 );
delete rules_listbox->takeItem( pos );
rules_listbox->removeItem( pos );
rules.erase( rules.begin() + pos );
emit changed( true );
}
void KCMRulesList::moveupClicked()
{
int pos = rules_listbox->currentRow();
int pos = rules_listbox->currentItem();
assert( pos != -1 );
if( pos > 0 )
{
QString txt = rules_listbox->item(pos)->text();
delete rules_listbox->takeItem( pos );
rules_listbox->insertItem( pos - 1 , txt );
rules_listbox->item(pos-1)->setSelected( true );
QString txt = rules_listbox->text( pos );
rules_listbox->removeItem( pos );
rules_listbox->insertItem( txt, pos - 1 );
rules_listbox->setSelected( pos - 1, true );
Rules* rule = rules[ pos ];
rules[ pos ] = rules[ pos - 1 ];
rules[ pos - 1 ] = rule;
@ -129,14 +126,14 @@ void KCMRulesList::moveupClicked()
void KCMRulesList::movedownClicked()
{
int pos = rules_listbox->currentRow();
int pos = rules_listbox->currentItem();
assert( pos != -1 );
if( pos < int( rules_listbox->count()) - 1 )
{
QString txt = rules_listbox->item(pos)->text();
delete rules_listbox->takeItem( pos );
rules_listbox->insertItem( pos + 1 , txt);
rules_listbox->item(pos+1)->setSelected( true );
QString txt = rules_listbox->text( pos );
rules_listbox->removeItem( pos );
rules_listbox->insertItem( txt, pos + 1 );
rules_listbox->setSelected( pos + 1, true );
Rules* rule = rules[ pos ];
rules[ pos ] = rules[ pos + 1 ];
rules[ pos + 1 ] = rule;
@ -163,10 +160,10 @@ void KCMRulesList::load()
cfg.setGroup( QString::number( i ));
Rules* rule = new Rules( cfg );
rules.append( rule );
rules_listbox->addItem( rule->description );
rules_listbox->insertItem( rule->description );
}
if( rules.count() > 0 )
rules_listbox->item(0)->setSelected( true );
rules_listbox->setSelected( 0, true );
else
activeChanged( NULL );
}

View file

@ -1,91 +1,95 @@
<ui version="4.0" stdsetdef="1" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>KWinInternal::KCMRulesListBase</class>
<widget class="QWidget" name="KWinInternal::KCMRulesListBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
</rect>
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>KWinInternal::KCMRulesListBase</class>
<widget class="QWidget">
<property name="name">
<cstring>KCMRulesListBase</cstring>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<item rowspan="6" row="0" column="0" colspan="1" >
<widget class="KListWidget" name="rules_listbox" />
</item>
<item row="0" column="1" >
<widget class="KPushButton" name="new_button" >
<property name="text" >
<string>&amp;New...</string>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
</rect>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<widget class="K3ListBox" row="0" column="0" rowspan="6" colspan="1">
<property name="name">
<cstring>rules_listbox</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KPushButton" name="modify_button" >
<property name="text" >
<string>&amp;Modify...</string>
</property>
<widget class="KPushButton" row="0" column="1">
<property name="name">
<cstring>new_button</cstring>
</property>
<property name="text">
<string>&amp;New...</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KPushButton" name="delete_button" >
<property name="text" >
<string>Delete</string>
</property>
<property name="shortcut" >
<string/>
</property>
<widget class="KPushButton" row="1" column="1">
<property name="name">
<cstring>modify_button</cstring>
</property>
<property name="text">
<string>&amp;Modify...</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KPushButton" name="moveup_button" >
<property name="text" >
<string>Move &amp;Up</string>
</property>
<widget class="KPushButton" row="2" column="1">
<property name="name">
<cstring>delete_button</cstring>
</property>
<property name="text">
<string>Delete</string>
</property>
<property name="accel">
<string></string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="KPushButton" name="movedown_button" >
<property name="text" >
<string>Move &amp;Down</string>
</property>
<widget class="KPushButton" row="3" column="1">
<property name="name">
<cstring>moveup_button</cstring>
</property>
<property name="text">
<string>Move &amp;Up</string>
</property>
</widget>
</item>
<item row="5" column="1" >
<spacer name="spacer1" >
<property name="sizeHint" >
<size>
<width>20</width>
<height>294</height>
</size>
</property>
<property name="sizeType" >
<enum>Expanding</enum>
</property>
<property name="orientation" >
<enum>Vertical</enum>
</property>
<widget class="KPushButton" row="4" column="1">
<property name="name">
<cstring>movedown_button</cstring>
</property>
<property name="text">
<string>Move &amp;Down</string>
</property>
</widget>
<spacer row="5" column="1">
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>294</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<layoutfunction spacing="KDialog::spacingHint" margin="KDialog::marginHint" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local" >kdialog.h</include>
</includes>
</ui>
</grid>
</widget>
<layoutdefaults spacing="6" margin="11"/>
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
<includes>
<include location="local" impldecl="in declaration">kdialog.h</include>
</includes>
</UI>

View file

@ -329,7 +329,7 @@
<cstring>types</cstring>
</property>
</widget>
<widget class="KListWidget" row="1" column="0" rowspan="1" colspan="4">
<widget class="K3ListBox" row="1" column="0" rowspan="1" colspan="4">
<item>
<property name="text">
<string>Normal Window</string>
@ -2541,10 +2541,4 @@
</slots>
<layoutdefaults spacing="6" margin="11"/>
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
<includehints>
<includehint>kpushbutton.h</includehint>
<includehint>klistbox.h</includehint>
<includehint>kcombobox.h</includehint>
<includehint>krestrictedline.h</includehint>
</includehints>
</UI>

View file

@ -146,7 +146,7 @@ class Scene::Window
// Window will not be painted because of which desktop it's on
PAINT_DISABLED_BY_DESKTOP = 1 << 2,
// Window will not be painted because it is minimized
PAINT_DISABLED_BY_MINIMIZE = 1 << 3,
PAINT_DISABLED_BY_MINIMIZE = 1 << 3
};
void enablePainting( int reason );
void disablePainting( int reason );