summaryrefslogtreecommitdiff
path: root/libopie2/opieui/okeyconfigwidget.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/okeyconfigwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/okeyconfigwidget.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp
index ef6d713..eb7acbd 100644
--- a/libopie2/opieui/okeyconfigwidget.cpp
+++ b/libopie2/opieui/okeyconfigwidget.cpp
@@ -453,119 +453,120 @@ bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const {
453OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, 453OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf,
454 const QString& group, 454 const QString& group,
455 const OKeyPair::List& black, 455 const OKeyPair::List& black,
456 bool grabkeyboard, QObject* par, 456 bool grabkeyboard, QObject* par,
457 const char* name) 457 const char* name)
458 : QObject( par, name ), m_conf( conf ), m_group( group ), 458 : QObject( par, name ), m_conf( conf ), m_group( group ),
459 m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ 459 m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){
460 if ( m_grab ) 460 if ( m_grab )
461 QPEApplication::grabKeyboard(); 461 QPEApplication::grabKeyboard();
462} 462}
463 463
464 464
465/** 465/**
466 * Destructor 466 * Destructor
467 */ 467 */
468OKeyConfigManager::~OKeyConfigManager() { 468OKeyConfigManager::~OKeyConfigManager() {
469 if ( m_grab ) 469 if ( m_grab )
470 QPEApplication::ungrabKeyboard(); 470 QPEApplication::ungrabKeyboard();
471} 471}
472 472
473/** 473/**
474 * Load the Configuration from the OConfig 474 * Load the Configuration from the OConfig
475 * If a Key is restricted but was in the config we will 475 * If a Key is restricted but was in the config we will
476 * make it be the empty key paur 476 * make it be the empty key paur
477 * We will change the group of the OConfig Item! 477 * We will change the group but restore to the previous.
478 * 478 *
479 * @see OKeyPair::emptyKey 479 * @see OKeyPair::emptyKey
480 */ 480 */
481void OKeyConfigManager::load() { 481void OKeyConfigManager::load() {
482 m_conf->setGroup( m_group ); 482 Opie::Core::OConfigGroupSaver( m_conf, m_group );
483 483
484 /* 484 /*
485 * Read each item 485 * Read each item
486 */ 486 */
487 int key, mod; 487 int key, mod;
488 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { 488 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) {
489 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); 489 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() );
490 mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); 490 mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() );
491 OKeyPair okey( key, mod ); 491 OKeyPair okey( key, mod );
492 492
493 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) 493 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 )
494 (*it).setKeyPair( OKeyPair(key, mod) ); 494 (*it).setKeyPair( OKeyPair(key, mod) );
495 else 495 else
496 (*it).setKeyPair( OKeyPair::emptyKey() ); 496 (*it).setKeyPair( OKeyPair::emptyKey() );
497 } 497 }
498 delete m_map; m_map = 0; 498 delete m_map; m_map = 0;
499} 499}
500 500
501/** 501/**
502 * We will save the current configuration 502 * We will save the current configuration
503 * to the OConfig. We will change the group. 503 * to the OConfig. We will change the group but restore
504 * to the previous
504 */ 505 */
505void OKeyConfigManager::save() { 506void OKeyConfigManager::save() {
506 m_conf->setGroup( m_group ); 507 Opie::Core::OConfigGroupSaver( m_conf, m_group );
507 508
508 /* 509 /*
509 * Write each item 510 * Write each item
510 */ 511 */
511 for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) { 512 for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) {
512 /* skip empty items */ 513 /* skip empty items */
513 if ( (*it).isEmpty() ) 514 if ( (*it).isEmpty() )
514 continue; 515 continue;
515 OKeyPair pair = (*it).keyPair(); 516 OKeyPair pair = (*it).keyPair();
516 OKeyPair deft = (*it).defaultKeyPair(); 517 OKeyPair deft = (*it).defaultKeyPair();
517 /* 518 /*
518 * don't write if it is the default setting 519 * don't write if it is the default setting
519 * FIXME allow to remove Keys from config 520 * FIXME allow to remove Keys from config
520 if ( (pair.keycode() == deft.keycode()) && 521 if ( (pair.keycode() == deft.keycode()) &&
521 (pair.modifier()== deft.modifier() ) ) 522 (pair.modifier()== deft.modifier() ) )
522 return; 523 return;
523 */ 524 */
524 525
525 m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); 526 m_conf->writeEntry((*it).configKey()+"key", pair.keycode() );
526 m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); 527 m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() );
527 } 528 }
528} 529}
529 530
530/** 531/**
531 * This is function uses a QMap internally but you can have the same keycode 532 * This is function uses a QMap internally but you can have the same keycode
532 * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem 533 * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem
533 * with same keycode and modifier key. The GUI takes care that a user can't 534 * with same keycode and modifier key. The GUI takes care that a user can't
534 * cofigure two keys. 535 * cofigure two keys.
535 * 536 *
536 * Make sure you call e->ignore if you don't want to handle this event 537 * Make sure you call e->ignore if you don't want to handle this event
537 */ 538 */
538OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { 539OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) {
539 /* 540 /*
540 * Fix Up issues with Qt/E, my keybard, and virtual input 541 * Fix Up issues with Qt/E, my keybard, and virtual input
541 * methods 542 * methods
542 * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state 543 * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state
543 * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower 544 * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower
544 * case ascii 545 * case ascii
545 */ 546 */
546 int key, mod; 547 int key, mod;
547 Opie::Ui::Private::fixupKeys( key, mod, e ); 548 Opie::Ui::Internal::fixupKeys( key, mod, e );
548 549
549 OKeyConfigItem::List _keyList = keyList( key ); 550 OKeyConfigItem::List _keyList = keyList( key );
550 if ( _keyList.isEmpty() ) 551 if ( _keyList.isEmpty() )
551 return OKeyConfigItem(); 552 return OKeyConfigItem();
552 553
553 OKeyConfigItem item; 554 OKeyConfigItem item;
554 for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); 555 for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end();
555 ++it ) { 556 ++it ) {
556 if ( (*it).keyPair().modifier() == mod ) { 557 if ( (*it).keyPair().modifier() == mod ) {
557 item = *it; 558 item = *it;
558 break; 559 break;
559 } 560 }
560 561
561 } 562 }
562 563
563 return item; 564 return item;
564} 565}
565 566
566/** 567/**
567 * Return the associated id of the item or -1 if no item 568 * Return the associated id of the item or -1 if no item
568 * matched the key 569 * matched the key
569 * 570 *
570 * @see handleKeyEvent 571 * @see handleKeyEvent
571 */ 572 */
@@ -695,49 +696,49 @@ OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) {
695 it!= m_keys.end(); ++it ) { 696 it!= m_keys.end(); ++it ) {
696 697
697 bool add = true; 698 bool add = true;
698 /* see if this key is blocked */ 699 /* see if this key is blocked */
699 OKeyPair pair = (*it).keyPair(); 700 OKeyPair pair = (*it).keyPair();
700 for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin(); 701 for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin();
701 pairIt != m_blackKeys.end(); ++pairIt ) { 702 pairIt != m_blackKeys.end(); ++pairIt ) {
702 if ( (*pairIt).keycode() == pair.keycode() && 703 if ( (*pairIt).keycode() == pair.keycode() &&
703 (*pairIt).modifier() == pair.modifier() ) { 704 (*pairIt).modifier() == pair.modifier() ) {
704 add = false; 705 add = false;
705 break; 706 break;
706 } 707 }
707 } 708 }
708 /* check if we added it */ 709 /* check if we added it */
709 if ( add ) 710 if ( add )
710 (*m_map)[pair.keycode()].append( *it ); 711 (*m_map)[pair.keycode()].append( *it );
711 } 712 }
712 } 713 }
713 return (*m_map)[keycode]; 714 return (*m_map)[keycode];
714} 715}
715 716
716 717
717namespace Opie { 718namespace Opie {
718namespace Ui { 719namespace Ui {
719namespace Private { 720namespace Internal {
720 721
721 OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) 722 OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent)
722 : Opie::Ui::OListViewItem( parent ), m_manager( man ) { 723 : Opie::Ui::OListViewItem( parent ), m_manager( man ) {
723 m_origItem = item; 724 m_origItem = item;
724 setItem( item ); 725 setItem( item );
725 } 726 }
726 OKeyListViewItem::~OKeyListViewItem() {} 727 OKeyListViewItem::~OKeyListViewItem() {}
727 OKeyConfigItem &OKeyListViewItem::item(){ 728 OKeyConfigItem &OKeyListViewItem::item(){
728 return m_item; 729 return m_item;
729 } 730 }
730 OKeyConfigItem OKeyListViewItem::origItem() const{ 731 OKeyConfigItem OKeyListViewItem::origItem() const{
731 return m_origItem; 732 return m_origItem;
732 } 733 }
733 OKeyConfigManager* OKeyListViewItem::manager() { 734 OKeyConfigManager* OKeyListViewItem::manager() {
734 return m_manager; 735 return m_manager;
735 } 736 }
736 void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { 737 void OKeyListViewItem::setItem( const OKeyConfigItem& item ) {
737 m_item = item; 738 m_item = item;
738 setPixmap( 0, m_item.pixmap() ); 739 setPixmap( 0, m_item.pixmap() );
739 setText ( 1, m_item.text() ); 740 setText ( 1, m_item.text() );
740 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : 741 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) :
741 setText( 2, keyToString( m_item.keyPair() ) ); 742 setText( 2, keyToString( m_item.keyPair() ) );
742 743
743 m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) : 744 m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) :
@@ -917,214 +918,214 @@ void OKeyConfigWidget::initUi() {
917 918
918/** 919/**
919 * Set the ChangeMode. 920 * Set the ChangeMode.
920 * You need to call this function prior to load 921 * You need to call this function prior to load
921 * If you call this function past load the behaviour is undefined 922 * If you call this function past load the behaviour is undefined
922 * But caling load again is safe 923 * But caling load again is safe
923 */ 924 */
924void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { 925void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) {
925 m_mode = mode; 926 m_mode = mode;
926} 927}
927 928
928 929
929/** 930/**
930 * return the current mode 931 * return the current mode
931 */ 932 */
932OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { 933OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const {
933 return m_mode; 934 return m_mode;
934} 935}
935 936
936 937
937/** 938/**
938 * insert these items before calling load 939 * insert these items before calling load
939 */ 940 */
940void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { 941void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) {
941 Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); 942 Opie::Ui::Internal::OKeyConfigWidgetPrivate root( str, man );
942 m_list.append(root); 943 m_list.append(root);
943} 944}
944 945
945 946
946/** 947/**
947 * loads the items and allows editing them 948 * loads the items and allows editing them
948 */ 949 */
949void OKeyConfigWidget::load() { 950void OKeyConfigWidget::load() {
950 Opie::Ui::Private::OKeyConfigWidgetPrivateList::Iterator it; 951 Opie::Ui::Internal::OKeyConfigWidgetPrivateList::Iterator it;
951 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 952 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
952 OListViewItem *item = new OListViewItem( m_view, (*it).name ); 953 OListViewItem *item = new OListViewItem( m_view, (*it).name );
953 OKeyConfigItem::List list = (*it).manager->keyConfigList(); 954 OKeyConfigItem::List list = (*it).manager->keyConfigList();
954 for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) 955 for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt )
955 (void )new Opie::Ui::Private::OKeyListViewItem(*keyIt, (*it).manager, item ); 956 (void )new Opie::Ui::Internal::OKeyListViewItem(*keyIt, (*it).manager, item );
956 957
957 } 958 }
958} 959}
959 960
960/** 961/**
961 * Saves if in Queue Mode. It'll update the supplied 962 * Saves if in Queue Mode. It'll update the supplied
962 * OKeyConfigManager objects. 963 * OKeyConfigManager objects.
963 * If in Queue mode it'll just return 964 * If in Queue mode it'll just return
964 */ 965 */
965void OKeyConfigWidget::save() { 966void OKeyConfigWidget::save() {
966 /* 967 /*
967 * Iterate over all config items 968 * Iterate over all config items
968 */ 969 */
969 QListViewItemIterator it( m_view ); 970 QListViewItemIterator it( m_view );
970 while ( it.current() ) { 971 while ( it.current() ) {
971 if (it.current()->parent() ) { 972 if (it.current()->parent() ) {
972 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( it.current() ); 973 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( it.current() );
973 OKeyConfigManager *man = item->manager(); 974 OKeyConfigManager *man = item->manager();
974 man->removeKeyConfig( item->origItem() ); 975 man->removeKeyConfig( item->origItem() );
975 man->addKeyConfig( item->item() ); 976 man->addKeyConfig( item->item() );
976 } 977 }
977 ++it; 978 ++it;
978 } 979 }
979 980
980 981
981} 982}
982 983
983 984
984/** 985/**
985 * @internal 986 * @internal
986 */ 987 */
987void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { 988void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) {
988 if ( !_item || !_item->parent() ) { 989 if ( !_item || !_item->parent() ) {
989 m_box->setEnabled( false ); 990 m_box->setEnabled( false );
990 m_none->setChecked( true ); 991 m_none->setChecked( true );
991 m_btn ->setEnabled( false ); 992 m_btn ->setEnabled( false );
992 m_def ->setChecked( false ); 993 m_def ->setChecked( false );
993 m_cus ->setChecked( false ); 994 m_cus ->setChecked( false );
994 }else{ 995 }else{
995 m_box->setEnabled( true ); 996 m_box->setEnabled( true );
996 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); 997 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( _item );
997 OKeyConfigItem keyItem= item->item(); 998 OKeyConfigItem keyItem= item->item();
998 m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); 999 m_lbl->setText( tr("Default: " )+ item->text( 3 ) );
999 if ( keyItem.keyPair().isEmpty() ) { 1000 if ( keyItem.keyPair().isEmpty() ) {
1000 m_none->setChecked( true ); 1001 m_none->setChecked( true );
1001 m_btn ->setEnabled( false ); 1002 m_btn ->setEnabled( false );
1002 m_def ->setChecked( false ); 1003 m_def ->setChecked( false );
1003 m_cus ->setChecked( false ); 1004 m_cus ->setChecked( false );
1004 }else { 1005 }else {
1005 m_none->setChecked( false ); 1006 m_none->setChecked( false );
1006 m_cus ->setChecked( true ); 1007 m_cus ->setChecked( true );
1007 m_btn ->setEnabled( true ); 1008 m_btn ->setEnabled( true );
1008 m_def ->setChecked( false ); 1009 m_def ->setChecked( false );
1009 } 1010 }
1010 } 1011 }
1011} 1012}
1012 1013
1013void OKeyConfigWidget::slotNoKey() { 1014void OKeyConfigWidget::slotNoKey() {
1014 m_none->setChecked( true ); 1015 m_none->setChecked( true );
1015 m_cus ->setChecked( false ); 1016 m_cus ->setChecked( false );
1016 m_btn ->setEnabled( false ); 1017 m_btn ->setEnabled( false );
1017 m_def ->setChecked( false ); 1018 m_def ->setChecked( false );
1018 1019
1019 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1020 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1020 return; 1021 return;
1021 1022
1022 1023
1023 1024
1024 /* 1025 /*
1025 * If immediate we need to remove and readd the key 1026 * If immediate we need to remove and readd the key
1026 */ 1027 */
1027 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1028 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1028 updateItem( item, OKeyPair::emptyKey() ); 1029 updateItem( item, OKeyPair::emptyKey() );
1029} 1030}
1030 1031
1031void OKeyConfigWidget::slotDefaultKey() { 1032void OKeyConfigWidget::slotDefaultKey() {
1032 m_none->setChecked( false ); 1033 m_none->setChecked( false );
1033 m_cus ->setChecked( false ); 1034 m_cus ->setChecked( false );
1034 m_btn ->setEnabled( false ); 1035 m_btn ->setEnabled( false );
1035 m_def ->setChecked( true ); 1036 m_def ->setChecked( true );
1036 1037
1037 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1038 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1038 return; 1039 return;
1039 1040
1040 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1041 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1041 updateItem( item, item->item().defaultKeyPair() ); 1042 updateItem( item, item->item().defaultKeyPair() );
1042} 1043}
1043 1044
1044void OKeyConfigWidget::slotCustomKey() { 1045void OKeyConfigWidget::slotCustomKey() {
1045 m_cus ->setChecked( true ); 1046 m_cus ->setChecked( true );
1046 m_btn ->setEnabled( true ); 1047 m_btn ->setEnabled( true );
1047 m_def ->setChecked( false ); 1048 m_def ->setChecked( false );
1048 m_none->setChecked( false ); 1049 m_none->setChecked( false );
1049 1050
1050 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1051 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1051 return; 1052 return;
1052 1053
1053 1054
1054} 1055}
1055 1056
1056void OKeyConfigWidget::slotConfigure() { 1057void OKeyConfigWidget::slotConfigure() {
1057 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1058 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1058 return; 1059 return;
1059 1060
1060 /* FIXME make use of OModalHelper */ 1061 /* FIXME make use of OModalHelper */
1061 OKeyChooserConfigDialog dlg( this, "Dialog Name", true ); 1062 OKeyChooserConfigDialog dlg( this, "Dialog Name", true );
1062 dlg.setCaption(tr("Configure Key")); 1063 dlg.setCaption(tr("Configure Key"));
1063 connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) ); 1064 connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) );
1064 1065
1065 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 1066 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
1066 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1067 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1067 updateItem( item, dlg.keyPair() ); 1068 updateItem( item, dlg.keyPair() );
1068 } 1069 }
1069 1070
1070 1071
1071} 1072}
1072 1073
1073bool OKeyConfigWidget::sanityCheck( Opie::Ui::Private::OKeyListViewItem* item, 1074bool OKeyConfigWidget::sanityCheck( Opie::Ui::Internal::OKeyListViewItem* item,
1074 const OKeyPair& newItem ) { 1075 const OKeyPair& newItem ) {
1075 OKeyPair::List bList = item->manager()->blackList(); 1076 OKeyPair::List bList = item->manager()->blackList();
1076 for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) { 1077 for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) {
1077 /* black list matched */ 1078 /* black list matched */
1078 if ( *it == newItem ) { 1079 if ( *it == newItem ) {
1079 QMessageBox::warning( 0, tr("Key is on BlackList" ), 1080 QMessageBox::warning( 0, tr("Key is on BlackList" ),
1080 tr("<qt>The Key you choose is on the black list " 1081 tr("<qt>The Key you choose is on the black list "
1081 "and may not be used with this manager. Please " 1082 "and may not be used with this manager. Please "
1082 "use a different key.</qt>" ) ); 1083 "use a different key.</qt>" ) );
1083 return false; 1084 return false;
1084 } 1085 }
1085 } 1086 }
1086 /* no we need to check the other items which is dog slow */ 1087 /* no we need to check the other items which is dog slow */
1087 QListViewItemIterator it( item->parent() ); 1088 QListViewItemIterator it( item->parent() );
1088 while ( it.current() ) { 1089 while ( it.current() ) {
1089 /* if not our parent and not us */ 1090 /* if not our parent and not us */
1090 if (it.current()->parent() && it.current() != item) { 1091 if (it.current()->parent() && it.current() != item) {
1091 /* damn already given away*/ 1092 /* damn already given away*/
1092 if ( newItem == static_cast<Opie::Ui::Private::OKeyListViewItem*>(it.current() )->item().keyPair() ) { 1093 if ( newItem == static_cast<Opie::Ui::Internal::OKeyListViewItem*>(it.current() )->item().keyPair() ) {
1093 QMessageBox::warning( 0, tr("Key is already assigned" ), 1094 QMessageBox::warning( 0, tr("Key is already assigned" ),
1094 tr("<qt>The Key you choose is already taken by " 1095 tr("<qt>The Key you choose is already taken by "
1095 "a different Item of your config. Please try" 1096 "a different Item of your config. Please try"
1096 "using a different key.</qt>" ) ); 1097 "using a different key.</qt>" ) );
1097 return false; 1098 return false;
1098 } 1099 }
1099 } 1100 }
1100 ++it; 1101 ++it;
1101 } 1102 }
1102 1103
1103 return true; 1104 return true;
1104} 1105}
1105 1106
1106void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, 1107void OKeyConfigWidget::updateItem( Opie::Ui::Internal::OKeyListViewItem *item,
1107 const OKeyPair& newItem) { 1108 const OKeyPair& newItem) {
1108 /* sanity check 1109 /* sanity check
1109 * check against the blacklist of the manager 1110 * check against the blacklist of the manager
1110 * check if another item uses this key which is o(n) at least 1111 * check if another item uses this key which is o(n) at least
1111 */ 1112 */
1112 if ( !newItem.isEmpty() && !sanityCheck(item, newItem )) 1113 if ( !newItem.isEmpty() && !sanityCheck(item, newItem ))
1113 return; 1114 return;
1114 1115
1115 1116
1116 1117
1117 /* 1118 /*
1118 * If immediate we need to remove and readd the key 1119 * If immediate we need to remove and readd the key
1119 */ 1120 */
1120 if ( m_mode == Imediate ) 1121 if ( m_mode == Imediate )
1121 item->manager()->removeKeyConfig( item->item() ); 1122 item->manager()->removeKeyConfig( item->item() );
1122 1123
1123 item->item().setKeyPair( newItem ); 1124 item->item().setKeyPair( newItem );
1124 item->updateText(); 1125 item->updateText();
1125 1126
1126 if ( m_mode == Imediate ) 1127 if ( m_mode == Imediate )
1127 item->manager()->addKeyConfig( item->item() ); 1128 item->manager()->addKeyConfig( item->item() );
1128} 1129}
1129 1130
1130 1131
@@ -1144,104 +1145,104 @@ OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam,
1144 1145
1145 m_lbl = new QLabel( this ); 1146 m_lbl = new QLabel( this );
1146 lay->addWidget( m_lbl ); 1147 lay->addWidget( m_lbl );
1147 m_lbl->setFocusPolicy( NoFocus ); 1148 m_lbl->setFocusPolicy( NoFocus );
1148 1149
1149 m_timer = new QTimer( this ); 1150 m_timer = new QTimer( this );
1150 connect(m_timer, SIGNAL(timeout()), 1151 connect(m_timer, SIGNAL(timeout()),
1151 this, SLOT(slotTimeUp()) ); 1152 this, SLOT(slotTimeUp()) );
1152} 1153}
1153 1154
1154OKeyChooserConfigDialog::~OKeyChooserConfigDialog() { 1155OKeyChooserConfigDialog::~OKeyChooserConfigDialog() {
1155} 1156}
1156 1157
1157Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ 1158Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{
1158 return m_keyPair; 1159 return m_keyPair;
1159} 1160}
1160 1161
1161void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { 1162void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1162 QDialog::keyPressEvent( ev ); 1163 QDialog::keyPressEvent( ev );
1163 1164
1164 if ( ev->isAutoRepeat() ) 1165 if ( ev->isAutoRepeat() )
1165 return; 1166 return;
1166 1167
1167 int mod, key; 1168 int mod, key;
1168 Opie::Ui::Private::fixupKeys( key,mod, ev ); 1169 Opie::Ui::Internal::fixupKeys( key,mod, ev );
1169 1170
1170 /* either we used software keyboard 1171 /* either we used software keyboard
1171 * or we've true support 1172 * or we've true support
1172 */ 1173 */
1173 if ( !m_virtKey && !ev->key()) { 1174 if ( !m_virtKey && !ev->key()) {
1174 m_virtKey = true; 1175 m_virtKey = true;
1175 m_keyPair = OKeyPair( key, mod ); 1176 m_keyPair = OKeyPair( key, mod );
1176 }else{ 1177 }else{
1177 mod = 0; 1178 mod = 0;
1178 switch( key ) { 1179 switch( key ) {
1179 case Qt::Key_Control: 1180 case Qt::Key_Control:
1180 mod = Qt::ControlButton; 1181 mod = Qt::ControlButton;
1181 break; 1182 break;
1182 case Qt::Key_Shift: 1183 case Qt::Key_Shift:
1183 mod = Qt::ShiftButton; 1184 mod = Qt::ShiftButton;
1184 break; 1185 break;
1185 case Qt::Key_Alt: 1186 case Qt::Key_Alt:
1186 mod = Qt::AltButton; 1187 mod = Qt::AltButton;
1187 break; 1188 break;
1188 default: 1189 default:
1189 break; 1190 break;
1190 } 1191 }
1191 if (mod ) { 1192 if (mod ) {
1192 m_mod |= mod; 1193 m_mod |= mod;
1193 key = 0; 1194 key = 0;
1194 }else 1195 }else
1195 m_key = key; 1196 m_key = key;
1196 1197
1197 if ( ( !mod || m_key || key ) && !m_timer->isActive() ) 1198 if ( ( !mod || m_key || key ) && !m_timer->isActive() )
1198 m_timer->start( 150, true ); 1199 m_timer->start( 150, true );
1199 1200
1200 m_keyPair = OKeyPair( m_key, m_mod ); 1201 m_keyPair = OKeyPair( m_key, m_mod );
1201 } 1202 }
1202 1203
1203 m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); 1204 m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) );
1204 1205
1205} 1206}
1206 1207
1207void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { 1208void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) {
1208 m_timer->stop(); 1209 m_timer->stop();
1209 QDialog::keyPressEvent( ev ); 1210 QDialog::keyPressEvent( ev );
1210 1211
1211 if ( ev->isAutoRepeat() ) 1212 if ( ev->isAutoRepeat() )
1212 return; 1213 return;
1213 1214
1214 1215
1215 if ( m_virtKey && !ev->key()) { 1216 if ( m_virtKey && !ev->key()) {
1216 m_virtKey = false; 1217 m_virtKey = false;
1217 slotTimeUp(); 1218 slotTimeUp();
1218 }else { 1219 }else {
1219 int mod = 0; 1220 int mod = 0;
1220 int key = ev->key(); 1221 int key = ev->key();
1221 switch( key ) { 1222 switch( key ) {
1222 case Qt::Key_Control: 1223 case Qt::Key_Control:
1223 mod = Qt::ControlButton; 1224 mod = Qt::ControlButton;
1224 break; 1225 break;
1225 case Qt::Key_Shift: 1226 case Qt::Key_Shift:
1226 mod = Qt::ShiftButton; 1227 mod = Qt::ShiftButton;
1227 break; 1228 break;
1228 case Qt::Key_Alt: 1229 case Qt::Key_Alt:
1229 mod = Qt::AltButton; 1230 mod = Qt::AltButton;
1230 break; 1231 break;
1231 default: 1232 default:
1232 break; 1233 break;
1233 } 1234 }
1234 if (mod ) 1235 if (mod )
1235 m_mod &= ~mod; 1236 m_mod &= ~mod;
1236 else 1237 else
1237 m_key = key; 1238 m_key = key;
1238 m_keyPair = OKeyPair( m_key, m_mod ); 1239 m_keyPair = OKeyPair( m_key, m_mod );
1239 m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); 1240 m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) );
1240 } 1241 }
1241} 1242}
1242 1243
1243 1244
1244void OKeyChooserConfigDialog::slotTimeUp() { 1245void OKeyChooserConfigDialog::slotTimeUp() {
1245 m_mod = m_key = 0; 1246 m_mod = m_key = 0;
1246 QTimer::singleShot(0, this, SIGNAL(keyCaptured()) ); 1247 QTimer::singleShot(0, this, SIGNAL(keyCaptured()) );
1247} 1248}