abeditor.cpp

来自「Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3」· C++ 代码 · 共 2,205 行 · 第 1/5 页

CPP
2,205
字号
    QWidget *wContactTab = contactTab->widget();    QWidget *wBusinessTab = businessTab->widget();    QWidget *wPersonalTab = personalTab->widget();    QWidget *wOtherTab = otherTab->widget();    const QMap<int, QString> &displayNames = PimContact::trFieldsMap(); // use field names from PimContact    QLabel *label;    int rowCount = 0;    // Contact tab    QGridLayout *gl = new QGridLayout( wContactTab, 8, 3, 4, 1 );#ifdef QTOPIA_DESKTOP    gl->setResizeMode( QLayout::FreeResize);#endif    mainGL = gl;#ifdef QTOPIA_DESKTOP    gl->setSpacing( 2 );    gl->setMargin( 2 );#else    gl->addColSpacing(1,4);#endif    // FIXME : Temporary fix to stop spacing from changing    //gl->addItem( new QSpacerItem( 50, 1, QSizePolicy::Fixed, QSizePolicy::Fixed ), rowCount, 0 );    //++rowCount;    //   Abstract Name    label = new QLabel( tr("Name"), wContactTab );    label->setAlignment(AlignRight|AlignVCenter);    gl->addWidget( label, rowCount, 0 );#ifdef QTOPIA_PHONE    abName = new AbstractName( wContactTab );    gl->addWidget( abName, rowCount, 2 );#else    QHBox *nb = new QHBox( wContactTab );    abName = new AbstractName( nb );    QPushButton *ncm = new QPushButton( "...", nb );    ncm->setMaximumWidth( ncm->height() );    connect( ncm, SIGNAL(clicked()), abName, SLOT(details()) );    gl->addWidget( nb, rowCount, 2 );#endif    ++rowCount;    //   Emails    label = new QLabel( displayNames[ PimContact::Emails ], wContactTab );    label->setAlignment(AlignRight|AlignVCenter);    gl->addWidget( label, rowCount, 0 );#ifdef QTOPIA_PHONE    emailLE = new QLineEdit( wContactTab );    QPEApplication::setInputMethodHint(emailLE,QPEApplication::Named,"email");    emailContextMenu = ContextMenu::menuFor( emailLE );    //TODO Icon for this action    actionEmailDetails = new QAction( tr( "Details" ), Resource::loadIconSet( 		"field-details" ), QString::null, 0, this, 0 );    emailContextMenu->insertSeparator(0);    emailContextMenu->insertAction(actionEmailDetails, 0);    connect( actionEmailDetails, SIGNAL(activated()), this, SLOT(editEmails()) );    gl->addWidget( emailLE, rowCount, 2 );#else    QHBox *ehb = new QHBox( wContactTab );    emailLE = new QLineEdit( ehb );    QPushButton *ecm = new QPushButton( "...", ehb );    ecm->setMaximumWidth( ecm->height() );    connect( ecm, SIGNAL(clicked()), this, SLOT(editEmails()) );    gl->addWidget( ehb, rowCount, 2 );#endif    ++rowCount;    //   Category Checkbox    categoryCB = new QCheckBox( tr("Business contact"), wContactTab );    connect( categoryCB, SIGNAL(toggled(bool)), this, SLOT(catCheckBoxChanged(bool)) );    gl->addMultiCellWidget( categoryCB, rowCount, rowCount, 0, 2, AlignHCenter );    ++rowCount;    //   Specific widgets : show up depending on contact type    specRow = rowCount;    setupSpecWidgets( wContactTab );    ++rowCount; ++rowCount;        //    Phone fields    int spacerRow = rowCount + phoneTypes.count();    phoneManRow = rowCount;    setupPhoneFields( wContactTab );    int t = rowCount;    rowCount = phoneManRow;    phoneManRow = t;    QSpacerItem *verticalSpacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum,						   QSizePolicy::Expanding );    gl->addItem( verticalSpacer, spacerRow, 2 );    // Business Tab    gl = new QGridLayout( wBusinessTab, 16, 3, 1, 1 );#ifdef QTOPIA_DESKTOP    gl->setResizeMode( QLayout::FreeResize );#endif    rowCount = 0;#ifdef QTOPIA_DESKTOP    gl->setSpacing( 4 );#else    gl->addColSpacing(1,4);#endif    //    Company    label = new QLabel( #if defined(QTOPIA_PHONE) && !defined(QTOPIA_DESKTOP)	    tr("Cmpny", "short for company")#else	   tr("Company")#endif		, wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    companyLE = new QLineEdit( wBusinessTab );    connect( companyLE, SIGNAL(textChanged(const QString&)), this, 					SLOT(specFieldsFilter(const QString&)) );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( companyLE, rowCount, 2 );    ++rowCount;    //    Company pronounciation    label = new QLabel( displayNames[ PimContact::CompanyPronunciation ], 								wBusinessTab );    companyProLE = new QLineEdit( wBusinessTab );    adjustPronWidgets(label,companyProLE);    gl->addWidget( label, rowCount, 0 );    gl->addWidget( companyProLE, rowCount, 2 );    ++rowCount;    //    Job title    label = new QLabel( tr("Title"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    jobTitleLE = new QLineEdit(  wBusinessTab );    connect( jobTitleLE, SIGNAL(textChanged(const QString&)), this, 					    SLOT(specFieldsFilter(const QString&)) );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( jobTitleLE, rowCount, 2 );    ++rowCount;    //    Phone    label = new QLabel( tr("Phone"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busPhoneLE = new QLineEdit( wBusinessTab );    QPEApplication::setInputMethodHint(busPhoneLE,QPEApplication::PhoneNumber);    connect( busPhoneLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    ContextMenu *menu = ContextMenu::menuFor( busPhoneLE );    busPhoneOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::BusinessPhone] = busPhoneOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busPhoneLE, rowCount, 2 );    ++rowCount;    //    Mobile    label = new QLabel( tr("Mobile"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busMobileLE = new QLineEdit( wBusinessTab );    QPEApplication::setInputMethodHint(busMobileLE,QPEApplication::PhoneNumber);    connect( busMobileLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( busMobileLE );    busMobileOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::BusinessMobile] = busMobileOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busMobileLE, rowCount, 2 );    ++rowCount;    //    Fax    label = new QLabel( tr("Fax"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busFaxLE = new QLineEdit( wBusinessTab );    QPEApplication::setInputMethodHint(busFaxLE,QPEApplication::PhoneNumber);    connect( busFaxLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( busFaxLE );    busFaxOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::BusinessFax] = busFaxOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busFaxLE, rowCount, 2 );    ++rowCount;    //    Pager    label = new QLabel( tr("Pager"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busPagerLE = new QLineEdit( wBusinessTab );    QPEApplication::setInputMethodHint(busPagerLE,QPEApplication::PhoneNumber);    connect( busPagerLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( busPagerLE );    busPagerOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::BusinessPager] = busPagerOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busPagerLE, rowCount, 2 );    ++rowCount;    //    Business Address    label = new QLabel( tr("Street"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busStreetME = new QMultiLineEdit( wBusinessTab );#ifdef QTOPIA_DESKTOP    busStreetME->setMaximumHeight( fontMetrics().lineSpacing() * 4 );#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busStreetME, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("City"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busCityLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busCityLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("State"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busStateLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busStateLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("Zip"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busZipLE = new QLineEdit( wBusinessTab );    QPEApplication::setInputMethodHint( busZipLE, QPEApplication::Number );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busZipLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("Country"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busCountryLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busCountryLE, rowCount, 2 );    ++rowCount;    //    Web page    label = new QLabel( tr("URL"), wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    busWebPageLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( busWebPageLE, rowCount, 2 );    ++rowCount;    //    Department    label = new QLabel( displayNames[ PimContact::Department ], wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    deptLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( deptLE, rowCount, 2 );    ++rowCount;    //    Office    label = new QLabel( displayNames[ PimContact::Office ], wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    officeLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( officeLE, rowCount, 2 );    ++rowCount;    //    Profession    label = new QLabel( displayNames[ PimContact::Profession ], wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    professionLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( professionLE, rowCount, 2 );    ++rowCount;    //    Manager    label = new QLabel( displayNames[ PimContact::Manager ], wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    managerLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( managerLE, rowCount, 2 );    ++rowCount;    //    Assistant    label = new QLabel( displayNames[ PimContact::Assistant ], wBusinessTab );    label->setAlignment(AlignRight|AlignVCenter);    assistantLE = new QLineEdit( wBusinessTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( assistantLE, rowCount, 2 );    ++rowCount;    verticalSpacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum,						   QSizePolicy::Expanding );    gl->addItem( verticalSpacer, rowCount, 0 );    // Home Tab    gl = new QGridLayout( wPersonalTab, 10, 3, 1, 1 );#ifdef QTOPIA_DESKTOP    gl->setResizeMode( QLayout::FreeResize );#endif#ifdef QTOPIA_DESKTOP    gl->setSpacing( 4 );#else    gl->addColSpacing(1,4);#endif    rowCount = 0;    //    Home phone    label = new QLabel( tr("Phone"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homePhoneLE = new QLineEdit( wPersonalTab );    QPEApplication::setInputMethodHint(homePhoneLE,QPEApplication::PhoneNumber);    connect( homePhoneLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( homePhoneLE );    homePhoneOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::HomePhone] = homePhoneOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homePhoneLE, rowCount, 2 );    ++rowCount;    //    Home mobile    label = new QLabel( tr("Mobile"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeMobileLE = new QLineEdit( wPersonalTab );    QPEApplication::setInputMethodHint(homeMobileLE,QPEApplication::PhoneNumber);    connect( homeMobileLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( homeMobileLE );    homeMobileOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::HomeMobile] = homeMobileOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeMobileLE, rowCount, 2 );    ++rowCount;    //    Home fax    label = new QLabel( tr("Fax"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeFaxLE = new QLineEdit( wPersonalTab );    QPEApplication::setInputMethodHint(homeFaxLE,QPEApplication::PhoneNumber);    connect( homeFaxLE, SIGNAL(textChanged(const QString&)), this,	    SLOT(detailsToPhoneFieldsFilter(const QString&)) );#ifdef QTOPIA_PHONE    menu = ContextMenu::menuFor( homeFaxLE );    homeFaxOnSim = addStoreOnSim(menu, this, SLOT(detailSimFilter(bool)));    simActions[PimContact::HomeFax] = homeFaxOnSim;#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeFaxLE, rowCount, 2 );    ++rowCount;    //    Home address    label = new QLabel( tr("Street"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeStreetME = new QMultiLineEdit( wPersonalTab );#ifdef QTOPIA_DESKTOP    homeStreetME->setMaximumHeight( fontMetrics().lineSpacing() * 4 );#endif    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeStreetME, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("City"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeCityLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeCityLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("State"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeStateLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeStateLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("Zip"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeZipLE = new QLineEdit( wPersonalTab );    QPEApplication::setInputMethodHint( homeZipLE, QPEApplication::Number );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeZipLE, rowCount, 2 );    ++rowCount;    label = new QLabel( tr("Country"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeCountryLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeCountryLE, rowCount, 2 );    ++rowCount;    //    Home web page    label = new QLabel( tr("URL"), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    homeWebPageLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( homeWebPageLE, rowCount, 2 );    ++rowCount;    //    Spouse    label = new QLabel( displayNames[ PimContact::Spouse ], wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    spouseLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( spouseLE, rowCount, 2 );    ++rowCount;    //    Children    label = new QLabel( displayNames[ PimContact::Children ], wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    childrenLE = new QLineEdit( wPersonalTab );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( childrenLE, rowCount, 2 );    ++rowCount;    //    Anniversary    label = new QLabel( tr("Anniv."), wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    anniversaryButton = new QPEDateEdit( wPersonalTab, "", FALSE, TRUE );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( anniversaryButton, rowCount, 2 );    ++rowCount;    //    Gender    label = new QLabel( displayNames[ PimContact::Gender ], wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    genderCombo = new QComboBox( FALSE, wPersonalTab );    genderCombo->insertItem( "", 0 );    genderCombo->insertItem( tr( "Male" ), 1 );    genderCombo->insertItem( tr( "Female" ), 2 );    gl->addWidget( label, rowCount, 0 );    gl->addWidget( genderCombo, rowCount, 2 );    ++rowCount;    //    Birthday    label = new QLabel( displayNames[ PimContact::Birthday ], wPersonalTab );    label->setAlignment(AlignRight|AlignVCenter);    bdayButton = new QPEDateEdit( wPersonalTab, "", FALSE, TRUE );    gl->addWidget( label,  rowCount, 0 );    gl->addWidget( bdayButton, rowCount, 2 );    ++rowCount;    verticalSpacer = new QSpacerItem( 1, 1, QSizePolicy::Minimum,						   QSizePolicy::Expanding );    gl->addItem( verticalSpacer, rowCount, 1 );    // Other Tab    rowCount = 0;    gl = new QGridLayout( wOtherTab, 4, 3, 1, 1 );#ifdef QTOPIA_DESKTOP    gl->setResizeMode( QLayout::FreeResize );#endif#ifdef QTOPIA_DESKTOP    gl->setSpacing( 4 );#else    gl->addColSpacing(1,4);#endif#ifndef QTOPIA_DES

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?